Commit nios2 port to master.
[glibc.git] / sysdeps / unix / sysv / linux / nios2 / vfork.S
blob67a06520d006723ef02596d92410b760fab16be2
1 /* vfork for Nios II Linux.
2    Copyright (C) 2005-2015 Free Software Foundation, Inc.
3    This file is part of the GNU C Library.
5    The GNU C Library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Lesser General Public
7    License as published by the Free Software Foundation; either
8    version 2.1 of the License, or (at your option) any later version.
10    The GNU C Library is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    Lesser General Public License for more details.
15    You should have received a copy of the GNU Lesser General Public
16    License along with the GNU C Library; if not, see
17    <http://www.gnu.org/licenses/>.  */
19 #include <sysdep.h>
20 #include <tcb-offsets.h>
22 ENTRY(__vfork)
24         ldw     r6, PID_OFFSET(r23)
25         sub     r7, zero, r6
26         bne     r7, zero, 2f
27         movhi   r7, %hi(0x80000000)
29         stw     r7, PID_OFFSET(r23)
31         movi    r4, 0x4111 /* (CLONE_VM | CLONE_VFORK | SIGCHLD) */
32         mov     r5, zero
33         DO_CALL (clone, 2)
35         beq     r2, zero, 1f
36         stw     r6, PID_OFFSET(r23)
38         bne     r7, zero, SYSCALL_ERROR_LABEL
39         ret
41 PSEUDO_END (__vfork)
42 libc_hidden_def (__vfork)
44 weak_alias (__vfork, vfork)