summaryrefslogtreecommitdiffstats
path: root/llgo/third_party/gofrontend/libgo/runtime/go-unsetenv.c
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2015-04-05 23:30:42 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2015-04-05 23:30:42 +0000
commit93c73ebcbd73f5436d13ffc41f49a86fc062deb8 (patch)
tree10bf9fb3a1314fc8a1c3b963b4550960718384ad /llgo/third_party/gofrontend/libgo/runtime/go-unsetenv.c
parent7d39641c805bf3263ffb55a23ecf4bbfd37402c0 (diff)
downloadbcm5719-llvm-93c73ebcbd73f5436d13ffc41f49a86fc062deb8.tar.gz
bcm5719-llvm-93c73ebcbd73f5436d13ffc41f49a86fc062deb8.zip
Roll gofrontend to a6e10414311a
This takes us to Go 1.4. Also includes a couple of changes to the test suite, both in the runtime package: - Disable TestSetPanicOnFault. We cannot support this scenario at all, due to LLVM's lack of non-call exceptions. - Tweak TestFinalizerType. This test only passes with two GC runs. Differential Revision: http://reviews.llvm.org/D8828 llvm-svn: 234134
Diffstat (limited to 'llgo/third_party/gofrontend/libgo/runtime/go-unsetenv.c')
-rw-r--r--llgo/third_party/gofrontend/libgo/runtime/go-unsetenv.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/llgo/third_party/gofrontend/libgo/runtime/go-unsetenv.c b/llgo/third_party/gofrontend/libgo/runtime/go-unsetenv.c
new file mode 100644
index 00000000000..409436a0d3f
--- /dev/null
+++ b/llgo/third_party/gofrontend/libgo/runtime/go-unsetenv.c
@@ -0,0 +1,54 @@
+/* go-unsetenv.c -- unset an environment variable from Go.
+
+ Copyright 2015 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 "config.h"
+
+#include <stddef.h>
+#include <stdlib.h>
+
+#include "go-alloc.h"
+#include "runtime.h"
+#include "arch.h"
+#include "malloc.h"
+
+/* Unset an environment variable from Go. This is called by
+ syscall.Unsetenv. */
+
+void unsetenv_c (String) __asm__ (GOSYM_PREFIX "syscall.unsetenv_c");
+
+void
+unsetenv_c (String k)
+{
+ const byte *ks;
+ unsigned char *kn;
+ intgo len;
+
+ ks = k.str;
+ if (ks == NULL)
+ ks = (const byte *) "";
+ kn = NULL;
+
+#ifdef HAVE_UNSETENV
+
+ if (ks != NULL && ks[k.len] != 0)
+ {
+ // Objects that are explicitly freed must be at least 16 bytes in size,
+ // so that they are not allocated using tiny alloc.
+ len = k.len + 1;
+ if (len < TinySize)
+ len = TinySize;
+ kn = __go_alloc (len);
+ __builtin_memcpy (kn, ks, k.len);
+ ks = kn;
+ }
+
+ unsetenv ((const char *) ks);
+
+#endif /* !defined(HAVE_UNSETENV) */
+
+ if (kn != NULL)
+ __go_free (kn);
+}
OpenPOWER on IntegriCloud