mirror of
https://github.com/golang/go
synced 2024-11-18 10:54:40 -07:00
runtime: fix timediv calls on NetBSD, OpenBSD
Document endian-ness assumption. R=dvyukov CC=golang-dev https://golang.org/cl/12056044
This commit is contained in:
parent
14e3540430
commit
98cc58e2c7
@ -54,6 +54,7 @@ runtime·futexsleep(uint32 *addr, uint32 val, int64 ns)
|
||||
return;
|
||||
goto fail;
|
||||
}
|
||||
// NOTE: tv_nsec is int64 on amd64, so this assumes a little-endian system.
|
||||
ts.tv_nsec = 0;
|
||||
ts.tv_sec = runtime·timediv(ns, 1000000000, (int32*)&ts.tv_nsec);
|
||||
ret = runtime·sys_umtx_op(addr, UMTX_OP_WAIT_UINT, val, nil, &ts);
|
||||
|
@ -48,6 +48,7 @@ runtime·futexsleep(uint32 *addr, uint32 val, int64 ns)
|
||||
runtime·futex(addr, FUTEX_WAIT, val, nil, nil, 0);
|
||||
return;
|
||||
}
|
||||
// NOTE: tv_nsec is int64 on amd64, so this assumes a little-endian system.
|
||||
ts.tv_nsec = 0;
|
||||
ts.tv_sec = runtime·timediv(ns, 1000000000LL, (int32*)&ts.tv_nsec);
|
||||
runtime·futex(addr, FUTEX_WAIT, val, &ts, nil, 0);
|
||||
|
@ -95,8 +95,9 @@ runtime·semasleep(int64 ns)
|
||||
runtime·lwp_park(nil, 0, &m->waitsemacount, nil);
|
||||
} else {
|
||||
ns += runtime·nanotime();
|
||||
// NOTE: tv_nsec is int64 on amd64, so this assumes a little-endian system.
|
||||
ts.tv_nsec = 0;
|
||||
ts.tv_sec = runtime·timediv(ns, 1000000000, (int32*)ts.tv_nsec);
|
||||
ts.tv_sec = runtime·timediv(ns, 1000000000, (int32*)&ts.tv_nsec);
|
||||
// TODO(jsing) - potential deadlock!
|
||||
// See above for details.
|
||||
runtime·atomicstore(&m->waitsemalock, 0);
|
||||
|
@ -78,8 +78,9 @@ runtime·semasleep(int64 ns)
|
||||
runtime·thrsleep(&m->waitsemacount, 0, nil, &m->waitsemalock, nil);
|
||||
else {
|
||||
ns += runtime·nanotime();
|
||||
// NOTE: tv_nsec is int64 on amd64, so this assumes a little-endian system.
|
||||
ts.tv_nsec = 0;
|
||||
ts.tv_sec = runtime·timediv(ns, 1000000000, (int32*)ts.tv_nsec);
|
||||
ts.tv_sec = runtime·timediv(ns, 1000000000, (int32*)&ts.tv_nsec);
|
||||
runtime·thrsleep(&m->waitsemacount, CLOCK_REALTIME, &ts, &m->waitsemalock, nil);
|
||||
}
|
||||
// reacquire lock
|
||||
|
Loading…
Reference in New Issue
Block a user