vfork.S 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /* Copyright 2002, 2015 Yoshinori Sato <ysato@users.sourceforge.jp> */
  2. #include <sys/syscall.h>
  3. #ifdef __H8300S__
  4. .h8300s
  5. #else
  6. .h8300h
  7. #endif
  8. .text
  9. .align 2
  10. .globl __vfork
  11. .hidden __vfork
  12. .type __vfork,@function
  13. __vfork:
  14. #ifdef __NR_vfork
  15. mov.l @sp+, er1
  16. sub.l er0,er0
  17. mov.b #__NR_vfork,r0l
  18. trapa #0
  19. mov.l #-4096, er2
  20. cmp.l er0,er2
  21. bcs fix_errno
  22. jmp @er1 /* don't return, just jmp directly */
  23. fix_errno:
  24. neg.l er0
  25. # if !defined(__PIC__)
  26. mov.l er0,@_errno
  27. # else
  28. mov.l @(_errno@GOTOFF,er5),er2
  29. mov.l er0,@er2
  30. # endif
  31. sub.l er0,er0
  32. dec.l #1,er0
  33. jmp @er1 /* don't return, just jmp directly */
  34. #else
  35. mov.l @sp+,er2 /* er2 = return address */
  36. mov.l #vfork_args,er1
  37. sub.l er0,er0
  38. mov.b #__NR_clone,r0l
  39. trapa #0
  40. mov.l #-4096,er1
  41. cmp.l er0,er1
  42. bcc done
  43. neg.l er0
  44. # if !defined(__PIC__)
  45. mov.l er0,@errno
  46. # else
  47. mov.l @(errno@GOTOFF,er5),er1
  48. mov.l er0,@er1
  49. # endif
  50. sub.l er0,er0
  51. dec.l #1,er0
  52. done:
  53. jmp @er2
  54. vfork_args:
  55. .long 0x00004111 /* CLONE_VFORK | CLONE_VM | SIGCHLD */
  56. .long 0
  57. .long 0
  58. .long 0
  59. .long 0
  60. #endif
  61. weak_alias(__vfork,vfork)
  62. libc_hidden_def(vfork)
  63. .end