diff options
author | njn <njn@a5019735-40e9-0310-863c-91ae7b9d1cf9> | 2005-06-19 01:24:32 +0000 |
---|---|---|
committer | njn <njn@a5019735-40e9-0310-863c-91ae7b9d1cf9> | 2005-06-19 01:24:32 +0000 |
commit | c7561b931e249acf3768ead77638545b0ccaa8f1 (patch) | |
tree | fe08fcd35349cccd5a50d421a1e35108e5d75f57 /include | |
parent | fd0922c413332ab905868dbac18da8dda1e5a0d4 (diff) | |
download | valgrind-c7561b931e249acf3768ead77638545b0ccaa8f1.tar.gz |
Final commit for the initial modularisation pass:
- Broke part of m_scheduler off into a new module m_threadstate. It
contains ThreadState, VG_(threads)[] and some basic operations on the
thread table. All simple stuff, the complex stuff stays in m_scheduler.
This avoids lots of circular dependencies between m_scheduler and other
modules.
- Managed to finally remove core.h and tool.h, double hurrah!
- Introduced pub_tool_basics.h and pub_core_basics.h, one of which is
include by every single C file.
- Lots of little cleanups and changes related to the above.
- I even did a small amount of documentation updating.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3944 a5019735-40e9-0310-863c-91ae7b9d1cf9
Diffstat (limited to 'include')
-rw-r--r-- | include/Makefile.am | 5 | ||||
-rw-r--r-- | include/pub_tool_basics.h (renamed from include/basic_types.h) | 95 | ||||
-rw-r--r-- | include/pub_tool_basics_asm.h | 50 | ||||
-rw-r--r-- | include/pub_tool_profile.h | 3 | ||||
-rw-r--r-- | include/pub_tool_stacktrace.h | 2 | ||||
-rw-r--r-- | include/pub_tool_threadstate.h (renamed from include/tool.h) | 40 |
6 files changed, 125 insertions, 70 deletions
diff --git a/include/Makefile.am b/include/Makefile.am index 5bf9b1d48..50624ab2a 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -2,9 +2,8 @@ incincdir = $(includedir)/valgrind incinc_HEADERS = \ - basic_types.h \ - tool.h \ - pub_basics_asm.h \ + pub_tool_basics.h \ + pub_tool_basics_asm.h \ pub_tool_aspacemgr.h \ pub_tool_cpuid.h \ pub_tool_errormgr.h \ diff --git a/include/basic_types.h b/include/pub_tool_basics.h index 62d5ae19f..03a9b7a4c 100644 --- a/include/basic_types.h +++ b/include/pub_tool_basics.h @@ -1,6 +1,6 @@ /*--------------------------------------------------------------------*/ -/*--- Header included by every C file. basic_types.h ---*/ +/*--- Header included by every tool C file. pub_tool_basics.h ---*/ /*--------------------------------------------------------------------*/ /* @@ -28,17 +28,44 @@ The GNU General Public License is contained in the file COPYING. */ -#ifndef __BASIC_TYPES_H -#define __BASIC_TYPES_H +#ifndef __PUB_TOOL_BASICS_H +#define __PUB_TOOL_BASICS_H + +//-------------------------------------------------------------------- +// PURPOSE: This header should be imported by every single C file in +// tools. It contains the basic types and other things needed everywhere. +// There is no corresponding C file because this isn't a module +// containing executable code, it's all just declarations. +//-------------------------------------------------------------------- /* --------------------------------------------------------------------- - builtin types + Other headers to include ------------------------------------------------------------------ */ +// VEX defines Char, UChar, Short, UShort, Int, UInt, Long, ULong, +// Addr32, Addr64, HWord, HChar, Bool, False and True. #include "libvex_basictypes.h" -/* VEX defines Char, UChar, Short, UShort, Int, UInt, Long, ULong, - Addr32, Addr64, HWord, HChar, Bool, False and True. */ +// For the VG_() macro +#include "pub_tool_basics_asm.h" + +// For varargs types +#include <stdarg.h> + +// Autoconf-generated settings +#include "config.h" + +// Kernel types. Might as well have them here, they're used so broadly +// (eg. in pub_core_threadstate.h). +#if defined(VGO_linux) +# include "vki-linux.h" +#else +# error Unknown OS +#endif + +/* --------------------------------------------------------------------- + builtin types + ------------------------------------------------------------------ */ // By choosing the right types, we can get these right for 32-bit and 64-bit // platforms without having to do any conditional compilation or anything. @@ -57,51 +84,47 @@ typedef Word SSizeT; // 32 64 typedef Word OffT; // 32 64 - -/* This is going to be either 4 or 8. */ -#define VG_WORDSIZE VEX_HOST_WORDSIZE - #if !defined(NULL) # define NULL ((void*)0) #endif -#if defined(VGA_x86) -# define VGA_REGPARM(n) __attribute__((regparm(n))) -#elif defined(VGA_amd64) || defined(VGA_arm) -# define VGA_REGPARM(n) /* */ -#else -# error Unknown arch -#endif - /* --------------------------------------------------------------------- non-builtin types ------------------------------------------------------------------ */ -// XXX: these probably shouldn't be here... +// These probably shouldn't be here, but moving them to their logical +// modules results in a lot more #includes... /* ThreadIds are simply indices into the VG_(threads)[] array. */ -typedef - UInt - ThreadId; - -/* Special magic value for an invalid ThreadId. It corresponds to - LinuxThreads using zero as the initial value for - pthread_mutex_t.__m_owner and pthread_cond_t.__c_waiting. */ -#define VG_INVALID_THREADID ((ThreadId)(0)) - +typedef UInt ThreadId; /* An abstraction of syscall return values. When .isError == False, val holds the return value. When .isError == True, val holds the error code. */ -typedef - struct { - UWord val; - Bool isError; - } - SysRes; - -#endif /* __BASIC_TYPES_H */ +typedef struct { + UWord val; + Bool isError; +} +SysRes; + +/* --------------------------------------------------------------------- + Miscellaneous + ------------------------------------------------------------------ */ + +/* This is going to be either 4 or 8. */ +// It should probably be in m_machine. +#define VG_WORDSIZE VEX_HOST_WORDSIZE + +#if defined(VGA_x86) +# define VGA_REGPARM(n) __attribute__((regparm(n))) +#elif defined(VGA_amd64) || defined(VGA_arm) +# define VGA_REGPARM(n) /* */ +#else +# error Unknown arch +#endif + +#endif /* __PUB_TOOL_BASICS_H */ /*--------------------------------------------------------------------*/ /*--- end ---*/ diff --git a/include/pub_tool_basics_asm.h b/include/pub_tool_basics_asm.h new file mode 100644 index 000000000..4de39fea8 --- /dev/null +++ b/include/pub_tool_basics_asm.h @@ -0,0 +1,50 @@ + +/*--------------------------------------------------------------------*/ +/*--- Header imported directly by every asm file, and indirectly ---*/ +/*--- (via pub_tool_basics.h) by every C file. ---*/ +/*--- pub_tool_basics_asm.h ---*/ +/*--------------------------------------------------------------------*/ + +/* + This file is part of Valgrind, a dynamic binary instrumentation + framework. + + Copyright (C) 2000-2005 Julian Seward + jseward@acm.org + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307, USA. + + The GNU General Public License is contained in the file COPYING. +*/ + +#ifndef __PUB_TOOL_BASICS_ASM_H +#define __PUB_TOOL_BASICS_ASM_H + +/* All symbols externally visible from Valgrind are prefixed + as specified here to avoid namespace conflict problems. */ + +#define VGAPPEND(str1,str2) str1##str2 + +#define VG_(str) VGAPPEND(vgPlain_, str) +#define VGA_(str) VGAPPEND(vgArch_, str) +#define VGO_(str) VGAPPEND(vgOS_, str) +#define VGP_(str) VGAPPEND(vgPlatform_, str) + +#endif /* __PUB_TOOL_BASICS_ASM_H */ + +/*--------------------------------------------------------------------*/ +/*--- end ---*/ +/*--------------------------------------------------------------------*/ diff --git a/include/pub_tool_profile.h b/include/pub_tool_profile.h index df9df66f8..a04b9891a 100644 --- a/include/pub_tool_profile.h +++ b/include/pub_tool_profile.h @@ -31,10 +31,9 @@ #ifndef __PUB_TOOL_PROFILE_H #define __PUB_TOOL_PROFILE_H -// Define this to turn on profiling. +// Define this to turn on profiling. (But it's currently not working...) //#define VG_DO_PROFILING 1 -/* Override the empty definitions from tool.h */ #ifdef VG_DO_PROFILING # define VGP_PUSHCC(x) if (VG_(clo_profile)) VG_(pushcc)(x) # define VGP_POPCC(x) if (VG_(clo_profile)) VG_(popcc)(x) diff --git a/include/pub_tool_stacktrace.h b/include/pub_tool_stacktrace.h index f74a1b109..b332bd834 100644 --- a/include/pub_tool_stacktrace.h +++ b/include/pub_tool_stacktrace.h @@ -31,8 +31,6 @@ #ifndef __PUB_TOOL_STACKTRACE_H #define __PUB_TOOL_STACKTRACE_H -#include "basic_types.h" - // The basic stack trace type: just an array of code addresses. typedef Addr* StackTrace; diff --git a/include/tool.h b/include/pub_tool_threadstate.h index 52a3a1df1..439fec025 100644 --- a/include/tool.h +++ b/include/pub_tool_threadstate.h @@ -1,5 +1,6 @@ -/*-*- c -*- ----------------------------------------------------------*/ -/*--- Header for lots of tool stuff. tool.h ---*/ + +/*--------------------------------------------------------------------*/ +/*--- The thread state. pub_tool_threadstate.h ---*/ /*--------------------------------------------------------------------*/ /* @@ -27,23 +28,8 @@ The GNU General Public License is contained in the file COPYING. */ -#ifndef __TOOL_H -#define __TOOL_H - -#include <stdarg.h> /* ANSI varargs stuff */ - -#include "basic_types.h" -#include "pub_basics_asm.h" /* asm stuff */ - -#if defined(VGO_linux) -# include "vki-linux.h" -#else -# error Unknown OS -#endif - -/*====================================================================*/ -/*=== Build options and table sizes. ===*/ -/*====================================================================*/ +#ifndef __PUB_TOOL_THREADSTATE_H +#define __PUB_TOOL_THREADSTATE_H /* The maximum number of pthreads that we support. This is deliberately not very high since our implementation of some of the @@ -52,12 +38,10 @@ programs do not need many threads. */ #define VG_N_THREADS 100 -/*====================================================================*/ -/*=== Useful stuff to call from generated code ===*/ -/*====================================================================*/ - -/* ------------------------------------------------------------------ */ -/* Thread-related stuff */ +/* Special magic value for an invalid ThreadId. It corresponds to + LinuxThreads using zero as the initial value for + pthread_mutex_t.__m_owner and pthread_cond_t.__c_waiting. */ +#define VG_INVALID_THREADID ((ThreadId)(0)) /* Get the TID of the thread which currently has the CPU. */ extern ThreadId VG_(get_running_tid) ( void ); @@ -68,6 +52,8 @@ extern ThreadId VG_(first_matching_thread_stack) ( Bool (*p) ( Addr stack_min, Addr stack_max, void* d ), void* d ); -#endif /* __TOOL_H */ - +#endif // __PUB_TOOL_THREADSTATE_H +/*--------------------------------------------------------------------*/ +/*--- end ---*/ +/*--------------------------------------------------------------------*/ |