123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171 |
- #include <sysdep.h>
- #define _ERRNO_H
- #include <features.h>
- #include <bits/errno.h>
- #include <sys/syscall.h>
- #include <bits/arm_asm.h>
- #include <bits/arm_bx.h>
- #if defined __UCLIBC_HAS_THREADS__ && !defined __UCLIBC_HAS_LINUXTHREADS__
- #include <sysdep-cancel.h>
- #endif
- #define CLONE_VM 0x00000100
- #define CLONE_THREAD 0x00010000
- #if defined(__NR_clone)
- .text
- .global __clone
- .type __clone,%function
- .align 2
- #if defined(THUMB1_ONLY)
- .thumb_func
- __clone:
-
- cmp r0, #0
- beq __einval
- cmp r1, #0
- beq __einval
-
- sub r1, r1, #8
- str r3, [r1, #4]
-
- str r0, [r1]
-
-
- mov r0, r2
-
- DO_CALL (clone)
- movs a1, a1
- blt __error
- beq 1f
- bx lr
- 1:
-
- ldr r0, [sp, #4]
- #if defined(ARCH_HAS_BX)
- ldr r1, [sp]
- bl 2f
- #else
- mov lr, pc
- ldr pc, [sp]
- #endif
-
- bl HIDDEN_JUMPTARGET(_exit)
-
- b .
- 2:
- bx r1
- __einval:
- ldr r0, =-EINVAL
- __error:
- push {r3, lr}
- bl __syscall_error
- POP_RET
- .pool
- #else
- __clone:
- .fnstart
- .cantunwind
-
- cmp r0, #0
- IT(te, ne)
- cmpne r1, #0
- moveq r0, #-EINVAL
- beq __error
-
- str r3, [r1, #-4]!
- str r0, [r1, #-4]!
-
-
- mov r0, r2
- #ifdef RESET_PID
- mov ip, r2
- #endif
-
- push {r4, r7}
- cfi_adjust_cfa_offset (8)
- cfi_rel_offset (r4, 0)
- cfi_rel_offset (r7, 4)
- ldr r2, [sp, #8]
- ldr r3, [sp, #12]
- ldr r4, [sp, #16]
- ldr r7, =SYS_ify(clone)
- swi 0x0
- cfi_endproc
- cmp r0, #0
- beq 1f
- pop {r4, r7}
- blt __error
- IT(t, ne)
- BXC(ne, lr)
- cfi_startproc
- .fnend
- PSEUDO_END (__clone)
- 1:
- .fnstart
- .cantunwind
- #ifdef RESET_PID
- tst ip, #CLONE_THREAD
- bne 3f
- GET_TLS (lr)
- mov r1, r0
- tst ip, #CLONE_VM
- ldr r7, =SYS_ify(getpid)
- ite ne
- movne r0, #-1
- swieq 0x0
- NEGOFF_ADJ_BASE (r1, TID_OFFSET)
- str r0, NEGOFF_OFF1 (r1, TID_OFFSET)
- str r0, NEGOFF_OFF2 (r1, PID_OFFSET, TID_OFFSET)
- 3:
- #endif
-
- ldr r0, [sp, #4]
- mov lr, pc
- ldr pc, [sp]
-
- b HIDDEN_JUMPTARGET(_exit)
- __error:
- b __syscall_error
- #endif
- .size __clone,.-__clone
- weak_alias(__clone, clone)
- #endif
|