[m-rev.] for review: change MR_bool from char to int

Fergus Henderson fjh at cs.mu.OZ.AU
Mon Sep 16 02:29:10 AEST 2002


Estimated hours taken: 1
Branches: main

Use `int' rather than `char' for MR_bool, since GCC has trouble
with tail call optimization for functions that return `char'
(see <http://gcc.gnu.org/ml/gcc/2002-09/msg00632.html>).

runtime/mercury_std.h:
	Change the definition of MR_bool to use int rather than char.
	Add a new typedef MR_small_bool, which is defined as char,
	for use when you need to optimize space.

runtime/mercury_grade.h:
	Increment binary compatibility version.
	This is needed due to the change in the size of MR_bool.

Workspace: /home/mars/fjh/ws-gcc-tailcall/mercury
Index: runtime/mercury_grade.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_grade.h,v
retrieving revision 1.41
diff -u -d -r1.41 mercury_grade.h
--- runtime/mercury_grade.h	1 Sep 2002 06:05:18 -0000	1.41
+++ runtime/mercury_grade.h	15 Sep 2002 16:10:09 -0000
@@ -52,7 +52,7 @@
 ** RTTI version number.
 */
 
-#define MR_GRADE_PART_0	v6_
+#define MR_GRADE_PART_0	v7_
 
 #ifdef MR_HIGHLEVEL_CODE
 
Index: runtime/mercury_std.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_std.h,v
retrieving revision 1.21
diff -u -d -r1.21 mercury_std.h
--- runtime/mercury_std.h	9 Aug 2002 05:26:50 -0000	1.21
+++ runtime/mercury_std.h	15 Sep 2002 16:20:18 -0000
@@ -27,7 +27,21 @@
   #include "safe-ctype.h"
 #endif
 
-typedef	char		MR_bool;
+/*
+** The boolean type, MR_bool, with constants MR_TRUE and MR_FALSE.
+**
+** We use `int' rather than `char' for MR_bool, because GCC has problems
+** optimizing tail calls for functions that return types smaller than `int'.
+** In most cases, `int' is more efficient anyway.
+** The only exception is that in some cases it is more important to optimize
+** space rather than time; in those (rare) cases, you can use `MR_small_bool'
+** instead of `MR_bool'.
+*/
+typedef	int		MR_bool;
+typedef	char		MR_small_bool;
+
+#define	MR_TRUE		1
+#define	MR_FALSE	0
 
 #define	MR_max(a, b)	((a) > (b) ? (a) : (b))
 #define	MR_min(a, b)	((a) < (b) ? (a) : (b))
@@ -55,9 +69,6 @@
 #define MR_strntest(s1, s2, n)	(strncmp(s1, s2, n))
 
 #define	MR_ungetchar(c)		ungetc(c, stdin)
-
-#define	MR_TRUE		1
-#define	MR_FALSE	0
 
 /*
 ** For speed, turn assertions off,

-- 
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