syscall.c 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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, write to the Free
  13. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  14. 02111-1307 USA. */
  15. #include <stdarg.h>
  16. #include <errno.h>
  17. #include <sys/syscall.h>
  18. #include <unistd.h>
  19. /* HPPA implements syscall() in 'C'; the assembler version would
  20. typically be in syscall.S. Also note that we have INLINE_SYSCALL,
  21. INTERNAL_SYSCALL, and all the generated pure assembly syscall wrappers.
  22. How often the function is used is unknown. */
  23. long int
  24. syscall (long int __sysno, ...)
  25. {
  26. /* FIXME: Keep this matching INLINE_SYSCALL for hppa */
  27. va_list args;
  28. long int arg0, arg1, arg2, arg3, arg4, arg5;
  29. long int __sys_res;
  30. /* Load varargs */
  31. va_start (args, __sysno);
  32. arg0 = va_arg (args, long int);
  33. arg1 = va_arg (args, long int);
  34. arg2 = va_arg (args, long int);
  35. arg3 = va_arg (args, long int);
  36. arg4 = va_arg (args, long int);
  37. arg5 = va_arg (args, long int);
  38. va_end (args);
  39. {
  40. register unsigned long int __res __asm__("r28");
  41. K_LOAD_ARGS_6 (arg0, arg1, arg2, arg3, arg4, arg5)
  42. __asm__ __volatile__ (K_STW_ASM_PIC
  43. " ble 0x100(%%sr2, %%r0) \n"
  44. " copy %1, %%r20 \n"
  45. K_LDW_ASM_PIC
  46. : "=r" (__res)
  47. : "r" (__sysno) K_ASM_ARGS_6
  48. : "memory", K_CALL_CLOB_REGS K_CLOB_ARGS_6);
  49. __sys_res = __res;
  50. }
  51. if ((unsigned long int) __sys_res >= (unsigned long int) -4095)
  52. {
  53. __set_errno (-__sys_res);
  54. __sys_res = -1;
  55. }
  56. return __sys_res;
  57. }