vfork.S 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /* Copyright (C) 2003 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. The GNU C Library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public
  5. License as published by the Free Software Foundation; either
  6. version 2.1 of the License, or (at your option) any later version.
  7. The GNU C Library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public
  12. License along with the GNU C Library; if not, see
  13. <http://www.gnu.org/licenses/>. */
  14. #include <sysdep-cancel.h>
  15. .align 4
  16. .globl __vfork
  17. .type __vfork, @function
  18. .usepv __vfork, std
  19. cfi_startproc
  20. __vfork:
  21. ldgp gp, 0(pv)
  22. PSEUDO_PROF
  23. #ifdef SHARED
  24. ldq t0, __libc_pthread_functions(gp) !gprel
  25. bne t0, HIDDEN_JUMPTARGET (fork) !samegp
  26. #else
  27. .weak pthread_create
  28. ldq t0, pthread_create(gp) !literal
  29. bne t0, $do_fork
  30. #endif
  31. lda v0, SYS_ify(vfork)
  32. call_pal PAL_callsys
  33. bne a3, SYSCALL_ERROR_LABEL
  34. ret
  35. #ifndef SHARED
  36. /* Can't tail-call due to possible mismatch between GP in
  37. fork and vfork object files. */
  38. $do_fork:
  39. subq sp, 16, sp
  40. cfi_adjust_cfa_offset(16)
  41. stq ra, 0(sp)
  42. cfi_offset(ra, -16)
  43. jsr ra, HIDDEN_JUMPTARGET (fork)
  44. ldgp gp, 0(ra)
  45. ldq ra, 0(sp)
  46. addq sp, 16, sp
  47. cfi_restore(ra)
  48. cfi_adjust_cfa_offset(-16)
  49. ret
  50. $syscall_error:
  51. SYSCALL_ERROR_HANDLER
  52. #endif
  53. cfi_endproc
  54. .size __vfork, .-__vfork
  55. libc_hidden_def (__vfork)
  56. weak_alias (__vfork, vfork)