(CFLAGS-tst-align.c): Add -mpreferred-stack-boundary=4.
[glibc.git] / linuxthreads / sysdeps / unix / sysv / linux / sh / vfork.S
blobf230c01226a72000105d6d708a51f8eff281a2bd
1 /* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
2    This file is part of the GNU C Library.
4    The GNU C Library is free software; you can redistribute it and/or
5    modify it under the terms of the GNU Lesser General Public
6    License as published by the Free Software Foundation; either
7    version 2.1 of the License, or (at your option) any later version.
9    The GNU C Library is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12    Lesser General Public License for more details.
14    You should have received a copy of the GNU Lesser General Public
15    License along with the GNU C Library; if not, write to the Free
16    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
17    02111-1307 USA.  */
19 #include <sysdep-cancel.h>
20 #define _ERRNO_H        1
21 #include <bits/errno.h>
23 /* Clone the calling process, but without copying the whole address space.
24    The calling process is suspended until the new process exits or is
25    replaced by a call to `execve'.  Return -1 for errors, 0 to the new process,
26    and the process ID of the new process to the old process.  */
28 ENTRY (__vfork)
29 #ifdef SHARED
30         mov.l   .Lgot, r1
31         mova    .Lgot, r0
32         add     r0, r1
33         mov.l   .Lpthread_func, r0
34         mov.l   @(r0,r1), r0
35 #else
36         mov.l   .Lpthread_create, r0
37 #endif
38         tst     r0, r0
39         bf      .Lhidden_fork
41         mov.w   .L1, r3
42         trapa   #0x10
43         mov     r0, r1
44         mov     #-12, r2
45         shad    r2, r1
46         not     r1, r1                  // r1=0 means r0 = -1 to -4095
47         tst     r1, r1                  // i.e. error in linux
48         bf      .Lpseudo_end
49         SYSCALL_ERROR_HANDLER
50 .Lpseudo_end:
51         rts
52          nop
53 .L1:    .word   __NR_vfork
54         .align  2
55 #ifdef SHARED
56 .Lgot:
57         .long   _GLOBAL_OFFSET_TABLE_
58 .Lpthread_func:
59         .long   __libc_pthread_functions@GOTOFF
60 #else
61 .Lpthread_create:
62         .weak   pthread_create
63         .long   pthread_create
64 #endif
66 .Lhidden_fork:  
67         mov.l   .L2, r1
68         braf    r1
69          nop
71         .align 2
72 .L2:    .long   HIDDEN_JUMPTARGET(__fork)-1b
74 PSEUDO_END (__vfork)
75 libc_hidden_def (__vfork)
77 weak_alias (__vfork, vfork)