vfork.S 1.1 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 <asm/unistd.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. .balign 4
  18. .globl errno
  19. .globl vfork
  20. .globl __libc_vfork
  21. #if defined __HAVE_ELF__
  22. .type vfork,@function
  23. .type __libc_vfork,@function
  24. #endif
  25. vfork:
  26. __libc_vfork:
  27. movui r2, TRAP_ID_SYSCALL
  28. movui r3, __NR_vfork
  29. trap
  30. movi r8, -4096
  31. bltu r8, r2, fix_errno
  32. ret
  33. fix_errno:
  34. sub r8, r0, r2
  35. addi sp, sp, -8
  36. stw ra, 4(sp)
  37. stw r8, 0(sp)
  38. #ifndef __PIC__
  39. call __errno_location
  40. #else
  41. #endif
  42. ldw ra, 4(sp)
  43. ldw r8, 0(sp)
  44. stw r8, 0(r2)
  45. addi r2, r0, -1
  46. addi sp, sp, 8
  47. ret