[m-dev.] diff: work around lcc bug

Fergus Henderson fjh at cs.mu.OZ.AU
Sat Feb 17 18:59:54 AEDT 2001


This is a pretty horrible hack, but I think it's worth it,
since this is needed to get things to work with lcc,
and testing with lcc has revealed quite a few real bugs and
portability problems in the Mercury implementation.

Estimated hours taken: 10

runtime/mercury_wrapper.c:
	Add a work-around for an lcc 4.1 bug which caused lcc to
	miscompile this file.

Workspace: /mnt/venus/home/venus/public/test_mercury_venus/mercury
Index: runtime/mercury_wrapper.c
===================================================================
RCS file: /home/staff/zs/imp/mercury/runtime/mercury_wrapper.c,v
retrieving revision 1.85
diff -u -d -r1.85 mercury_wrapper.c
--- runtime/mercury_wrapper.c	2001/01/18 01:19:09	1.85
+++ runtime/mercury_wrapper.c	2001/02/17 07:56:49
@@ -362,7 +362,17 @@
 	(*MR_library_initializer)();
 
 #ifndef MR_HIGHLEVEL_CODE
+  #ifndef __LCC__
 	MR_save_context(&(MR_ENGINE(context)));
+  #else
+	{
+	  /* XXX Work around lcc bug -- lcc 4.1 miscompiles the original code */
+	  size_t offset = offsetof(MercuryEngine, context);
+	  char *tmp = (char *) MR_cur_engine();
+	  MR_Context *eng_context = (tmp += offset, (MR_Context *) tmp);
+	  MR_save_context(eng_context);
+	}
+  #endif
 #endif
 
 	/*

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
                                    |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- 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