vfork.S 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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, write to the Free
  13. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  14. 02111-1307 USA. */
  15. #include <sysdep-cancel.h>
  16. .align 4
  17. .globl __vfork
  18. .type __vfork, @function
  19. .usepv __vfork, std
  20. cfi_startproc
  21. __vfork:
  22. ldgp gp, 0(pv)
  23. PSEUDO_PROF
  24. #ifdef SHARED
  25. ldq t0, __libc_pthread_functions(gp) !gprel
  26. bne t0, HIDDEN_JUMPTARGET (__fork) !samegp
  27. #else
  28. .weak pthread_create
  29. ldq t0, pthread_create(gp) !literal
  30. bne t0, $do_fork
  31. #endif
  32. lda v0, SYS_ify(vfork)
  33. call_pal PAL_callsys
  34. bne a3, SYSCALL_ERROR_LABEL
  35. ret
  36. #ifndef SHARED
  37. /* Can't tail-call due to possible mismatch between GP in
  38. fork and vfork object files. */
  39. $do_fork:
  40. subq sp, 16, sp
  41. cfi_adjust_cfa_offset(16)
  42. stq ra, 0(sp)
  43. cfi_offset(ra, -16)
  44. jsr ra, HIDDEN_JUMPTARGET (__fork)
  45. ldgp gp, 0(ra)
  46. ldq ra, 0(sp)
  47. addq sp, 16, sp
  48. cfi_restore(ra)
  49. cfi_adjust_cfa_offset(-16)
  50. ret
  51. $syscall_error:
  52. SYSCALL_ERROR_HANDLER
  53. #endif
  54. cfi_endproc
  55. .size __vfork, .-__vfork
  56. libc_hidden_def (__vfork)
  57. weak_alias (__vfork, vfork)