vfork.S 934 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
  3. *
  4. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  5. */
  6. #include <features.h>
  7. #include <asm/unistd.h>
  8. #ifndef __NR_vfork
  9. #define __NR_vfork __NR_fork /* uClinux-2.0 only has fork which is vfork */
  10. #endif
  11. #define IMM #
  12. .text
  13. .align 2
  14. .globl errno
  15. .globl vfork
  16. #ifdef __HAVE_ELF__
  17. .type vfork,@function
  18. #endif
  19. vfork:
  20. movl %sp@+, %a1 /* save the return address for later */
  21. movl IMM __NR_vfork,%d0
  22. trap #0
  23. movl IMM -4097, %d1
  24. cmpl %d0, %d1
  25. bcs fix_errno
  26. jmp %a1@ /* don't return, just jmp directly */
  27. fix_errno:
  28. negl %d0
  29. #ifndef __PIC__ /* needs handling as the other archs */
  30. movl errno, %a0
  31. #else
  32. movl errno@GOT(%a5), %a0
  33. #endif
  34. movl %d0, %a0@
  35. movl IMM -1, %d0
  36. jmp %a1@ /* don't return, just jmp directly */
  37. .size vfork,.-vfork
  38. libc_hidden_def(vfork)