2 /*--------------------------------------------------------------------*/
3 /*--- Notional "implementation" for m_vkiscnums. ---*/
4 /*--- m_vkiscnums.c ---*/
5 /*--------------------------------------------------------------------*/
8 This file is part of Valgrind, a dynamic binary instrumentation
11 Copyright (C) 2006-2013 OpenWorks LLP
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, write to the Free Software
26 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
29 The GNU General Public License is contained in the file COPYING.
32 #include "pub_core_basics.h"
33 #include "pub_core_libcprint.h"
34 #include "pub_core_vkiscnums.h" /* self */
36 /* We have pub_{core,tool}_vkiscnums.h. This is the matching implementation
39 On Linux, the interface exports a bunch of "#define __NR_foo 42" style
40 definitions, so there is no implementation.
43 //---------------------------------------------------------------------------
44 #if defined(VGO_linux)
45 //---------------------------------------------------------------------------
47 const HChar
* VG_(sysnum_string
)(Word sysnum
)
49 static HChar buf
[20+1]; // large enough
51 VG_(sprintf
)(buf
, "%ld", sysnum
);
55 //---------------------------------------------------------------------------
56 #elif defined(VGO_darwin)
57 //---------------------------------------------------------------------------
59 const HChar
* VG_(sysnum_string
)(Word sysnum
)
61 static HChar buf
[7+1+20+1]; // large enough
63 const HChar
* classname
= NULL
;
64 switch (VG_DARWIN_SYSNO_CLASS(sysnum
)) {
65 case VG_DARWIN_SYSCALL_CLASS_MACH
: classname
= "mach"; break;
66 case VG_DARWIN_SYSCALL_CLASS_UNIX
: classname
= "unix"; break;
67 case VG_DARWIN_SYSCALL_CLASS_MDEP
: classname
= "mdep"; break;
68 case VG_DARWIN_SYSCALL_CLASS_DIAG
: classname
= "diag"; break;
69 default: classname
= "UNKNOWN"; break;
71 VG_(sprintf
)(buf
, "%s:%ld", classname
, VG_DARWIN_SYSNO_INDEX(sysnum
));
75 //---------------------------------------------------------------------------
77 //---------------------------------------------------------------------------
81 /*--------------------------------------------------------------------*/
83 /*--------------------------------------------------------------------*/