OLD | NEW |
1 // Copyright 2010 The Go Authors. All rights reserved. | 1 // Copyright 2010 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 #include "runtime.h" | 5 #include "runtime.h" |
6 #include "arch_GOARCH.h" | 6 #include "arch_GOARCH.h" |
7 #include "defs_GOOS_GOARCH.h" | 7 #include "defs_GOOS_GOARCH.h" |
8 #include "os_GOOS.h" | 8 #include "os_GOOS.h" |
9 #include "malloc.h" | 9 #include "malloc.h" |
| 10 #include "textflag.h" |
10 | 11 |
11 enum | 12 enum |
12 { | 13 { |
13 ENOMEM = 12, | 14 ENOMEM = 12, |
14 }; | 15 }; |
15 | 16 |
| 17 #pragma textflag NOSPLIT |
16 void* | 18 void* |
17 runtime·SysAlloc(uintptr n, uint64 *stat) | 19 runtime·sysAlloc(uintptr n, uint64 *stat) |
18 { | 20 { |
19 void *v; | 21 void *v; |
20 | 22 |
21 v = runtime·mmap(nil, n, PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE, -1,
0); | 23 v = runtime·mmap(nil, n, PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE, -1,
0); |
22 if(v < (void*)4096) | 24 if(v < (void*)4096) |
23 return nil; | 25 return nil; |
24 runtime·xadd64(stat, n); | 26 runtime·xadd64(stat, n); |
25 return v; | 27 return v; |
26 } | 28 } |
27 | 29 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 } | 91 } |
90 return; | 92 return; |
91 } | 93 } |
92 | 94 |
93 p = runtime·mmap(v, n, PROT_READ|PROT_WRITE, MAP_ANON|MAP_FIXED|MAP_PRIV
ATE, -1, 0); | 95 p = runtime·mmap(v, n, PROT_READ|PROT_WRITE, MAP_ANON|MAP_FIXED|MAP_PRIV
ATE, -1, 0); |
94 if(p == (void*)ENOMEM) | 96 if(p == (void*)ENOMEM) |
95 runtime·throw("runtime: out of memory"); | 97 runtime·throw("runtime: out of memory"); |
96 if(p != v) | 98 if(p != v) |
97 runtime·throw("runtime: cannot map pages in arena address space"
); | 99 runtime·throw("runtime: cannot map pages in arena address space"
); |
98 } | 100 } |
OLD | NEW |