diff: library/benchmarking.m work-around for gcc bug

Fergus Henderson fjh at cs.mu.oz.au
Wed Dec 10 16:34:06 AEDT 1997


library/benchmarking.m:
	Work around a gcc internal error on x86 machines:
	use memmove() and/or memcpy() rather than structure assignment.

Index: benchmarking.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/library/benchmarking.m,v
retrieving revision 1.6
diff -u -u -r1.6 benchmarking.m
--- benchmarking.m	1997/12/07 22:45:07	1.6
+++ benchmarking.m	1997/12/10 02:58:11
@@ -84,6 +84,7 @@
 :- pragma c_code("
 
 #include <stdio.h>
+#include <stdlib.h>
 #include ""mercury_prof_mem.h""
 #include ""mercury_heap_profile.h""
 
@@ -356,11 +357,21 @@
 	*/
 	if (slot < table_size) {
 		int i;
+#if 0
+/*
+** The following code is disabled because it causes gcc (2.7.2) internal
+** errors (``fixed or forbidden register spilled'') on x86 machines when
+** using gcc global register variables.
+*/
 		for (i = table_size - 1; i > slot; i--) {
 			table[i] = table[i - 1];
 		}
-
 		table[slot] = *new_entry;
+#else
+		memmove(&table[slot + 1], &table[slot],
+			(table_size - slot - 1) * sizeof(*table));
+		memcpy(&table[slot], new_entry, sizeof(*table));
+#endif
 
 		if (next_slot < table_size) {
 			next_slot++;

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



More information about the developers mailing list