1 /* go-setenv.c -- set the C environment from Go.
3 Copyright 2011 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. */
15 /* Set the C environment from Go. This is called by syscall.Setenv. */
17 void setenv_c (String
, String
) __asm__ ("syscall.setenv_c");
20 setenv_c (String k
, String v
)
36 kn
= __go_alloc (k
.len
+ 1);
37 __builtin_memcpy (kn
, ks
, k
.len
);
43 vn
= __go_alloc (v
.len
+ 1);
44 __builtin_memcpy (vn
, vs
, v
.len
);
48 setenv ((const char *) ks
, (const char *) vs
, 1);
50 #else /* !defined(HAVE_SETENV) */
52 kn
= __go_alloc (k
.len
+ v
.len
+ 2);
53 __builtin_memcpy (kn
, ks
, k
.len
);
55 __builtin_memcpy (kn
+ k
.len
+ 1, vs
, v
.len
);
56 kn
[k
.len
+ v
.len
+ 1] = '\0';
59 #endif /* !defined(HAVE_SETENV) */