[m-rev.] fix MR_hash_string() type error for lcc
Fergus Henderson
fjh at cs.mu.OZ.AU
Mon Sep 30 12:46:36 AEST 2002
Estimated hours taken: 4
Branches: main, version-0_10_y
Fix a bug where the C code that we generated contained a type error
which showed up when using non-GCC C compilers.
runtime/mercury_string.h:
runtime/mercury_misc.c:
Change the argument type for MR_hash_string() from MR_Word to
MR_ConstString, to match the code that the MLDS back-end generates
(and common sense).
runtime/mercury_tabling.c:
compiler/llds.m:
Update to match the change to runtime/mercury_string.h.
Workspace: /home/ceres/fjh/mercury
Index: compiler/llds.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/llds.m,v
retrieving revision 1.287
diff -u -d -r1.287 llds.m
--- compiler/llds.m 30 Jul 2002 08:25:03 -0000 1.287
+++ compiler/llds.m 27 Sep 2002 06:45:34 -0000
@@ -1162,7 +1162,7 @@
llds__unop_arg_type(strip_tag, word).
llds__unop_arg_type(mkbody, word).
llds__unop_arg_type(unmkbody, word).
-llds__unop_arg_type(hash_string, word).
+llds__unop_arg_type(hash_string, string).
llds__unop_arg_type(bitwise_complement, integer).
llds__unop_arg_type(not, bool).
Index: runtime/mercury_misc.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_misc.c,v
retrieving revision 1.24
diff -u -d -r1.24 mercury_misc.c
--- runtime/mercury_misc.c 30 Jan 2002 14:51:07 -0000 1.24
+++ runtime/mercury_misc.c 27 Sep 2002 06:31:10 -0000
@@ -114,7 +114,7 @@
#undef MR_hash_string
int
-MR_hash_string(MR_Word s)
+MR_hash_string(MR_ConstString s)
{
MR_HASH_STRING_FUNC_BODY
}
Index: runtime/mercury_string.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_string.h,v
retrieving revision 1.26
diff -u -d -r1.26 mercury_string.h
--- runtime/mercury_string.h 6 Mar 2002 04:34:31 -0000 1.26
+++ runtime/mercury_string.h 27 Sep 2002 06:33:05 -0000
@@ -127,8 +127,8 @@
** Given a Mercury string `string', set `hash' to the hash value
** for that string. (`hash' must be an lvalue.)
**
-** This is an implementation detail used to implement hash_string().
-** It should not be used directly. Use hash_string() instead.
+** This is an implementation detail used to implement MR_hash_string().
+** It should not be used directly. Use MR_hash_string() instead.
**
** Note that hash_string is also defined in library/string.m.
** The definition here and the definition in string.m
@@ -136,7 +136,10 @@
*/
#define MR_do_hash_string(hash, s) \
{ \
- int len = 0; \
+ int len; \
+ MR_CHECK_EXPR_TYPE(hash, int); \
+ MR_CHECK_EXPR_TYPE(s, MR_ConstString); \
+ len = 0; \
hash = 0; \
while(((MR_ConstString)(s))[len]) { \
hash ^= (hash << 5); \
@@ -150,11 +153,12 @@
** MR_hash_string(s):
** Given a Mercury string `s', return a hash value for that string.
*/
-int MR_hash_string(MR_Word);
+int MR_hash_string(MR_ConstString);
#ifdef __GNUC__
#define MR_hash_string(s) \
({ int hash_string_result; \
+ MR_CHECK_EXPR_TYPE(s, MR_ConstString); \
MR_do_hash_string(hash_string_result, s); \
hash_string_result; \
})
Index: runtime/mercury_tabling.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_tabling.c,v
retrieving revision 1.52
diff -u -d -r1.52 mercury_tabling.c
--- runtime/mercury_tabling.c 1 Aug 2002 11:52:27 -0000 1.52
+++ runtime/mercury_tabling.c 27 Sep 2002 06:34:36 -0000
@@ -454,7 +454,7 @@
#define key_cast const char *
#define table_type MR_StringHashTableSlot
#define table_field string_slot_ptr
-#define hash(key) (MR_hash_string((MR_Word) key))
+#define hash(key) (MR_hash_string(key))
#define equal_keys(k1, k2) (MR_strtest(k1, k2) == 0)
MR_GENERIC_HASH_LOOKUP_OR_ADD
#undef key_format
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
The University of Melbourne | of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list