Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(815)

Delta Between Two Patch Sets: src/pkg/runtime/thread_linux.c

Issue 5697066: code review 5697066: runtime/pprof: support OS X CPU profiling (Closed)
Left Patch Set: Created 13 years ago
Right Patch Set: diff -r aa03e1f59b18 https://go.googlecode.com/hg/ Created 13 years ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « src/pkg/runtime/thread_freebsd.c ('k') | src/pkg/runtime/thread_netbsd.c » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(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
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 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b