vfork.S 953 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * June 27, 2001 Manuel Novoa III
  3. *
  4. * Modified to (hopefully) be PIC and REENTRANT safe.
  5. * Modified again to better follow the glibc implementation.
  6. *
  7. */
  8. #define _ERRNO_H 1
  9. #include <bits/errno.h>
  10. #include <sys/syscall.h>
  11. .text
  12. .globl __vfork;
  13. .type __vfork,@function;
  14. .align 1<<4;
  15. __vfork:
  16. #ifdef __NR_vfork
  17. popl %ecx
  18. movl $__NR_vfork,%eax
  19. int $0x80
  20. pushl %ecx
  21. cmpl $-4095,%eax
  22. jae .Lerror
  23. ret
  24. .Lerror:
  25. cmpl $-ENOSYS,%eax
  26. jne __syscall_error
  27. #endif
  28. /* Fall back on calling fork */
  29. movl $__NR_fork,%eax
  30. int $0x80
  31. cmpl $-4095,%eax
  32. jae __syscall_error
  33. ret
  34. __syscall_error:
  35. negl %eax
  36. pushl %eax
  37. #ifdef __PIC__
  38. call .Lthere
  39. .Lthere:
  40. popl %ebx
  41. addl $_GLOBAL_OFFSET_TABLE_+[.- .Lthere ], %ebx
  42. call __errno_location@PLT
  43. #else
  44. call __errno_location
  45. #endif
  46. popl %ecx
  47. movl %ecx, (%eax)
  48. xorl %eax, %eax
  49. decl %eax
  50. .Lsize:
  51. .size __vfork,.Lsize-__vfork
  52. .weak vfork ; vfork = __vfork