From 4b572a567ef01760465d4b8be0f2fdd427bd4791 Mon Sep 17 00:00:00 2001 From: Julian Seward Date: Sat, 14 Oct 2006 15:51:32 +0000 Subject: [PATCH] Create a new module, m_vkiscnums, and move all the system call numbers into that. Mostly this means moving vki_unistd-.h to include/vki/vki-scnums-.h. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6224 --- coregrind/Makefile.am | 7 +--- coregrind/m_aspacemgr/aspacemgr.c | 2 +- coregrind/m_libcassert.c | 2 +- coregrind/m_libcfile.c | 2 +- coregrind/m_libcproc.c | 2 +- coregrind/m_libcsignal.c | 2 +- coregrind/m_scheduler/scheduler.c | 2 +- coregrind/m_signals.c | 2 +- coregrind/m_syswrap/syscall-x86-linux.S | 2 +- coregrind/m_syswrap/syswrap-generic.c | 2 +- coregrind/m_syswrap/syswrap-linux.c | 2 +- coregrind/m_syswrap/syswrap-x86-linux.c | 2 +- coregrind/m_trampoline.S | 2 +- coregrind/m_ume.c | 2 +- include/Makefile.am | 9 ++-- .../pub_tool_vkiscnums.h | 42 ++++++++++++++----- .../vki/vki-scnums-amd64-linux.h | 15 +++++-- .../vki/vki-scnums-ppc32-linux.h | 18 ++++++-- .../vki/vki-scnums-ppc64-linux.h | 17 ++++++-- .../vki/vki-scnums-x86-linux.h | 15 +++++-- memcheck/tests/x86/scalar.h | 2 +- 21 files changed, 104 insertions(+), 47 deletions(-) rename coregrind/vki_unistd.h => include/pub_tool_vkiscnums.h (50%) rename coregrind/vki_unistd-amd64-linux.h => include/vki/vki-scnums-amd64-linux.h (95%) rename coregrind/vki_unistd-ppc32-linux.h => include/vki/vki-scnums-ppc32-linux.h (93%) rename coregrind/vki_unistd-ppc64-linux.h => include/vki/vki-scnums-ppc64-linux.h (94%) rename coregrind/vki_unistd-x86-linux.h => include/vki/vki-scnums-x86-linux.h (94%) diff --git a/coregrind/Makefile.am b/coregrind/Makefile.am index 4727318dd..8d216b392 100644 --- a/coregrind/Makefile.am +++ b/coregrind/Makefile.am @@ -108,11 +108,7 @@ noinst_HEADERS = \ pub_core_transtab.h \ pub_core_transtab_asm.h \ pub_core_ume.h \ - vki_unistd.h \ - vki_unistd-amd64-linux.h\ - vki_unistd-ppc32-linux.h\ - vki_unistd-ppc64-linux.h\ - vki_unistd-x86-linux.h \ + pub_core_vkiscnums.h \ m_coredump/priv_elf.h \ m_debuginfo/priv_storage.h \ m_debuginfo/priv_readstabs.h \ @@ -166,6 +162,7 @@ COREGRIND_SOURCES_COMMON = \ m_translate.c \ m_transtab.c \ m_ume.c \ + m_vkiscnums.c \ m_aspacemgr/aspacemgr.c \ m_debuginfo/storage.c \ m_debuginfo/readdwarf.c \ diff --git a/coregrind/m_aspacemgr/aspacemgr.c b/coregrind/m_aspacemgr/aspacemgr.c index c410deccb..0e857cd13 100644 --- a/coregrind/m_aspacemgr/aspacemgr.c +++ b/coregrind/m_aspacemgr/aspacemgr.c @@ -48,7 +48,7 @@ #include "pub_core_options.h" // VG_(clo_sanity_level) -#include "vki_unistd.h" // __NR_* constants +#include "pub_core_vkiscnums.h" // __NR_* constants #include "pub_core_aspacemgr.h" // self diff --git a/coregrind/m_libcassert.c b/coregrind/m_libcassert.c index eb39e5d10..5e4c5ed05 100644 --- a/coregrind/m_libcassert.c +++ b/coregrind/m_libcassert.c @@ -38,7 +38,7 @@ #include "pub_core_syscall.h" #include "pub_core_tooliface.h" // For VG_(details).{name,bug_reports_to} #include "pub_core_options.h" // For VG_(clo_xml) -#include "vki_unistd.h" +#include "pub_core_vkiscnums.h" /* --------------------------------------------------------------------- Assertery. diff --git a/coregrind/m_libcfile.c b/coregrind/m_libcfile.c index 4afe9cfd5..ec455841f 100644 --- a/coregrind/m_libcfile.c +++ b/coregrind/m_libcfile.c @@ -36,7 +36,7 @@ #include "pub_core_libcproc.h" // VG_(getpid), VG_(getppid) #include "pub_core_clientstate.h" // VG_(fd_hard_limit) #include "pub_core_syscall.h" -#include "vki_unistd.h" +#include "pub_core_vkiscnums.h" /* --------------------------------------------------------------------- File stuff diff --git a/coregrind/m_libcproc.c b/coregrind/m_libcproc.c index d6fe29fa7..16efd4da1 100644 --- a/coregrind/m_libcproc.c +++ b/coregrind/m_libcproc.c @@ -36,7 +36,7 @@ #include "pub_core_mallocfree.h" #include "pub_core_syscall.h" #include "pub_core_clientstate.h" -#include "vki_unistd.h" +#include "pub_core_vkiscnums.h" /* --------------------------------------------------------------------- Command line and environment stuff diff --git a/coregrind/m_libcsignal.c b/coregrind/m_libcsignal.c index c62220b09..39c81cdb9 100644 --- a/coregrind/m_libcsignal.c +++ b/coregrind/m_libcsignal.c @@ -33,7 +33,7 @@ #include "pub_core_libcassert.h" #include "pub_core_libcsignal.h" #include "pub_core_syscall.h" -#include "vki_unistd.h" +#include "pub_core_vkiscnums.h" /* sigemptyset, sigfullset, sigaddset and sigdelset return 0 on success and -1 on error. */ diff --git a/coregrind/m_scheduler/scheduler.c b/coregrind/m_scheduler/scheduler.c index d50e9e2c1..c2f4333b8 100644 --- a/coregrind/m_scheduler/scheduler.c +++ b/coregrind/m_scheduler/scheduler.c @@ -81,7 +81,7 @@ #include "pub_core_tooliface.h" #include "pub_core_translate.h" // For VG_(translate)() #include "pub_core_transtab.h" -#include "vki_unistd.h" +#include "pub_core_vkiscnums.h" #include "priv_sema.h" /* #include "pub_core_debuginfo.h" */ // DEBUGGING HACK ONLY diff --git a/coregrind/m_signals.c b/coregrind/m_signals.c index cb4153e11..3ca139868 100644 --- a/coregrind/m_signals.c +++ b/coregrind/m_signals.c @@ -103,7 +103,7 @@ #include "pub_core_syswrap.h" #include "pub_core_tooliface.h" #include "pub_core_coredump.h" -#include "vki_unistd.h" +#include "pub_core_vkiscnums.h" /* --------------------------------------------------------------------- diff --git a/coregrind/m_syswrap/syscall-x86-linux.S b/coregrind/m_syswrap/syscall-x86-linux.S index 117fa1f42..7432edbd8 100644 --- a/coregrind/m_syswrap/syscall-x86-linux.S +++ b/coregrind/m_syswrap/syscall-x86-linux.S @@ -29,7 +29,7 @@ */ #include "pub_core_basics_asm.h" -#include "vki_unistd.h" +#include "pub_core_vkiscnums.h" #include "libvex_guest_offsets.h" diff --git a/coregrind/m_syswrap/syswrap-generic.c b/coregrind/m_syswrap/syswrap-generic.c index 5801afce1..3812e1963 100644 --- a/coregrind/m_syswrap/syswrap-generic.c +++ b/coregrind/m_syswrap/syswrap-generic.c @@ -55,7 +55,7 @@ #include "priv_types_n_macros.h" #include "priv_syswrap-generic.h" -#include "vki_unistd.h" /* for the __NR_* constants */ +#include "pub_core_vkiscnums.h" /* for the __NR_* constants */ /* Returns True iff address range is something the client can diff --git a/coregrind/m_syswrap/syswrap-linux.c b/coregrind/m_syswrap/syswrap-linux.c index 7a774458c..de5e7371d 100644 --- a/coregrind/m_syswrap/syswrap-linux.c +++ b/coregrind/m_syswrap/syswrap-linux.c @@ -53,7 +53,7 @@ #include "priv_syswrap-generic.h" #include "priv_syswrap-linux.h" -#include "vki_unistd.h" /* for the __NR_* constants */ +#include "pub_core_vkiscnums.h" /* for the __NR_* constants */ // Run a thread from beginning to end and return the thread's // scheduler-return-code. diff --git a/coregrind/m_syswrap/syswrap-x86-linux.c b/coregrind/m_syswrap/syswrap-x86-linux.c index 228fb47d9..a782af15d 100644 --- a/coregrind/m_syswrap/syswrap-x86-linux.c +++ b/coregrind/m_syswrap/syswrap-x86-linux.c @@ -58,7 +58,7 @@ #include "priv_syswrap-linux-variants.h" /* decls of linux variant wrappers */ #include "priv_syswrap-main.h" -#include "vki_unistd.h" /* for the __NR_* constants */ +#include "pub_core_vkiscnums.h" /* for the __NR_* constants */ /* --------------------------------------------------------------------- diff --git a/coregrind/m_trampoline.S b/coregrind/m_trampoline.S index a795a5962..59f8588bf 100644 --- a/coregrind/m_trampoline.S +++ b/coregrind/m_trampoline.S @@ -29,7 +29,7 @@ */ #include "pub_core_basics_asm.h" -#include "vki_unistd.h" +#include "pub_core_vkiscnums.h" /* ------------------ SIMULATED CPU HELPERS ------------------ */ /* diff --git a/coregrind/m_ume.c b/coregrind/m_ume.c index e46a354f9..4ff5953d7 100644 --- a/coregrind/m_ume.c +++ b/coregrind/m_ume.c @@ -48,7 +48,7 @@ #include "pub_core_libcassert.h" // VG_(exit), vg_assert #include "pub_core_mallocfree.h" // VG_(malloc), VG_(free) #include "pub_core_syscall.h" // VG_(strerror) -#include "vki_unistd.h" // mmap-related constants +#include "pub_core_vkiscnums.h" // mmap-related constants #include "pub_core_ume.h" diff --git a/include/Makefile.am b/include/Makefile.am index 4fb93cb25..0331635c9 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -28,13 +28,14 @@ incinc_HEADERS = \ pub_tool_stacktrace.h \ pub_tool_threadstate.h \ pub_tool_tooliface.h \ + pub_tool_vkiscnums.h \ valgrind.h \ vki-linux.h \ vki-amd64-linux.h \ vki-ppc32-linux.h \ vki-ppc64-linux.h \ vki-x86-linux.h \ - vki_posixtypes-amd64-linux.h \ - vki_posixtypes-ppc32-linux.h \ - vki_posixtypes-ppc64-linux.h \ - vki_posixtypes-x86-linux.h + vki/vki-scnums-amd64-linux.h \ + vki/vki-scnums-ppc32-linux.h \ + vki/vki-scnums-ppc64-linux.h \ + vki/vki-scnums-x86-linux.h diff --git a/coregrind/vki_unistd.h b/include/pub_tool_vkiscnums.h similarity index 50% rename from coregrind/vki_unistd.h rename to include/pub_tool_vkiscnums.h index 934442da0..f33c6b4f3 100644 --- a/coregrind/vki_unistd.h +++ b/include/pub_tool_vkiscnums.h @@ -1,15 +1,17 @@ /*--------------------------------------------------------------------*/ -/*--- Generic header for Valgrind's kernel interface. ---*/ -/*--- vki_unistd.h ---*/ +/*--- Top level for kernel interface system call numbers. ---*/ +/*--- pub_tool_vkiscnums.h ---*/ /*--------------------------------------------------------------------*/ /* This file is part of Valgrind, a dynamic binary instrumentation framework. - Copyright (C) 2005 Nicholas Nethercote + Copyright (C) 2005-2006 Nicholas Nethercote njn@valgrind.org + Copyright (C) 2006-2006 OpenWorks LLP + info@open-works.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -29,22 +31,42 @@ The GNU General Public License is contained in the file COPYING. */ -#ifndef __VKI_UNISTD_H -#define __VKI_UNISTD_H +/* This file defines the system call numbers. + + On Linux they are a bunch of #define'd constants of the form + __NR_name, and this file must contain nothing else, since it will + be included in assembly code (m_trampoline.S). + + On AIX the __NR_name consts are renamings of global variables which + tell us the number for each syscall. This elaboration is necessary + because on AIX the syscall numbers are not constant; they can be + different for each process (in principle; in practice they rarely + change). 32- and 64-bit AIX5 share a common "implementation". + + This file is merely a top-level "steering" file, which pulls in the + correct bits for the relevant platform. You should not directly + #include any file in include/vki; instead #include only this one or + pub_core_vkiscnums.h. +*/ + +#ifndef __PUB_TOOL_VKISCNUMS_H +#define __PUB_TOOL_VKISCNUMS_H #if defined(VGP_x86_linux) -# include "vki_unistd-x86-linux.h" +# include "vki/vki-scnums-x86-linux.h" #elif defined(VGP_amd64_linux) -# include "vki_unistd-amd64-linux.h" +# include "vki/vki-scnums-amd64-linux.h" #elif defined(VGP_ppc32_linux) -# include "vki_unistd-ppc32-linux.h" +# include "vki/vki-scnums-ppc32-linux.h" #elif defined(VGP_ppc64_linux) -# include "vki_unistd-ppc64-linux.h" +# include "vki/vki-scnums-ppc64-linux.h" +#elif defined(VGP_ppc32_aix5) || defined(VGP_ppc64_aix5) +# include "vki/vki-scnums-aix5.h" #else # error Unknown platform #endif -#endif // __VKI_UNISTD_H +#endif // __PUB_TOOL_VKISCNUMS_H /*--------------------------------------------------------------------*/ /*--- end ---*/ diff --git a/coregrind/vki_unistd-amd64-linux.h b/include/vki/vki-scnums-amd64-linux.h similarity index 95% rename from coregrind/vki_unistd-amd64-linux.h rename to include/vki/vki-scnums-amd64-linux.h index 617f6a304..c2d94dea9 100644 --- a/coregrind/vki_unistd-amd64-linux.h +++ b/include/vki/vki-scnums-amd64-linux.h @@ -1,4 +1,9 @@ +/*--------------------------------------------------------------------*/ +/*--- System call numbers for amd64-linux. ---*/ +/*--- vki-scnums-amd64-linux.h ---*/ +/*--------------------------------------------------------------------*/ + /* This file is part of Valgrind, a dynamic binary instrumentation framework. @@ -24,8 +29,8 @@ The GNU General Public License is contained in the file COPYING. */ -#ifndef __VKI_UNISTD_AMD64_LINUX_H -#define __VKI_UNISTD_AMD64_LINUX_H +#ifndef __VKI_SCNUMS_AMD64_LINUX_H +#define __VKI_SCNUMS_AMD64_LINUX_H // From linux-2.6.9/include/asm-x86_64/unistd.h @@ -356,4 +361,8 @@ #define __NR_sync_file_range 277 #define __NR_vmsplice 278 -#endif /* __VKI_UNISTD_AMD64_LINUX_H */ +#endif /* __VKI_SCNUMS_AMD64_LINUX_H */ + +/*--------------------------------------------------------------------*/ +/*--- end ---*/ +/*--------------------------------------------------------------------*/ diff --git a/coregrind/vki_unistd-ppc32-linux.h b/include/vki/vki-scnums-ppc32-linux.h similarity index 93% rename from coregrind/vki_unistd-ppc32-linux.h rename to include/vki/vki-scnums-ppc32-linux.h index b5c7e68e7..9ea8199cf 100644 --- a/coregrind/vki_unistd-ppc32-linux.h +++ b/include/vki/vki-scnums-ppc32-linux.h @@ -1,8 +1,14 @@ + +/*--------------------------------------------------------------------*/ +/*--- System call numbers for ppc32-linux. ---*/ +/*--- vki-scnums-ppc32-linux.h ---*/ +/*--------------------------------------------------------------------*/ + /* This file is part of Valgrind, a dynamic binary instrumentation framework. - Copyright (C) 2005 Julian Seward + Copyright (C) 2005-2006 Julian Seward jseward@acm.org This program is free software; you can redistribute it and/or @@ -23,8 +29,8 @@ The GNU General Public License is contained in the file COPYING. */ -#ifndef __VKI_UNISTD_PPC32_LINUX_H -#define __VKI_UNISTD_PPC32_LINUX_H +#ifndef __VKI_SCNUMS_PPC32_LINUX_H +#define __VKI_SCNUMS_PPC32_LINUX_H // From linux-2.6.9/include/asm-ppc/unistd.h @@ -340,4 +346,8 @@ #define __NR_syscalls 301 -#endif /* __VKI_UNISTD_PPC32_LINUX_H */ +#endif /* __VKI_SCNUMS_PPC32_LINUX_H */ + +/*--------------------------------------------------------------------*/ +/*--- end ---*/ +/*--------------------------------------------------------------------*/ diff --git a/coregrind/vki_unistd-ppc64-linux.h b/include/vki/vki-scnums-ppc64-linux.h similarity index 94% rename from coregrind/vki_unistd-ppc64-linux.h rename to include/vki/vki-scnums-ppc64-linux.h index 3748a6cab..79f448177 100644 --- a/coregrind/vki_unistd-ppc64-linux.h +++ b/include/vki/vki-scnums-ppc64-linux.h @@ -1,9 +1,14 @@ +/*--------------------------------------------------------------------*/ +/*--- System call numbers for ppc64-linux. ---*/ +/*--- vki-scnums-ppc64-linux.h ---*/ +/*--------------------------------------------------------------------*/ + /* This file is part of Valgrind, a dynamic binary instrumentation framework. - Copyright (C) 2005 Julian Seward + Copyright (C) 2005-2006 Julian Seward jseward@acm.org This program is free software; you can redistribute it and/or @@ -24,8 +29,8 @@ The GNU General Public License is contained in the file COPYING. */ -#ifndef __VKI_UNISTD_PPC64_LINUX_H -#define __VKI_UNISTD_PPC64_LINUX_H +#ifndef __VKI_SCNUMS_PPC64_LINUX_H +#define __VKI_SCNUMS_PPC64_LINUX_H // From linux-2.6.16-rc4/include/asm-powerpc/unistd.h @@ -331,4 +336,8 @@ #define __NR_get_robust_list 299 #define __NR_set_robust_list 300 -#endif /* __VKI_UNISTD_PPC64_LINUX_H */ +#endif /* __VKI_SCNUMS_PPC64_LINUX_H */ + +/*--------------------------------------------------------------------*/ +/*--- end ---*/ +/*--------------------------------------------------------------------*/ diff --git a/coregrind/vki_unistd-x86-linux.h b/include/vki/vki-scnums-x86-linux.h similarity index 94% rename from coregrind/vki_unistd-x86-linux.h rename to include/vki/vki-scnums-x86-linux.h index 60f2f2f74..92473ec96 100644 --- a/coregrind/vki_unistd-x86-linux.h +++ b/include/vki/vki-scnums-x86-linux.h @@ -1,4 +1,9 @@ +/*--------------------------------------------------------------------*/ +/*--- System call numbers for x86-linux. ---*/ +/*--- vki-scnums-x86-linux.h ---*/ +/*--------------------------------------------------------------------*/ + /* This file is part of Valgrind, a dynamic binary instrumentation framework. @@ -24,8 +29,8 @@ The GNU General Public License is contained in the file COPYING. */ -#ifndef __VKI_UNISTD_X86_LINUX_H -#define __VKI_UNISTD_X86_LINUX_H +#ifndef __VKI_SCNUMS_X86_LINUX_H +#define __VKI_SCNUMS_X86_LINUX_H // From linux-2.6.9/include/asm-i386/unistd.h @@ -347,4 +352,8 @@ #define __NR_tee 315 #define __NR_vmsplice 316 -#endif /* __VKI_UNISTD_X86_LINUX_H */ +#endif /* __VKI_SCNUMS_X86_LINUX_H */ + +/*--------------------------------------------------------------------*/ +/*--- end ---*/ +/*--------------------------------------------------------------------*/ diff --git a/memcheck/tests/x86/scalar.h b/memcheck/tests/x86/scalar.h index 3fa86c911..072b9c67a 100644 --- a/memcheck/tests/x86/scalar.h +++ b/memcheck/tests/x86/scalar.h @@ -1,4 +1,4 @@ -#include "../../../coregrind/vki_unistd-x86-linux.h" +#include "../../../include/vki/vki-scnums-x86-linux.h" #include #include