syscall.c 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. * libc/sysdeps/linux/v850/syscall.c -- generic syscall function for linux/v850
  3. *
  4. * Copyright (C) 2002 NEC Corporation
  5. * Copyright (C) 2002 Miles Bader <miles@gnu.org>
  6. *
  7. * This file is subject to the terms and conditions of the GNU Lesser
  8. * General Public License. See the file COPYING.LIB in the main
  9. * directory of this archive for more details.
  10. *
  11. * Written by Miles Bader <miles@gnu.org>
  12. */
  13. #include <errno.h>
  14. #include <sys/syscall.h>
  15. typedef unsigned long arg_t;
  16. /* Invoke `system call' NUM, passing it the remaining arguments.
  17. This is completely system-dependent, and not often useful. */
  18. long
  19. syscall (long num, arg_t a1, arg_t a2, arg_t a3, arg_t a4, arg_t a5, arg_t a6)
  20. {
  21. /* We don't know how many arguments are valid, so A5 and A6 are fetched
  22. off the stack even for (the majority of) system calls with fewer
  23. arguments; hopefully this won't cause any problems. A1-A4 are in
  24. registers, so they're OK. */
  25. register arg_t a asm (SYSCALL_ARG0) = a1;
  26. register arg_t b asm (SYSCALL_ARG1) = a2;
  27. register arg_t c asm (SYSCALL_ARG2) = a3;
  28. register arg_t d asm (SYSCALL_ARG3) = a4;
  29. register arg_t e asm (SYSCALL_ARG4) = a5;
  30. register arg_t f asm (SYSCALL_ARG5) = a6;
  31. register unsigned long syscall asm (SYSCALL_NUM) = num;
  32. register unsigned long ret asm (SYSCALL_RET);
  33. asm ("trap " SYSCALL_LONG_TRAP
  34. : "=r" (ret)
  35. : "r" (syscall), "r" (a), "r" (b), "r" (c), "r" (d), "r" (e), "r" (f)
  36. : SYSCALL_CLOBBERS);
  37. __syscall_return (long, ret);
  38. }