diff -r 42dfe9ab0c96 libgo/configure.ac --- a/libgo/configure.ac Tue May 24 14:44:49 2011 -0700 +++ b/libgo/configure.ac Tue May 24 15:01:29 2011 -0700 @@ -431,7 +431,7 @@ AC_CHECK_HEADERS(sys/mman.h syscall.h sys/epoll.h sys/ptrace.h sys/syscall.h sys/user.h sys/utsname.h sys/select.h) AM_CONDITIONAL(HAVE_SYS_MMAN_H, test "$ac_cv_header_sys_mman_h" = yes) -AC_CHECK_FUNCS(srandom random strerror_r strsignal wait4 mincore) +AC_CHECK_FUNCS(srandom random strerror_r strsignal wait4 mincore setenv) AM_CONDITIONAL(HAVE_STRERROR_R, test "$ac_cv_func_strerror_r" = yes) AM_CONDITIONAL(HAVE_WAIT4, test "$ac_cv_func_wait4" = yes) diff -r 42dfe9ab0c96 libgo/runtime/go-setenv.c --- a/libgo/runtime/go-setenv.c Tue May 24 14:44:49 2011 -0700 +++ b/libgo/runtime/go-setenv.c Tue May 24 15:01:29 2011 -0700 @@ -4,6 +4,8 @@ Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. */ +#include "config.h" + #include #include @@ -25,24 +27,38 @@ ks = k.__data; kn = NULL; + vs = v.__data; + vn = NULL; + +#ifdef HAVE_SETENV + if (ks[k.__length] != 0) { kn = __go_alloc (k.__length + 1); - __builtin_memcpy (kn, k.__data, k.__length); + __builtin_memcpy (kn, ks, k.__length); ks = kn; } - vs = v.__data; - vn = NULL; if (vs[v.__length] != 0) { vn = __go_alloc (v.__length + 1); - __builtin_memcpy (vn, v.__data, v.__length); + __builtin_memcpy (vn, vs, v.__length); vs = vn; } setenv ((const char *) ks, (const char *) vs, 1); +#else /* !defined(HAVE_SETENV) */ + + kn = malloc (k.__length + v.__length + 2); + __builtin_memcpy (kn, ks, k.__length); + kn[k.__length] = '='; + __builtin_memcpy (kn + k.__length + 1, vs, v.__length); + kn[k.__length + v.__length + 1] = '\0'; + putenv ((char *) kn); + +#endif /* !defined(HAVE_SETENV) */ + if (kn != NULL) __go_free (kn); if (vn != NULL)