[m-rev.] for review: c_header_code in string.m

Zoltan Somogyi zs at cs.mu.OZ.AU
Thu Aug 8 13:12:57 AEST 2002


While I am sure the diff below is a step in the right direction (I got the
error in the log message during a test install, in grade asm_fast.gc.debug.tr),
it would also be nice if the compiler ensured that no c_header_code was
actually included twice. Since this code has been in string.m for almost two
years without leading to an error, it seems the compiler wasn't doing such
double inclusions until recently.

Zoltan.

library/string.m:
	Fix a bug. Move the definition of a function out of a pragma
	c_header_code, leaving just its declaration; move its definition
	to a pragma c_code. This avoids the compilation errors you could get
	if the c_header code was included in a file twice. It seems that this
	could actually happen, e.g. when compiling bool.c, with the duplicate
	definitions coming from bool.mh and string.opt.

cvs diff: Diffing .
Index: string.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/string.m,v
retrieving revision 1.175
diff -u -b -r1.175 string.m
--- string.m	2002/08/06 15:27:10	1.175
+++ string.m	2002/08/08 03:04:26
@@ -1999,13 +1999,24 @@
 	** register spilled' in grade asm_fast.gc.tr.debug
 	** if we write this inline.
 	*/
+	static void MR_set_char(MR_String str, MR_Integer ind, MR_Char ch);
+#else
+	#define MR_set_char(str, ind, ch) \\
+		((str)[ind] = (ch))
+#endif
+").
+
+:- pragma c_code("
+#ifdef MR_USE_GCC_GLOBAL_REGISTERS
+	/*
+	** GNU C version egcs-1.1.2 crashes with `fixed or forbidden
+	** register spilled' in grade asm_fast.gc.tr.debug
+	** if we write this inline.
+	*/
 	static void MR_set_char(MR_String str, MR_Integer ind, MR_Char ch)
 	{
 		str[ind] = ch;
 	}
-#else
-	#define MR_set_char(str, ind, ch) \\
-		((str)[ind] = (ch))
 #endif
 ").
 
--------------------------------------------------------------------------
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