vfork.S 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * libc/sysdeps/linux/nios2/vfork.S -- `vfork' syscall for linux/nios2
  3. *
  4. * Copyright (C) 2004 Microtronix Datacom Ltd
  5. *
  6. * This file is subject to the terms and conditions of the GNU Lesser
  7. * General Public License. See the file COPYING.LIB in the main
  8. * directory of this archive for more details.
  9. *
  10. * Written by Wentao Xu <wentao@microtronix.com>
  11. */
  12. #include <sys/syscall.h>
  13. #ifndef __NR_vfork
  14. #define __NR_vfork __NR_fork /* uClinux-2.0 only has fork which is vfork */
  15. #endif
  16. .text
  17. .global __vfork
  18. .hidden __vfork
  19. .type __vfork,%function
  20. .align 4
  21. __vfork:
  22. movui r2, TRAP_ID_SYSCALL
  23. movui r3, __NR_vfork
  24. trap
  25. movi r8, -4096
  26. bltu r8, r2, fix_errno
  27. ret
  28. fix_errno:
  29. sub r8, r0, r2
  30. addi sp, sp, -8
  31. stw ra, 4(sp)
  32. stw r8, 0(sp)
  33. #ifndef __PIC__
  34. call __errno_location
  35. #else
  36. #endif
  37. ldw ra, 4(sp)
  38. ldw r8, 0(sp)
  39. stw r8, 0(r2)
  40. addi r2, r0, -1
  41. addi sp, sp, 8
  42. ret
  43. .size __vfork,.-__vfork
  44. weak_alias(__vfork,vfork)
  45. libc_hidden_def(vfork)