mirror of
https://github.com/golang/go.git
synced 2024-09-30 06:47:04 +00:00
runtime: give proper messages when user defined DYLD_INSERT_LIBRARIES on Darwin
also gives clear error when bsdthread_register fails on Darwin Fixes #2992. R=rsc, krautz CC=golang-dev https://golang.org/cl/5966067
This commit is contained in:
parent
1bdb788b2e
commit
44fd1d1a6a
@ -6,7 +6,7 @@
|
||||
#define SIG_IGN ((void*)1)
|
||||
|
||||
int32 runtime·bsdthread_create(void*, M*, G*, void(*)(void));
|
||||
void runtime·bsdthread_register(void);
|
||||
int32 runtime·bsdthread_register(void);
|
||||
int32 runtime·mach_msg_trap(MachHeader*, int32, uint32, uint32, uint32, uint32, uint32);
|
||||
uint32 runtime·mach_reply_port(void);
|
||||
int32 runtime·mach_semacquire(uint32, int64);
|
||||
|
@ -268,8 +268,10 @@ TEXT runtime·bsdthread_register(SB),7,$40
|
||||
MOVL $0, 20(SP) // targetconc_ptr
|
||||
MOVL $0, 24(SP) // dispatchqueue_offset
|
||||
INT $0x80
|
||||
JAE 2(PC)
|
||||
MOVL $0xf1, 0xf1 // crash
|
||||
JAE 3(PC)
|
||||
NEGL AX
|
||||
RET
|
||||
MOVL $0, AX
|
||||
RET
|
||||
|
||||
// Invoke Mach system call.
|
||||
|
@ -265,8 +265,10 @@ TEXT runtime·bsdthread_register(SB),7,$0
|
||||
MOVQ $0, R9 // dispatchqueue_offset
|
||||
MOVQ $(0x2000000+366), AX // bsdthread_register
|
||||
SYSCALL
|
||||
JCC 2(PC)
|
||||
MOVL $0xf1, 0xf1 // crash
|
||||
JCC 3(PC)
|
||||
NEGL AX
|
||||
RET
|
||||
MOVL $0, AX
|
||||
RET
|
||||
|
||||
// Mach system calls use 0x1000000 instead of the BSD's 0x2000000.
|
||||
|
@ -50,11 +50,8 @@ runtime·semacreate(void)
|
||||
void
|
||||
runtime·osinit(void)
|
||||
{
|
||||
// Register our thread-creation callback (see sys_darwin_{amd64,386}.s)
|
||||
// but only if we're not using cgo. If we are using cgo we need
|
||||
// to let the C pthread libary install its own thread-creation callback.
|
||||
if(!runtime·iscgo)
|
||||
runtime·bsdthread_register();
|
||||
// bsdthread_register delayed until end of goenvs so that we
|
||||
// can look at the environment first.
|
||||
|
||||
// Use sysctl to fetch hw.ncpu.
|
||||
uint32 mib[2];
|
||||
@ -75,6 +72,18 @@ void
|
||||
runtime·goenvs(void)
|
||||
{
|
||||
runtime·goenvs_unix();
|
||||
|
||||
// Register our thread-creation callback (see sys_darwin_{amd64,386}.s)
|
||||
// but only if we're not using cgo. If we are using cgo we need
|
||||
// to let the C pthread libary install its own thread-creation callback.
|
||||
if(!runtime·iscgo) {
|
||||
if(runtime·bsdthread_register() != 0) {
|
||||
if(runtime·getenv("DYLD_INSERT_LIBRARIES"))
|
||||
runtime·throw("runtime: bsdthread_register error (unset DYLD_INSERT_LIBRARIES)");
|
||||
runtime·throw("runtime: bsdthread_register error");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
|
Loading…
Reference in New Issue
Block a user