vfork.S 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. #include <bits/arm_asm.h>
  9. #include <bits/arm_bx.h>
  10. #define _ERRNO_H
  11. #include <bits/errno.h>
  12. #include <sys/syscall.h>
  13. #ifdef __NR_fork
  14. .text
  15. .global __vfork
  16. .hidden __vfork
  17. .type __vfork,%function
  18. .align 4
  19. #if defined(__thumb__) && !defined(__thumb2__)
  20. .thumb_func
  21. __vfork:
  22. #ifdef __NR_vfork
  23. DO_CALL (vfork)
  24. ldr r1, =0xfffff000
  25. cmp r0, r1
  26. bcs 1f
  27. bx lr
  28. 1:
  29. /* Check if vfork even exists. */
  30. ldr r1, =-ENOSYS
  31. cmp r0, r1
  32. bne __error
  33. /* If we don't have vfork, use fork. */
  34. DO_CALL (fork)
  35. ldr r1, =0xfffff000
  36. cmp r0, r1
  37. /* Syscall worked. Return to child/parent */
  38. bcs 1f
  39. bx lr
  40. 1:
  41. __error:
  42. push {r3, lr}
  43. bl __syscall_error
  44. POP_RET
  45. .pool
  46. #endif
  47. #else
  48. __vfork:
  49. #ifdef __NR_vfork
  50. DO_CALL (vfork)
  51. cmn r0, #4096
  52. IT(t, cc)
  53. BXC(cc, lr)
  54. /* Check if vfork even exists. */
  55. ldr r1, =-ENOSYS
  56. teq r0, r1
  57. bne __error
  58. #endif
  59. /* If we don't have vfork, use fork. */
  60. DO_CALL (fork)
  61. cmn r0, #4096
  62. /* Syscall worked. Return to child/parent */
  63. IT(t, cc)
  64. BXC(cc, lr)
  65. __error:
  66. b __syscall_error
  67. #endif
  68. .size __vfork,.-__vfork
  69. weak_alias(__vfork,vfork)
  70. libc_hidden_def(vfork)
  71. #endif