vfork.S 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. #ifndef __NR_vfork
  17. #define __NR_vfork __NR_fork /* uClinux-2.0 only has fork which is vfork */
  18. #endif
  19. .text
  20. .global __vfork
  21. .hidden __vfork
  22. .type __vfork,%function
  23. .align 4
  24. __vfork:
  25. movui r2, TRAP_ID_SYSCALL
  26. movui r3, __NR_vfork
  27. trap
  28. movi r8, -4096
  29. bltu r8, r2, fix_errno
  30. ret
  31. fix_errno:
  32. sub r8, r0, r2
  33. addi sp, sp, -8
  34. stw ra, 4(sp)
  35. stw r8, 0(sp)
  36. #ifndef __PIC__
  37. call __errno_location
  38. #else
  39. #endif
  40. ldw ra, 4(sp)
  41. ldw r8, 0(sp)
  42. stw r8, 0(r2)
  43. addi r2, r0, -1
  44. addi sp, sp, 8
  45. ret
  46. .size __vfork,.-__vfork
  47. weak_alias(__vfork,vfork)
  48. libc_hidden_weak(vfork)