mc_translate.c: enable further uses of DLexpensive for scalar EQ/NE comparisons
[valgrind.git] / coregrind / m_vkiscnums.c
bloba7ffbf7b5152254f2d83837a16fafe763e974d5a
2 /*--------------------------------------------------------------------*/
3 /*--- Notional "implementation" for m_vkiscnums. ---*/
4 /*--- m_vkiscnums.c ---*/
5 /*--------------------------------------------------------------------*/
7 /*
8 This file is part of Valgrind, a dynamic binary instrumentation
9 framework.
11 Copyright (C) 2006-2017 OpenWorks LLP
12 info@open-works.co.uk
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.
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.
24 You should have received a copy of the GNU General Public License
25 along with this program; if not, see <http://www.gnu.org/licenses/>.
27 The GNU General Public License is contained in the file COPYING.
30 #include "pub_core_basics.h"
31 #include "pub_core_libcprint.h"
32 #include "pub_core_vkiscnums.h" /* self */
34 /* We have pub_{core,tool}_vkiscnums.h. This is the matching implementation
35 for that interface.
37 On Linux, the interface exports a bunch of "#define __NR_foo 42" style
38 definitions, so there is no implementation.
41 //---------------------------------------------------------------------------
42 #if defined(VGO_linux)
43 //---------------------------------------------------------------------------
45 const HChar* VG_(sysnum_string)(Word sysnum)
47 static HChar buf[20+1]; // large enough
49 VG_(sprintf)(buf, "%ld", sysnum);
50 return buf;
53 /* include/pub_tool_basics.h hardcodes the following syscall numbers
54 on mips{32,64}-linux so as to avoid a module cycle. We make that
55 safe here by causing the build to fail if those numbers should ever
56 change. See comments in function sr_EQ in the mips{32,64}-linux
57 section of include/pub_tool_basics.h for more details. */
58 #if defined(VGP_mips32_linux)
59 STATIC_ASSERT(__NR_pipe == 4042);
60 STATIC_ASSERT(__NR_pipe2 == 4328);
61 #elif defined(VGP_mips64_linux) && defined(VGABI_N32)
62 STATIC_ASSERT(__NR_pipe == 6021);
63 STATIC_ASSERT(__NR_pipe2 == 6291);
64 #elif defined(VGP_mips64_linux)
65 STATIC_ASSERT(__NR_pipe == 5021);
66 STATIC_ASSERT(__NR_pipe2 == 5287);
67 #endif
69 //---------------------------------------------------------------------------
70 #elif defined(VGO_darwin)
71 //---------------------------------------------------------------------------
73 const HChar* VG_(sysnum_string)(Word sysnum)
75 static HChar buf[7+1+20+1]; // large enough
77 const HChar* classname = NULL;
78 switch (VG_DARWIN_SYSNO_CLASS(sysnum)) {
79 case VG_DARWIN_SYSCALL_CLASS_MACH: classname = "mach"; break;
80 case VG_DARWIN_SYSCALL_CLASS_UNIX: classname = "unix"; break;
81 case VG_DARWIN_SYSCALL_CLASS_MDEP: classname = "mdep"; break;
82 case VG_DARWIN_SYSCALL_CLASS_DIAG: classname = "diag"; break;
83 default: classname = "UNKNOWN"; break;
85 VG_(sprintf)(buf, "%s:%ld", classname, VG_DARWIN_SYSNO_INDEX(sysnum));
86 return buf;
89 //---------------------------------------------------------------------------
90 #elif defined(VGO_solaris)
91 //---------------------------------------------------------------------------
93 const HChar *VG_(sysnum_string)(Word sysnum)
95 static HChar buf[8+20+1]; // large enough
97 const HChar* classname = NULL;
98 switch (VG_SOLARIS_SYSNO_CLASS(sysnum)) {
99 case VG_SOLARIS_SYSCALL_CLASS_CLASSIC: classname = ""; break;
100 case VG_SOLARIS_SYSCALL_CLASS_FASTTRAP: classname = "fast:"; break;
101 default: classname = "UNKNOWN:"; break;
103 VG_(sprintf)(buf, "%s%ld", classname, VG_SOLARIS_SYSNO_INDEX(sysnum));
104 return buf;
107 //---------------------------------------------------------------------------
108 #else
109 //---------------------------------------------------------------------------
110 # error Unknown OS
111 #endif
113 /*--------------------------------------------------------------------*/
114 /*--- end ---*/
115 /*--------------------------------------------------------------------*/