LEFT | RIGHT |
(no file at all) | |
1 // Use of this source file is governed by a BSD-style | 1 // Use of this source file is governed by a BSD-style |
2 // license that can be found in the LICENSE file.` | 2 // license that can be found in the LICENSE file.` |
3 | 3 |
4 #include "runtime.h" | 4 #include "runtime.h" |
5 #include "defs.h" | 5 #include "defs.h" |
6 #include "os.h" | 6 #include "os.h" |
7 #include "stack.h" | 7 #include "stack.h" |
8 | 8 |
9 extern SigTab runtime·sigtab[]; | 9 extern SigTab runtime·sigtab[]; |
10 extern int32 runtime·sys_umtx_op(uint32*, int32, uint32, void*, void*); | 10 extern int32 runtime·sys_umtx_op(uint32*, int32, uint32, void*, void*); |
11 | 11 |
12 // FreeBSD's umtx_op syscall is effectively the same as Linux's futex, and | 12 // FreeBSD's umtx_op syscall is effectively the same as Linux's futex, and |
13 // thus the code is largely similar. See linux/thread.c for comments. | 13 // thus the code is largely similar. See linux/thread.c and lock_futex.c for com
ments. |
14 | 14 |
15 void | 15 void |
16 runtime·futexsleep(uint32 *addr, uint32 val) | 16 runtime·futexsleep(uint32 *addr, uint32 val, int64 ns) |
17 { | 17 { |
18 int32 ret; | 18 int32 ret; |
| 19 Timespec ts, *tsp; |
19 | 20 |
20 » ret = runtime·sys_umtx_op(addr, UMTX_OP_WAIT, val, nil, nil); | 21 » if(ns < 0) |
| 22 » » tsp = nil; |
| 23 » else { |
| 24 » » ts.sec = ns / 1000000000LL; |
| 25 » » ts.nsec = ns % 1000000000LL; |
| 26 » » tsp = &ts; |
| 27 » } |
| 28 |
| 29 » ret = runtime·sys_umtx_op(addr, UMTX_OP_WAIT, val, nil, tsp); |
21 if(ret >= 0 || ret == -EINTR) | 30 if(ret >= 0 || ret == -EINTR) |
22 return; | 31 return; |
23 | 32 |
24 runtime·printf("umtx_wait addr=%p val=%d ret=%d\n", addr, val, ret); | 33 runtime·printf("umtx_wait addr=%p val=%d ret=%d\n", addr, val, ret); |
25 *(int32*)0x1005 = 0x1005; | 34 *(int32*)0x1005 = 0x1005; |
26 } | 35 } |
27 | 36 |
28 void | 37 void |
29 runtime·futexwakeup(uint32 *addr, uint32 cnt) | 38 runtime·futexwakeup(uint32 *addr, uint32 cnt) |
30 { | 39 { |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 runtime·panicstring("floating point error"); | 122 runtime·panicstring("floating point error"); |
114 } | 123 } |
115 runtime·panicstring(runtime·sigtab[g->sig].name); | 124 runtime·panicstring(runtime·sigtab[g->sig].name); |
116 } | 125 } |
117 | 126 |
118 // TODO: fill this in properly. | 127 // TODO: fill this in properly. |
119 void | 128 void |
120 runtime·osyield(void) | 129 runtime·osyield(void) |
121 { | 130 { |
122 } | 131 } |
LEFT | RIGHT |