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