# Taken from http://people.freebsd.org/~peter/ezm3-amd64/ezm3-port.diff.gz
#
# Ok, now get brutal.  These are HACKS and shouldn't be committed anywhere.
# The XVEC/XVECEXP stuff is to work around null pointer derefs on the amd64
# platform.  I dont know why it happens, but I suspect its because the m3cg
# plugin doesn't provide all the details and it blows up when doing the amd64
# funky calling conventions in a few places.
#
# Stop trapping signals to catch it when it segfaults more cleanly.
#
Index: language/modula3/m3compiler/m3cc/gcc/gcc/calls.c
--- language/modula3/m3compiler/m3cc/gcc/gcc/calls.c	Tue Feb 17 01:34:58 2004
+++ language/modula3/m3compiler/m3cc/gcc/gcc/calls.c	Mon Feb 16 21:15:16 2004
@@ -1343,5 +1343,5 @@
 	 by the PARALLEL, but also to pass it in the stack.  */
       if (args[i].reg && GET_CODE (args[i].reg) == PARALLEL
-	  && XEXP (XVECEXP (args[i].reg, 0, 0), 0) == 0)
+	  && XVECEXP (args[i].reg, 0, 0) && XEXP (XVECEXP (args[i].reg, 0, 0), 0) == 0)
 	args[i].pass_on_stack = 1;
 
Index: language/modula3/m3compiler/m3cc/gcc/gcc/expr.c
--- language/modula3/m3compiler/m3cc/gcc/gcc/expr.c	Tue Feb 17 01:06:14 2004
+++ language/modula3/m3compiler/m3cc/gcc/gcc/expr.c	Mon Feb 16 21:17:08 2004
@@ -1957,5 +1957,5 @@
   /* Check for a NULL entry, used to indicate that the parameter goes
      both on the stack and in registers.  */
-  if (XEXP (XVECEXP (dst, 0, 0), 0))
+  if (XVECEXP (dst, 0, 0) && XEXP (XVECEXP (dst, 0, 0), 0))
     start = 0;
   else
@@ -2067,5 +2067,5 @@
   /* Check for a NULL entry, used to indicate that the parameter goes
      both on the stack and in registers.  */
-  if (XEXP (XVECEXP (src, 0, 0), 0))
+  if (XVECEXP (src, 0, 0) && XEXP (XVECEXP (src, 0, 0), 0))
     start = 0;
   else
Index: language/modula3/m3compiler/m3cc/gcc/gcc/function.c
--- language/modula3/m3compiler/m3cc/gcc/gcc/function.c	Tue Feb 17 01:06:14 2004
+++ language/modula3/m3compiler/m3cc/gcc/gcc/function.c	Mon Feb 16 21:17:17 2004
@@ -4617,5 +4617,6 @@
       if (entry_parm == stack_parm
           || (GET_CODE (entry_parm) == PARALLEL
-              && XEXP (XVECEXP (entry_parm, 0, 0), 0) == NULL_RTX)
+              && XVECEXP (entry_parm, 0, 0) != NULL
+	      && XEXP (XVECEXP (entry_parm, 0, 0), 0) == NULL_RTX)
 #if defined (REG_PARM_STACK_SPACE) && ! defined (MAYBE_REG_PARM_STACK_SPACE)
 	  /* On some machines, even if a parm value arrives in a register
Index: language/modula3/m3compiler/m3cc/gcc/gcc/toplev.c
--- language/modula3/m3compiler/m3cc/gcc/gcc/toplev.c	Sat Jan 11 12:58:40 2003
+++ language/modula3/m3compiler/m3cc/gcc/gcc/toplev.c	Mon Feb 16 21:17:48 2004
@@ -4602,4 +4602,5 @@
   gcc_init_libintl ();
 
+#if 0
   /* Install handler for SIGFPE, which may be received while we do
      compile-time floating point arithmetic.  */
@@ -4621,4 +4622,5 @@
 #if defined SIGIOT && (!defined SIGABRT || SIGABRT != SIGIOT)
   signal (SIGIOT, crash_signal);
+#endif
 #endif
 
