vfork.S 998 B

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