summaryrefslogtreecommitdiff
path: root/runtime/libtrace
diff options
context:
space:
mode:
authorVikram S. Adve <vadve@cs.uiuc.edu>2003-07-11 22:02:28 +0000
committerVikram S. Adve <vadve@cs.uiuc.edu>2003-07-11 22:02:28 +0000
commite04a2e056bf529c81d0a1de624c697ebce57b972 (patch)
tree1fe5ff3ad037a697389e9d7cb40824500ee7e2ee /runtime/libtrace
parent919fc8c367bb875326a2420041a385a3f5f6ad4f (diff)
downloadllvm-e04a2e056bf529c81d0a1de624c697ebce57b972.tar.gz
llvm-e04a2e056bf529c81d0a1de624c697ebce57b972.tar.bz2
llvm-e04a2e056bf529c81d0a1de624c697ebce57b972.tar.xz
Use uint32_t for table index and size: table will never be > 4GB.
Also, make Pointer type depend on architecture. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7170 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'runtime/libtrace')
-rw-r--r--runtime/libtrace/tracelib.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/runtime/libtrace/tracelib.c b/runtime/libtrace/tracelib.c
index 189409ea86..dce05aa2f4 100644
--- a/runtime/libtrace/tracelib.c
+++ b/runtime/libtrace/tracelib.c
@@ -20,25 +20,29 @@
/* use #defines until we have inlining */
-typedef int64_t Generic;
-typedef uint64_t Index;
-typedef uint64_t Pointer;
+#ifndef sun
+typedef uint32_t Pointer; /* int representation of a pointer */
+#else
+typedef uint64_t Pointer; /* int representation of a pointer */
+#endif
+typedef uint32_t Index; /* type of index/size for hash table */
+typedef uint32_t Generic; /* type of values stored in table */
/* Index IntegerHashFunc(const Generic value, const Index size) */
#define IntegerHashFunc(value, size) \
- (((value << 3) ^ (value >> 3)) % size)
+ ( ((((Index) value) << 3) ^ (((Index) value) >> 3)) % size )
/* Index IntegerRehashFunc(const Generic oldHashValue, const Index size) */
#define IntegerRehashFunc(oldHashValue, size) \
- ((oldHashValue+16) % size) /* 16 is relatively prime to a Mersenne prime! */
+ ((Index) ((oldHashValue+16) % size)) /* 16 is relatively prime to a Mersenne prime! */
/* Index PointerHashFunc(const void* value, const Index size) */
#define PointerHashFunc(value, size) \
- IntegerHashFunc((Pointer) value, size)
+ IntegerHashFunc((Index) value, size)
/* Index PointerRehashFunc(const void* value, const Index size) */
#define PointerRehashFunc(value, size) \
- IntegerRehashFunc((Pointer) value, size)
+ IntegerRehashFunc((Index) value, size)
/*===---------------------------------------------------------------------=====
@@ -375,7 +379,7 @@ main(int argc, char** argv)
/* print sequence numbers out again to compare with (-r) and w/o release */
for (i=argc-1; i >= 0; --i)
for (j=0; argv[i][j]; ++j)
- printf("Sequence number for argc[%d][%d] (%c) = Hash(%p) = %d\n",
+ printf("Sequence number for argc[%d][%d] (%c) = %d\n",
i, j, argv[i][j], argv[i]+j, HashPointerToSeqNum(argv[i]+j));
return 0;