gcc/libgo/runtime/go-unsetenv.c
Ian Lance Taylor f8d9fa9e80 libgo, compiler: Upgrade libgo to Go 1.4, except for runtime.
This upgrades all of libgo other than the runtime package to
the Go 1.4 release.  In Go 1.4 much of the runtime was
rewritten into Go.  Merging that code will take more time and
will not change the API, so I'm putting it off for now.

There are a few runtime changes anyhow, to accomodate other
packages that rely on minor modifications to the runtime
support.

The compiler changes slightly to add a one-bit flag to each
type descriptor kind that is stored directly in an interface,
which for gccgo is currently only pointer types.  Another
one-bit flag (gcprog) is reserved because it is used by the gc
compiler, but gccgo does not currently use it.

There is another error check in the compiler since I ran
across it during testing.

gotools/:
	* Makefile.am (go_cmd_go_files): Sort entries.  Add generate.go.
	* Makefile.in: Rebuild.

From-SVN: r219627
2015-01-15 00:27:56 +00:00

55 lines
1.1 KiB
C

/* 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);
}