2014-04-11 Marc Glisse <marc.glisse@inria.fr>
[official-gcc.git] / libgo / runtime / go-getgoroot.c
blob1b52d44043837bf0218d95676c3a8dd0702b4ac5
1 /* go-getgoroot.c -- getgoroot function for runtime package.
3 Copyright 2010 The Go Authors. All rights reserved.
4 Use of this source code is governed by a BSD-style
5 license that can be found in the LICENSE file. */
7 #include <stdlib.h>
9 #include "runtime.h"
11 String getgoroot (void) __asm__ (GOSYM_PREFIX "runtime.getgoroot");
13 String
14 getgoroot ()
16 const char *p;
17 String ret;
19 p = getenv ("GOROOT");
20 ret.str = (const byte *) p;
21 if (ret.str == NULL)
22 ret.len = 0;
23 else
24 ret.len = __builtin_strlen (p);
25 return ret;