diff -ru orig/src/runtime/os_netbsd.go go-1.9.2/src/runtime/os_netbsd.go --- orig/src/runtime/os_netbsd.go 2017-10-25 14:30:21.000000000 -0400 +++ go-1.9.2/src/runtime/os_netbsd.go 2017-12-02 01:17:36.000000000 -0500 @@ -55,7 +55,7 @@ func lwp_create(ctxt unsafe.Pointer, flags uintptr, lwpid unsafe.Pointer) int32 //go:noescape -func lwp_park(abstime *timespec, unpark int32, hint, unparkhint unsafe.Pointer) int32 +func lwp_park(clockid, flags int32, ts *timespec, unpark int32, hint, unparkhint unsafe.Pointer) int32 //go:noescape func lwp_unpark(lwp int32, hint unsafe.Pointer) int32 @@ -73,6 +73,9 @@ _CLOCK_VIRTUAL = 1 _CLOCK_PROF = 2 _CLOCK_MONOTONIC = 3 + + _TIMER_RELTIME = 0 + _TIMER_ABSTIME = 1 ) var sigset_all = sigset{[4]uint32{^uint32(0), ^uint32(0), ^uint32(0), ^uint32(0)}} @@ -119,7 +122,6 @@ if ns >= 0 { var ts timespec var nsec int32 - ns += nanotime() ts.set_sec(timediv(ns, 1000000000, &nsec)) ts.set_nsec(nsec) tsp = &ts @@ -135,7 +137,7 @@ } // Sleep until unparked by semawakeup or timeout. - ret := lwp_park(tsp, 0, unsafe.Pointer(&_g_.m.waitsemacount), nil) + ret := lwp_park(_CLOCK_MONOTONIC, _TIMER_RELTIME, tsp, 0, unsafe.Pointer(&_g_.m.waitsemacount), nil) if ret == _ETIMEDOUT { return -1 } diff -ru orig/src/runtime/sys_netbsd_386.s go-1.9.2/src/runtime/sys_netbsd_386.s --- orig/src/runtime/sys_netbsd_386.s 2017-10-25 14:30:21.000000000 -0400 +++ go-1.9.2/src/runtime/sys_netbsd_386.s 2017-12-02 11:52:22.543344417 -0500 @@ -155,7 +155,7 @@ // void nanotime(int64 *nsec) TEXT runtime·nanotime(SB),NOSPLIT,$32 LEAL 12(SP), BX - MOVL $0, 4(SP) // arg 1 - clock_id + MOVL $3, 4(SP) // arg 1 - clock_id MOVL BX, 8(SP) // arg 2 - tp MOVL $427, AX // sys_clock_gettime INT $0x80 @@ -337,9 +337,9 @@ RET TEXT runtime·lwp_park(SB),NOSPLIT,$-4 - MOVL $434, AX // sys__lwp_park + MOVL $478, AX // sys__lwp_park INT $0x80 - MOVL AX, ret+16(FP) + MOVL AX, ret+24(FP) RET TEXT runtime·lwp_unpark(SB),NOSPLIT,$-4 diff -ru orig/src/runtime/sys_netbsd_amd64.s go-1.9.2/src/runtime/sys_netbsd_amd64.s --- orig/src/runtime/sys_netbsd_amd64.s 2017-10-25 14:30:21.000000000 -0400 +++ go-1.9.2/src/runtime/sys_netbsd_amd64.s 2017-12-02 07:52:50.000000000 -0500 @@ -48,13 +48,15 @@ RET TEXT runtime·lwp_park(SB),NOSPLIT,$0 - MOVQ abstime+0(FP), DI // arg 1 - abstime - MOVL unpark+8(FP), SI // arg 2 - unpark - MOVQ hint+16(FP), DX // arg 3 - hint - MOVQ unparkhint+24(FP), R10 // arg 4 - unparkhint - MOVL $434, AX // sys__lwp_park + MOVL clockid+0(FP), DI // arg 1 - clockid + MOVL flags+4(FP), SI // arg 2 - flags + MOVQ ts+8(FP), DX // arg 3 - ts + MOVL unpark+16(FP), R10 // arg 4 - unpark + MOVQ hint+24(FP), R8 // arg 5 - hint + MOVQ unparkhint+32(FP), R9 // arg 6 - unparkhint + MOVL $478, AX // sys__lwp_park SYSCALL - MOVL AX, ret+32(FP) + MOVL AX, ret+40(FP) RET TEXT runtime·lwp_unpark(SB),NOSPLIT,$0 @@ -184,7 +186,7 @@ RET TEXT runtime·nanotime(SB),NOSPLIT,$32 - MOVQ $0, DI // arg 1 - clock_id + MOVQ $3, DI // arg 1 - clock_id LEAQ 8(SP), SI // arg 2 - tp MOVL $427, AX // sys_clock_gettime SYSCALL diff -ru orig/src/runtime/sys_netbsd_arm.s go-1.9.2/src/runtime/sys_netbsd_arm.s --- orig/src/runtime/sys_netbsd_arm.s 2017-10-25 14:30:21.000000000 -0400 +++ go-1.9.2/src/runtime/sys_netbsd_arm.s 2017-12-02 07:53:07.000000000 -0500 @@ -72,11 +72,15 @@ RET TEXT runtime·lwp_park(SB),NOSPLIT,$0 - MOVW abstime+0(FP), R0 // arg 1 - abstime - MOVW unpark+4(FP), R1 // arg 2 - unpark - MOVW hint+8(FP), R2 // arg 3 - hint - MOVW unparkhint+12(FP), R3 // arg 4 - unparkhint - SWI $0xa001b2 // sys__lwp_park + MOVW clock_id+0(FP), R0 // arg 1 - clock_id + MOVW flags+4(FP), R1 // arg 2 - flags + MOVW ts+8(FP), R2 // arg 3 - ts + MOVW unpark+12(FP), R3 // arg 4 - unpark + MOVW hint+16(FP), R4 // arg 5 - hint + MOVW R4, 4(R13) + MOVW unparkhint+20(FP), R5 // arg 6 - unparkhint + MOVW R5, 8(R13) + SWI $0xa001de // sys__lwp_park MOVW R0, ret+16(FP) RET @@ -155,7 +159,7 @@ // int64 nanotime(void) so really // void nanotime(int64 *nsec) TEXT runtime·nanotime(SB), NOSPLIT, $32 - MOVW $0, R0 // CLOCK_REALTIME + MOVW $3, R0 // CLOCK_MONOTONIC MOVW $8(R13), R1 SWI $0xa001ab // clock_gettime diff -ru orig/src/syscall/zsysnum_netbsd_386.go go-1.9.2/src/syscall/zsysnum_netbsd_386.go --- orig/src/syscall/zsysnum_netbsd_386.go 2017-10-25 14:30:21.000000000 -0400 +++ go-1.9.2/src/syscall/zsysnum_netbsd_386.go 2017-12-02 11:41:25.115658550 -0500 @@ -229,7 +229,6 @@ SYS_CLOCK_GETRES = 429 // { int|sys|50|clock_getres(clockid_t clock_id, struct timespec *tp); } SYS_NANOSLEEP = 430 // { int|sys|50|nanosleep(const struct timespec *rqtp, struct timespec *rmtp); } SYS___SIGTIMEDWAIT = 431 // { int|sys|50|__sigtimedwait(const sigset_t *set, siginfo_t *info, struct timespec *timeout); } - SYS__LWP_PARK = 434 // { int|sys|50|_lwp_park(const struct timespec *ts, lwpid_t unpark, const void *hint, const void *unparkhint); } SYS_KEVENT = 435 // { int|sys|50|kevent(int fd, const struct kevent *changelist, size_t nchanges, struct kevent *eventlist, size_t nevents, const struct timespec *timeout); } SYS_PSELECT = 436 // { int|sys|50|pselect(int nd, fd_set *in, fd_set *ou, fd_set *ex, const struct timespec *ts, const sigset_t *mask); } SYS_POLLTS = 437 // { int|sys|50|pollts(struct pollfd *fds, u_int nfds, const struct timespec *ts, const sigset_t *mask); } @@ -270,4 +269,5 @@ SYS_POSIX_SPAWN = 474 // { int|sys||posix_spawn(pid_t *pid, const char *path, const struct posix_spawn_file_actions *file_actions, const struct posix_spawnattr *attrp, char *const *argv, char *const *envp); } SYS_RECVMMSG = 475 // { int|sys||recvmmsg(int s, struct mmsghdr *mmsg, unsigned int vlen, unsigned int flags, struct timespec *timeout); } SYS_SENDMMSG = 476 // { int|sys||sendmmsg(int s, struct mmsghdr *mmsg, unsigned int vlen, unsigned int flags); } + SYS__LWP_PARK = 478 // { int|sys||lwp_park(clockid_t clock_id, int flags, const struct timespec *ts, lwpid_t unpark, const void *hint, const void *unparkhint); ) diff -ru orig/src/syscall/zsysnum_netbsd_amd64.go go-1.9.2/src/syscall/zsysnum_netbsd_amd64.go --- orig/src/syscall/zsysnum_netbsd_amd64.go 2017-10-25 14:30:21.000000000 -0400 +++ go-1.9.2/src/syscall/zsysnum_netbsd_amd64.go 2017-12-02 11:41:34.507048643 -0500 @@ -229,7 +229,6 @@ SYS_CLOCK_GETRES = 429 // { int|sys|50|clock_getres(clockid_t clock_id, struct timespec *tp); } SYS_NANOSLEEP = 430 // { int|sys|50|nanosleep(const struct timespec *rqtp, struct timespec *rmtp); } SYS___SIGTIMEDWAIT = 431 // { int|sys|50|__sigtimedwait(const sigset_t *set, siginfo_t *info, struct timespec *timeout); } - SYS__LWP_PARK = 434 // { int|sys|50|_lwp_park(const struct timespec *ts, lwpid_t unpark, const void *hint, const void *unparkhint); } SYS_KEVENT = 435 // { int|sys|50|kevent(int fd, const struct kevent *changelist, size_t nchanges, struct kevent *eventlist, size_t nevents, const struct timespec *timeout); } SYS_PSELECT = 436 // { int|sys|50|pselect(int nd, fd_set *in, fd_set *ou, fd_set *ex, const struct timespec *ts, const sigset_t *mask); } SYS_POLLTS = 437 // { int|sys|50|pollts(struct pollfd *fds, u_int nfds, const struct timespec *ts, const sigset_t *mask); } @@ -270,4 +269,5 @@ SYS_POSIX_SPAWN = 474 // { int|sys||posix_spawn(pid_t *pid, const char *path, const struct posix_spawn_file_actions *file_actions, const struct posix_spawnattr *attrp, char *const *argv, char *const *envp); } SYS_RECVMMSG = 475 // { int|sys||recvmmsg(int s, struct mmsghdr *mmsg, unsigned int vlen, unsigned int flags, struct timespec *timeout); } SYS_SENDMMSG = 476 // { int|sys||sendmmsg(int s, struct mmsghdr *mmsg, unsigned int vlen, unsigned int flags); } + SYS__LWP_PARK = 478 // { int|sys||lwp_park(clockid_t clock_id, int flags, const struct timespec *ts, lwpid_t unpark, const void *hint, const void *unparkhint); ) diff -ru orig/src/syscall/zsysnum_netbsd_arm.go go-1.9.2/src/syscall/zsysnum_netbsd_arm.go --- orig/src/syscall/zsysnum_netbsd_arm.go 2017-10-25 14:30:21.000000000 -0400 +++ go-1.9.2/src/syscall/zsysnum_netbsd_arm.go 2017-12-02 11:41:43.416418780 -0500 @@ -229,7 +229,6 @@ SYS_CLOCK_GETRES = 429 // { int|sys|50|clock_getres(clockid_t clock_id, struct timespec *tp); } SYS_NANOSLEEP = 430 // { int|sys|50|nanosleep(const struct timespec *rqtp, struct timespec *rmtp); } SYS___SIGTIMEDWAIT = 431 // { int|sys|50|__sigtimedwait(const sigset_t *set, siginfo_t *info, struct timespec *timeout); } - SYS__LWP_PARK = 434 // { int|sys|50|_lwp_park(const struct timespec *ts, lwpid_t unpark, const void *hint, const void *unparkhint); } SYS_KEVENT = 435 // { int|sys|50|kevent(int fd, const struct kevent *changelist, size_t nchanges, struct kevent *eventlist, size_t nevents, const struct timespec *timeout); } SYS_PSELECT = 436 // { int|sys|50|pselect(int nd, fd_set *in, fd_set *ou, fd_set *ex, const struct timespec *ts, const sigset_t *mask); } SYS_POLLTS = 437 // { int|sys|50|pollts(struct pollfd *fds, u_int nfds, const struct timespec *ts, const sigset_t *mask); } @@ -270,4 +269,5 @@ SYS_POSIX_SPAWN = 474 // { int|sys||posix_spawn(pid_t *pid, const char *path, const struct posix_spawn_file_actions *file_actions, const struct posix_spawnattr *attrp, char *const *argv, char *const *envp); } SYS_RECVMMSG = 475 // { int|sys||recvmmsg(int s, struct mmsghdr *mmsg, unsigned int vlen, unsigned int flags, struct timespec *timeout); } SYS_SENDMMSG = 476 // { int|sys||sendmmsg(int s, struct mmsghdr *mmsg, unsigned int vlen, unsigned int flags); } + SYS__LWP_PARK = 478 // { int|sys||lwp_park(clockid_t clock_id, int flags, const struct timespec *ts, lwpid_t unpark, const void *hint, const void *unparkhint); )