diff options
| author | Ondřej Surý <ondrej@sury.org> | 2011-09-13 12:00:31 +0200 |
|---|---|---|
| committer | Ondřej Surý <ondrej@sury.org> | 2011-09-13 12:00:31 +0200 |
| commit | 04f99b387021a8ce32a8795360cba9beaf986a81 (patch) | |
| tree | f806c632c5dec5bb83190946d6d8ff8bd33c0e57 /src/pkg/runtime/openbsd/mem.c | |
| parent | d9514677ddaa705852cbba5034cb6d284261b53a (diff) | |
| download | golang-04f99b387021a8ce32a8795360cba9beaf986a81.tar.gz | |
Imported Upstream version 2011.09.07upstream-weekly/2011.09.07
Diffstat (limited to 'src/pkg/runtime/openbsd/mem.c')
| -rw-r--r-- | src/pkg/runtime/openbsd/mem.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/pkg/runtime/openbsd/mem.c b/src/pkg/runtime/openbsd/mem.c index 07abf2cfe..46b6b07ee 100644 --- a/src/pkg/runtime/openbsd/mem.c +++ b/src/pkg/runtime/openbsd/mem.c @@ -3,6 +3,11 @@ #include "os.h" #include "malloc.h" +enum +{ + ENOMEM = 12, +}; + void* runtime·SysAlloc(uintptr n) { @@ -33,19 +38,20 @@ runtime·SysFree(void *v, uintptr n) void* runtime·SysReserve(void *v, uintptr n) { + void *p; + // On 64-bit, people with ulimit -v set complain if we reserve too // much address space. Instead, assume that the reservation is okay // and check the assumption in SysMap. if(sizeof(void*) == 8) return v; - - return runtime·mmap(v, n, PROT_NONE, MAP_ANON|MAP_PRIVATE, -1, 0); -} -enum -{ - ENOMEM = 12, -}; + p = runtime·mmap(v, n, PROT_NONE, MAP_ANON|MAP_PRIVATE, -1, 0); + if (p == ((void *)-ENOMEM)) + return nil; + else + return p; +} void runtime·SysMap(void *v, uintptr n) |
