runtime: implement runtime.usleep for FreeBSD/386 and amd64.
R=golang-dev, jsing
CC=golang-dev
https://golang.org/cl/5528106
diff --git a/src/pkg/runtime/sys_freebsd_amd64.s b/src/pkg/runtime/sys_freebsd_amd64.s
index d5bb5f0..dcd5585 100644
--- a/src/pkg/runtime/sys_freebsd_amd64.s
+++ b/src/pkg/runtime/sys_freebsd_amd64.s
@@ -184,8 +184,22 @@
CALL runtime·notok(SB)
RET
-// TODO: Implement usleep
-TEXT runtime·usleep(SB),7,$0
+TEXT runtime·usleep(SB),7,$16
+ MOVL $0, DX
+ MOVL usec+0(FP), AX
+ MOVL $1000000, CX
+ DIVL CX
+ MOVQ AX, 0(SP) // tv_sec
+ MOVL $1000, AX
+ MULL DX
+ MOVQ AX, 8(SP) // tv_nsec
+
+ MOVQ SP, DI // arg 1 - rqtp
+ MOVQ $0, SI // arg 2 - rmtp
+ MOVL $240, AX // sys_nanosleep
+ SYSCALL
+ JCC 2(PC)
+ CALL runtime·notok(SB)
RET
// set tls base to DI