summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2016-07-12 13:44:26 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2016-07-12 13:44:26 (GMT)
commit71e7049f8ea65780583e847f2b3055b519395517 (patch)
treeed2a2c3cdb9d99794e2c09daee427b78362051b3 /generic
parent7ad31bb0a3bc7e0e2a4a4ce4c6f05eb21f250f64 (diff)
downloadtcl-71e7049f8ea65780583e847f2b3055b519395517.zip
tcl-71e7049f8ea65780583e847f2b3055b519395517.tar.gz
tcl-71e7049f8ea65780583e847f2b3055b519395517.tar.bz2
Make hash type changable by compiling with -DTCL_HASH_TYPE=size_t (for example). Default (unsigned) cannot be changed in Tcl 8.x, that must wait until Tcl 9.
Diffstat (limited to 'generic')
-rw-r--r--generic/tcl.h6
-rw-r--r--generic/tclHash.c12
-rw-r--r--generic/tclInt.h2
-rw-r--r--generic/tclObj.c4
4 files changed, 14 insertions, 10 deletions
diff --git a/generic/tcl.h b/generic/tcl.h
index 6061ea8..ded8d0b 100644
--- a/generic/tcl.h
+++ b/generic/tcl.h
@@ -1157,11 +1157,15 @@ typedef struct Tcl_DString {
* Forward declarations of Tcl_HashTable and related types.
*/
+#ifndef TCL_HASH_TYPE
+# define TCL_HASH_TYPE unsigned
+#endif
+
typedef struct Tcl_HashKeyType Tcl_HashKeyType;
typedef struct Tcl_HashTable Tcl_HashTable;
typedef struct Tcl_HashEntry Tcl_HashEntry;
-typedef unsigned (Tcl_HashKeyProc) (Tcl_HashTable *tablePtr, void *keyPtr);
+typedef TCL_HASH_TYPE (Tcl_HashKeyProc) (Tcl_HashTable *tablePtr, void *keyPtr);
typedef int (Tcl_CompareHashKeysProc) (void *keyPtr, Tcl_HashEntry *hPtr);
typedef Tcl_HashEntry * (Tcl_AllocHashEntryProc) (Tcl_HashTable *tablePtr,
void *keyPtr);
diff --git a/generic/tclHash.c b/generic/tclHash.c
index 3ea9dd9..ac9d40e 100644
--- a/generic/tclHash.c
+++ b/generic/tclHash.c
@@ -43,7 +43,7 @@
static Tcl_HashEntry * AllocArrayEntry(Tcl_HashTable *tablePtr, void *keyPtr);
static int CompareArrayKeys(void *keyPtr, Tcl_HashEntry *hPtr);
-static unsigned int HashArrayKey(Tcl_HashTable *tablePtr, void *keyPtr);
+static TCL_HASH_TYPE HashArrayKey(Tcl_HashTable *tablePtr, void *keyPtr);
/*
* Prototypes for the one word hash key methods. Not actually declared because
@@ -65,7 +65,7 @@ static unsigned int HashOneWordKey(Tcl_HashTable *tablePtr, void *keyPtr);
static Tcl_HashEntry * AllocStringEntry(Tcl_HashTable *tablePtr,
void *keyPtr);
static int CompareStringKeys(void *keyPtr, Tcl_HashEntry *hPtr);
-static unsigned int HashStringKey(Tcl_HashTable *tablePtr, void *keyPtr);
+static TCL_HASH_TYPE HashStringKey(Tcl_HashTable *tablePtr, void *keyPtr);
/*
* Function prototypes for static functions in this file:
@@ -774,7 +774,7 @@ CompareArrayKeys(
*----------------------------------------------------------------------
*/
-static unsigned int
+static TCL_HASH_TYPE
HashArrayKey(
Tcl_HashTable *tablePtr, /* Hash table. */
void *keyPtr) /* Key from which to compute hash value. */
@@ -787,7 +787,7 @@ HashArrayKey(
count--, array++) {
result += *array;
}
- return result;
+ return (TCL_HASH_TYPE) result;
}
/*
@@ -870,7 +870,7 @@ CompareStringKeys(
*----------------------------------------------------------------------
*/
-static unsigned
+static TCL_HASH_TYPE
HashStringKey(
Tcl_HashTable *tablePtr, /* Hash table. */
void *keyPtr) /* Key from which to compute hash value. */
@@ -916,7 +916,7 @@ HashStringKey(
result += (result << 3) + UCHAR(c);
}
}
- return result;
+ return (TCL_HASH_TYPE) result;
}
/*
diff --git a/generic/tclInt.h b/generic/tclInt.h
index c01b0c1..33476ed 100644
--- a/generic/tclInt.h
+++ b/generic/tclInt.h
@@ -3977,7 +3977,7 @@ MODULE_SCOPE int TclObjCallVarTraces(Interp *iPtr, Var *arrayPtr,
MODULE_SCOPE int TclCompareObjKeys(void *keyPtr, Tcl_HashEntry *hPtr);
MODULE_SCOPE void TclFreeObjEntry(Tcl_HashEntry *hPtr);
-MODULE_SCOPE unsigned TclHashObjKey(Tcl_HashTable *tablePtr, void *keyPtr);
+MODULE_SCOPE TCL_HASH_TYPE TclHashObjKey(Tcl_HashTable *tablePtr, void *keyPtr);
MODULE_SCOPE int TclFullFinalizationRequested(void);
diff --git a/generic/tclObj.c b/generic/tclObj.c
index 776b034..0cd7839 100644
--- a/generic/tclObj.c
+++ b/generic/tclObj.c
@@ -4048,7 +4048,7 @@ TclFreeObjEntry(
*----------------------------------------------------------------------
*/
-unsigned int
+TCL_HASH_TYPE
TclHashObjKey(
Tcl_HashTable *tablePtr, /* Hash table. */
void *keyPtr) /* Key from which to compute hash value. */
@@ -4098,7 +4098,7 @@ TclHashObjKey(
result += (result << 3) + UCHAR(*++string);
}
}
- return result;
+ return (TCL_HASH_TYPE) result;
}
/*