summaryrefslogtreecommitdiff
path: root/src/pkg/runtime/openbsd/mem.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/pkg/runtime/openbsd/mem.c')
-rw-r--r--src/pkg/runtime/openbsd/mem.c20
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)