123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- #include <features.h>
- #define _ERRNO_H 1
- #include <bits/errno.h>
- #include <sysdep.h>
- #define CLONE_VM 0x00000100
- #define CLONE_THREAD 0x00010000
- #ifdef __NR_clone
- .globl __clone
- .type __clone,@function
- .align 2
- __clone:
-
- cmpwi cr0,r4,0
- cmpwi cr1,r3,0
- cror cr0*4+eq,cr1*4+eq,cr0*4+eq
- beq- cr0,.Lbadargs
-
- stwu r1,-32(r1)
- cfi_adjust_cfa_offset (32)
- #ifdef RESET_PID
- stmw r28,16(r1)
- #else
- # ifndef __ASSUME_FIXED_CLONE_SYSCALL
- stmw r29,16(r1)
- # else
- stmw r30,16(r1)
- # endif
- #endif
-
- clrrwi r4,r4,4
- li r0,0
- stwu r0,-16(r4)
-
- mr r30,r3
- #ifndef __ASSUME_FIXED_CLONE_SYSCALL
- mr r29,r4
- #endif
- #ifdef RESET_PID
- mr r28,r5
- #endif
- mr r31,r6
-
- mr r3,r5
-
- mr r5,r7
- mr r6,r8
- mr r7,r9
-
- cfi_endproc
-
- li 0, __NR_clone
- sc
-
- cmpwi cr1,r3,0
- crandc cr1*4+eq,cr1*4+eq,cr0*4+so
- bne- cr1,.Lparent
- #ifndef __ASSUME_FIXED_CLONE_SYSCALL
-
- mr r1,r29
- #endif
- #ifdef RESET_PID
- andis. r0,r28,CLONE_THREAD>>16
- bne+ r0,.Loldpid
- andi. r0,r28,CLONE_VM
- li r3,-1
- bne- r0,.Lnomoregetpid
- .Lnomoregetpid:
- stw r3,TID(r2)
- stw r3,PID(r2)
- .Loldpid:
- #endif
-
- mtctr r30
- mr r3,r31
- bctrl
-
- b HIDDEN_JUMPTARGET(_exit)
- .Lparent:
-
- #ifdef RESET_PID
- lmw r28,16(r1)
- #else
- # ifndef __ASSUME_FIXED_CLONE_SYSCALL
- lmw r29,16(r1)
- # else
- lmw r30,16(r1)
- # endif
- #endif
- addi r1,r1,32
- bnslr+
- b __syscall_error
- .Lbadargs:
- li r3,EINVAL
- b __syscall_error
- cfi_startproc
- .size __clone,.-__clone
- weak_alias(__clone, clone)
- #endif
|