vfork.S 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /* Copyright (C) 2003 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. Contributed by Martin Schwidefsky <schwidefsky@de.ibm.com>
  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.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, see
  14. <http://www.gnu.org/licenses/>. */
  15. #include <sysdep-cancel.h>
  16. #define _ERRNO_H 1
  17. #include <bits/errno.h>
  18. /* Clone the calling process, but without copying the whole address space.
  19. The calling process is suspended until the new process exits or is
  20. replaced by a call to `execve'. Return -1 for errors, 0 to the new process,
  21. and the process ID of the new process to the old process. */
  22. ENTRY (__vfork)
  23. basr %r1,0
  24. 0:
  25. #ifdef SHARED
  26. al %r1,4f-0b(%r1)
  27. l %r1,0(%r1)
  28. ltr %r1,%r1
  29. #else
  30. icm %r1,15,4f-0b(%r1)
  31. #endif
  32. jne 1f
  33. /* Do vfork system call. */
  34. svc SYS_ify (vfork)
  35. /* Check for error. */
  36. lhi %r4,-4095
  37. clr %r2,%r4
  38. jnl SYSCALL_ERROR_LABEL
  39. /* Normal return. */
  40. br %r14
  41. 1:
  42. basr %r1,0
  43. 2:
  44. al %r1,3f-2b(%r1)
  45. br %r1
  46. 3:
  47. .long HIDDEN_JUMPTARGET(fork)-2b
  48. 4:
  49. #ifdef SHARED
  50. .long __libc_pthread_functions-0b
  51. #else
  52. .weak pthread_create
  53. .long pthread_create
  54. #endif
  55. PSEUDO_END(__vfork)
  56. libc_hidden_def (__vfork)
  57. weak_alias (__vfork, vfork)