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[]; |
11 | 11 |
12 static Sigset sigset_none; | 12 static Sigset sigset_none; |
13 static Sigset sigset_all = { ~(uint32)0, ~(uint32)0 }; | 13 static Sigset sigset_all = { ~(uint32)0, ~(uint32)0 }; |
14 | 14 |
15 // Linux futex. | 15 // Linux futex. |
16 // | 16 // |
17 // futexsleep(uint32 *addr, uint32 val) | 17 // futexsleep(uint32 *addr, uint32 val) |
18 // futexwakeup(uint32 *addr) | 18 // futexwakeup(uint32 *addr) |
19 // | 19 // |
20 // Futexsleep atomically checks if *addr == val and if so, sleeps on addr. | 20 // Futexsleep atomically checks if *addr == val and if so, sleeps on addr. |
21 // Futexwakeup wakes up threads sleeping on addr. | 21 // Futexwakeup wakes up threads sleeping on addr. |
22 // Futexsleep is allowed to wake up spuriously. | 22 // Futexsleep is allowed to wake up spuriously. |
23 | 23 |
24 enum | 24 enum |
25 { | 25 { |
26 FUTEX_WAIT = 0, | 26 FUTEX_WAIT = 0, |
27 FUTEX_WAKE = 1, | 27 FUTEX_WAKE = 1, |
28 | |
29 EINTR = 4, | |
30 EAGAIN = 11, | |
31 }; | 28 }; |
32 | 29 |
33 // Atomically, | 30 // Atomically, |
34 // if(*addr == val) sleep | 31 // if(*addr == val) sleep |
35 // Might be woken up spuriously; that's allowed. | 32 // Might be woken up spuriously; that's allowed. |
36 // Don't sleep longer than ns; ns < 0 means forever. | 33 // Don't sleep longer than ns; ns < 0 means forever. |
37 void | 34 void |
38 runtime·futexsleep(uint32 *addr, uint32 val, int64 ns) | 35 runtime·futexsleep(uint32 *addr, uint32 val, int64 ns) |
39 { | 36 { |
40 Timespec ts, *tsp; | 37 Timespec ts, *tsp; |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 } | 302 } |
306 runtime·write(2, badsignal, sizeof badsignal - 1); | 303 runtime·write(2, badsignal, sizeof badsignal - 1); |
307 if (0 <= sig && sig < NSIG) { | 304 if (0 <= sig && sig < NSIG) { |
308 // Call runtime·findnull dynamically to circumvent static stack
size check. | 305 // Call runtime·findnull dynamically to circumvent static stack
size check. |
309 static int32 (*findnull)(byte*) = runtime·findnull; | 306 static int32 (*findnull)(byte*) = runtime·findnull; |
310 runtime·write(2, runtime·sigtab[sig].name, findnull((byte*)runti
me·sigtab[sig].name)); | 307 runtime·write(2, runtime·sigtab[sig].name, findnull((byte*)runti
me·sigtab[sig].name)); |
311 } | 308 } |
312 runtime·write(2, "\n", 1); | 309 runtime·write(2, "\n", 1); |
313 runtime·exit(1); | 310 runtime·exit(1); |
314 } | 311 } |
OLD | NEW |