go-getgoroot.c 546 Bytes
Newer Older
1 2 3 4 5 6 7 8
/* 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>

9
#include "runtime.h"
10

11
String getgoroot (void) __asm__ (GOSYM_PREFIX "runtime.getgoroot");
12

13
String
14 15 16
getgoroot ()
{
  const char *p;
17
  String ret;
18 19

  p = getenv ("GOROOT");
20 21 22
  ret.str = (const byte *) p;
  if (ret.str == NULL)
    ret.len = 0;
23
  else
24
    ret.len = __builtin_strlen (p);
25 26
  return ret;
}