2010-12-03 05:34:57 +01:00
|
|
|
/* go-getgoroot.c -- getgoroot function for runtime package.
|
|
|
|
|
|
|
|
Copyright 2010 The Go Authors. All rights reserved.
|
|
|
|
Use of this source code is governed by a BSD-style
|
|
|
|
license that can be found in the LICENSE file. */
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2012-11-01 04:02:13 +01:00
|
|
|
#include "runtime.h"
|
2010-12-03 05:34:57 +01:00
|
|
|
|
2013-01-24 20:44:23 +01:00
|
|
|
String getgoroot (void) __asm__ (GOSYM_PREFIX "runtime.getgoroot");
|
2010-12-03 05:34:57 +01:00
|
|
|
|
2012-11-01 04:02:13 +01:00
|
|
|
String
|
2010-12-03 05:34:57 +01:00
|
|
|
getgoroot ()
|
|
|
|
{
|
|
|
|
const char *p;
|
2012-11-01 04:02:13 +01:00
|
|
|
String ret;
|
2010-12-03 05:34:57 +01:00
|
|
|
|
|
|
|
p = getenv ("GOROOT");
|
2012-11-01 04:02:13 +01:00
|
|
|
ret.str = (const byte *) p;
|
|
|
|
if (ret.str == NULL)
|
|
|
|
ret.len = 0;
|
2010-12-03 05:34:57 +01:00
|
|
|
else
|
2012-11-01 04:02:13 +01:00
|
|
|
ret.len = __builtin_strlen (p);
|
2010-12-03 05:34:57 +01:00
|
|
|
return ret;
|
|
|
|
}
|