aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authornjn <njn@a5019735-40e9-0310-863c-91ae7b9d1cf9>2009-01-15 21:29:24 +0000
committernjn <njn@a5019735-40e9-0310-863c-91ae7b9d1cf9>2009-01-15 21:29:24 +0000
commitc4431bfe04c7490ea2d74939d222d87f13f30960 (patch)
treed701361ded9eb32398ca0074a77a43fa47ecd200 /include
parenta81465a37cee19a5d8a03ee1b1b51a3cdc7b04c9 (diff)
downloadvalgrind-c4431bfe04c7490ea2d74939d222d87f13f30960.tar.gz
Introduce a new type, PtrdiffT. Replace lots of uses of OffT (all those
that are memory offsets) with PtrdiffT; OffT should only be used for file sizes and offsets. Change Off64T from a ULong to a Long, as it should be. Replace some uses of ULong in the address space manager with Off64T to match. Also add a comment explaining the meanings of the basic types like Addr, OffT, SizeT, etc. Also fix the prototype for VG_(pread) -- the last arg is an OffT, not an Int. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8959 a5019735-40e9-0310-863c-91ae7b9d1cf9
Diffstat (limited to 'include')
-rw-r--r--include/pub_tool_aspacemgr.h2
-rw-r--r--include/pub_tool_basics.h28
-rw-r--r--include/pub_tool_debuginfo.h14
-rw-r--r--include/pub_tool_machine.h4
-rw-r--r--include/pub_tool_oset.h2
-rw-r--r--include/pub_tool_tooliface.h6
6 files changed, 37 insertions, 19 deletions
diff --git a/include/pub_tool_aspacemgr.h b/include/pub_tool_aspacemgr.h
index 6144d270e..118655126 100644
--- a/include/pub_tool_aspacemgr.h
+++ b/include/pub_tool_aspacemgr.h
@@ -101,7 +101,7 @@ typedef
/* Associated file (SkFile{C,V} only) */
ULong dev;
ULong ino;
- ULong offset;
+ Off64T offset;
UInt mode;
Int fnIdx; // file name table index, if name is known
/* Permissions (SkAnon{C,V}, SkFile{C,V} only) */
diff --git a/include/pub_tool_basics.h b/include/pub_tool_basics.h
index 3292f00b9..d91bb81f3 100644
--- a/include/pub_tool_basics.h
+++ b/include/pub_tool_basics.h
@@ -62,22 +62,40 @@
// 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.
+// POSIX references:
+// - http://www.opengroup.org/onlinepubs/009695399/basedefs/sys/types.h.html
+// - http://www.opengroup.org/onlinepubs/009695399/basedefs/stddef.h.html
//
// Size in bits on: 32-bit archs 64-bit archs
// ------------ ------------
typedef unsigned long UWord; // 32 64
+typedef signed long Word; // 32 64
-typedef signed long Word; // 32 64
-
+// Addr is for holding an address. AddrH was intended to be "Addr on the
+// host", for the notional case where host word size != guest word size.
+// But since the assumption that host arch == guest arch has become so
+// deeply wired in, it's a pretty pointless distinction now.
typedef UWord Addr; // 32 64
typedef UWord AddrH; // 32 64
+// Our equivalents of POSIX 'size_t' and 'ssize_t':
+// - size_t is an "unsigned integer type of the result of the sizeof operator".
+// - ssize_t is "used for a count of bytes or an error indication".
typedef UWord SizeT; // 32 64
typedef Word SSizeT; // 32 64
-typedef Word OffT; // 32 64
-
-typedef ULong Off64T; // 64 64
+// Our equivalent of POSIX 'ptrdiff_t':
+// - ptrdiff_t is a "signed integer type of the result of subtracting two
+// pointers".
+// We use it for memory offsets, eg. the offset into a memory block.
+typedef Word PtrdiffT; // 32 64
+
+// Our equivalent of POSIX 'off_t':
+// - off_t is "used for file sizes".
+// At one point we were using it for memory offsets, but PtrdiffT should be
+// used in those cases.
+typedef Word OffT; // 32 64
+typedef Long Off64T; // 64 64
#if !defined(NULL)
# define NULL ((void*)0)
diff --git a/include/pub_tool_debuginfo.h b/include/pub_tool_debuginfo.h
index 30725d542..baf998147 100644
--- a/include/pub_tool_debuginfo.h
+++ b/include/pub_tool_debuginfo.h
@@ -80,7 +80,7 @@ extern Bool VG_(get_fnname_if_entry) ( Addr a, Char* fnname, Int n_fnname );
from the symbol start is put into *offset. */
extern Bool VG_(get_datasym_and_offset)( Addr data_addr,
/*OUT*/Char* dname, Int n_dname,
- /*OUT*/OffT* offset );
+ /*OUT*/PtrdiffT* offset );
/* Try to form some description of data_addr by looking at the DWARF3
debug info we have. This considers all global variables, and all
@@ -113,11 +113,11 @@ extern Char* VG_(describe_IP)(Addr eip, Char* buf, Int n_buf);
typedef
struct {
- OffT base; /* offset from sp or fp */
- SizeT szB; /* size in bytes */
- Bool spRel; /* True => sp-rel, False => fp-rel */
- Bool isVec; /* does block have an array type, or not? */
- HChar name[16]; /* first 15 chars of name (asciiz) */
+ PtrdiffT base; /* offset from sp or fp */
+ SizeT szB; /* size in bytes */
+ Bool spRel; /* True => sp-rel, False => fp-rel */
+ Bool isVec; /* does block have an array type, or not? */
+ HChar name[16]; /* first 15 chars of name (asciiz) */
}
StackBlock;
@@ -167,7 +167,7 @@ extern Addr VG_(seginfo_get_gotplt_avma)( const DebugInfo *di );
extern SizeT VG_(seginfo_get_gotplt_size)( const DebugInfo *di );
extern const UChar* VG_(seginfo_soname) ( const DebugInfo *di );
extern const UChar* VG_(seginfo_filename) ( const DebugInfo *di );
-extern ULong VG_(seginfo_get_text_bias)( const DebugInfo *di );
+extern PtrdiffT VG_(seginfo_get_text_bias)( const DebugInfo *di );
/* Function for traversing the seginfo list. When called with NULL it
returns the first element; otherwise it returns the given element's
diff --git a/include/pub_tool_machine.h b/include/pub_tool_machine.h
index ae9669c05..fc86bf960 100644
--- a/include/pub_tool_machine.h
+++ b/include/pub_tool_machine.h
@@ -90,10 +90,10 @@ extern void VG_(set_IP) ( ThreadId tid, Addr ip );
void
VG_(get_shadow_regs_area) ( ThreadId tid,
/*DST*/UChar* dst,
- /*SRC*/Int shadowNo, OffT offset, SizeT size );
+ /*SRC*/Int shadowNo, PtrdiffT offset, SizeT size );
void
VG_(set_shadow_regs_area) ( ThreadId tid,
- /*DST*/Int shadowNo, OffT offset, SizeT size,
+ /*DST*/Int shadowNo, PtrdiffT offset, SizeT size,
/*SRC*/const UChar* src );
// Sets the shadow values for the syscall return value register(s).
diff --git a/include/pub_tool_oset.h b/include/pub_tool_oset.h
index 1573136fa..c496523fb 100644
--- a/include/pub_tool_oset.h
+++ b/include/pub_tool_oset.h
@@ -183,7 +183,7 @@ extern Bool VG_(OSetWord_Next) ( OSet* os, /*OUT*/UWord* val );
// a deallocation function (such as VG_(free)()) directly will likely
// lead to assertions in Valgrind's allocator.
-extern OSet* VG_(OSetGen_Create) ( OffT keyOff, OSetCmp_t cmp,
+extern OSet* VG_(OSetGen_Create) ( PtrdiffT keyOff, OSetCmp_t cmp,
OSetAlloc_t alloc, HChar* ec,
OSetFree_t free );
extern void VG_(OSetGen_Destroy) ( OSet* os );
diff --git a/include/pub_tool_tooliface.h b/include/pub_tool_tooliface.h
index 210df361a..8194706c8 100644
--- a/include/pub_tool_tooliface.h
+++ b/include/pub_tool_tooliface.h
@@ -567,15 +567,15 @@ void VG_(track_post_mem_write) (void(*f)(CorePart part, ThreadId tid,
/* Register events. Use VG_(set_shadow_state_area)() to set the shadow regs
for these events. */
void VG_(track_pre_reg_read) (void(*f)(CorePart part, ThreadId tid,
- Char* s, OffT guest_state_offset,
+ Char* s, PtrdiffT guest_state_offset,
SizeT size));
void VG_(track_post_reg_write)(void(*f)(CorePart part, ThreadId tid,
- OffT guest_state_offset,
+ PtrdiffT guest_state_offset,
SizeT size));
/* This one is called for malloc() et al if they are replaced by a tool. */
void VG_(track_post_reg_write_clientcall_return)(
- void(*f)(ThreadId tid, OffT guest_state_offset, SizeT size, Addr f));
+ void(*f)(ThreadId tid, PtrdiffT guest_state_offset, SizeT size, Addr f));
/* Scheduler events (not exhaustive) */