$NetBSD: patch-af,v 1.3 2012/09/14 23:45:27 asau Exp $

Fixes to support the various NetBSD mips ports.

--- src/mips/ffi.c.orig	2011-08-23 18:28:08.000000000 +0400
+++ src/mips/ffi.c	2012-02-19 20:04:17.000000000 +0400
@@ -33,12 +33,17 @@
 
 #ifdef __GNUC__
 #  if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3))
-#    define USE__BUILTIN___CLEAR_CACHE 1
+#    if !defined(__NetBSD__)
+#      define USE__BUILTIN___CLEAR_CACHE 1
+#    endif
 #  endif
 #endif
 
 #ifndef USE__BUILTIN___CLEAR_CACHE
-#  if defined(__OpenBSD__)
+#  if defined(__NetBSD__)
+#    include <mips/cachectl.h>
+#    define cacheflush _cacheflush
+#  elif defined(__OpenBSD__)
 #    include <mips64/sysarch.h>
 #  else
 #    include <sys/cachectl.h>
@@ -465,6 +470,7 @@
               ((cif->arg_types)[index]->type << (arg_reg * FFI_FLAG_BITS));
 	    arg_reg++;
 	    break;
+#ifdef __mips64
           case FFI_TYPE_LONGDOUBLE:
             /* Align it.  */
             arg_reg = ALIGN(arg_reg, 2);
@@ -483,7 +489,7 @@
 		arg_reg++;
 	      }
             break;
-
+#endif
 	  case FFI_TYPE_STRUCT:
             loc = arg_reg * FFI_SIZEOF_ARG;
 	    cif->flags += calc_n32_struct_flags(soft_float,
@@ -545,6 +551,7 @@
 	  cif->flags += cif->rtype->type << (FFI_FLAG_BITS * 8);
 	break;
 
+#ifdef __mips64
       case FFI_TYPE_LONGDOUBLE:
 	/* Long double is returned as if it were a struct containing
 	   two doubles.  */
@@ -561,6 +568,7 @@
 					      << (4 + (FFI_FLAG_BITS * 8));
 	  }
 	break;
+#endif
       default:
 	cif->flags += FFI_TYPE_INT << (FFI_FLAG_BITS * 8);
 	break;
