diff options
| author | Russ Cox <rsc@golang.org> | 2011-08-31 07:02:46 -0400 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2011-08-31 07:02:46 -0400 |
| commit | 4304de6e0c64653ddf5d57c7724b28b859ce28af (patch) | |
| tree | b18f58346209d04e2b475457276d3f0625ac7eaf /src/pkg/runtime/linux | |
| parent | 0cfa0fe2421accf8887a444fd76a6a1d0393796f (diff) | |
| download | go-4304de6e0c64653ddf5d57c7724b28b859ce28af.tar.xz | |
runtime: make arm work on Ubuntu Natty qemu
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/4963050
Diffstat (limited to 'src/pkg/runtime/linux')
| -rw-r--r-- | src/pkg/runtime/linux/mem.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/pkg/runtime/linux/mem.c b/src/pkg/runtime/linux/mem.c index ad0fac6d3f..6c5c908cc5 100644 --- a/src/pkg/runtime/linux/mem.c +++ b/src/pkg/runtime/linux/mem.c @@ -6,23 +6,26 @@ enum { ENOMEM = 12, + _PAGE_SIZE = 4096, }; static int32 addrspace_free(void *v, uintptr n) { - uintptr page_size = 4096; + int32 errval; + uintptr chunk; uintptr off; - int8 one_byte; + static byte vec[4096]; - for(off = 0; off < n; off += page_size) { - int32 errval = runtime·mincore((int8 *)v + off, page_size, (void *)&one_byte); + for(off = 0; off < n; off += chunk) { + chunk = _PAGE_SIZE * sizeof vec; + if(chunk > (n - off)) + chunk = n - off; + errval = runtime·mincore((int8*)v + off, chunk, vec); // errval is 0 if success, or -(error_code) if error. if (errval == 0 || errval != -ENOMEM) return 0; } - USED(v); - USED(n); return 1; } @@ -72,7 +75,7 @@ runtime·SysReserve(void *v, uintptr n) return v; p = runtime·mmap(v, n, PROT_NONE, MAP_ANON|MAP_PRIVATE, -1, 0); - if(p < (void*)4096) { + if((uintptr)p < 4096 || -(uintptr)p < 4096) { return nil; } return p; |
