vfork.S 1.0 KB

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