vfork.S 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /* Copyright (C) 2003, 2004 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. #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. #ifdef SHARED
  24. mov.l .Lgot, r1
  25. mova .Lgot, r0
  26. add r0, r1
  27. mov.l .Lpthread_func, r0
  28. mov.l @(r0,r1), r0
  29. #else
  30. mov.l .Lpthread_create, r0
  31. #endif
  32. tst r0, r0
  33. bf .Lhidden_fork
  34. mov.w .L1, r3
  35. trapa #0x10
  36. mov r0, r1
  37. mov #-12, r2
  38. shad r2, r1
  39. not r1, r1 // r1=0 means r0 = -1 to -4095
  40. tst r1, r1 // i.e. error in linux
  41. bf .Lpseudo_end
  42. SYSCALL_ERROR_HANDLER
  43. .Lpseudo_end:
  44. rts
  45. nop
  46. .L1: .word __NR_vfork
  47. .align 2
  48. #ifdef SHARED
  49. .Lgot:
  50. .long _GLOBAL_OFFSET_TABLE_
  51. .Lpthread_func:
  52. .long __libc_pthread_functions@GOTOFF
  53. #else
  54. .Lpthread_create:
  55. .weak pthread_create
  56. .long pthread_create
  57. #endif
  58. .Lhidden_fork:
  59. mov.l .L2, r1
  60. braf r1
  61. nop
  62. 1:
  63. .align 2
  64. .L2: .long HIDDEN_JUMPTARGET(__fork)-1b
  65. PSEUDO_END (__vfork)
  66. libc_hidden_def (__vfork)
  67. weak_alias (__vfork, vfork)