LEFT | RIGHT |
(no file at all) | |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 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 "defs_GOOS_GOARCH.h" | 6 #include "defs_GOOS_GOARCH.h" |
7 #include "os_GOOS.h" | 7 #include "os_GOOS.h" |
8 #include "stack.h" | 8 #include "stack.h" |
9 | 9 |
10 extern SigTab runtime·sigtab[]; | 10 extern SigTab runtime·sigtab[]; |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 } | 221 } |
222 runtime·panicstring(runtime·sigtab[g->sig].name); | 222 runtime·panicstring(runtime·sigtab[g->sig].name); |
223 } | 223 } |
224 | 224 |
225 uintptr | 225 uintptr |
226 runtime·memlimit(void) | 226 runtime·memlimit(void) |
227 { | 227 { |
228 Rlimit rl; | 228 Rlimit rl; |
229 extern byte text[], end[]; | 229 extern byte text[], end[]; |
230 uintptr used; | 230 uintptr used; |
231 » | 231 |
232 if(runtime·getrlimit(RLIMIT_AS, &rl) != 0) | 232 if(runtime·getrlimit(RLIMIT_AS, &rl) != 0) |
233 return 0; | 233 return 0; |
234 if(rl.rlim_cur >= 0x7fffffff) | 234 if(rl.rlim_cur >= 0x7fffffff) |
235 return 0; | 235 return 0; |
236 | 236 |
237 // Estimate our VM footprint excluding the heap. | 237 // Estimate our VM footprint excluding the heap. |
238 // Not an exact science: use size of binary plus | 238 // Not an exact science: use size of binary plus |
239 // some room for thread stacks. | 239 // some room for thread stacks. |
240 used = end - text + (64<<20); | 240 used = end - text + (64<<20); |
241 if(used >= rl.rlim_cur) | 241 if(used >= rl.rlim_cur) |
242 return 0; | 242 return 0; |
243 | 243 |
244 // If there's not at least 16 MB left, we're probably | 244 // If there's not at least 16 MB left, we're probably |
245 // not going to be able to do much. Treat as no limit. | 245 // not going to be able to do much. Treat as no limit. |
246 rl.rlim_cur -= used; | 246 rl.rlim_cur -= used; |
247 if(rl.rlim_cur < (16<<20)) | 247 if(rl.rlim_cur < (16<<20)) |
248 return 0; | 248 return 0; |
249 | 249 |
250 return rl.rlim_cur - used; | 250 return rl.rlim_cur - used; |
251 } | 251 } |
| 252 |
| 253 void |
| 254 runtime·setprof(bool on) |
| 255 { |
| 256 USED(on); |
| 257 } |
LEFT | RIGHT |