$NetBSD: patch-af,v 1.4 2016/01/25 17:56:39 jperkin Exp $

Fixes to support the various NetBSD mips ports.

--- src/mips/ffi.c.orig	2014-11-08 12:47:24.000000000 +0000
+++ src/mips/ffi.c
@@ -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>
@@ -472,6 +477,7 @@ ffi_status ffi_prep_cif_machdep(ffi_cif 
               ((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);
@@ -490,7 +496,7 @@ ffi_status ffi_prep_cif_machdep(ffi_cif 
 		arg_reg++;
 	      }
             break;
-
+#endif
 	  case FFI_TYPE_STRUCT:
             loc = arg_reg * FFI_SIZEOF_ARG;
 	    cif->flags += calc_n32_struct_flags(soft_float,
@@ -552,6 +558,7 @@ ffi_status ffi_prep_cif_machdep(ffi_cif 
 	  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.  */
@@ -568,6 +575,7 @@ ffi_status ffi_prep_cif_machdep(ffi_cif 
 					      << (4 + (FFI_FLAG_BITS * 8));
 	  }
 	break;
+#endif
       default:
 	cif->flags += FFI_TYPE_INT << (FFI_FLAG_BITS * 8);
 	break;
