vfork.S 961 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. .hidden __vfork
  17. .type __vfork,@function
  18. __vfork:
  19. movl %sp@+, %a1 /* save the return address for later */
  20. movl IMM __NR_vfork,%d0
  21. trap #0
  22. movl IMM -4097, %d1
  23. cmpl %d0, %d1
  24. bcs fix_errno
  25. jmp %a1@ /* don't return, just jmp directly */
  26. fix_errno:
  27. negl %d0
  28. #ifndef __PIC__ /* needs handling as the other archs */
  29. movl errno, %a0
  30. #else
  31. movl errno@GOT(%a5), %a0
  32. #endif
  33. movl %d0, %a0@
  34. movl IMM -1, %d0
  35. jmp %a1@ /* don't return, just jmp directly */
  36. .size __vfork,.-__vfork
  37. weak_alias(__vfork,vfork)
  38. libc_hidden_weak(vfork)