[m-dev.] diff: minor reorganization of code in runtime

Fergus Henderson fjh at cs.mu.OZ.AU
Mon May 8 23:57:04 AEST 2000


Estimated hours taken: 2

Reorganize some code in the runtime.

These changes were motivated in part by the desire to keep the runtime
for the MLDS back-end as well separated from the complications of the
current LLDS back-end as possible.

runtime/mercury_std.h:
runtime/mercury_misc.h:
	Move the definition of NO_RETURN from miscury_misc.h
	to mercury_std.h, since it's better to define all the
	compiler-dependent macros like this in one spot.

runtime/Mmakefile:
runtime/mercury_misc.h:
runtime/mercury_misc.c:
runtime/mercury_debug.h:
runtime/mercury_debug.c:
	Move the debugging stuff from mercury_misc.{h,c}
	to mercury_debug.{h,c}.  Note that mercury_debug.c
	is a new file.

runtime/mercury_misc.h:
runtime/mercury_misc.c:
runtime/mercury_reg_workarounds.h:
runtime/mercury_reg_workarounds.c:
	Move MR_memcpy() from mercury_misc.{h,c} to
	mercury_reg_workarounds.{h,c}.

runtime/mercury_stack_trace.c:
runtime/mercury_array_macros.h:
runtime/mercury_tabling.h:
	Add/remove/modify the #include directives
	to reflect the above-mentioned changes.

Workspace: /home/pgrad/fjh/ws/hg
Index: runtime/mercury_array_macros.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_array_macros.h,v
retrieving revision 1.6
diff -u -d -r1.6 mercury_array_macros.h
--- runtime/mercury_array_macros.h	2000/01/12 07:03:48	1.6
+++ runtime/mercury_array_macros.h	2000/05/08 12:15:57
@@ -12,7 +12,7 @@
 #ifndef MERCURY_ARRAY_MACROS_H
 #define MERCURY_ARRAY_MACROS_H
 
-#include	"mercury_misc.h"	/* for MR_memcpy */
+#include	"mercury_reg_workarounds.h"	/* for MR_memcpy */
 
 /*
 ** This macro defines a safe way to perform assignment between
cvs diff: runtime/mercury_debug.c is a new entry, no comparison available
Index: runtime/mercury_debug.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_debug.h,v
retrieving revision 1.7
diff -u -d -r1.7 mercury_debug.h
--- runtime/mercury_debug.h	1999/04/30 04:25:38	1.7
+++ runtime/mercury_debug.h	2000/05/08 12:38:44
@@ -9,6 +9,11 @@
 #ifndef MERCURY_DEBUG_H
 #define MERCURY_DEBUG_H
 
+#include "mercury_types.h"	/* for `Word' and `Code' */
+#include <stdio.h>		/* for `FILE' */
+
+/*---------------------------------------------------------------------------*/
+
 #ifdef DEBUG_ON
 	#define DEBUG(X) X
 #else
@@ -136,5 +141,52 @@
 
 #endif /* MR_LOWLEVEL_DEBUG */
 
-#endif /* not MERCURY_DEBUG_H */
+/*---------------------------------------------------------------------------*/
+
+#ifdef MR_LOWLEVEL_DEBUG
+extern	void	mkframe_msg(const char *);
+extern	void	succeed_msg(void);
+extern	void	succeeddiscard_msg(void);
+extern	void	fail_msg(void);
+extern	void	redo_msg(void);
+extern	void	call_msg(/* const */ Code *proc, /* const */ Code *succcont);
+extern	void	tailcall_msg(/* const */ Code *proc);
+extern	void	proceed_msg(void);
+extern	void	cr1_msg(Word val0, const Word *addr);
+extern	void	cr2_msg(Word val0, Word val1, const Word *addr);
+extern	void	incr_hp_debug_msg(Word val, const Word *addr);
+extern	void	incr_sp_msg(Word val, const Word *addr);
+extern	void	decr_sp_msg(Word val, const Word *addr);
+extern	void	push_msg(Word val, const Word *addr);
+extern	void	pop_msg(Word val, const Word *addr);
+#endif
+
+#ifdef MR_DEBUG_GOTOS
+extern	void	goto_msg(/* const */ Code *addr);
+extern	void	reg_msg(void);
+#endif
+
+#ifdef MR_LOWLEVEL_DEBUG
+extern	void	printint(Word n);
+extern	void	printstring(const char *s);
+extern	void	printheap(const Word *h);
+extern	void	dumpframe(/* const */ Word *);
+extern	void	dumpnondstack(void);
+extern	void	printlist(Word p);
+extern	void	printframe(const char *);
+extern	void	printregs(const char *msg);
+#endif
 
+extern	void	printdetstack(const Word *s);
+extern	void	MR_printdetstackptr(const Word *s);
+extern	void	MR_print_detstackptr(FILE *fp, const Word *s);
+extern	void	printnondstack(const Word *s);
+extern	void	MR_printnondstackptr(const Word *s);
+extern	void	MR_print_nondstackptr(FILE *fp, const Word *s);
+extern	void	MR_print_heapptr(FILE *fp, const Word *s);
+extern	void	MR_print_label(FILE *fp, /* const */ Code *w);
+extern	void	printlabel(/* const */ Code *w);
+
+/*---------------------------------------------------------------------------*/
+
+#endif /* not MERCURY_DEBUG_H */
Index: runtime/mercury_misc.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_misc.c,v
retrieving revision 1.21
diff -u -d -r1.21 mercury_misc.c
--- runtime/mercury_misc.c	2000/05/08 13:48:45	1.21
+++ runtime/mercury_misc.c	2000/05/08 13:50:28
@@ -1,427 +1,19 @@
 /*
-** Copyright (C) 1996-1999 The University of Melbourne.
+** Copyright (C) 1996-2000 The University of Melbourne.
 ** This file may only be copied under the terms of the GNU Library General
 ** Public License - see the file COPYING.LIB in the Mercury distribution.
 */
 
-#include	"mercury_imp.h"
-#include	"mercury_dlist.h"
-#include	"mercury_regs.h"
-#include	"mercury_trace_base.h"
-#include	"mercury_label.h"
+#include	"mercury_conf.h"
+#ifndef MR_HIGHLEVEL_CODE
+  #include	"mercury_imp.h"
+#endif
+#include	"mercury_string.h"
 #include	"mercury_misc.h"
 
 #include	<stdio.h>
 #include	<stdarg.h>
 
-/*--------------------------------------------------------------------*/
-
-static void	print_ordinary_regs(void);
-static void	MR_printdetslot_as_label(const Integer offset);
-
-/* debugging messages */
-
-#ifdef MR_LOWLEVEL_DEBUG
-
-void 
-mkframe_msg(const char *predname)
-{
-	restore_transient_registers();
-
-	printf("\nnew choice point for procedure %s\n", predname);
-	printf("new  fr: "); printnondstack(MR_curfr);
-	printf("prev fr: "); printnondstack(MR_prevfr_slot(MR_curfr));
-	printf("succ fr: "); printnondstack(MR_succfr_slot(MR_curfr));
-	printf("succ ip: "); printlabel(MR_succip_slot(MR_curfr));
-	printf("redo ip: "); printlabel(MR_redoip_slot(MR_curfr));
-
-	if (MR_detaildebug) {
-		dumpnondstack();
-	}
-}
-
-void 
-succeed_msg(void)
-{
-	restore_transient_registers();
-
-	printf("\nsucceeding from procedure\n");
-	printf("curr fr: "); printnondstack(MR_curfr);
-	printf("succ fr: "); printnondstack(MR_succfr_slot(MR_curfr));
-	printf("succ ip: "); printlabel(MR_succip_slot(MR_curfr));
-
-	if (MR_detaildebug) {
-		printregs("registers at success");
-	}
-}
-
-void 
-succeeddiscard_msg(void)
-{
-	restore_transient_registers();
-
-	printf("\nsucceeding from procedure\n");
-	printf("curr fr: "); printnondstack(MR_curfr);
-	printf("succ fr: "); printnondstack(MR_succfr_slot(MR_curfr));
-	printf("succ ip: "); printlabel(MR_succip_slot(MR_curfr));
-
-	if (MR_detaildebug) {
-		printregs("registers at success");
-	}
-}
-
-void 
-fail_msg(void)
-{
-	restore_transient_registers();
-
-	printf("\nfailing from procedure\n");
-	printf("curr fr: "); printnondstack(MR_curfr);
-	printf("fail fr: "); printnondstack(MR_prevfr_slot(MR_curfr));
-	printf("fail ip: "); printlabel(MR_redoip_slot(MR_prevfr_slot(MR_curfr)));
-}
-
-void 
-redo_msg(void)
-{
-	restore_transient_registers();
-
-	printf("\nredo from procedure\n");
-	printf("curr fr: "); printnondstack(MR_curfr);
-	printf("redo fr: "); printnondstack(MR_maxfr);
-	printf("redo ip: "); printlabel(MR_redoip_slot(MR_maxfr));
-}
-
-void 
-call_msg(/* const */ Code *proc, /* const */ Code *succcont)
-{
-	printf("\ncalling      "); printlabel(proc);
-	printf("continuation "); printlabel(succcont);
-	printregs("registers at call");
-}
-
-void 
-tailcall_msg(/* const */ Code *proc)
-{
-	restore_transient_registers();
-
-	printf("\ntail calling "); printlabel(proc);
-	printf("continuation "); printlabel(MR_succip);
-	printregs("registers at tailcall");
-}
-
-void 
-proceed_msg(void)
-{
-	printf("\nreturning from determinate procedure\n");
-	printregs("registers at proceed");
-}
-
-void 
-cr1_msg(Word val0, const Word *addr)
-{
-	printf("put value %9lx at ", (long) (Integer) val0);
-	printheap(addr);
-}
-
-void 
-cr2_msg(Word val0, Word val1, const Word *addr)
-{
-	printf("put values %9lx,%9lx at ",	
-		(long) (Integer) val0, (long) (Integer) val1);
-	printheap(addr);
-}
-
-void 
-incr_hp_debug_msg(Word val, const Word *addr)
-{
-#ifdef CONSERVATIVE_GC
-	printf("allocated %ld words at %p\n", (long) val, addr);
-#else
-	printf("increment hp by %ld from ", (long) (Integer) val);
-	printheap(addr);
-#endif
-}
-
-void 
-incr_sp_msg(Word val, const Word *addr)
-{
-	printf("increment sp by %ld from ", (long) (Integer) val);
-	printdetstack(addr);
-}
-
-void 
-decr_sp_msg(Word val, const Word *addr)
-{
-	printf("decrement sp by %ld from ", (long) (Integer) val);
-	printdetstack(addr);
-}
-
-void 
-push_msg(Word val, const Word *addr)
-{
-	printf("push value %9lx to ", (long) (Integer) val);
-	printdetstack(addr);
-}
-
-void 
-pop_msg(Word val, const Word *addr)
-{
-	printf("pop value %9lx from ", (long) (Integer) val);
-	printdetstack(addr);
-}
-
-#endif /* defined(MR_LOWLEVEL_DEBUG) */
-
-#ifdef MR_DEBUG_GOTOS
-
-void 
-goto_msg(/* const */ Code *addr)
-{
-	printf("\ngoto ");
-	printlabel(addr);
-}
-
-void 
-reg_msg(void)
-{
-	int	i;
-	Integer	x;
-
-	for(i=1; i<=8; i++) {
-		x = (Integer) get_reg(i);
-#ifndef CONSERVATIVE_GC
-		if ((Integer) MR_ENGINE(heap_zone)->min <= x
-				&& x < (Integer) MR_ENGINE(heap_zone)->top) {
-			x -= (Integer) MR_ENGINE(heap_zone)->min;
-		}
-#endif
-		printf("%8lx ", (long) x);
-	}
-	printf("\n");
-}
-
-#endif /* defined(MR_DEBUG_GOTOS) */
-
-/*--------------------------------------------------------------------*/
-
-#ifdef MR_LOWLEVEL_DEBUG
-
-/* debugging printing tools */
-
-void 
-printint(Word n)
-{
-	printf("int %ld\n", (long) (Integer) n);
-}
-
-void 
-printstring(const char *s)
-{
-	printf("string %p %s\n", (const void *) s, s);
-}
-
-void 
-printheap(const Word *h)
-{
-#ifndef CONSERVATIVE_GC
-	printf("ptr %p, offset %3ld words\n",
-		(const void *) h,
-		(long) (Integer) (h - MR_ENGINE(heap_zone)->min));
-#else
-	printf("ptr %p\n",
-		(const void *) h);
-#endif
-}
-
-void 
-dumpframe(/* const */ Word *fr)
-{
-	reg	int	i;
-
-	printf("frame at ptr %p, offset %3ld words\n",
-		(const void *) fr, 
-		(long) (Integer) (fr - MR_CONTEXT(nondetstack_zone)->min));
-	printf("\t succip    "); printlabel(MR_succip_slot(fr));
-	printf("\t redoip    "); printlabel(MR_redoip_slot(fr));
-	printf("\t succfr    "); printnondstack(MR_succfr_slot(fr));
-	printf("\t prevfr    "); printnondstack(MR_prevfr_slot(fr));
-
-	for (i = 1; &MR_based_framevar(fr,i) > MR_prevfr_slot(fr); i++) {
-		printf("\t framevar(%d)  %ld 0x%lx\n",
-			i, (long) (Integer) MR_based_framevar(fr,i),
-			(unsigned long) MR_based_framevar(fr,i));
-	}
-}
-
-void 
-dumpnondstack(void)
-{
-	reg	Word	*fr;
-
-	printf("\nnondstack dump\n");
-	for (fr = MR_maxfr; fr > MR_CONTEXT(nondetstack_zone)->min;
-			fr = MR_prevfr_slot(fr)) {
-		dumpframe(fr);
-	}
-}
-
-void 
-printframe(const char *msg)
-{
-	printf("\n%s\n", msg);
-	dumpframe(MR_curfr);
-
-	print_ordinary_regs();
-}
-
-void 
-printregs(const char *msg)
-{
-	restore_transient_registers();
-
-	printf("\n%s\n", msg);
-
-	printf("%-9s", "succip:");  printlabel(MR_succip);
-	printf("%-9s", "curfr:");   printnondstack(MR_curfr);
-	printf("%-9s", "maxfr:");   printnondstack(MR_maxfr);
-	printf("%-9s", "hp:");      printheap(MR_hp);
-	printf("%-9s", "sp:");      printdetstack(MR_sp);
-
-	print_ordinary_regs();
-}
-
-static void 
-print_ordinary_regs(void)
-{
-	int	i;
-	Integer	value;
-
-	for (i = 0; i < 8; i++) {
-		printf("r%d:      ", i + 1);
-		value = (Integer) get_reg(i+1);
-
-#ifndef	CONSERVATIVE_GC
-		if ((Integer) MR_ENGINE(heap_zone)->min <= value &&
-				value < (Integer) MR_ENGINE(heap_zone)->top) {
-			printf("(heap) ");
-		}
-#endif
-
-		printf("%ld\n", (long) value);
-	}
-
-	if (MR_sp >= &MR_CONTEXT(detstack_zone)->min[300]) {
-		for (i = 321; i < 335; i++) {
-			MR_printdetslot_as_label(i);
-		}
-	}
-}
-
-#endif /* defined(MR_DEBUG_GOTOS) */
-
-static void 
-MR_printdetslot_as_label(const Integer offset)
-{
-	MR_printdetstackptr(&MR_CONTEXT(detstack_zone)->min[offset]);
-	printf(" ");
-	printlabel((Code *) (MR_CONTEXT(detstack_zone)->min[offset]));
-}
-
-void 
-MR_printdetstackptr(const Word *s)
-{
-	MR_print_detstackptr(stdout, s);
-}
-
-void 
-MR_print_detstackptr(FILE *fp, const Word *s)
-{
-	fprintf(fp, "det %3ld (%p)",
-		(long) (Integer) (s - MR_CONTEXT(detstack_zone)->min),
-		(const void *) s);
-}
-
-void 
-printdetstack(const Word *s)
-{
-	printf("ptr %p, offset %3ld words\n",
-		(const void *) s,
-		(long) (Integer) (s - MR_CONTEXT(detstack_zone)->min));
-}
-
-void 
-MR_printnondstackptr(const Word *s)
-{
-	MR_print_nondstackptr(stdout, s);
-}
-
-void 
-MR_print_nondstackptr(FILE *fp, const Word *s)
-{
-	fprintf(fp, "non %3ld (%p)",
-		(long) (Integer) (s - MR_CONTEXT(nondetstack_zone)->min),
-		(const void *) s);
-}
-
-void 
-printnondstack(const Word *s)
-{
-	printf("ptr %p, offset %3ld words\n",
-		(const void *) s,
-		(long) (Integer) (s - MR_CONTEXT(nondetstack_zone)->min));
-}
-
-void 
-MR_print_heapptr(FILE *fp, const Word *s)
-{
-#ifdef	CONSERVATIVE_GC
-	fprintf(fp, "heap %ld (%p)",
-		(long) s, (const void *) s);
-#else
-	fprintf(fp, "heap %3ld (%p)",
-		(long) (Integer) (s - MR_ENGINE(heap_zone)->min),
-		(const void *) s);
-#endif
-}
-
-void 
-MR_print_label(FILE *fp, /* const */ Code *w)
-{
-	MR_Internal	*internal;
-
-	internal = MR_lookup_internal_by_addr(w);
-	if (internal != NULL) {
-		if (internal->i_name != NULL) {
-			fprintf(fp, "label %s (%p)", internal->i_name, w);
-		} else {
-			fprintf(fp, "label (%p)", w);
-		}
-	} else {
-#ifdef	MR_DEBUG_GOTOS
-		MR_Entry	*entry;
-
-		entry = MR_prev_entry_by_addr(w);
-		if (entry != NULL && entry->e_addr == w
-			&& entry->e_name != NULL)
-		{
-			fprintf(fp, "label %s (%p)", entry->e_name, w);
-		} else {
-			fprintf(fp, "label UNKNOWN (%p)", w);
-		}
-#else
-		fprintf(fp, "label UNKNOWN (%p)", w);
-#endif	/* not MR_DEBUG_GOTOS */
-	}
-}
-
-void 
-printlabel(/* const */ Code *w)
-{
-	MR_print_label(stdout, w);
-	fprintf(stdout, "\n");
-}
-
 void
 MR_warning(const char *fmt, ...)
 {
@@ -456,25 +48,13 @@
 	va_end(args);
 	fprintf(stderr, "\n");
 
+#ifndef MR_HIGHLEVEL_CODE
 	MR_trace_report(stderr);
+#endif
 
 	fflush(NULL);		/* flushes all stdio output streams */
 
 	exit(EXIT_FAILURE);
-}
-
-/*
-** See the header file for documentation on why we need this function.
-*/
-
-void
-MR_memcpy(void *dest, const void *src, size_t nbytes)
-{
-	char		*d = (char *) dest;
-	const char	*s = (const char *) src;
-
-	while (nbytes-- > 0)
-		*d++ = *s++;
 }
 
 /*
Index: runtime/mercury_misc.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_misc.h,v
retrieving revision 1.19
diff -u -d -r1.19 mercury_misc.h
--- runtime/mercury_misc.h	2000/05/08 13:48:45	1.19
+++ runtime/mercury_misc.h	2000/05/08 13:50:41
@@ -1,85 +1,21 @@
 /*
-** Copyright (C) 1995-1999 The University of Melbourne.
+** Copyright (C) 1995-2000 The University of Melbourne.
 ** This file may only be copied under the terms of the GNU Library General
 ** Public License - see the file COPYING.LIB in the Mercury distribution.
 */
 
 /*
-** mercury_misc.h -	debugging messages,
-**			MR_warning(),
-**			MR_fatal_error(),
-**			MR_memcpy
-**			MR_fd_zero
+** mercury_misc.h -	MR_warning(),
+**			MR_fatal_error()
 */
 
 #ifndef	MERCURY_MISC_H
 #define	MERCURY_MISC_H
 
-#include "mercury_types.h"	/* for `Code *' */
+#include "mercury_std.h"	/* for `NO_RETURN' */
 #include <stdlib.h>		/* for `size_t' */
-#include <stdio.h>		/* for `FILE' */
-
-#ifdef MR_LOWLEVEL_DEBUG
-extern	void	mkframe_msg(const char *);
-extern	void	succeed_msg(void);
-extern	void	succeeddiscard_msg(void);
-extern	void	fail_msg(void);
-extern	void	redo_msg(void);
-extern	void	call_msg(/* const */ Code *proc, /* const */ Code *succcont);
-extern	void	tailcall_msg(/* const */ Code *proc);
-extern	void	proceed_msg(void);
-extern	void	cr1_msg(Word val0, const Word *addr);
-extern	void	cr2_msg(Word val0, Word val1, const Word *addr);
-extern	void	incr_hp_debug_msg(Word val, const Word *addr);
-extern	void	incr_sp_msg(Word val, const Word *addr);
-extern	void	decr_sp_msg(Word val, const Word *addr);
-extern	void	push_msg(Word val, const Word *addr);
-extern	void	pop_msg(Word val, const Word *addr);
-#endif
-
-#ifdef MR_DEBUG_GOTOS
-extern	void	goto_msg(/* const */ Code *addr);
-extern	void	reg_msg(void);
-#endif
-
-#ifdef MR_LOWLEVEL_DEBUG
-extern	void	printint(Word n);
-extern	void	printstring(const char *s);
-extern	void	printheap(const Word *h);
-extern	void	dumpframe(/* const */ Word *);
-extern	void	dumpnondstack(void);
-extern	void	printlist(Word p);
-extern	void	printframe(const char *);
-extern	void	printregs(const char *msg);
-#endif
-
-extern	void	printdetstack(const Word *s);
-extern	void	MR_printdetstackptr(const Word *s);
-extern	void	MR_print_detstackptr(FILE *fp, const Word *s);
-extern	void	printnondstack(const Word *s);
-extern	void	MR_printnondstackptr(const Word *s);
-extern	void	MR_print_nondstackptr(FILE *fp, const Word *s);
-extern	void	MR_print_heapptr(FILE *fp, const Word *s);
-extern	void	MR_print_label(FILE *fp, /* const */ Code *w);
-extern	void	printlabel(/* const */ Code *w);
 
-#if __GNUC__
-	#define NO_RETURN __attribute__((noreturn))
-#else
-	#define NO_RETURN
-#endif
 extern	void	MR_warning(const char *msg, ...);
 extern	void	MR_fatal_error(const char *msg, ...) NO_RETURN;
-
-/*
-** We use our own version of memcpy because gcc recognises calls to the
-** standard memcpy (even in things that do not mention memcpy by name, e.g.
-** structure assignments) and generates inline code for them. Unfortunately
-** this causes gcc to abort because it tries to use a register that we have
-** already reserved.
-** XXX We should fix this eventually by using -fno-builtin since pragma
-** c_code may call the builtin functions.
-*/
-extern	void	MR_memcpy(void *dest, const void *src, size_t nbytes);
 
 #endif /* not MERCURY_MISC_H */
Index: runtime/mercury_reg_workarounds.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_reg_workarounds.c,v
retrieving revision 1.2
diff -u -d -r1.2 mercury_reg_workarounds.c
--- runtime/mercury_reg_workarounds.c	1998/12/20 01:13:36	1.2
+++ runtime/mercury_reg_workarounds.c	2000/05/08 12:33:34
@@ -12,6 +12,7 @@
 
 #include "mercury_conf.h"
 #include "mercury_reg_workarounds.h"
+#include <stdlib.h>
 
 #ifdef	MR_CAN_DO_PENDING_IO
 
@@ -26,3 +27,17 @@
 }
 
 #endif /* MR_CAN_DO_PENDING_IO */
+
+/*
+** See the header file for documentation on why we need this function.
+*/
+
+void
+MR_memcpy(void *dest, const void *src, size_t nbytes)
+{
+	char		*d = (char *) dest;
+	const char	*s = (const char *) src;
+
+	while (nbytes-- > 0)
+		*d++ = *s++;
+}
Index: runtime/mercury_reg_workarounds.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_reg_workarounds.h,v
retrieving revision 1.2
diff -u -d -r1.2 mercury_reg_workarounds.h
--- runtime/mercury_reg_workarounds.h	1999/11/25 09:09:44	1.2
+++ runtime/mercury_reg_workarounds.h	2000/05/08 12:03:36
@@ -5,16 +5,29 @@
 */
 
 /*
-** mercury_reg_workarounds.h -	MR_fd_zero
+** mercury_reg_workarounds.h -	MR_memcpy(), MR_fd_zero()
 */
 
 #ifndef	MERCURY_REG_WORKAROUNDS_H
 #define	MERCURY_REG_WORKAROUNDS_H
 
+#include "mercury_conf.h"
+
 #ifdef MR_CAN_DO_PENDING_IO
   #include <sys/types.h>		/* for fd_set */
   #include <sys/time.h>			/* for FD_ZERO() */
 #endif
+
+/*
+** We use our own version of memcpy because gcc recognises calls to the
+** standard memcpy (even in things that do not mention memcpy by name, e.g.
+** structure assignments) and generates inline code for them. Unfortunately
+** this causes gcc to abort because it tries to use a register that we have
+** already reserved.
+** XXX We should fix this eventually by using -fno-builtin since pragma
+** c_code may call the builtin functions.
+*/
+extern	void	MR_memcpy(void *dest, const void *src, size_t nbytes);
 
 /*
 ** We use a forwarding function to FD_ZERO because the Linux headers
Index: runtime/mercury_stack_trace.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_stack_trace.c,v
retrieving revision 1.33
diff -u -d -r1.33 mercury_stack_trace.c
--- runtime/mercury_stack_trace.c	1999/11/15 00:43:38	1.33
+++ runtime/mercury_stack_trace.c	2000/05/08 12:18:44
@@ -12,6 +12,7 @@
 
 #include "mercury_imp.h"
 #include "mercury_stack_trace.h"
+#include "mercury_debug.h"
 #include <stdio.h>
 
 static	void	MR_dump_stack_record_init(bool include_contexts);
Index: runtime/mercury_std.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_std.h,v
retrieving revision 1.12
diff -u -d -r1.12 mercury_std.h
--- runtime/mercury_std.h	2000/05/05 10:14:48	1.12
+++ runtime/mercury_std.h	2000/05/08 11:41:10
@@ -119,6 +119,16 @@
 
 /*---------------------------------------------------------------------------*/
 
+/* A macro for declaring functions that never return */
+
+#if __GNUC__
+  #define NO_RETURN __attribute__((noreturn))
+#else
+  #define NO_RETURN
+#endif
+
+/*---------------------------------------------------------------------------*/
+
 /*
 ** C preprocessor tricks.
 */
Index: runtime/mercury_tabling.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_tabling.h,v
retrieving revision 1.20
diff -u -d -r1.20 mercury_tabling.h
--- runtime/mercury_tabling.h	2000/03/24 10:27:51	1.20
+++ runtime/mercury_tabling.h	2000/05/08 12:17:12
@@ -18,6 +18,7 @@
 #include "mercury_types.h"
 #include "mercury_type_info.h"
 #include "mercury_float.h"
+#include "mercury_reg_workarounds.h"
 
 #ifndef CONSERVATIVE_GC
   #include "mercury_deep_copy.h"
Index: runtime/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/Mmakefile,v
retrieving revision 1.54
diff -u -d -r1.54 Mmakefile
--- runtime/Mmakefile	2000/05/05 10:14:50	1.54
+++ runtime/Mmakefile	2000/05/08 13:51:14
@@ -113,6 +113,7 @@
 			mercury_agc_debug.c	\
 			mercury_bootstrap.c	\
 			mercury_context.c	\
+			mercury_debug.c		\
 			mercury_deep_copy.c	\
 			mercury_dlist.c		\
 			mercury_dummy.c		\

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