vfork.S 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /* Copyright (C) 1999, 2000 Free Software Foundation, Inc.
  2. Copyright (C) 2001 Hewlett-Packard Australia
  3. This program is free software; you can redistribute it and/or modify it under
  4. the terms of the GNU Library General Public License as published by the Free
  5. Software Foundation; either version 2 of the License, or (at your option) any
  6. later version.
  7. This program is distributed in the hope that it will be useful, but WITHOUT
  8. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more
  10. details.
  11. You should have received a copy of the GNU Library General Public License
  12. along with this program; if not, write to the Free Software Foundation, Inc.,
  13. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  14. Derived in part from the Linux-8086 C library, the GNU C Library, and several
  15. other sundry sources. Files within this library are copyright by their
  16. respective copyright holders.
  17. */
  18. #define _ERRNO_H 1
  19. #include <bits/errno.h>
  20. /* Clone the calling process, but without copying the whole address space.
  21. The calling process is suspended until the new process exits or is
  22. replaced by a call to `execve'. Return -1 for errors, 0 to the new process,
  23. and the process ID of the new process to the old process. */
  24. .global errno
  25. .text
  26. .align 5
  27. .type __vfork,@function
  28. .globl __vfork;
  29. __vfork:
  30. mov.l @r15+,r3 // pop value from the stack
  31. mov.l .L5,r1
  32. mov.l r3,@r1 // save it in .sav_stack
  33. mov.w .L3, r3
  34. #ifdef HIOS
  35. trapa #0x28
  36. #else
  37. trapa #0x10
  38. #endif
  39. mov r0, r1
  40. // 12 arithmetic shifts for the crappy sh2, because shad doesn't exist!
  41. shar r1
  42. shar r1
  43. shar r1
  44. shar r1
  45. shar r1
  46. shar r1
  47. shar r1
  48. shar r1
  49. shar r1
  50. shar r1
  51. shar r1
  52. shar r1
  53. // mov #-12, r2
  54. // shad r2, r1
  55. not r1, r1 // r1=0 means r0 = -1 to -4095
  56. tst r1, r1 // i.e. error in linux
  57. bf 1f
  58. mov.w .L1, r1
  59. cmp/eq r1, r0
  60. bt 2f
  61. mov.l .L2, r1
  62. jmp @r1
  63. mov r0, r4
  64. .align 4
  65. 1:
  66. mov.l .L5,r1
  67. mov.l @r1,r3 // get it from .sav_stack
  68. mov.l r3,@-r15 // restore value to the stack
  69. rts
  70. nop
  71. .align 4
  72. 2:
  73. .global __syscall_error
  74. __syscall_error:
  75. /* Store it in errno... */
  76. mov.l .L4, r1
  77. mov.l r0, @r1
  78. mov.l .L5,r1
  79. mov.l @r1,r3 // get it from .sav_stack
  80. mov.l r3,@-r15 // restore value to the stack
  81. /* And just kick back a -1. */
  82. rts
  83. mov #-1, r0
  84. .align 4
  85. .L1:
  86. .word -ENOSYS
  87. .L3:
  88. .word 190 //__NR_vfork
  89. .align 4 // Shouldn't be necessary as previously with have two words
  90. .L2:
  91. .long __syscall_error
  92. .L4: .long errno
  93. .L5: .long .sav_stack
  94. .data
  95. .align 4
  96. .sav_stack: //area to temporary save the stach
  97. .long 0
  98. .weak vfork
  99. vfork = __vfork