mirror of
https://github.com/golang/go
synced 2024-10-04 04:21:22 -06:00
851f30136d
Collapse the arch,os-specific directories into the main directory by renaming xxx/foo.c to foo_xxx.c, and so on. There are no substantial edits here, except to the Makefile. The assumption is that the Go tool will #define GOOS_darwin and GOARCH_amd64 and will make any file named something like signals_darwin.h available as signals_GOOS.h during the build. This replaces what used to be done with -I$(GOOS). There is still work to be done to make runtime build with standard tools, but this is a big step. After this we will have to write a script to generate all the generated files so they can be checked in (instead of generated during the build). R=r, iant, r, lucio.dere CC=golang-dev https://golang.org/cl/5490053
69 lines
1.2 KiB
C
69 lines
1.2 KiB
C
// 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 "runtime.h"
|
|
#include "arch_GOARCH.h"
|
|
#include "malloc.h"
|
|
#include "os_GOOS.h"
|
|
|
|
extern byte end[];
|
|
static byte *bloc = { end };
|
|
static Lock memlock;
|
|
|
|
enum
|
|
{
|
|
Round = 4095
|
|
};
|
|
|
|
void*
|
|
runtime·SysAlloc(uintptr nbytes)
|
|
{
|
|
uintptr bl;
|
|
|
|
runtime·lock(&memlock);
|
|
mstats.sys += nbytes;
|
|
// Plan 9 sbrk from /sys/src/libc/9sys/sbrk.c
|
|
bl = ((uintptr)bloc + Round) & ~Round;
|
|
if(runtime·brk_((void*)(bl + nbytes)) < 0) {
|
|
runtime·unlock(&memlock);
|
|
return nil;
|
|
}
|
|
bloc = (byte*)bl + nbytes;
|
|
runtime·unlock(&memlock);
|
|
return (void*)bl;
|
|
}
|
|
|
|
void
|
|
runtime·SysFree(void *v, uintptr nbytes)
|
|
{
|
|
runtime·lock(&memlock);
|
|
mstats.sys -= nbytes;
|
|
// from tiny/mem.c
|
|
// Push pointer back if this is a free
|
|
// of the most recent SysAlloc.
|
|
nbytes += (nbytes + Round) & ~Round;
|
|
if(bloc == (byte*)v+nbytes)
|
|
bloc -= nbytes;
|
|
runtime·unlock(&memlock);
|
|
}
|
|
|
|
void
|
|
runtime·SysUnused(void *v, uintptr nbytes)
|
|
{
|
|
USED(v, nbytes);
|
|
}
|
|
|
|
void
|
|
runtime·SysMap(void *v, uintptr nbytes)
|
|
{
|
|
USED(v, nbytes);
|
|
}
|
|
|
|
void*
|
|
runtime·SysReserve(void *v, uintptr nbytes)
|
|
{
|
|
USED(v);
|
|
return runtime·SysAlloc(nbytes);
|
|
}
|