syscall.c 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /* Copyright (C) 1997, 1998, 2001, 2003 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. The GNU C Library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public
  5. License as published by the Free Software Foundation; either
  6. version 2.1 of the License, or (at your option) any later version.
  7. The GNU C Library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public
  12. License along with the GNU C Library; if not, see
  13. <http://www.gnu.org/licenses/>. */
  14. #include <stdarg.h>
  15. #include <errno.h>
  16. #include <sys/syscall.h>
  17. #include <unistd.h>
  18. /* HPPA implements syscall() in 'C'; the assembler version would
  19. typically be in syscall.S. Also note that we have INLINE_SYSCALL,
  20. INTERNAL_SYSCALL, and all the generated pure assembly syscall wrappers.
  21. How often the function is used is unknown. */
  22. long int
  23. syscall (long int __sysno, ...)
  24. {
  25. /* FIXME: Keep this matching INLINE_SYSCALL for hppa */
  26. va_list args;
  27. long int arg0, arg1, arg2, arg3, arg4, arg5;
  28. long int __sys_res;
  29. /* Load varargs */
  30. va_start (args, __sysno);
  31. arg0 = va_arg (args, long int);
  32. arg1 = va_arg (args, long int);
  33. arg2 = va_arg (args, long int);
  34. arg3 = va_arg (args, long int);
  35. arg4 = va_arg (args, long int);
  36. arg5 = va_arg (args, long int);
  37. va_end (args);
  38. {
  39. register unsigned long int __res __asm__("r28");
  40. K_LOAD_ARGS_6 (arg0, arg1, arg2, arg3, arg4, arg5)
  41. __asm__ __volatile__ (K_STW_ASM_PIC
  42. " ble 0x100(%%sr2, %%r0) \n"
  43. " copy %1, %%r20 \n"
  44. K_LDW_ASM_PIC
  45. : "=r" (__res)
  46. : "r" (__sysno) K_ASM_ARGS_6
  47. : "memory", K_CALL_CLOB_REGS K_CLOB_ARGS_6);
  48. __sys_res = __res;
  49. }
  50. if ((unsigned long int) __sys_res >= (unsigned long int) -4095)
  51. {
  52. __set_errno (-__sys_res);
  53. __sys_res = -1;
  54. }
  55. return __sys_res;
  56. }