njn | 9abd608 | 2005-06-17 21:31:45 +0000 | [diff] [blame] | 1 | |
| 2 | /*--------------------------------------------------------------------*/ |
| 3 | /*--- Doing system calls. pub_core_syscall.h ---*/ |
| 4 | /*--------------------------------------------------------------------*/ |
| 5 | |
| 6 | /* |
| 7 | This file is part of Valgrind, a dynamic binary instrumentation |
| 8 | framework. |
| 9 | |
sewardj | 9ebd6e0 | 2007-01-08 06:01:59 +0000 | [diff] [blame] | 10 | Copyright (C) 2000-2007 Julian Seward |
njn | 9abd608 | 2005-06-17 21:31:45 +0000 | [diff] [blame] | 11 | jseward@acm.org |
| 12 | |
| 13 | This program is free software; you can redistribute it and/or |
| 14 | modify it under the terms of the GNU General Public License as |
| 15 | published by the Free Software Foundation; either version 2 of the |
| 16 | License, or (at your option) any later version. |
| 17 | |
| 18 | This program is distributed in the hope that it will be useful, but |
| 19 | WITHOUT ANY WARRANTY; without even the implied warranty of |
| 20 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 21 | General Public License for more details. |
| 22 | |
| 23 | You should have received a copy of the GNU General Public License |
| 24 | along with this program; if not, write to the Free Software |
| 25 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
| 26 | 02111-1307, USA. |
| 27 | |
| 28 | The GNU General Public License is contained in the file COPYING. |
| 29 | */ |
| 30 | |
| 31 | #ifndef __PUB_CORE_SYSCALL_H |
| 32 | #define __PUB_CORE_SYSCALL_H |
| 33 | |
| 34 | //-------------------------------------------------------------------- |
| 35 | // PURPOSE: This module contains the code for actually executing syscalls. |
| 36 | //-------------------------------------------------------------------- |
| 37 | |
| 38 | /* Do a syscall on this platform, with 6 args, and return the result |
| 39 | in canonical format in a SysRes value. */ |
| 40 | |
| 41 | // We use a full prototype for VG_(do_syscall) rather than "..." to ensure |
| 42 | // that all arguments get converted to a UWord appropriately. Not doing so |
| 43 | // can cause problems when passing 32-bit integers on 64-bit platforms, |
| 44 | // because the top 32-bits might not be zeroed appropriately, eg. as would |
| 45 | // happen with the 6th arg on AMD64 which is passed on the stack. |
| 46 | |
| 47 | extern SysRes VG_(do_syscall) ( UWord sysno, |
| 48 | UWord, UWord, UWord, |
sewardj | 17edf03 | 2006-10-17 01:53:34 +0000 | [diff] [blame] | 49 | UWord, UWord, UWord, |
| 50 | UWord, UWord ); |
njn | 9abd608 | 2005-06-17 21:31:45 +0000 | [diff] [blame] | 51 | |
| 52 | /* Macros make life easier. */ |
| 53 | |
sewardj | 17edf03 | 2006-10-17 01:53:34 +0000 | [diff] [blame] | 54 | #define vgPlain_do_syscall0(s) VG_(do_syscall)((s),0,0,0,0,0,0,0,0) |
| 55 | #define vgPlain_do_syscall1(s,a) VG_(do_syscall)((s),(a),\ |
| 56 | 0,0,0,0,0,0,0) |
| 57 | #define vgPlain_do_syscall2(s,a,b) VG_(do_syscall)((s),(a),(b),\ |
| 58 | 0,0,0,0,0,0) |
| 59 | #define vgPlain_do_syscall3(s,a,b,c) VG_(do_syscall)((s),(a),(b),(c),\ |
| 60 | 0,0,0,0,0) |
njn | 9abd608 | 2005-06-17 21:31:45 +0000 | [diff] [blame] | 61 | #define vgPlain_do_syscall4(s,a,b,c,d) VG_(do_syscall)((s),(a),(b),\ |
sewardj | 17edf03 | 2006-10-17 01:53:34 +0000 | [diff] [blame] | 62 | (c),(d),0,0,0,0) |
njn | 9abd608 | 2005-06-17 21:31:45 +0000 | [diff] [blame] | 63 | #define vgPlain_do_syscall5(s,a,b,c,d,e) VG_(do_syscall)((s),(a),(b),\ |
sewardj | 17edf03 | 2006-10-17 01:53:34 +0000 | [diff] [blame] | 64 | (c),(d),(e),0,0,0) |
| 65 | #define vgPlain_do_syscall6(s,a,b,c,d,e,f) VG_(do_syscall)((s),(a),(b),(c),\ |
| 66 | (d),(e),(f),0,0) |
njn | 9abd608 | 2005-06-17 21:31:45 +0000 | [diff] [blame] | 67 | |
sewardj | 2c48c7b | 2005-11-29 13:05:56 +0000 | [diff] [blame] | 68 | extern SysRes VG_(mk_SysRes_x86_linux) ( UInt val ); |
| 69 | extern SysRes VG_(mk_SysRes_amd64_linux) ( ULong val ); |
| 70 | extern SysRes VG_(mk_SysRes_ppc32_linux) ( UInt val, UInt cr0so ); |
| 71 | extern SysRes VG_(mk_SysRes_ppc64_linux) ( ULong val, ULong cr0so ); |
sewardj | 17edf03 | 2006-10-17 01:53:34 +0000 | [diff] [blame] | 72 | extern SysRes VG_(mk_SysRes_ppc32_aix5) ( UInt val, UInt err ); |
| 73 | extern SysRes VG_(mk_SysRes_ppc64_aix5) ( ULong val, ULong err ); |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 74 | extern SysRes VG_(mk_SysRes_Error) ( UWord val ); |
| 75 | extern SysRes VG_(mk_SysRes_Success) ( UWord val ); |
njn | 9abd608 | 2005-06-17 21:31:45 +0000 | [diff] [blame] | 76 | |
sewardj | 45f4e7c | 2005-09-27 19:20:21 +0000 | [diff] [blame] | 77 | |
| 78 | /* Return a string which gives the name of an error value. Note, |
| 79 | unlike the standard C syserror fn, the returned string is not |
| 80 | malloc-allocated or writable -- treat it as a constant. */ |
| 81 | |
| 82 | extern const HChar* VG_(strerror) ( UWord errnum ); |
| 83 | |
| 84 | |
njn | 9abd608 | 2005-06-17 21:31:45 +0000 | [diff] [blame] | 85 | #endif // __PUB_CORE_SYSCALL_H |
| 86 | |
| 87 | /*--------------------------------------------------------------------*/ |
| 88 | /*--- end ---*/ |
| 89 | /*--------------------------------------------------------------------*/ |