]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/l4re-core/uclibc/lib/contrib/uclibc/libc/sysdeps/linux/arm/vfork.S
Update
[l4.git] / l4 / pkg / l4re-core / uclibc / lib / contrib / uclibc / libc / sysdeps / linux / arm / vfork.S
1 /* vi: set sw=4 ts=4: */
2 /*
3  * vfork for uClibc
4  * Copyright (C) 2000-2006 by Erik Andersen <andersen@uclibc.org>
5  * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
6  */
7
8 #include <features.h>
9 #include <bits/arm_asm.h>
10 #include <bits/arm_bx.h>
11
12 #define _ERRNO_H
13 #include <bits/errno.h>
14 #include <sys/syscall.h>
15
16 #ifndef SAVE_PID
17 #define SAVE_PID
18 #endif
19
20 #ifndef RESTORE_PID
21 #define RESTORE_PID
22 #endif
23
24
25 #ifdef __NR_fork
26 .text
27 .global __vfork
28 .hidden __vfork
29 .type   __vfork,%function
30 .align 4
31
32 #if defined(__thumb__) && !defined(__thumb2__)
33 .thumb_func
34 __vfork:
35 #ifdef __NR_vfork
36         SAVE_PID
37         DO_CALL (vfork)
38         RESTORE_PID
39         ldr             r1, =0xfffff000
40         cmp             r0, r1
41         bcs             1f
42         bx              lr
43 1:
44
45         /* Check if vfork even exists.  */
46         ldr             r1, =-ENOSYS
47         cmp             r0, r1
48         bne             __error
49
50         /* If we don't have vfork, use fork.  */
51         DO_CALL (fork)
52         ldr             r1, =0xfffff000
53         cmp             r0, r1
54
55         /* Syscall worked.  Return to child/parent */
56         bcs             1f
57         bx              lr
58 1:
59
60 __error:
61         push    {r3, lr}
62         bl      __syscall_error
63         POP_RET
64 .pool
65
66 #endif
67
68 #else
69 __vfork:
70
71 #ifdef __NR_vfork
72         SAVE_PID
73         DO_CALL (vfork)
74         RESTORE_PID
75         cmn     r0, #4096
76         IT(t, cc)
77 #if defined(__USE_BX__)
78         bxcc    lr
79 #else
80         movcc   pc, lr
81 #endif
82
83         /* Check if vfork even exists.  */
84         ldr     r1, =-ENOSYS
85         teq     r0, r1
86         bne     __error
87 #endif
88
89         /* If we don't have vfork, use fork.  */
90         DO_CALL (fork)
91         cmn     r0, #4096
92
93         /* Syscall worked.  Return to child/parent */
94         IT(t, cc)
95 #if defined(__USE_BX__)
96         bxcc    lr
97 #else
98         movcc   pc, lr
99 #endif
100
101 __error:
102         b       __syscall_error
103 #endif
104
105 .size __vfork,.-__vfork
106
107 weak_alias(__vfork,vfork)
108 libc_hidden_def(vfork)
109 #endif