vfork.S 992 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. #define __NR_vfork 1071
  14. .text
  15. .global __vfork
  16. .hidden __vfork
  17. .type __vfork,%function
  18. .align 4
  19. __vfork:
  20. movui r2, TRAP_ID_SYSCALL
  21. movui r3, __NR_vfork
  22. trap
  23. movi r8, -4096
  24. bltu r8, r2, fix_errno
  25. ret
  26. fix_errno:
  27. sub r8, r0, r2
  28. addi sp, sp, -8
  29. stw ra, 4(sp)
  30. stw r8, 0(sp)
  31. #ifndef __PIC__
  32. call __errno_location
  33. #else
  34. #endif
  35. ldw ra, 4(sp)
  36. ldw r8, 0(sp)
  37. stw r8, 0(r2)
  38. addi r2, r0, -1
  39. addi sp, sp, 8
  40. ret
  41. .size __vfork,.-__vfork
  42. weak_alias(__vfork,vfork)
  43. libc_hidden_def(vfork)