vfork.S 1.3 KB

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