vfork.S 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /* Copyright (C) 1999, 2002, 2003, 2005 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. Contributed by Philip Blundell <philb@gnu.org>.
  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. #include <kernel-features.h>
  19. /* Clone the calling process, but without copying the whole address space.
  20. The calling process is suspended until the new process exits or is
  21. replaced by a call to `execve'. Return -1 for errors, 0 to the new process,
  22. and the process ID of the new process to the old process. */
  23. ENTRY (__vfork)
  24. #ifdef __NR_vfork
  25. #ifdef SHARED
  26. ldr ip, 1f
  27. ldr r0, 2f
  28. 3: add ip, pc, ip
  29. ldr r0, [ip, r0]
  30. #else
  31. ldr r0, 1f
  32. #endif
  33. movs r0, r0
  34. bne HIDDEN_JUMPTARGET (fork)
  35. DO_CALL (vfork, 0)
  36. cmn a1, #4096
  37. RETINSTR(cc, lr)
  38. #ifndef __ASSUME_VFORK_SYSCALL
  39. /* Check if vfork syscall is known at all. */
  40. cmn a1, #ENOSYS
  41. bne PLTJMP(C_SYMBOL_NAME(__syscall_error))
  42. #endif
  43. #endif
  44. #ifndef __ASSUME_VFORK_SYSCALL
  45. /* If we don't have vfork, fork is close enough. */
  46. DO_CALL (fork, 0)
  47. cmn a1, #4096
  48. RETINSTR(cc, lr)
  49. #elif !defined __NR_vfork
  50. # error "__NR_vfork not available and __ASSUME_VFORK_SYSCALL defined"
  51. #endif
  52. b PLTJMP(C_SYMBOL_NAME(__syscall_error))
  53. #ifdef SHARED
  54. 1: .word _GLOBAL_OFFSET_TABLE_ - 3b - 8
  55. 2: .word __libc_pthread_functions(GOTOFF)
  56. #else
  57. .weak pthread_create
  58. 1: .word pthread_create
  59. #endif
  60. PSEUDO_END (__vfork)
  61. libc_hidden_def (__vfork)
  62. weak_alias (__vfork, vfork)