[m-dev.] diff: conditional fix for gcc 2.95 on gcc version number

Fergus Henderson fjh at cs.mu.OZ.AU
Sat Oct 23 16:41:29 AEST 1999


Estimated hours taken: 0.25

runtime/mercury_goto.h:
	Change it so that the code added by my recent fix for gcc 2.95
	is only included for gcc versions > gcc 2.91 (egcs 1.1).
	The reason is that my recent fix seems to have had a significant
	effect on code size.

Workspace: /home/mercury0/fjh/mercury
Index: runtime/mercury_goto.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_goto.h,v
retrieving revision 1.20
diff -u -d -r1.20 mercury_goto.h
--- mercury_goto.h	1999/10/20 14:35:27	1.20
+++ mercury_goto.h	1999/10/23 06:32:43
@@ -485,14 +485,20 @@
   ** cannot be live, when in fact they really are).
   ** That is what the two occurrences of the PRETEND_ADDRESS_IS_USED
   ** macro are for.
-  ** We also need to include at least one `goto *' with an unknown
+  ** For versions of gcc later than egcs 1.1.2 (which corresponds to gcc 2.91,
+  ** according to __GNUC_MINOR__), and in particular for gcc 2.95,
+  ** we also need to include at least one `goto *' with an unknown
   ** target, so that gcc doesn't optimize away all the labels
   ** because it thinks they are unreachable.
   ** The dummy_identify_function() function just returns the address
   ** passed to it, so `goto *dummy_identify_function(&& dummy_label); dummy_label:'
   ** is the same as `goto dummy_label; label:', i.e. it just falls through.
+  ** For older versions of gcc, we don't do this, since it adds significantly
+  ** to the code size.
   */
-  #define BEGIN_MODULE(module_name)					\
+  #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 91)
+    /* gcc version > egcs 1.1.2 */
+    #define BEGIN_MODULE(module_name)					\
 	MR_MODULE_STATIC_OR_EXTERN void module_name(void);		\
 	MR_MODULE_STATIC_OR_EXTERN void module_name(void) {		\
 		PRETEND_ADDRESS_IS_USED(module_name);			\
@@ -501,9 +507,18 @@
 			&&paste(module_name,_dummy_label));		\
 		paste(module_name,_dummy_label):			\
 		{
-  /* initialization code for module goes here */
+  #else /* gcc version <= egcs 1.1.2 */
+    #define BEGIN_MODULE(module_name)					\
+	MR_MODULE_STATIC_OR_EXTERN void module_name(void);		\
+	MR_MODULE_STATIC_OR_EXTERN void module_name(void) {		\
+		PRETEND_ADDRESS_IS_USED(module_name);			\
+		PRETEND_ADDRESS_IS_USED(&&paste(module_name,_dummy_label)); \
+		paste(module_name,_dummy_label):			\
+		{
+  #endif /* gcc version <= egcs 1.1.2 */
+  /* initialization code for module goes between BEGIN_MODULE and BEGIN_CODE */
   #define BEGIN_CODE } return; {
-  /* body of module goes here */
+  /* body of module goes between BEGIN_CODE and END_MODULE */
   #define END_MODULE } }
 
 

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3        |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list