Left: | ||
Right: |
OLD | NEW |
---|---|
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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
62 mib[0] = 6; | 62 mib[0] = 6; |
63 mib[1] = 3; | 63 mib[1] = 3; |
64 nout = sizeof out; | 64 nout = sizeof out; |
65 out = 0; | 65 out = 0; |
66 ret = runtime·sysctl(mib, 2, (byte*)&out, &nout, nil, 0); | 66 ret = runtime·sysctl(mib, 2, (byte*)&out, &nout, nil, 0); |
67 if(ret >= 0) | 67 if(ret >= 0) |
68 runtime·ncpu = out; | 68 runtime·ncpu = out; |
69 } | 69 } |
70 | 70 |
71 void | 71 void |
72 runtime·get_random_data(byte **rnd, int32 *rnd_len) { | |
rsc
2013/03/12 16:32:29
{ on next line. sorry.
| |
73 static byte urandom_data[HashRandomBytes]; | |
74 int32 fd = runtime·open((uint8*)"/dev/urandom", 0 /* O_RDONLY */, 0); | |
rsc
2013/03/12 16:32:29
Please initialize variables in separate statements
| |
75 if(runtime·read(fd, urandom_data, HashRandomBytes) == HashRandomBytes) { | |
76 *rnd = urandom_data; | |
77 *rnd_len = HashRandomBytes; | |
78 } else { | |
79 *rnd = nil; | |
80 *rnd_len = 0; | |
81 } | |
82 runtime·close(fd); | |
83 } | |
84 | |
85 void | |
72 runtime·goenvs(void) | 86 runtime·goenvs(void) |
73 { | 87 { |
74 runtime·goenvs_unix(); | 88 runtime·goenvs_unix(); |
75 | 89 |
76 // Register our thread-creation callback (see sys_darwin_{amd64,386}.s) | 90 // Register our thread-creation callback (see sys_darwin_{amd64,386}.s) |
77 // but only if we're not using cgo. If we are using cgo we need | 91 // but only if we're not using cgo. If we are using cgo we need |
78 // to let the C pthread libary install its own thread-creation callback. | 92 // to let the C pthread libary install its own thread-creation callback. |
79 if(!runtime·iscgo) { | 93 if(!runtime·iscgo) { |
80 if(runtime·bsdthread_register() != 0) { | 94 if(runtime·bsdthread_register() != 0) { |
81 if(runtime·getenv("DYLD_INSERT_LIBRARIES")) | 95 if(runtime·getenv("DYLD_INSERT_LIBRARIES")) |
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
523 } | 537 } |
524 runtime·write(2, badsignal, sizeof badsignal - 1); | 538 runtime·write(2, badsignal, sizeof badsignal - 1); |
525 if (0 <= sig && sig < NSIG) { | 539 if (0 <= sig && sig < NSIG) { |
526 // Call runtime·findnull dynamically to circumvent static stack size check. | 540 // Call runtime·findnull dynamically to circumvent static stack size check. |
527 static int32 (*findnull)(byte*) = runtime·findnull; | 541 static int32 (*findnull)(byte*) = runtime·findnull; |
528 runtime·write(2, runtime·sigtab[sig].name, findnull((byte*)runti me·sigtab[sig].name)); | 542 runtime·write(2, runtime·sigtab[sig].name, findnull((byte*)runti me·sigtab[sig].name)); |
529 } | 543 } |
530 runtime·write(2, "\n", 1); | 544 runtime·write(2, "\n", 1); |
531 runtime·exit(1); | 545 runtime·exit(1); |
532 } | 546 } |
OLD | NEW |