2001-03-16 09:57:45 +00:00
|
|
|
/* Wrapper around clone system call. 64 bit S/390 version.
|
2016-01-04 16:05:18 +00:00
|
|
|
Copyright (C) 2001-2016 Free Software Foundation, Inc.
|
2000-08-02 15:15:00 +00:00
|
|
|
Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
|
2001-03-16 09:57:45 +00:00
|
|
|
This file is part of the GNU C Library.
|
2000-08-02 15:15:00 +00:00
|
|
|
|
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
2001-07-06 04:58:11 +00:00
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2.1 of the License, or (at your option) any later version.
|
2000-08-02 15:15:00 +00:00
|
|
|
|
|
|
|
The GNU C Library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
2001-07-06 04:58:11 +00:00
|
|
|
Lesser General Public License for more details.
|
2000-08-02 15:15:00 +00:00
|
|
|
|
2001-07-06 04:58:11 +00:00
|
|
|
You should have received a copy of the GNU Lesser General Public
|
2012-02-09 23:18:22 +00:00
|
|
|
License along with the GNU C Library; if not, see
|
|
|
|
<http://www.gnu.org/licenses/>. */
|
2000-08-02 15:15:00 +00:00
|
|
|
|
|
|
|
/* clone is even more special than fork as it mucks with stacks
|
|
|
|
and invokes a function in the right context after its all over. */
|
|
|
|
|
|
|
|
#include <sysdep.h>
|
2004-12-15 17:45:55 +00:00
|
|
|
#include <tls.h>
|
2000-08-02 15:15:00 +00:00
|
|
|
#define _ERRNO_H 1
|
|
|
|
#include <bits/errno.h>
|
|
|
|
|
2003-01-28 10:42:28 +00:00
|
|
|
/* int __clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg,
|
2003-01-28 18:51:03 +00:00
|
|
|
pid_t *parent_tid, void *tls, pid_t *child_tid); */
|
2003-01-28 10:42:28 +00:00
|
|
|
/* sys_clone (void *child_stack, unsigned long flags,
|
|
|
|
pid_t *parent_tid, pid_t *child_tid, void *tls); */
|
|
|
|
|
2000-08-02 15:15:00 +00:00
|
|
|
.text
|
|
|
|
ENTRY(__clone)
|
2003-01-28 18:51:03 +00:00
|
|
|
stg %r6,48(%r15) /* store %r6 to save area */
|
Update.
2003-12-05 Martin Schwidefsky <schwidefsky@de.ibm.com>
* sysdeps/s390/s390-32/elf/setjmp.S (setjmp, __setjmp): Add END
statements.
* sysdeps/s390/s390-64/elf/setjmp.S (setjmp, __setjmp): Likewise.
* sysdeps/s390/s390-32/sysdep.h (ENTRY): Add cfi_startproc directive.
(END): Add cfi_endproc directive.
* sysdeps/s390/s390-64/sysdep.h (ENTRY, END): Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/socket.S (__socket): Remove
cfi_startproc and cfi_endproc directive.
* sysdeps/unix/sysv/linux/s390/s390-64/socket.S (__socket): Likewise.
* sysdeps/s390/s390-32/addmul_1.S (__mpn_addmul_1): Add CFI directives.
* sysdeps/s390/s390-32/add_n.S (__mpn_add_n): Likewise.
* sysdeps/s390/s390-64/add_n.S (__mpn_add_n): Likewise.
* sysdeps/s390/s390-32/dl-machine.h (ELF_MACHINE_RUNTIME_TRAMPOLINE):
Likewise.
* sysdeps/s390/s390-64/dl-machine.h (ELF_MACHINE_RUNTIME_TRAMPOLINE):
Likewise.
* sysdeps/s390/s390-32/mul_1.S (__mpn_mul_1): Likewise.
* sysdeps/s390/s390-32/sub_n.S (__mpn_sub_n): Likewise.
* sysdeps/s390/s390-64/sub_n.S (__mpn_sub_n): Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/mmap64.S (__mmap64): Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/mmap.S (__mmap): Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/mmap.S (__mmap): Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/syscall.S (syscall): Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/syscall.S (syscall): Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/sysdep.S (__syscall_error):
Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/sysdep.S (__syscall_error):
Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/clone.S (__clone): Add CFI
directives. Move thread_start out of ENTRY/PSEUDO_END block to
make backchain terminate.
* sysdeps/unix/sysv/linux/s390/s390-64/clone.S (__clone): Likewise.
* sysdeps/s390/s390-32/backtrace.c (trace_arg): New structure.
(unwind_backtrace, unwind_getip): New variables.
(init, __backchain_backtrace, backtrace_helper): New functions.
(__backtrace): Use unwind info for backtrace instead of backchain
walking if the unwind functions can be found.
* sysdeps/s390/s390-64/backtrace.c: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/posix_fadvise64.c: New file.
* sysdeps/unix/sysv/linux/s390/sys/procfs.h (ELF_NGREG32): New #define.
(elf_greg_t32, elf_gregset_t32, elf_fpregset_t32): New types.
(elf_prstatus32, elf_prpsinfo32): New structures.
(prgregset32_t, prfpregset32_t, prstatus32_t, prpsinfo32_t): New types.
* scripts/data/c++-types-s390-linux-gnu.data: New file.
* scripts/data/c++-types-s390x-linux-gnu.data: New file.
2003-12-06 00:20:16 +00:00
|
|
|
cfi_offset (%r6,-112)
|
2003-01-28 10:42:28 +00:00
|
|
|
lgr %r0,%r5 /* move *arg out of the way */
|
2003-01-28 18:51:03 +00:00
|
|
|
ltgr %r1,%r2 /* check fn and move to %r1 */
|
|
|
|
jz error /* no NULL function pointers */
|
|
|
|
ltgr %r2,%r3 /* check child_stack and move to %r2 */
|
|
|
|
jz error /* no NULL stack pointers */
|
|
|
|
lgr %r3,%r4 /* move flags to %r3 */
|
|
|
|
lgr %r4,%r6 /* move parent_tid to %r4 */
|
|
|
|
lg %r5,168(%r15) /* load child_tid from stack */
|
2003-01-30 21:09:44 +00:00
|
|
|
lg %r6,160(%r15) /* load tls from stack */
|
2001-03-16 09:57:45 +00:00
|
|
|
svc SYS_ify(clone)
|
|
|
|
ltgr %r2,%r2 /* check return code */
|
|
|
|
jz thread_start
|
Update.
2003-01-30 Jakub Jelinek <jakub@redhat.com>
* sysdeps/alpha/tls.h (THREAD_GETMEM, THREAD_GETMEM_NC,
THREAD_SETMEM, THREAD_SETMEM_NC): Avoid warnings about unused self
variable.
* sysdeps/ia64/pt-machine.h (THREAD_GETMEM, THREAD_GETMEM_NC,
THREAD_SETMEM, THREAD_SETMEM_NC): Likewise.
* sysdeps/s390/s390-32/pt-machine.h (THREAD_GETMEM, THREAD_GETMEM_NC,
THREAD_SETMEM, THREAD_SETMEM_NC): Likewise.
* sysdeps/s390/s390-64/pt-machine.h (THREAD_GETMEM, THREAD_GETMEM_NC,
THREAD_SETMEM, THREAD_SETMEM_NC): Likewise.
* sysdeps/sh/pt-machine.h (THREAD_GETMEM, THREAD_GETMEM_NC,
THREAD_SETMEM, THREAD_SETMEM_NC): Likewise.
* sysdeps/sparc/sparc32/pt-machine.h (THREAD_GETMEM, THREAD_GETMEM_NC,
THREAD_SETMEM, THREAD_SETMEM_NC): Likewise.
* sysdeps/sparc/sparc64/pt-machine.h (THREAD_GETMEM, THREAD_GETMEM_NC,
THREAD_SETMEM, THREAD_SETMEM_NC): Likewise.
2003-01-30 18:04:01 +00:00
|
|
|
lg %r6,48(%r15) /* restore %r6 */
|
|
|
|
jgm SYSCALL_ERROR_LABEL
|
2001-03-16 09:57:45 +00:00
|
|
|
br %r14
|
2003-01-28 18:51:03 +00:00
|
|
|
error:
|
|
|
|
lghi %r2,-EINVAL
|
|
|
|
jg SYSCALL_ERROR_LABEL
|
Update.
2003-12-05 Martin Schwidefsky <schwidefsky@de.ibm.com>
* sysdeps/s390/s390-32/elf/setjmp.S (setjmp, __setjmp): Add END
statements.
* sysdeps/s390/s390-64/elf/setjmp.S (setjmp, __setjmp): Likewise.
* sysdeps/s390/s390-32/sysdep.h (ENTRY): Add cfi_startproc directive.
(END): Add cfi_endproc directive.
* sysdeps/s390/s390-64/sysdep.h (ENTRY, END): Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/socket.S (__socket): Remove
cfi_startproc and cfi_endproc directive.
* sysdeps/unix/sysv/linux/s390/s390-64/socket.S (__socket): Likewise.
* sysdeps/s390/s390-32/addmul_1.S (__mpn_addmul_1): Add CFI directives.
* sysdeps/s390/s390-32/add_n.S (__mpn_add_n): Likewise.
* sysdeps/s390/s390-64/add_n.S (__mpn_add_n): Likewise.
* sysdeps/s390/s390-32/dl-machine.h (ELF_MACHINE_RUNTIME_TRAMPOLINE):
Likewise.
* sysdeps/s390/s390-64/dl-machine.h (ELF_MACHINE_RUNTIME_TRAMPOLINE):
Likewise.
* sysdeps/s390/s390-32/mul_1.S (__mpn_mul_1): Likewise.
* sysdeps/s390/s390-32/sub_n.S (__mpn_sub_n): Likewise.
* sysdeps/s390/s390-64/sub_n.S (__mpn_sub_n): Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/mmap64.S (__mmap64): Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/mmap.S (__mmap): Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/mmap.S (__mmap): Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/syscall.S (syscall): Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/syscall.S (syscall): Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/sysdep.S (__syscall_error):
Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/sysdep.S (__syscall_error):
Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/clone.S (__clone): Add CFI
directives. Move thread_start out of ENTRY/PSEUDO_END block to
make backchain terminate.
* sysdeps/unix/sysv/linux/s390/s390-64/clone.S (__clone): Likewise.
* sysdeps/s390/s390-32/backtrace.c (trace_arg): New structure.
(unwind_backtrace, unwind_getip): New variables.
(init, __backchain_backtrace, backtrace_helper): New functions.
(__backtrace): Use unwind info for backtrace instead of backchain
walking if the unwind functions can be found.
* sysdeps/s390/s390-64/backtrace.c: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/posix_fadvise64.c: New file.
* sysdeps/unix/sysv/linux/s390/sys/procfs.h (ELF_NGREG32): New #define.
(elf_greg_t32, elf_gregset_t32, elf_fpregset_t32): New types.
(elf_prstatus32, elf_prpsinfo32): New structures.
(prgregset32_t, prfpregset32_t, prstatus32_t, prpsinfo32_t): New types.
* scripts/data/c++-types-s390-linux-gnu.data: New file.
* scripts/data/c++-types-s390x-linux-gnu.data: New file.
2003-12-06 00:20:16 +00:00
|
|
|
PSEUDO_END (__clone)
|
2000-08-02 15:15:00 +00:00
|
|
|
|
|
|
|
thread_start:
|
2004-12-15 17:45:55 +00:00
|
|
|
tmh %r3,1 /* CLONE_THREAD == 0x00010000 */
|
|
|
|
jne 1f
|
|
|
|
lhi %r2,-1
|
|
|
|
tml %r3,256 /* CLONE_VM == 0x00000100 */
|
|
|
|
jne 2f
|
|
|
|
svc SYS_ify(getpid)
|
|
|
|
2: ear %r3,%a0
|
|
|
|
sllg %r3,%r3,32
|
|
|
|
ear %r3,%a1
|
|
|
|
st %r2,PID(%r3)
|
|
|
|
st %r2,TID(%r3)
|
|
|
|
1:
|
2003-01-28 10:42:28 +00:00
|
|
|
/* fn is in gpr 1, arg in gpr 0 */
|
|
|
|
lgr %r2,%r0 /* set first parameter to void *arg */
|
2001-05-16 16:12:54 +00:00
|
|
|
aghi %r15,-160 /* make room on the stack for the save area */
|
2003-01-28 10:42:28 +00:00
|
|
|
xc 0(8,%r15),0(%r15)
|
2001-03-16 09:57:45 +00:00
|
|
|
basr %r14,%r1 /* jump to fn */
|
2004-07-01 17:50:47 +00:00
|
|
|
DO_CALL (exit, 1)
|
2002-02-07 17:54:45 +00:00
|
|
|
weak_alias (__clone, clone)
|