[m-rev.] diff: MR_hash_string{2,3} function defns

Peter Wang novalazy at gmail.com
Wed Feb 9 11:36:36 AEDT 2011


Branches: main, 11.01

runtime/mercury_string.c:
runtime/mercury_string.h:
        Add missing non-macro definitions of MR_hash_string2, MR_hash_string3.
        These are required for non-gcc compilers.

diff --git a/runtime/mercury_string.c b/runtime/mercury_string.c
index 3358b28..0f20219 100644
--- a/runtime/mercury_string.c
+++ b/runtime/mercury_string.c
@@ -97,16 +97,29 @@ MR_make_string(MR_Code *proclabel, const char *fmt, ...)
 }
 
 /*
-**  Note that MR_hash_string is actually defined as a macro in
+**  Note that MR_hash_string{,2,3} are actually defined as macros in
 **  mercury_string.h, if we're using GNU C.
-**  We define it here whether or not we're using gcc, so that users
+**  We define them here whether or not we're using gcc, so that users
 **  can easily switch between gcc and cc without rebuilding the libraries.
 */
 
 #undef MR_hash_string
+#undef MR_hash_string2
+#undef MR_hash_string3
 
 MR_Integer
 MR_hash_string(MR_ConstString s)
 {
     MR_HASH_STRING_FUNC_BODY
 }
+MR_Integer
+MR_hash_string2(MR_ConstString s)
+{
+    MR_HASH_STRING2_FUNC_BODY
+}
+
+MR_Integer
+MR_hash_string3(MR_ConstString s)
+{
+    MR_HASH_STRING3_FUNC_BODY
+}
diff --git a/runtime/mercury_string.h b/runtime/mercury_string.h
index 800bb6e..b12afbe 100644
--- a/runtime/mercury_string.h
+++ b/runtime/mercury_string.h
@@ -277,7 +277,7 @@ MR_Integer	MR_hash_string3(MR_ConstString);
 
 /*
 ** If we are not using gcc, the actual definitions of these functions
-** are runtime/mercury_misc.c; they use the macros below.
+** are runtime/mercury_string.c; they use the macros below.
 */
 
 #define MR_HASH_STRING_FUNC_BODY					\
@@ -287,9 +287,11 @@ MR_Integer	MR_hash_string3(MR_ConstString);
 #define MR_HASH_STRING2_FUNC_BODY					\
 	   MR_Integer hash_string_result;				\
 	   MR_do_hash_string2(hash_string_result, s);			\
+	   return hash_string_result;
 #define MR_HASH_STRING3_FUNC_BODY					\
 	   MR_Integer hash_string_result;				\
 	   MR_do_hash_string3(hash_string_result, s);			\
+	   return hash_string_result;
 
 /*
 ** A version of strcmp to which we can pass Mercury words

--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list