1
0
mirror of https://github.com/golang/go synced 2024-11-23 23:00:03 -07:00

runtime: fix darwin/386, darwin/arm builds

In cl/8652 I broke darwin/arm and darwin/386 because I removed the *g
parameter, which they both expect and use. This CL adjusts both ports
to look for g0 in m, just as darwin/amd64 does.

Tested on darwin{386,arm,amd64}.

Change-Id: Ia56f3d97e126b40d8bbd2e8f677b008e4a1badad
Reviewed-on: https://go-review.googlesource.com/8666
Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
David Crawshaw 2015-04-08 19:44:14 -04:00
parent e0d9342da7
commit c844bf4cfc
3 changed files with 21 additions and 22 deletions

View File

@ -327,33 +327,32 @@ TEXT runtime·usleep(SB),NOSPLIT,$32
INT $0x80
RET
// func bsdthread_create(stk unsafe.Pointer, mm *m, gg *g, fn uintptr) int32
// func bsdthread_create(stk, arg unsafe.Pointer, fn uintptr) int32
// System call args are: func arg stack pthread flags.
TEXT runtime·bsdthread_create(SB),NOSPLIT,$32
MOVL $360, AX
// 0(SP) is where the caller PC would be; kernel skips it
MOVL fn+12(FP), BX
MOVL fn+8(FP), BX
MOVL BX, 4(SP) // func
MOVL mm+4(FP), BX
MOVL arg+4(FP), BX
MOVL BX, 8(SP) // arg
MOVL stk+0(FP), BX
MOVL BX, 12(SP) // stack
MOVL gg+8(FP), BX
MOVL BX, 16(SP) // pthread
MOVL $0, 16(SP) // pthread
MOVL $0x1000000, 20(SP) // flags = PTHREAD_START_CUSTOM
INT $0x80
JAE 4(PC)
NEGL AX
MOVL AX, ret+16(FP)
MOVL AX, ret+12(FP)
RET
MOVL $0, AX
MOVL AX, ret+16(FP)
MOVL AX, ret+12(FP)
RET
// The thread that bsdthread_create creates starts executing here,
// because we registered this function using bsdthread_register
// at startup.
// AX = "pthread" (= g)
// AX = "pthread" (= 0x0)
// BX = mach thread port
// CX = "func" (= fn)
// DX = "arg" (= m)
@ -380,6 +379,7 @@ TEXT runtime·bsdthread_start(SB),NOSPLIT,$0
// Now segment is established. Initialize m, g.
get_tls(BP)
MOVL m_g0(DX), AX
MOVL AX, g(BP)
MOVL DX, g_m(AX)
MOVL BX, m_procid(DX) // m->procid = thread port (for debuggers)

View File

@ -308,12 +308,12 @@ TEXT runtime·bsdthread_create(SB),NOSPLIT,$0
// Set up arguments to bsdthread_create system call.
// The ones in quotes pass through to the thread callback
// uninterpreted, so we can put whatever we want there.
MOVQ fn+24(SP), DI // "func"
MOVQ arg+16(SP), SI // "arg"
MOVQ stk+8(SP), DX // stack
MOVQ $0, R10 // "pthread", paranoia
MOVQ $0x01000000, R8 // flags = PTHREAD_START_CUSTOM
MOVQ $0, R9 // paranoia
MOVQ fn+24(SP), DI
MOVQ arg+16(SP), SI
MOVQ stk+8(SP), DX
MOVQ $0x01000000, R8 // flags = PTHREAD_START_CUSTOM
MOVQ $0, R9 // paranoia
MOVQ $0, R10 // paranoia, "pthread"
MOVQ $(0x2000000+360), AX // bsdthread_create
SYSCALL
JCC 4(PC)

View File

@ -320,26 +320,25 @@ sysctl_ret:
RET
// Thread related functions
// void bsdthread_create(void *stk, M *m, G *g, void (*fn)(void))
// func bsdthread_create(stk, arg unsafe.Pointer, fn uintptr) int32
TEXT runtime·bsdthread_create(SB),NOSPLIT,$0
// Set up arguments to bsdthread_create system call.
// The ones in quotes pass through to the thread callback
// uninterpreted, so we can put whatever we want there.
MOVW fn+12(FP), R0 // "func"
MOVW mm+4(FP), R1 // "arg"
MOVW stk+0(FP), R2 // stack
MOVW gg+8(FP), R3 // "pthread"
MOVW fn+8(FP), R0 // "func"
MOVW arg+4(FP), R1 // "arg"
MOVW stk+0(FP), R2 // stack
MOVW $0x01000000, R4 // flags = PTHREAD_START_CUSTOM
MOVW $0, R5 // paranoia
MOVW $0, R5 // paranoia
MOVW $SYS_bsdthread_create, R12
SWI $0x80
BCC create_ret
RSB $0, R0, R0
MOVW R0, ret+16(FP)
MOVW R0, ret+12(FP)
RET
create_ret:
MOVW $0, R0
MOVW R0, ret+16(FP)
MOVW R0, ret+12(FP)
RET
// The thread that bsdthread_create creates starts executing here,