vfork.S 887 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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,2001 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. swi __NR_vfork
  23. cmn r0, #4096
  24. movcc pc, lr
  25. /* Check if vfork even exists. */
  26. ldr r1, =-ENOSYS
  27. teq r0, r1
  28. bne __error
  29. #endif
  30. /* If we don't have vfork, use fork. */
  31. swi __NR_fork
  32. cmn r0, #4096
  33. /* Syscall worked. Return to child/parent */
  34. movcc pc, lr
  35. __error:
  36. b __syscall_error
  37. .size __vfork,.-__vfork
  38. strong_alias(__vfork,vfork)
  39. #endif