Back to index

glibc  2.9
sysdep.c
Go to the documentation of this file.
00001 /* Copyright (C) 1997, 1998, 2001, 2003, 2007 
00002    Free Software Foundation, Inc.
00003    This file is part of the GNU C Library.
00004 
00005    The GNU C Library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Lesser General Public
00007    License as published by the Free Software Foundation; either
00008    version 2.1 of the License, or (at your option) any later version.
00009 
00010    The GNU C Library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Lesser General Public License for more details.
00014 
00015    You should have received a copy of the GNU Lesser General Public
00016    License along with the GNU C Library; if not, write to the Free
00017    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00018    02111-1307 USA.  */
00019 
00020 #include <stdarg.h>
00021 #include <sysdep.h>
00022 #include <errno.h>
00023 
00024 extern int __syscall_error(int err_no);
00025 extern long int syscall (long int __sysno, ...) __THROW;
00026 
00027 /* This routine is jumped to by all the syscall handlers, to stash
00028    an error number into errno.  */
00029 int
00030 __syscall_error (int err_no)
00031 {
00032   __set_errno (err_no);
00033   return -1;
00034 }
00035 
00036 
00037 /* HPPA implements syscall() in 'C'; the assembler version would
00038    typically be in syscall.S. Also note that we have INLINE_SYSCALL,
00039    INTERNAL_SYSCALL, and all the generated pure assembly syscall wrappers.
00040    How often the function is used is unknown. */
00041 
00042 long int 
00043 syscall (long int __sysno, ...) 
00044 {
00045   /* FIXME: Keep this matching INLINE_SYSCALL for hppa */
00046   va_list args;
00047   long int arg0, arg1, arg2, arg3, arg4, arg5;
00048   long int __sys_res;
00049 
00050   /* Load varargs */
00051   va_start (args, __sysno);
00052   arg0 = va_arg (args, long int);
00053   arg1 = va_arg (args, long int);
00054   arg2 = va_arg (args, long int);
00055   arg3 = va_arg (args, long int);
00056   arg4 = va_arg (args, long int);
00057   arg5 = va_arg (args, long int);
00058   va_end (args);
00059   
00060   {
00061     register unsigned long int __res asm("r28");
00062     PIC_REG_DEF
00063     LOAD_ARGS_6 (arg0, arg1, arg2, arg3, arg4, arg5)
00064     asm volatile (SAVE_ASM_PIC
00065                 "    ble  0x100(%%sr2, %%r0)     \n"
00066                 "    copy %1, %%r20              \n"
00067                 LOAD_ASM_PIC
00068                 : "=r" (__res)
00069                 : "r" (__sysno) PIC_REG_USE ASM_ARGS_6
00070                 : "memory", CALL_CLOB_REGS CLOB_ARGS_6);
00071     __sys_res = __res;
00072   }
00073   if ((unsigned long int) __sys_res >= (unsigned long int) -4095)
00074     {
00075       __set_errno (-__sys_res);
00076       __sys_res = -1;
00077     }
00078   return __sys_res;
00079 }
00080