arc: clone: Simplify CLONE_THREAD detection
[uclibc-ng.git] / libc / sysdeps / linux / arc / vfork.S
blob573a29f26852f7cdf85b275cdbcfb551e929c4d6
1 /*
2  * Copyright (C) 2013 Synopsys, Inc. (www.synopsys.com)
3  *
4  * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
5  */
7 #include <sys/syscall.h>
8 #include <sysdep.h>
10 /* No legacy syscall ABI means NR_vfork is not available at all, use clone */
11 #define _SIGNAL_H
12 #include <bits/signum.h>       /* For SIGCHLD */
14 #define CLONE_VM                0x00000100
15 #define CLONE_VFORK             0x00004000
16 #define CLONE_FLAGS_FOR_VFORK   (CLONE_VM|CLONE_VFORK|SIGCHLD)
18 ENTRY(__vfork)
19 #ifdef SAVE_PID
20         THREAD_SELF r1          ; Get to struct pthread (just before TCB)
21         ld      r2, [r1, PTHREAD_PID]
22         neg.f   r3, r2
23         bset.z  r3, r3, 31
24         st      r3, [r1, PTHREAD_PID]
25 #endif
26         mov     r0, CLONE_FLAGS_FOR_VFORK
27         mov_s   r1, sp
28         mov     r8, __NR_clone
29         ARC_TRAP_INSN
31         cmp     r0, 0
32 #ifdef RESTORE_PID
33         bz      1f      ; child continues
34         THREAD_SELF r1          ; Get to struct pthread (just before TCB)
35         st      r2, [r1, PTHREAD_PID]
37 #endif
38         jge     [blink] ; pid >=0 return, else detour via tailcall to errno
40         b   __syscall_error
41 END(__vfork)
43 weak_alias(__vfork,vfork)
44 libc_hidden_def(vfork)