vfork.S 891 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * vfork for uClibc
  4. * Copyright (C) 2000-2006 by Erik Andersen <andersen@uclibc.org>
  5. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  6. */
  7. #include <features.h>
  8. #define _ERRNO_H
  9. #include <bits/errno.h>
  10. #include <sys/syscall.h>
  11. #ifdef __NR_fork
  12. .text
  13. .global __vfork
  14. .hidden __vfork
  15. .type __vfork,%function
  16. .align 4
  17. __vfork:
  18. #ifdef __NR_vfork
  19. DO_CALL (vfork)
  20. cmn r0, #4096
  21. #if defined(__USE_BX__)
  22. bxcc lr
  23. #else
  24. movcc pc, lr
  25. #endif
  26. /* Check if vfork even exists. */
  27. ldr r1, =-ENOSYS
  28. teq r0, r1
  29. bne __error
  30. #endif
  31. /* If we don't have vfork, use fork. */
  32. DO_CALL (fork)
  33. cmn r0, #4096
  34. /* Syscall worked. Return to child/parent */
  35. #if defined(__USE_BX__)
  36. bxcc lr
  37. #else
  38. movcc pc, lr
  39. #endif
  40. __error:
  41. b __syscall_error
  42. .size __vfork,.-__vfork
  43. weak_alias(__vfork,vfork)
  44. libc_hidden_weak(vfork)
  45. #endif