sewardj | ad83394 | 2006-10-14 19:34:11 +0000 | [diff] [blame] | 1 | |
| 2 | /*--------------------------------------------------------------------*/ |
| 3 | /*--- Notional "implementation" for m_vkiscnums. ---*/ |
| 4 | /*--- m_vkiscnums.c ---*/ |
| 5 | /*--------------------------------------------------------------------*/ |
| 6 | |
| 7 | /* |
| 8 | This file is part of Valgrind, a dynamic binary instrumentation |
| 9 | framework. |
| 10 | |
sewardj | b3a1e4b | 2015-08-21 11:32:26 +0000 | [diff] [blame] | 11 | Copyright (C) 2006-2015 OpenWorks LLP |
sewardj | ad83394 | 2006-10-14 19:34:11 +0000 | [diff] [blame] | 12 | info@open-works.co.uk |
| 13 | |
| 14 | This program is free software; you can redistribute it and/or |
| 15 | modify it under the terms of the GNU General Public License as |
| 16 | published by the Free Software Foundation; either version 2 of the |
| 17 | License, or (at your option) any later version. |
| 18 | |
| 19 | This program is distributed in the hope that it will be useful, but |
| 20 | WITHOUT ANY WARRANTY; without even the implied warranty of |
| 21 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 22 | General Public License for more details. |
| 23 | |
| 24 | You should have received a copy of the GNU General Public License |
| 25 | along with this program; if not, write to the Free Software |
| 26 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
| 27 | 02111-1307, USA. |
| 28 | |
| 29 | The GNU General Public License is contained in the file COPYING. |
| 30 | */ |
| 31 | |
| 32 | #include "pub_core_basics.h" |
njn | 1a1e95c | 2009-06-03 06:50:06 +0000 | [diff] [blame] | 33 | #include "pub_core_libcprint.h" |
sewardj | ad83394 | 2006-10-14 19:34:11 +0000 | [diff] [blame] | 34 | #include "pub_core_vkiscnums.h" /* self */ |
| 35 | |
| 36 | /* We have pub_{core,tool}_vkiscnums.h. This is the matching implementation |
| 37 | for that interface. |
| 38 | |
| 39 | On Linux, the interface exports a bunch of "#define __NR_foo 42" style |
| 40 | definitions, so there is no implementation. |
sewardj | ad83394 | 2006-10-14 19:34:11 +0000 | [diff] [blame] | 41 | */ |
| 42 | |
njn | 1a1e95c | 2009-06-03 06:50:06 +0000 | [diff] [blame] | 43 | //--------------------------------------------------------------------------- |
| 44 | #if defined(VGO_linux) |
| 45 | //--------------------------------------------------------------------------- |
| 46 | |
florian | 1123362 | 2014-08-12 11:43:17 +0000 | [diff] [blame] | 47 | const HChar* VG_(sysnum_string)(Word sysnum) |
njn | 1a1e95c | 2009-06-03 06:50:06 +0000 | [diff] [blame] | 48 | { |
florian | 1123362 | 2014-08-12 11:43:17 +0000 | [diff] [blame] | 49 | static HChar buf[20+1]; // large enough |
njn | 1a1e95c | 2009-06-03 06:50:06 +0000 | [diff] [blame] | 50 | |
florian | 1123362 | 2014-08-12 11:43:17 +0000 | [diff] [blame] | 51 | VG_(sprintf)(buf, "%ld", sysnum); |
| 52 | return buf; |
njn | 1a1e95c | 2009-06-03 06:50:06 +0000 | [diff] [blame] | 53 | } |
| 54 | |
sewardj | bd664fd | 2015-07-08 17:08:23 +0000 | [diff] [blame] | 55 | /* include/pub_tool_basics.h hardcodes the following syscall numbers |
| 56 | on mips{32,64}-linux so as to avoid a module cycle. We make that |
| 57 | safe here by causing the build to fail if those numbers should ever |
| 58 | change. See comments in function sr_EQ in the mips{32,64}-linux |
| 59 | section of include/pub_tool_basics.h for more details. */ |
| 60 | #if defined(VGP_mips32_linux) |
| 61 | STATIC_ASSERT(__NR_pipe == 4042); |
| 62 | STATIC_ASSERT(__NR_pipe2 == 4328); |
petarj | 435aa2c | 2015-07-15 18:07:36 +0000 | [diff] [blame] | 63 | #elif defined(VGP_mips64_linux) |
sewardj | bd664fd | 2015-07-08 17:08:23 +0000 | [diff] [blame] | 64 | STATIC_ASSERT(__NR_pipe == 5021); |
| 65 | STATIC_ASSERT(__NR_pipe2 == 5287); |
| 66 | #endif |
| 67 | |
njn | 1a1e95c | 2009-06-03 06:50:06 +0000 | [diff] [blame] | 68 | //--------------------------------------------------------------------------- |
njn | 1a1e95c | 2009-06-03 06:50:06 +0000 | [diff] [blame] | 69 | #elif defined(VGO_darwin) |
| 70 | //--------------------------------------------------------------------------- |
| 71 | |
florian | bc7e539 | 2014-08-12 21:11:44 +0000 | [diff] [blame] | 72 | const HChar* VG_(sysnum_string)(Word sysnum) |
njn | 1a1e95c | 2009-06-03 06:50:06 +0000 | [diff] [blame] | 73 | { |
florian | 1123362 | 2014-08-12 11:43:17 +0000 | [diff] [blame] | 74 | static HChar buf[7+1+20+1]; // large enough |
| 75 | |
florian | dbb3584 | 2012-10-27 18:39:11 +0000 | [diff] [blame] | 76 | const HChar* classname = NULL; |
njn | 1a1e95c | 2009-06-03 06:50:06 +0000 | [diff] [blame] | 77 | switch (VG_DARWIN_SYSNO_CLASS(sysnum)) { |
sewardj | 12445b8 | 2010-07-01 11:15:32 +0000 | [diff] [blame] | 78 | case VG_DARWIN_SYSCALL_CLASS_MACH: classname = "mach"; break; |
| 79 | case VG_DARWIN_SYSCALL_CLASS_UNIX: classname = "unix"; break; |
| 80 | case VG_DARWIN_SYSCALL_CLASS_MDEP: classname = "mdep"; break; |
| 81 | case VG_DARWIN_SYSCALL_CLASS_DIAG: classname = "diag"; break; |
| 82 | default: classname = "UNKNOWN"; break; |
njn | 1a1e95c | 2009-06-03 06:50:06 +0000 | [diff] [blame] | 83 | } |
florian | bc7e539 | 2014-08-12 21:11:44 +0000 | [diff] [blame] | 84 | VG_(sprintf)(buf, "%s:%ld", classname, VG_DARWIN_SYSNO_INDEX(sysnum)); |
njn | 1a1e95c | 2009-06-03 06:50:06 +0000 | [diff] [blame] | 85 | return buf; |
| 86 | } |
| 87 | |
njn | 1a1e95c | 2009-06-03 06:50:06 +0000 | [diff] [blame] | 88 | //--------------------------------------------------------------------------- |
sewardj | 8eb8bab | 2015-07-21 14:44:28 +0000 | [diff] [blame] | 89 | #elif defined(VGO_solaris) |
| 90 | //--------------------------------------------------------------------------- |
| 91 | |
| 92 | const HChar *VG_(sysnum_string)(Word sysnum) |
| 93 | { |
| 94 | static HChar buf[8+20+1]; // large enough |
| 95 | |
| 96 | const HChar* classname = NULL; |
| 97 | switch (VG_SOLARIS_SYSNO_CLASS(sysnum)) { |
| 98 | case VG_SOLARIS_SYSCALL_CLASS_CLASSIC: classname = ""; break; |
| 99 | case VG_SOLARIS_SYSCALL_CLASS_FASTTRAP: classname = "fast:"; break; |
| 100 | default: classname = "UNKNOWN:"; break; |
| 101 | } |
| 102 | VG_(sprintf)(buf, "%s%ld", classname, VG_SOLARIS_SYSNO_INDEX(sysnum)); |
| 103 | return buf; |
| 104 | } |
| 105 | |
| 106 | //--------------------------------------------------------------------------- |
njn | 1a1e95c | 2009-06-03 06:50:06 +0000 | [diff] [blame] | 107 | #else |
| 108 | //--------------------------------------------------------------------------- |
| 109 | # error Unknown OS |
| 110 | #endif |
sewardj | ad83394 | 2006-10-14 19:34:11 +0000 | [diff] [blame] | 111 | |
| 112 | /*--------------------------------------------------------------------*/ |
| 113 | /*--- end ---*/ |
| 114 | /*--------------------------------------------------------------------*/ |