#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);
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.
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.
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];
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