blob: 03a9b7a4caca130eba666ce921c253885d249397 [file] [log] [blame]
nethercoteebf1d862004-11-01 18:22:05 +00001
2/*--------------------------------------------------------------------*/
njnc7561b92005-06-19 01:24:32 +00003/*--- Header included by every tool C file. pub_tool_basics.h ---*/
nethercoteebf1d862004-11-01 18:22:05 +00004/*--------------------------------------------------------------------*/
5
6/*
njnb9c427c2004-12-01 14:14:42 +00007 This file is part of Valgrind, a dynamic binary instrumentation
8 framework.
nethercoteebf1d862004-11-01 18:22:05 +00009
njn53612422005-03-12 16:22:54 +000010 Copyright (C) 2000-2005 Julian Seward
nethercoteebf1d862004-11-01 18:22:05 +000011 jseward@acm.org
12
13 This program is free software; you can redistribute it and/or
14 modify it under the terms of the GNU General Public License as
15 published by the Free Software Foundation; either version 2 of the
16 License, or (at your option) any later version.
17
18 This program is distributed in the hope that it will be useful, but
19 WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 General Public License for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, write to the Free Software
25 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
26 02111-1307, USA.
27
28 The GNU General Public License is contained in the file COPYING.
29*/
30
njnc7561b92005-06-19 01:24:32 +000031#ifndef __PUB_TOOL_BASICS_H
32#define __PUB_TOOL_BASICS_H
33
34//--------------------------------------------------------------------
35// PURPOSE: This header should be imported by every single C file in
36// tools. It contains the basic types and other things needed everywhere.
37// There is no corresponding C file because this isn't a module
38// containing executable code, it's all just declarations.
39//--------------------------------------------------------------------
40
41/* ---------------------------------------------------------------------
42 Other headers to include
43 ------------------------------------------------------------------ */
44
45// VEX defines Char, UChar, Short, UShort, Int, UInt, Long, ULong,
46// Addr32, Addr64, HWord, HChar, Bool, False and True.
47#include "libvex_basictypes.h"
48
49// For the VG_() macro
50#include "pub_tool_basics_asm.h"
51
52// For varargs types
53#include <stdarg.h>
54
55// Autoconf-generated settings
56#include "config.h"
57
58// Kernel types. Might as well have them here, they're used so broadly
59// (eg. in pub_core_threadstate.h).
60#if defined(VGO_linux)
61# include "vki-linux.h"
62#else
63# error Unknown OS
64#endif
nethercoteebf1d862004-11-01 18:22:05 +000065
66/* ---------------------------------------------------------------------
njnd01fef72005-03-25 23:35:48 +000067 builtin types
nethercoteebf1d862004-11-01 18:22:05 +000068 ------------------------------------------------------------------ */
69
70// By choosing the right types, we can get these right for 32-bit and 64-bit
71// platforms without having to do any conditional compilation or anything.
nethercote8b5f40c2004-11-02 13:29:50 +000072//
nethercoteebf1d862004-11-01 18:22:05 +000073// Size in bits on: 32-bit archs 64-bit archs
74// ------------ ------------
nethercoteebf1d862004-11-01 18:22:05 +000075typedef unsigned long UWord; // 32 64
nethercoteebf1d862004-11-01 18:22:05 +000076
nethercoteebf1d862004-11-01 18:22:05 +000077typedef signed long Word; // 32 64
nethercoteebf1d862004-11-01 18:22:05 +000078
79typedef UWord Addr; // 32 64
sewardjfa8ec112005-01-19 11:55:34 +000080typedef UWord AddrH; // 32 64
nethercoteebf1d862004-11-01 18:22:05 +000081
nethercote7ac7f7b2004-11-02 12:36:02 +000082typedef UWord SizeT; // 32 64
83typedef Word SSizeT; // 32 64
84
nethercoteada0d2b2004-11-04 19:10:43 +000085typedef Word OffT; // 32 64
nethercote5b9fafd2004-11-04 18:39:22 +000086
njn21edee32005-06-11 04:44:38 +000087#if !defined(NULL)
88# define NULL ((void*)0)
89#endif
sewardjbc7df202005-05-02 10:25:34 +000090
njnc7561b92005-06-19 01:24:32 +000091/* ---------------------------------------------------------------------
92 non-builtin types
93 ------------------------------------------------------------------ */
94
95// These probably shouldn't be here, but moving them to their logical
96// modules results in a lot more #includes...
97
98/* ThreadIds are simply indices into the VG_(threads)[] array. */
99typedef UInt ThreadId;
100
101/* An abstraction of syscall return values.
102 When .isError == False, val holds the return value.
103 When .isError == True, val holds the error code.
104*/
105typedef struct {
106 UWord val;
107 Bool isError;
108}
109SysRes;
110
111/* ---------------------------------------------------------------------
112 Miscellaneous
113 ------------------------------------------------------------------ */
114
115/* This is going to be either 4 or 8. */
116// It should probably be in m_machine.
117#define VG_WORDSIZE VEX_HOST_WORDSIZE
118
njnf536bbb2005-06-13 04:21:38 +0000119#if defined(VGA_x86)
120# define VGA_REGPARM(n) __attribute__((regparm(n)))
121#elif defined(VGA_amd64) || defined(VGA_arm)
122# define VGA_REGPARM(n) /* */
123#else
124# error Unknown arch
125#endif
126
njnc7561b92005-06-19 01:24:32 +0000127#endif /* __PUB_TOOL_BASICS_H */
nethercoteebf1d862004-11-01 18:22:05 +0000128
129/*--------------------------------------------------------------------*/
130/*--- end ---*/
131/*--------------------------------------------------------------------*/