-#elif defined(__arm__)
-
- .globl cerror
- MI_ENTRY_POINT(_fork)
- stmfd sp!, {r4, r7, lr}
- add r7, sp, #4
- MI_CALL_EXTERNAL(__cthread_fork_prepare)
- mov r1, #1 // prime results
- mov r12, #SYS_fork
- swi #SWI_SYSCALL // make the syscall
- bcs Lbotch // error?
- cmp r1, #0 // parent (r1=0) or child(r1=1)
- beq Lparent
-
- //child here...
- MI_GET_ADDRESS(r3, __current_pid)
- mov r0, #0
- str r0, [r3] // clear cached pid in child
-
-#if defined(__DYNAMIC__)
-// Here on the child side of the fork we need to tell the dynamic linker that
-// we have forked. To do this we call __dyld_fork_child in the dyanmic
-// linker. But since we can't dynamicly bind anything until this is done we
-// do this by using the private extern __dyld_func_lookup() function to get the
-// address of __dyld_fork_child (the 'C' code equivlent):
-//
-// _dyld_func_lookup("__dyld_fork_child", &address);
-// address();
-//
- .cstring
- .align 2
-LC0:
- .ascii "__dyld_fork_child\0"
-.text
-.align 2
- sub sp, sp, #4 // allocate space for the address parameter
- mov r1, sp // get the address of the allocated space
- ldr r0, LP0 // get the name of the function to look up
-L0: add r0, pc, r0
- bl __dyld_func_lookup
- mov lr, pc
- ldr pc, [sp], #4 // call __dyld_fork_child indirectly and pop
-#endif
- MI_CALL_EXTERNAL(__cthread_fork_child) // let child get ready
- mov r0, #0
- ldmfd sp!, {r4, r7, pc}
-
-Lbotch:
- MI_CALL_EXTERNAL(cerror) // jump here on error
- mov r0,#-1 // set the error
- // fall thru
-
-Lparent:
- mov r4, r0 // save child pid
- MI_CALL_EXTERNAL(__cthread_fork_parent)
- mov r0, r4 // restore child pid
- ldmfd sp!, {r4, r7, pc} // pop and return
-
- .align 2
-#if defined(__DYNAMIC__)
-LP0:
- .long LC0-(L0+8)
-#endif
-