[m-dev.] for review: Linux-m68k port.

Tyson Dowd trd at cs.mu.OZ.AU
Thu Oct 1 17:11:39 AEST 1998


I have fixed the problems in this diff, and fixed a few problems
that Roman pointed out in my diff (the use of "bsd" to describe
the 3 argument signal handler is not really accurate).

An important thing is that the configure.in script still needs to
handle getting the program counter at signal time.  I haven't
done this yet, as testing it is difficult and the only thing
that uses it is the accurate GC (and it would require a lot
more modifications, and it is no release critical).

The important thing to remember is that the m68k uses
context.sc_pc to get the program counter (the i386 uses context.eip).

Here is a relative diff and new log message:

Estimated hours taken: 20

Port to Linux-m68k.  A lot of this work was done by Roman Hodek,
<Roman.Hodek at informatik.uni-erlangen.de>.

README.Linux-m68k:
	Mention that we have a port to the 68k.

configure.in:
	Add a test for two different sorts of signal handlers
	  void handler(int signum, struct sigcontext_struct context)
	and
	  void handler(int signum, int code, struct sigcontext_struct context)
	Set HAVE_SIGCONTEXT_STRUCT_2ARG or HAVE_SIGCONTEXT_STRUCT_3ARG 
	appropriately.

	Add support for shared libraries on the m68k as they should
	work.

	Make "working struct sigcontext" tests use MR_GET_FAULT_ADDR.

boehm_gc/config.h:
	Add some definitions for the m68k.

boehm_gc/os_dep.c:
	Get fault addresses using m68k specific code.

runtime/mercury_conf.h.in:
	Add new configuration definitions HAVE_SIGCONTEXT_STRUCT_2ARG,
	and HAVE_SIGCONTEXT_STRUCT_3ARG.

runtime/mercury_faultaddr.h:
	Add MR_GET_FAULT_ADDR.

runtime/mercury_goto.h:
	Add support for non-local gotos with Linux-68k.

runtime/mercury_memory_handlers.c:
	Handle 2 or 3 argument signal handlers.

--- configure.in.old	Thu Oct  1 16:49:22 1998
+++ configure.in	Thu Oct  1 15:32:00 1998
@@ -375,9 +375,9 @@
 #
 # check the basics of sigcontext_struct
 #
-AC_MSG_CHECKING(for working \`sigcontext_struct')
-AC_CACHE_VAL(mercury_cv_sigcontext_struct_nonbsd,
-mercury_cv_sigcontext_struct_nonbsd=no
+AC_MSG_CHECKING(for working \`sigcontext_struct' in second arg)
+AC_CACHE_VAL(mercury_cv_sigcontext_struct_2arg,
+mercury_cv_sigcontext_struct_2arg=no
 AC_TRY_RUN([
 /* see runtime/memory.c for documentation of this code */
 
@@ -416,16 +416,17 @@
 	} else {
 		exit(1);
 	}
-}], [mercury_cv_sigcontext_struct_nonbsd=yes], [true], [true]))
-AC_MSG_RESULT($mercury_cv_sigcontext_struct_nonbsd)
+}], [mercury_cv_sigcontext_struct_2arg=yes], [true], [true]))
+AC_MSG_RESULT($mercury_cv_sigcontext_struct_2arg)
 
-if test $mercury_cv_sigcontext_struct_nonbsd = no; then
+if test $mercury_cv_sigcontext_struct_2arg = no; then
 	#
-	# check for a BSD style sigcontext_struct
+	# check for a sigcontext_struct in the third argument of
+	# the signal handler (Linux-68k has this).
 	#
-	AC_MSG_CHECKING(for BSD-ish \`sigcontext_struct')
-	AC_CACHE_VAL(mercury_cv_sigcontext_struct_bsd,
-	mercury_cv_sigcontext_struct_bsd=no
+	AC_MSG_CHECKING(for working \`sigcontext_struct' in third arg)
+	AC_CACHE_VAL(mercury_cv_sigcontext_struct_3arg,
+	mercury_cv_sigcontext_struct_3arg=no
 
 	/* see runtime/mercury_memory.c for documentation of this code */
 
@@ -467,19 +468,19 @@
 		} else {
 			exit(1);
 		}
-	}], [mercury_cv_sigcontext_struct_bsd=yes], [true], [true]))
+	}], [mercury_cv_sigcontext_struct_3arg=yes], [true], [true]))
 else
-	mercury_cv_sigcontext_struct_bsd=no
+	mercury_cv_sigcontext_struct_3arg=no
 fi
 
-if test $mercury_cv_sigcontext_struct_nonbsd = yes; then
+if test $mercury_cv_sigcontext_struct_2arg = yes; then
 	mercury_cv_sigcontext_struct=yes
-	AC_DEFINE(HAVE_SIGCONTEXT_STRUCT_NONBSD)
+	AC_DEFINE(HAVE_SIGCONTEXT_STRUCT_2ARG)
 fi
 
-if test $mercury_cv_sigcontext_struct_bsd = yes; then
+if test $mercury_cv_sigcontext_struct_3arg = yes; then
 	mercury_cv_sigcontext_struct=yes
-	AC_DEFINE(HAVE_SIGCONTEXT_STRUCT_BSD)
+	AC_DEFINE(HAVE_SIGCONTEXT_STRUCT_3ARG)
 fi
 
 if test $mercury_cv_sigcontext_struct = yes; then
@@ -509,7 +510,7 @@
 
 	#include <stdio.h>
 
-	#if HAVE_SIGCONTEXT_STRUCT_BSD
+	#if HAVE_SIGCONTEXT_STRUCT_3ARG
 	extern void handler(int signum, int code, 
 			struct sigcontext_struct context);
 	#else
@@ -527,7 +528,7 @@
 		exit(1);
 	}
 
-	#if HAVE_SIGCONTEXT_STRUCT_BSD
+	#if HAVE_SIGCONTEXT_STRUCT_3ARG
 	void handler(int signum, int code, struct sigcontext_struct context) {
 	#else
 	void handler(int signum, struct sigcontext_struct context) {
diff -u runtime.old/.cvsignore runtime/.cvsignore
--- runtime.old/.cvsignore	Thu Oct  1 14:24:08 1998
+++ runtime/.cvsignore	Fri Nov 21 17:33:48 1997
@@ -1,2 +1,2 @@
diff -u runtime.old/mercury_conf.h.in runtime/mercury_conf.h.in
--- runtime.old/mercury_conf.h.in	Thu Oct  1 16:43:43 1998
+++ runtime/mercury_conf.h.in	Thu Oct  1 15:32:46 1998
@@ -125,11 +125,11 @@
 **	HAVE_SIGCONTEXT_STRUCT	defined iff normal signal handlers are given
 **				sigcontext_struct arguments that we can use to
 **				figure out the fault address for SIGSEGVs.
-**	HAVE_SIGCONTEXT_STRUCT_BSD
+**	HAVE_SIGCONTEXT_STRUCT_3ARG
 **				defined iff signal handlers have three
 **				parameters, the third being the
 **				sigcontext struct.
-**	HAVE_SIGCONTEXT_STRUCT_NONBSD
+**	HAVE_SIGCONTEXT_STRUCT_2ARG
 **				defined iff signal handlers have two
 **				parameters, the second being the
 **				sigcontext struct. 
@@ -137,8 +137,8 @@
 #undef	HAVE_SIGINFO
 #undef	HAVE_SIGINFO_T
 #undef	HAVE_SIGCONTEXT_STRUCT
-#undef	HAVE_SIGCONTEXT_STRUCT_BSD
-#undef	HAVE_SIGCONTEXT_STRUCT_NONBSD
+#undef	HAVE_SIGCONTEXT_STRUCT_3ARG
+#undef	HAVE_SIGCONTEXT_STRUCT_2ARG
 
 /*
 ** For debugging purposes, if we get a fatal signal, we print out the
diff -u runtime.old/mercury_goto.h runtime/mercury_goto.h
--- runtime.old/mercury_goto.h	Thu Oct  1 16:43:43 1998
+++ runtime/mercury_goto.h	Wed Sep 30 19:29:58 1998
@@ -137,10 +137,17 @@
   **
   ** I know this is awful.  It wasn't _my_ idea to use non-local gotos ;-)
   */
-  #define ASM_JUMP(label)				\
+  #if defined(__i386__)
+    #define ASM_JUMP(label)				\
   	{ register int stack_pointer __asm__("esp");	\
   	__asm__("" : : "g"(stack_pointer)); }		\
   	goto *(label)
+  #elif defined(__mc68000__)
+    #define ASM_JUMP(label)				\
+  	{ register int stack_pointer __asm__("sp");	\
+  	__asm__("" : : "g"(stack_pointer)); }		\
+  	goto *(label)
+  #endif
 
   /*
   ** That hack above needs to be done for all non-local jumps,
diff -u runtime.old/mercury_memory_handlers.c runtime/mercury_memory_handlers.c
--- runtime.old/mercury_memory_handlers.c	Thu Oct  1 16:43:43 1998
+++ runtime/mercury_memory_handlers.c	Thu Oct  1 15:33:28 1998
@@ -74,8 +74,8 @@
 
 #ifdef HAVE_SIGINFO
   #if defined(HAVE_SIGCONTEXT_STRUCT)
-    #if defined(HAVE_SIGCONTEXT_STRUCT_BSD)
-      static	void	complex_sighandler_bsd(int, int, 
+    #if defined(HAVE_SIGCONTEXT_STRUCT_3ARG)
+      static	void	complex_sighandler_3arg(int, int, 
 		      struct sigcontext_struct);
     #else
       static	void	complex_sighandler(int, struct sigcontext_struct);
@@ -93,9 +93,9 @@
 
 #ifdef HAVE_SIGINFO
   #if defined(HAVE_SIGCONTEXT_STRUCT)
-    #if defined(HAVE_SIGCONTEXT_STRUCT_BSD)
-      #define     bus_handler	complex_sighandler_bsd
-      #define     segv_handler	complex_sighandler_bsd
+    #if defined(HAVE_SIGCONTEXT_STRUCT_3ARG)
+      #define     bus_handler	complex_sighandler_3arg
+      #define     segv_handler	complex_sighandler_3arg
     #else
       #define     bus_handler	complex_sighandler
       #define     segv_handler	complex_sighandler
@@ -317,9 +317,10 @@
 }
 
 #if defined(HAVE_SIGCONTEXT_STRUCT)
-  #if defined(HAVE_SIGCONTEXT_STRUCT_BSD)
+  #if defined(HAVE_SIGCONTEXT_STRUCT_3ARG)
     static void
-    complex_sighandler(int sig, int code, struct sigcontext_struct sigcontext)
+    complex_sighandler_3arg(int sig, int code,
+		    struct sigcontext_struct sigcontext)
   #else
     static void
     complex_sighandler(int sig, struct sigcontext_struct sigcontext)




More information about the developers mailing list