This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PING] libffi reorg


- first, the patch does not cleanly apply on mips file.


Well, the file's being deleted so no big deal :-) Here's an updated one against current CVS.

The UINT32 and friends where defined before in ffi.h.

They were meant to be private. I forgot I had patched it on my system. Can you test the libjava patch I'm posting to gcc-patches?


Thanks for assisting me. Regards,

Paolo
2003-09-19  Paolo Bonzini  <bonzini@gnu.org>
            Richard Henderson  <rth@redhat.com>

        Avoid that ffi.h includes fficonfig.h.

        * Makefile.am (EXTRA_DIST): Include ffitarget.h files
	(TARGET_SRC_MIPS_GCC): Renamed to TARGET_SRC_MIPS_IRIX.
	(TARGET_SRC_MIPS_SGI): Removed.
	(MIPS_GCC): Renamed to TARGET_SRC_MIPS_IRIX.
	(MIPS_SGI): Removed.
        (CLEANFILES): Removed.
        (mostlyclean-am, clean-am, mostlyclean-sub, clean-sub): New
        targets.
        * acconfig.h: Removed.
        * configure.in: Compute sizeofs only for double and long double.
        Use them to define and subst HAVE_LONG_DOUBLE.  Include comments
        into AC_DEFINE instead of using acconfig.h.  Create
        include/ffitarget.h instead of include/fficonfig.h.  Rename
        MIPS_GCC to MIPS_IRIX, drop MIPS_SGI since we are in gcc's tree.
        AC_DEFINE EH_FRAME_FLAGS.
        * include/Makefile.am (DISTCLEANFILES): New automake macro.
        (hack_DATA): Add ffitarget.h.
        * include/ffi.h.in: Remove all system specific definitions.
        Declare raw API even if it is not installed, why bother?
	Use limits.h instead of SIZEOF_* to define ffi_type_*.  Do
	not define EH_FRAME_FLAGS, it is in fficonfig.h now.  Include
	ffitarget.h instead of fficonfig.h.  Remove ALIGN macro.
	(UINT_ARG, INT_ARG): Removed, use ffi_arg and ffi_sarg instead.
	* include/ffi_common.h (bool): Do not define.
	(ffi_assert): Accept failed assertion.
	(ffi_type_test): Return void and accept file/line.
	(FFI_ASSERT): Pass stringized failed assertion.
	(FFI_ASSERT_AT): New macro.
	(FFI_ASSERT_VALID_TYPE): New macro.
	(UINT8, SINT8, UINT16, SINT16, UINT32, SINT32,
	UINT64, SINT64): Define here with gcc's __attribute__ macro
	instead of in ffi.h
	(FLOAT32, ALIGN): Define here instead of in ffi.h
	* include/ffi-mips.h: Removed.  Its content moved to
	src/mips/ffitarget.h after separating assembly and C sections.
	* src/alpha/ffi.c, src/alpha/ffi.c, src/java_raw_api.c
	src/prep_cif.c, src/raw_api.c, src/ia64/ffi.c,
	src/mips/ffi.c, src/mips/n32.S, src/mips/o32.S,
	src/mips/ffitarget.h, src/sparc/ffi.c, src/x86/ffi64.c:
	SIZEOF_ARG -> FFI_SIZEOF_ARG.
	* src/ia64/ffi.c: Include stdbool.h (provided by GCC 2.95+).
	* src/debug.c (ffi_assert): Accept stringized failed assertion.
	(ffi_type_test): Rewritten.
	* src/prep-cif.c (initialize_aggregate, ffi_prep_cif): Call
	FFI_ASSERT_VALID_TYPE.
        * src/alpha/ffitarget.h, src/arm/ffitarget.h,
        src/ia64/ffitarget.h, src/m68k/ffitarget.h,
        src/mips/ffitarget.h, src/powerpc/ffitarget.h,
        src/s390/ffitarget.h, src/sh/ffitarget.h,
        src/sh64/ffitarget.h, src/sparc/ffitarget.h,
        src/x86/ffitarget.h: New files.
        * src/alpha/osf.S, src/arm/sysv.S, src/ia64/unix.S,
        src/m68k/sysv.S, src/mips/n32.S, src/mips/o32.S,
	src/powerpc/aix.S, src/powerpc/darwin.S, 
        src/powerpc/ffi_darwin.c, src/powerpc/linux64.S,
        src/powerpc/linux64_closure.S, src/powerpc/ppc_closure.S,
        src/powerpc/sysv.S, src/s390/sysv.S, src/sh/sysv.S,
	src/sh64/sysv.S, src/sparc/v8.S, src/sparc/v9.S,
        src/x86/sysv.S, src/x86/unix64.S, src/x86/win32.S:
        include fficonfig.h


diff -rNU3 libffi-orig/LICENSE libffi/LICENSE
--- libffi-orig/LICENSE	1999-08-08 15:27:19.000000000 +0200
+++ libffi/LICENSE	2003-10-14 14:23:14.000000000 +0200
@@ -1,4 +1,4 @@
-libffi - Copyright (c) 1996-1999  Cygnus Solutions
+libffi - Copyright (c) 1996-2003  Red Hat, Inc.
 
 Permission is hereby granted, free of charge, to any person obtaining
 a copy of this software and associated documentation files (the
diff -rNU3 libffi-orig/Makefile.am libffi/Makefile.am
--- libffi-orig/Makefile.am	2003-09-04 19:21:51.000000000 +0200
+++ libffi/Makefile.am	2003-10-14 14:23:14.000000000 +0200
@@ -4,24 +4,26 @@
 
 SUBDIRS = include testsuite
 
+EXTRA_DIST = LICENSE ChangeLog.v1 \
+	src/alpha/ffi.c src/alpha/osf.S src/alpha/ffitarget.h \
+	src/arm/ffi.c src/arm/sysv.S src/arm/ffitarget.h \
+	src/mips/ffi.c src/mips/n32.S src/mips/o32.S \
+	src/mips/ffitarget.h \
+	src/m68k/ffi.c src/m68k/sysv.S src/m68k/ffitarget.h \
+	src/powerpc/ffi.c src/powerpc/sysv.S \
+	src/powerpc/linux64.S src/powerpc/linux64_closure.S \
+	src/powerpc/ppc_closure.S src/powerpc/asm.h \
+	src/powerpc/aix.S src/powerpc/darwin.S \
+	src/powerpc/aix_closure.S src/powerpc/darwin_closure.S \
+	src/powerpc/ffi_darwin.c src/powerpc/ffitarget.h \
+	src/s390/ffi.c src/s390/sysv.S src/s390/ffitarget.h \
+	src/sh/ffi.c src/sh/sysv.S src/sh/ffitarget.h \
+	src/sh64/ffi.c src/sh64/sysv.S src/sh64/ffitarget.h \
+	src/sparc/v8.S src/sparc/v9.S src/sparc/ffitarget.h \
+	src/sparc/ffi.c \
+	src/x86/ffi.c src/x86/sysv.S src/x86/win32.S \
+	src/x86/ffi64.c src/x86/unix64.S src/x86/ffitarget.h
 
-EXTRA_DIST = LICENSE ChangeLog.v1 src/mips/ffi.c src/mips/n32.S \
-		src/mips/n32.s src/mips/o32.S src/mips/o32.s \
-		src/sparc/ffi.c src/sparc/v8.S src/sparc/v9.S \
-		src/x86/ffi.c src/x86/sysv.S src/x86/win32.S \
-		src/x86/ffi64.c src/x86/unix64.S \
-		src/alpha/ffi.c src/alpha/osf.S \
-		src/m68k/ffi.c src/m68k/sysv.S \
-		src/powerpc/ffi.c src/powerpc/sysv.S \
-		src/powerpc/linux64.S src/powerpc/linux64_closure.S \
-		src/powerpc/ppc_closure.S src/powerpc/asm.h \
-		src/powerpc/ffi_darwin.c \
-		src/powerpc/darwin.S src/powerpc/aix.S \
-		src/powerpc/darwin_closure.S src/powerpc/aix_closure.S \
-		src/arm/ffi.c src/arm/sysv.S \
-		src/s390/ffi.c src/s390/sysv.S \
-		src/sh/ffi.c src/sh/sysv.S \
-		src/sh64/ffi.c src/sh64/sysv.S
 
 VPATH = @srcdir@:@srcdir@/src:@srcdir@/src/@TARGETDIR@
 
@@ -85,9 +87,8 @@
 
 
 
-TARGET_SRC_MIPS_GCC = src/mips/ffi.c src/mips/o32.S src/mips/n32.S
+TARGET_SRC_MIPS_IRIX = src/mips/ffi.c src/mips/o32.S src/mips/n32.S
 TARGET_SRC_MIPS_LINUX = src/mips/ffi.c src/mips/o32.S
-TARGET_SRC_MIPS_SGI = src/mips/ffi.c src/mips/o32.s src/mips/n32.s
 TARGET_SRC_X86 = src/x86/ffi.c src/x86/sysv.S
 TARGET_SRC_X86_WIN32 = src/x86/ffi.c src/x86/win32.S
 TARGET_SRC_SPARC = src/sparc/ffi.c src/sparc/v8.S src/sparc/v9.S
@@ -107,18 +108,14 @@
 ## Work around automake deficiency
 libffi_la_common_SOURCES = src/debug.c src/prep_cif.c src/types.c \
 		src/raw_api.c src/java_raw_api.c
-if MIPS_GCC
-libffi_la_SOURCES = $(libffi_la_common_SOURCES) $(TARGET_SRC_MIPS_GCC)
-libffi_convenience_la_SOURCES = $(libffi_la_common_SOURCES) $(TARGET_SRC_MIPS_GCC)
+if MIPS_IRIX
+libffi_la_SOURCES = $(libffi_la_common_SOURCES) $(TARGET_SRC_MIPS_IRIX)
+libffi_convenience_la_SOURCES = $(libffi_la_common_SOURCES) $(TARGET_SRC_MIPS_IRIX)
 endif
 if MIPS_LINUX
 libffi_la_SOURCES = $(libffi_la_common_SOURCES) $(TARGET_SRC_MIPS_LINUX)
 libffi_convenience_la_SOURCES = $(libffi_la_common_SOURCES) $(TARGET_SRC_MIPS_LINUX)
 endif
-if MIPS_SGI
-libffi_la_SOURCES = $(libffi_la_common_SOURCES) $(TARGET_SRC_MIPS_SGI)
-libffi_convenience_la_SOURCES = $(libffi_la_common_SOURCES) $(TARGET_SRC_MIPS_SGI)
-endif
 if X86
 libffi_la_SOURCES = $(libffi_la_common_SOURCES) $(TARGET_SRC_X86)
 libffi_convenience_la_SOURCES = $(libffi_la_common_SOURCES) $(TARGET_SRC_X86)
@@ -180,7 +177,7 @@
 
 libffi_la_LDFLAGS = -release $(VERSION) 
 
-INCLUDES = -I$(top_srcdir)/include -Iinclude -I$(top_srcdir)/src
+INCLUDES = -I. -I$(top_srcdir)/include -Iinclude -I$(top_srcdir)/src
 
 # Override these rules so that object files get put in the correct 
 # subdirectories. 
@@ -229,7 +226,15 @@
 
 ## ################################################################
 
-CLEANFILES = $(libffi_convenience_la_OBJECTS)		\
-	     $(libffi_la_OBJECTS) 			\
-	     $(libffi_convenience_la_OBJECTS:.lo=.o)	\
-	     $(libffi_la_OBJECTS:.lo=.o)
+# Our hacked automake doesn't clean subdirectories properly.
+mostlyclean-am: mostlyclean-sub
+mostlyclean-sub:
+	-rm -f src/*.o src/*.lo
+	-rm -f src/@TARGETDIR@/*.o src/@TARGETDIR@/*.lo
+
+clean-am: clean-sub
+clean-sub:
+	-rm -rf src/.libs src/_libs
+	-rm -rf src/@TARGETDIR@/.libs src/@TARGETDIR@/_libs
+
+
diff -rNU3 libffi-orig/acconfig.h libffi/acconfig.h
--- libffi-orig/acconfig.h	1999-09-02 01:16:33.000000000 +0200
+++ libffi/acconfig.h	1970-01-01 01:00:00.000000000 +0100
@@ -1,12 +0,0 @@
-/* Define this if you want extra debugging */
-#undef FFI_DEBUG
-
-/* Define this if you are using Purify and want to suppress 
-   spurious messages. */
-#undef USING_PURIFY
-
-/* Define this is you do not want support for aggregate types.  */
-#undef FFI_NO_STRUCTS
-
-/* Define this is you do not want support for the raw API.  */
-#undef FFI_NO_RAW_API
diff -rNU3 libffi-orig/configure.in libffi/configure.in
--- libffi-orig/configure.in	2003-09-04 16:47:05.000000000 +0200
+++ libffi/configure.in	2003-10-14 14:23:14.000000000 +0200
@@ -52,7 +52,6 @@
 
 TARGETDIR="unknown"
 case "$host" in
-mips-sgi-irix5.* | mips-sgi-irix6.*) TARGET=MIPS; TARGETDIR=mips;;
 i*86-*-linux*) TARGET=X86; TARGETDIR=x86;;
 i*86-*-solaris*) TARGET=X86; TARGETDIR=x86;;
 i*86-*-beos*) TARGET=X86; TARGETDIR=x86;;
@@ -69,6 +68,7 @@
 ia64*-*-*) TARGET=IA64; TARGETDIR=ia64;;
 m68k-*-linux*) TARGET=M68K; TARGETDIR=m68k;;
 mips64*-*);;
+mips-sgi-irix5.* | mips-sgi-irix6.*) TARGET=MIPS_IRIX; TARGETDIR=mips;;
 mips*-*-linux*) TARGET=MIPS_LINUX; TARGETDIR=mips;;
 powerpc*-*-linux* | powerpc-*-sysv*) TARGET=POWERPC; TARGETDIR=powerpc;;
 powerpc-*-beos*) TARGET=POWERPC; TARGETDIR=powerpc;;
@@ -90,8 +90,7 @@
   AC_ERROR("libffi has not been ported to $host.")
 fi
 
-AM_CONDITIONAL(MIPS_GCC, test ${TARGET}${ac_cv_prog_gcc} = MIPSyes)
-AM_CONDITIONAL(MIPS_SGI, test ${TARGET}${ac_cv_prog_gcc} = MIPSno)
+AM_CONDITIONAL(MIPS_IRIX, test x$TARGET = xMIPS_IRIX)
 AM_CONDITIONAL(MIPS_LINUX, test x$TARGET = xMIPS_LINUX)
 AM_CONDITIONAL(SPARC, test x$TARGET = xSPARC)
 AM_CONDITIONAL(X86, test x$TARGET = xX86)
@@ -108,24 +107,28 @@
 AM_CONDITIONAL(SH, test x$TARGET = xSH)
 AM_CONDITIONAL(SH64, test x$TARGET = xSH64)
 
-if test x$TARGET = xMIPS_LINUX; then
-  TARGET=MIPS
-fi
+case x$TARGET in
+  xMIPS*) TARGET=MIPS ;;
+  *) ;;
+esac
 
 AC_HEADER_STDC
 AC_CHECK_FUNCS(memcpy)
 AC_FUNC_ALLOCA
 
-dnl AC_CHECK_SIZEOF(char)
-AC_COMPILE_CHECK_SIZEOF(short)
-AC_COMPILE_CHECK_SIZEOF(int)
-AC_COMPILE_CHECK_SIZEOF(long)
-AC_COMPILE_CHECK_SIZEOF(long long)
-AC_COMPILE_CHECK_SIZEOF(float)
 AC_COMPILE_CHECK_SIZEOF(double)
 AC_COMPILE_CHECK_SIZEOF(long double)
 
-AC_COMPILE_CHECK_SIZEOF(void *)
+# Also AC_SUBST this variable for ffi.h.
+HAVE_LONG_DOUBLE=0
+if test $ac_cv_sizeof_double != $ac_cv_sizeof_long_double; then
+  if test $ac_cv_sizeof_long_double != 0; then
+    HAVE_LONG_DOUBLE=1
+    AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define if you have the long double type and it is bigger than a double])
+  fi
+fi
+AC_SUBST(HAVE_LONG_DOUBLE)
+
 AC_C_BIGENDIAN_CROSS
 
 if test x$TARGET = xSPARC; then
@@ -176,6 +179,11 @@
 if test "x$libffi_cv_ro_eh_frame" = xyes; then
     AC_DEFINE(HAVE_RO_EH_FRAME, 1,
 	      [Define if .eh_frame sections should be read-only.])
+    AC_DEFINE(EH_FRAME_FLAGS, "a",
+	      [Define to the flags needed for the .section .eh_frame directive.])
+else
+    AC_DEFINE(EH_FRAME_FLAGS, "aw",
+	      [Define to the flags needed for the .section .eh_frame directive.])
 fi
 
 AC_SUBST(TARGET)
@@ -186,25 +194,25 @@
 AC_ARG_ENABLE(debug,
 [  --enable-debug          debugging mode],
   if test "$enable_debug" = "yes"; then
-    AC_DEFINE(FFI_DEBUG)
+    AC_DEFINE(FFI_DEBUG, 1, [Define this if you want extra debugging.])
   fi)
 
 AC_ARG_ENABLE(structs,
 [  --disable-structs       omit code for struct support],
   if test "$enable_structs" = "no"; then
-    AC_DEFINE(FFI_NO_STRUCTS)
+    AC_DEFINE(FFI_NO_STRUCTS, 1, [Define this is you do not want support for aggregate types.])
   fi)
 
 AC_ARG_ENABLE(raw-api,
 [  --disable-raw-api       make the raw api unavailable],
   if test "$enable_raw_api" = "no"; then
-    AC_DEFINE(FFI_NO_RAW_API)
+    AC_DEFINE(FFI_NO_RAW_API, 1, [Define this is you do not want support for the raw API.])
   fi)
 
 AC_ARG_ENABLE(purify-safety,
 [  --enable-purify-safety  purify-safe mode],
   if test "$enable_purify_safety" = "yes"; then
-    AC_DEFINE(USING_PURIFY)
+    AC_DEFINE(USING_PURIFY, 1, [Define this if you are using Purify and want to suppress spurious messages.])
   fi)
 
 if test -n "$with_cross_host" &&
@@ -246,16 +254,17 @@
 CC="${CC}"
 DEFS="$DEFS"
 ORIGINAL_LD_FOR_MULTILIBS="${ORIGINAL_LD_FOR_MULTILIBS}"
-test ! -d include && mkdir include
-test ! -f include/fficonfig.h && cp fficonfig.h include/fficonfig.h
-if cmp -s fficonfig.h include/fficonfig.h 2>/dev/null; then 
-	echo fficonfig.h unchanged
-else
-	echo Moving fficonfig.h to include/fficonfig.h
-	cp fficonfig.h include/fficonfig.h
-fi
-)
 
 # Make target subdirectories if required.
 test -d src || mkdir src
 test -d src/${TARGETDIR} || mkdir src/${TARGETDIR}
+test ! -d include && mkdir include
+
+test ! -f include/ffitarget.h && cp ${srcdir}/src/$TARGETDIR/ffitarget.h include/ffitarget.h
+if cmp -s ${srcdir}/src/$TARGETDIR/ffitarget.h include/ffitarget.h 2>/dev/null; then 
+	echo include/ffitarget.h unchanged
+else
+	echo Moving ${srcdir}/src/$TARGETDIR/ffitarget.h to include/ffitarget.h
+	cp ${srcdir}/src/$TARGETDIR/ffitarget.h include/ffitarget.h
+fi
+)
diff -rNU3 libffi-orig/include/Makefile.am libffi/include/Makefile.am
--- libffi-orig/include/Makefile.am	1999-08-09 00:58:30.000000000 +0200
+++ libffi/include/Makefile.am	2003-10-14 14:23:14.000000000 +0200
@@ -1,9 +1,10 @@
 ## Process this with automake to create Makefile.in
 
-AUTOMAKE_OPTIONS = foreign
+AUTOMAKE_OPTIONS=foreign
 
-EXTRA_DIST = ffi.h.in ffi_common.h ffi_mips.h
+DISTCLEANFILES=ffitarget.h
+EXTRA_DIST=ffi.h.in ffi_common.h
 
 hackdir=$(includedir)
 
-hack_DATA=fficonfig.h ffi.h ffi_mips.h
\ No newline at end of file
+hack_DATA=ffitarget.h ffi.h
diff -rNU3 libffi-orig/include/ffi.h.in libffi/include/ffi.h.in
--- libffi-orig/include/ffi.h.in	2003-06-13 04:23:26.000000000 +0200
+++ libffi/include/ffi.h.in	2003-10-14 14:23:14.000000000 +0200
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------*-C-*-
-   libffi @VERSION@ - Copyright (c) 1996-2003  Cygnus Solutions
+   libffi @VERSION@ - Copyright (c) 1996-2003  Red Hat, Inc.
 
    Permission is hereby granted, free of charge, to any person obtaining
    a copy of this software and associated documentation files (the
@@ -60,258 +60,70 @@
 
 /* ---- System configuration information --------------------------------- */
 
-#include <fficonfig.h>
+#include <ffitarget.h>
 
-#if !defined(LIBFFI_ASM)
-#include <stddef.h>
-#if defined(FFI_DEBUG) 
-#include <stdio.h>
-#endif
-#endif
-
-/* ---- Generic type definitions ----------------------------------------- */
-
-#define FLOAT32 float
-#define FLOAT64 double
-#define FLOAT80 long double
-
-#define UINT8   unsigned char
-#define SINT8   signed char
-
-#if SIZEOF_INT == 2
-
-#define UINT16	unsigned int
-#define SINT16  int
-#define ffi_type_uint ffi_type_uint16
-#define ffi_type_sint ffi_type_sint16
-
-#else 
-#if SIZEOF_SHORT == 2
-
-#define UINT16  unsigned short
-#define SINT16  short
-#define ffi_type_ushort ffi_type_uint16
-#define ffi_type_sshort ffi_type_sint16
-
-#endif
-#endif
-
-#if SIZEOF_INT == 4
-
-#define UINT32	unsigned int
-#define SINT32  int
-#define ffi_type_uint ffi_type_uint32
-#define ffi_type_sint ffi_type_sint32
-
-#else 
-#if SIZEOF_SHORT == 4
-
-#define UINT32  unsigned short
-#define SINT32  short
-#define ffi_type_ushort ffi_type_uint32
-#define ffi_type_sshort ffi_type_sint32
-
-#else
-#if SIZEOF_LONG == 4
+#ifndef LIBFFI_ASM
 
-#define UINT32  unsigned long
-#define SINT32  long
-#define ffi_type_ulong ffi_type_uint32
-#define ffi_type_slong ffi_type_sint32
-
-#endif
-#endif
-#endif
-
-#if SIZEOF_INT == 8
-
-#define UINT64  unsigned int
-#define SINT64  int
-#define ffi_type_uint ffi_type_uint64
-#define ffi_type_sint ffi_type_sint64
-
-#else
-#if SIZEOF_LONG == 8
-
-#define UINT64  unsigned long
-#define SINT64  long
-#define ffi_type_ulong ffi_type_uint64
-#define ffi_type_slong ffi_type_sint64
-
-#else
-#if SIZEOF_LONG_LONG == 8
-
-#define UINT64  unsigned long long
-#define SINT64  long long
-#define ffi_type_ulong ffi_type_uint64
-#define ffi_type_slong ffi_type_sint64
-
-#endif
-#endif
-#endif
-
-/* ---- System specific configurations ----------------------------------- */
+#include <stddef.h>
+#include <limits.h>
 
-#ifdef MIPS
-#include <ffi_mips.h>
+/* LONG_LONG_MAX is not always defined (not if STRICT_ANSI, for example).
+   But we can find it either under the correct ANSI name, or under GNU
+   C's internal name.  */
+#ifdef LONG_LONG_MAX
+# define FFI_LONG_LONG_MAX LONG_LONG_MAX
 #else
-#define SIZEOF_ARG SIZEOF_VOID_P
-#endif
-
-#ifdef POWERPC
-#if defined (__powerpc64__)
-#define POWERPC64
-#endif
-#endif
-
-#ifdef SPARC
-#if defined(__arch64__) || defined(__sparcv9)
-#define SPARC64
-#endif
-#endif
-
-#ifdef S390
-#if defined (__s390x__)
-#define S390X
-#endif
-#endif
-
-#ifdef X86_64
-#if defined (__i386__)
-#undef X86_64
-#define X86
-#endif
+# ifdef LLONG_MAX
+#  define FFI_LONG_LONG_MAX LLONG_MAX
+# else
+#  ifdef __GNUC__
+#   define FFI_LONG_LONG_MAX __LONG_LONG_MAX__
+#  endif
+# endif
 #endif
 
-#ifdef LIBFFI_ASM
-
-#ifdef HAVE_RO_EH_FRAME
-#define EH_FRAME_FLAGS "a"
+#if SCHAR_MAX == 127
+# define ffi_type_uchar                ffi_type_uint8
+# define ffi_type_schar                ffi_type_sint8
 #else
-#define EH_FRAME_FLAGS "aw"
+ #error "char size not supported"
 #endif
 
+#if SHRT_MAX == 32767
+# define ffi_type_ushort       ffi_type_uint16
+# define ffi_type_sshort       ffi_type_sint16
+#elif SHRT_MAX == 2147483647
+# define ffi_type_ushort       ffi_type_uint32
+# define ffi_type_sshort       ffi_type_sint32
 #else
-
-/* ---- Generic type definitions ----------------------------------------- */
-
-#define ALIGN(v, a)  (((((size_t) (v))-1) | ((a)-1))+1)
-/* The closure code assumes that this works on pointers, i.e. a size_t	*/
-/* can hold a pointer.							*/
-
-typedef enum ffi_abi {
-
-  /* Leave this for debugging purposes */
-  FFI_FIRST_ABI = 0,
-
-  /* ---- Sparc -------------------- */
-#ifdef SPARC
-  FFI_V8,
-  FFI_V8PLUS,
-  FFI_V9,
-#ifdef SPARC64
-  FFI_DEFAULT_ABI = FFI_V9,
-#else
-  FFI_DEFAULT_ABI = FFI_V8,
-#endif
+ #error "short size not supported"
 #endif
 
-  /* ---- Intel x86 Win32 ---------- */
-#ifdef X86_WIN32
-  FFI_SYSV,
-  FFI_STDCALL,
-  /* TODO: Add fastcall support for the sake of completeness */
-  FFI_DEFAULT_ABI = FFI_SYSV,
-#endif
-
-  /* ---- Intel x86 and AMD x86-64 - */
-#if !defined(X86_WIN32) && (defined(__i386__) || defined(__x86_64__))
-  FFI_SYSV,
-  FFI_UNIX64,   /* Unix variants all use the same ABI for x86-64  */
-#ifdef __i386__
-  FFI_DEFAULT_ABI = FFI_SYSV,
+#if INT_MAX == 32767
+# define ffi_type_uint         ffi_type_uint16
+# define ffi_type_sint         ffi_type_sint16
+#elif INT_MAX == 2147483647
+# define ffi_type_uint         ffi_type_uint32
+# define ffi_type_sint         ffi_type_sint32
+#elif INT_MAX == 9223372036854775807
+# define ffi_type_uint         ffi_type_uint64
+# define ffi_type_sint         ffi_type_sint64
 #else
-  FFI_DEFAULT_ABI = FFI_UNIX64,
-#endif
-#endif
-
-  /* ---- Intel ia64 ---------------- */
-#ifdef IA64
-  FFI_UNIX,   	/* Linux and all Unix variants use the same conventions	*/
-  FFI_DEFAULT_ABI = FFI_UNIX,
-#endif
-
-  /* ---- Mips --------------------- */
-#ifdef MIPS
-  FFI_O32,
-  FFI_N32,
-  FFI_N64,
-#endif
-
-  /* ---- Alpha -------------------- */
-#ifdef ALPHA
-  FFI_OSF,
-  FFI_DEFAULT_ABI = FFI_OSF,
+ #error "int size not supported"
 #endif
 
-  /* ---- Motorola m68k ------------ */
-#ifdef M68K
-  FFI_SYSV,
-  FFI_DEFAULT_ABI = FFI_SYSV,
-#endif
-
-  /* ---- PowerPC ------------------ */
-#ifdef POWERPC
-  FFI_SYSV,
-  FFI_GCC_SYSV,
-  FFI_LINUX64,
-# ifdef POWERPC64
-  FFI_DEFAULT_ABI = FFI_LINUX64,
-# else
-  FFI_DEFAULT_ABI = FFI_GCC_SYSV,
+#define ffi_type_ulong         ffi_type_uint64
+#define ffi_type_slong         ffi_type_sint64
+#if LONG_MAX == 2147483647
+# if FFI_LONG_LONG_MAX != 9223372036854775807
+  #error "no 64-bit data type supported"
 # endif
+#elif LONG_MAX != 9223372036854775807
+ #error "long size not supported"
 #endif
 
-#ifdef POWERPC_AIX
-  FFI_AIX,
-  FFI_DARWIN,
-  FFI_DEFAULT_ABI = FFI_AIX,
-#endif
-
-#ifdef POWERPC_DARWIN
-  FFI_AIX,
-  FFI_DARWIN,
-  FFI_DEFAULT_ABI = FFI_DARWIN,
-#endif
-
-  /* ---- ARM  --------------------- */
-#ifdef ARM
-  FFI_SYSV,
-  FFI_DEFAULT_ABI = FFI_SYSV,
-#endif
-
-  /* ---- S390 --------------------- */
-#ifdef S390
-  FFI_SYSV,
-  FFI_DEFAULT_ABI = FFI_SYSV,
-#endif
-
-  /* ---- SuperH ------------------- */
-#ifdef SH
-  FFI_SYSV,
-  FFI_DEFAULT_ABI = FFI_SYSV,
-#endif
-
-  /* ---- SuperH - SHmedia --------- */
-#ifdef SH64
-  FFI_SYSV,
-  FFI_DEFAULT_ABI = FFI_SYSV,
-#endif
-
-  /* Leave this for debugging purposes */
-  FFI_LAST_ABI
-
-} ffi_abi;
+/* The closure code assumes that this works on pointers, i.e. a size_t	*/
+/* can hold a pointer.							*/
 
 typedef struct _ffi_type
 {
@@ -336,9 +148,6 @@
 extern ffi_type ffi_type_longdouble;
 extern ffi_type ffi_type_pointer;
 
-/* Characters are 8 bit integral types */
-#define ffi_type_schar ffi_type_sint8
-#define ffi_type_uchar ffi_type_uint8
 
 typedef enum {
   FFI_OK = 0,
@@ -355,53 +164,27 @@
   /*@dependent@*/ ffi_type *rtype;
   unsigned bytes;
   unsigned flags;
-
-#ifdef MIPS
-#if _MIPS_SIM == _ABIN32
-  unsigned rstruct_flag;
+#ifdef FFI_EXTRA_CIF_FIELDS
+  FFI_EXTRA_CIF_FIELDS;
 #endif
-#endif
-
-#ifdef SH64
-  long long flags2;
-#endif
-
 } ffi_cif;
 
-#if SIZEOF_ARG == 4
-typedef UINT32 ffi_arg;
-#else
-#if SIZEOF_ARG == 8
-typedef UINT64 ffi_arg;
-#else
--- unsupported configuration
-#endif
-#endif
-
 /* ---- Definitions for the raw API -------------------------------------- */
 
-#if !FFI_NO_RAW_API
-
-#if SIZEOF_ARG == 4
-
-#define UINT_ARG UINT32
-#define SINT_ARG SINT32
-
-#endif
-
-#if SIZEOF_ARG == 8
-
-#define UINT_ARG UINT64
-#define SINT_ARG SINT64
-
+#ifndef FFI_SIZEOF_ARG
+# if LONG_MAX == 2147483647
+#  define FFI_SIZEOF_ARG        4
+# elif LONG_MAX == 9223372036854775807
+#  define FFI_SIZEOF_ARG        8
+# endif
 #endif
 
 typedef union {
-  SINT_ARG sint;
-  UINT_ARG uint;
-  float	   flt;
-  char     data[SIZEOF_ARG];
-  void*    ptr;
+  ffi_sarg  sint;
+  ffi_arg   uint;
+  float	    flt;
+  char      data[FFI_SIZEOF_ARG];
+  void*     ptr;
 } ffi_raw;
 
 void ffi_raw_call (/*@dependent@*/ ffi_cif *cif, 
@@ -413,8 +196,6 @@
 void ffi_raw_to_ptrarray (ffi_cif *cif, ffi_raw *raw, void **args);
 size_t ffi_raw_size (ffi_cif *cif);
 
-#if !NO_JAVA_RAW_API
-
 /* This is analogous to the raw API, except it uses Java parameter	*/
 /* packing, even on 64-bit machines.  I.e. on 64-bit machines		*/
 /* longs and doubles are followed by an empty 64-bit word.		*/
@@ -428,120 +209,8 @@
 void ffi_java_raw_to_ptrarray (ffi_cif *cif, ffi_raw *raw, void **args);
 size_t ffi_java_raw_size (ffi_cif *cif);
 
-#endif /* !NO_JAVA_RAW_API */
-
-#endif /* !FFI_NO_RAW_API */
-
 /* ---- Definitions for closures ----------------------------------------- */
 
-#ifdef __i386__
-
-#define FFI_CLOSURES 1		/* x86 supports closures */
-#define FFI_TRAMPOLINE_SIZE 10
-#define FFI_NATIVE_RAW_API 1	/* and has native raw api support */
-
-#elif defined(IA64)
-
-#define FFI_CLOSURES 1
-#define FFI_TRAMPOLINE_SIZE 24  /* Really the following struct, which 	*/
-				/* can be interpreted as a C function	*/
-				/* decriptor:				*/
-
-struct ffi_ia64_trampoline_struct {
-    void * code_pointer;	/* Pointer to ffi_closure_UNIX	*/
-    void * fake_gp;		/* Pointer to closure, installed as gp	*/
-    void * real_gp;		/* Real gp value, reinstalled by 	*/
-				/* ffi_closure_UNIX.			*/
-};
-#define FFI_NATIVE_RAW_API 0
-
-#elif defined(ALPHA)
-
-#define FFI_CLOSURES 1
-#define FFI_TRAMPOLINE_SIZE 24
-#define FFI_NATIVE_RAW_API 0
-
-#elif defined(POWERPC)
-
-#define FFI_CLOSURES 1
-#ifdef POWERPC64
-#define FFI_TRAMPOLINE_SIZE 24
-#else
-#define FFI_TRAMPOLINE_SIZE 40
-#endif
-#define FFI_NATIVE_RAW_API 0
-
-#elif defined(POWERPC_DARWIN)
-
-#define FFI_CLOSURES 1
-#define FFI_TRAMPOLINE_SIZE 40
-#define FFI_NATIVE_RAW_API 0
-
-#elif defined(POWERPC_AIX)
-
-#define FFI_CLOSURES 1
-#define FFI_TRAMPOLINE_SIZE 24 /* see struct below */ 
-#define FFI_NATIVE_RAW_API 0
-
-#elif defined(SPARC64)
-
-#define FFI_CLOSURES 1
-#define FFI_TRAMPOLINE_SIZE 24
-#define FFI_NATIVE_RAW_API 0
-
-#elif defined(SPARC)
-
-#define FFI_CLOSURES 1
-#define FFI_TRAMPOLINE_SIZE 16
-#define FFI_NATIVE_RAW_API 0
-
-#elif defined(S390)
-
-#define FFI_CLOSURES 1
-#ifdef S390X
-#define FFI_TRAMPOLINE_SIZE 32
-#else
-#define FFI_TRAMPOLINE_SIZE 16
-#endif
-#define FFI_NATIVE_RAW_API 0
-
-#elif defined(SH)
-
-#define FFI_CLOSURES 1
-#define FFI_TRAMPOLINE_SIZE 16
-#define FFI_NATIVE_RAW_API 0
-
-#elif defined(SH64)
-
-#define FFI_CLOSURES 1
-#define FFI_TRAMPOLINE_SIZE 32
-#define FFI_NATIVE_RAW_API 0
-
-#elif defined(__x86_64__)
-
-#define FFI_CLOSURES 1
-#define FFI_TRAMPOLINE_SIZE 24
-#define FFI_NATIVE_RAW_API 0
-
-#else 
-
-#define FFI_CLOSURES 0
-#define FFI_NATIVE_RAW_API 0
-
-#endif
-
-#if defined(POWERPC_DARWIN) || defined(POWERPC_AIX)
-
-struct ffi_aix_trampoline_struct {
-    void * code_pointer;	/* Pointer to ffi_closure_ASM */
-    void * toc;			/* TOC */
-    void * static_chain;	/* Pointer to closure */
-};
-
-#endif
-
-
-
 #if FFI_CLOSURES
 
 typedef struct {
@@ -557,8 +226,6 @@
 		  void (*fun)(ffi_cif*,void*,void**,void*),
 		  void *user_data);
 
-#if !FFI_NO_RAW_API
-
 typedef struct {
   char tramp[FFI_TRAMPOLINE_SIZE];
 
@@ -586,15 +253,12 @@
 		      void (*fun)(ffi_cif*,void*,ffi_raw*,void*),
 		      void *user_data);
 
-#ifndef NO_JAVA_RAW_API
 ffi_status
 ffi_prep_java_raw_closure (ffi_raw_closure*,
 		           ffi_cif *cif,
 		           void (*fun)(ffi_cif*,void*,ffi_raw*,void*),
 		           void *user_data);
-#endif
 
-#endif /* !FFI_NO_RAW_API */
 #endif /* FFI_CLOSURES */
 
 /* ---- Public interface definition -------------------------------------- */
@@ -617,25 +281,25 @@
 
 #endif
 
+/* If these change, update src/mips/ffitarget.h. */
 #define FFI_TYPE_VOID       0    
 #define FFI_TYPE_INT        1
 #define FFI_TYPE_FLOAT      2    
 #define FFI_TYPE_DOUBLE     3
-#if SIZEOF_LONG_DOUBLE == SIZEOF_DOUBLE
-#define FFI_TYPE_LONGDOUBLE FFI_TYPE_DOUBLE
-#else
+#if @HAVE_LONG_DOUBLE@
 #define FFI_TYPE_LONGDOUBLE 4
+#else
+#define FFI_TYPE_LONGDOUBLE FFI_TYPE_DOUBLE
 #endif
-
-#define FFI_TYPE_UINT8      5   /* If this changes, update ffi_mips.h. */
-#define FFI_TYPE_SINT8      6   /* If this changes, update ffi_mips.h. */
+#define FFI_TYPE_UINT8      5   
+#define FFI_TYPE_SINT8      6
 #define FFI_TYPE_UINT16     7 
 #define FFI_TYPE_SINT16     8
 #define FFI_TYPE_UINT32     9
 #define FFI_TYPE_SINT32     10
 #define FFI_TYPE_UINT64     11
 #define FFI_TYPE_SINT64     12
-#define FFI_TYPE_STRUCT     13  /* If this changes, update ffi_mips.h. */
+#define FFI_TYPE_STRUCT     13
 #define FFI_TYPE_POINTER    14
 
 /* This should always refer to the last type code (for sanity checks) */
diff -rNU3 libffi-orig/include/ffi_common.h libffi/include/ffi_common.h
--- libffi-orig/include/ffi_common.h	1999-08-09 00:58:30.000000000 +0200
+++ libffi/include/ffi_common.h	2003-10-14 14:23:14.000000000 +0200
@@ -1,7 +1,5 @@
 /* -----------------------------------------------------------------------
-   ffi_common.h - Copyright (c) 1996  Cygnus Solutions
-
-   $Id: ffi_common.h,v 1.1 1999/08/08 22:58:30 green Exp $
+   ffi_common.h - Copyright (c) 1996  Red Hat, Inc.
 
    Common internal definitions and macros. Only necessary for building
    libffi.
@@ -14,6 +12,8 @@
 extern "C" {
 #endif
 
+#include <fficonfig.h>
+
 /* Do not move this. Some versions of AIX are very picky about where
    this is positioned. */
 #ifdef __GNUC__
@@ -41,36 +41,26 @@
 # endif
 #endif
 
-#ifndef FALSE
-#define FALSE 0
-#endif
-
-#ifndef TRUE
-#define TRUE (!FALSE)
-#endif
-
-#ifndef __cplusplus
-/* bool is a keyword in C++ */
-/*@-cppnames@*/
-typedef int bool;
-/*@=cppnames@*/
+#if defined(FFI_DEBUG) 
+#include <stdio.h>
 #endif
 
 #ifdef FFI_DEBUG
-
-/* Debugging functions */
-/*@exits@*/ int ffi_assert(/*@temp@*/ char *file, int line);
+/*@exits@*/ void ffi_assert(/*@temp@*/ char *expr, /*@temp@*/ char *file, int line);
 void ffi_stop_here(void);
-bool ffi_type_test(/*@temp@*/ /*@out@*/ ffi_type *a);
-
-#define FFI_ASSERT(x) ((x) ? 0 : ffi_assert(__FILE__,__LINE__))
+void ffi_type_test(/*@temp@*/ /*@out@*/ ffi_type *a, /*@temp@*/ char *file, int line);
 
+#define FFI_ASSERT(x) ((x) ? (void)0 : ffi_assert(#x, __FILE__,__LINE__))
+#define FFI_ASSERT_AT(x, f, l) ((x) ? 0 : ffi_assert(#x, (f), (l)))
+#define FFI_ASSERT_VALID_TYPE(x) ffi_type_test (x, __FILE__, __LINE__)
 #else
-
 #define FFI_ASSERT(x) 
-
+#define FFI_ASSERT_AT(x, f, l)
+#define FFI_ASSERT_VALID_TYPE(x)
 #endif
 
+#define ALIGN(v, a)  (((((size_t) (v))-1) | ((a)-1))+1)
+
 /* Perform machine dependent cif processing */
 ffi_status ffi_prep_cif_machdep(ffi_cif *cif);
 
@@ -82,6 +72,19 @@
   /*@dependent@*/ void **avalue;
 } extended_cif;
 
+/* Terse sized type definitions.  */
+typedef unsigned int UINT8  __attribute__((__mode__(__QI__)));
+typedef signed int   SINT8  __attribute__((__mode__(__QI__)));
+typedef unsigned int UINT16 __attribute__((__mode__(__HI__)));
+typedef signed int   SINT16 __attribute__((__mode__(__HI__)));
+typedef unsigned int UINT32 __attribute__((__mode__(__SI__)));
+typedef signed int   SINT32 __attribute__((__mode__(__SI__)));
+typedef unsigned int UINT64 __attribute__((__mode__(__DI__)));
+typedef signed int   SINT64 __attribute__((__mode__(__DI__)));
+
+typedef float FLOAT32;
+
+
 #ifdef __cplusplus
 }
 #endif
diff -rNU3 libffi-orig/include/ffi_mips.h libffi/include/ffi_mips.h
--- libffi-orig/include/ffi_mips.h	2003-10-06 21:18:35.000000000 +0200
+++ libffi/include/ffi_mips.h	1970-01-01 01:00:00.000000000 +0100
@@ -1,137 +0,0 @@
-/* -----------------------------------------------------------------------
-   ffi-mips.h - Copyright (c) 1996 Cygnus Support
-   
-   MIPS FFI Definitions
-
-   Permission is hereby granted, free of charge, to any person obtaining
-   a copy of this software and associated documentation files (the
-   ``Software''), to deal in the Software without restriction, including
-   without limitation the rights to use, copy, modify, merge, publish,
-   distribute, sublicense, and/or sell copies of the Software, and to
-   permit persons to whom the Software is furnished to do so, subject to
-   the following conditions:
-
-   The above copyright notice and this permission notice shall be included
-   in all copies or substantial portions of the Software.
-
-   THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
-   OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-   IN NO EVENT SHALL CYGNUS SUPPORT BE LIABLE FOR ANY CLAIM, DAMAGES OR
-   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-   OTHER DEALINGS IN THE SOFTWARE.
-   ----------------------------------------------------------------------- */
-
-#ifndef FFI_MIPS_H
-
-#include <ffi.h>
-
-#if !defined(_MIPS_SIM)
--- something is very wrong --
-#else
-#  if (_MIPS_SIM==_ABIN32 && defined(_ABIN32)) || (_MIPS_SIM==_ABI64 && defined(_ABI64))
-#    define FFI_MIPS_N32
-#  else
-#    if _MIPS_SIM==_ABIO32 && defined(_ABIO32)
-#      define FFI_MIPS_O32
-#    else
--- this is an unsupported platform --
-#    endif
-#  endif
-#endif
-
-#define v0 $2
-#define v1 $3
-#define a0 $4
-#define a1 $5
-#define a2 $6
-#define a3 $7
-#define a4 $8		
-#define a5 $9		
-#define a6 $10		
-#define a7 $11		
-#define t0 $8
-#define t1 $9
-#define t2 $10
-#define t3 $11
-#define t4 $12		
-#define t5 $13
-#define t6 $14	
-#define t7 $15
-#define t8 $24
-#define t9 $25
-#define ra $31		
-
-#if defined(FFI_MIPS_O32)
-
-#define FFI_DEFAULT_ABI FFI_O32
-
-/* O32 stack frames have 32bit integer args */
-#define SLOT_TYPE_UNSIGNED UINT32
-#define SLOT_TYPE_SIGNED   SINT32
-#define SIZEOF_ARG         4
-
-#define REG_L	lw
-#define REG_S	sw
-#define SUBU	subu
-#define ADDU	addu
-#define SRL	srl
-#define LI	li
-
-#else
-
-#define FFI_DEFAULT_ABI FFI_N32
-
-/* N32 and N64 frames have 64bit integer args */
-#define SLOT_TYPE_UNSIGNED UINT64
-#define SLOT_TYPE_SIGNED   SINT64
-#define SIZEOF_ARG         8
-
-#define REG_L	ld
-#define REG_S	sd
-#define SUBU	dsubu
-#define ADDU	daddu
-#define SRL	dsrl
-#define LI 	dli
-
-#endif
-
-#define FFI_FLAG_BITS 2
-
-/* SGI's strange assembler requires that we multiply by 4 rather 
-   than shift left by FFI_FLAG_BITS */
-
-#define FFI_ARGS_D   FFI_TYPE_DOUBLE
-#define FFI_ARGS_F   FFI_TYPE_FLOAT
-#define FFI_ARGS_DD  FFI_TYPE_DOUBLE * 4 + FFI_TYPE_DOUBLE
-#define FFI_ARGS_FF  FFI_TYPE_FLOAT * 4 +  FFI_TYPE_FLOAT
-#define FFI_ARGS_FD  FFI_TYPE_DOUBLE * 4 + FFI_TYPE_FLOAT
-#define FFI_ARGS_DF  FFI_TYPE_FLOAT * 4 + FFI_TYPE_DOUBLE
-
-/* Needed for N32 structure returns */
-#define FFI_TYPE_SMALLSTRUCT  FFI_TYPE_UINT8
-#define FFI_TYPE_SMALLSTRUCT2 FFI_TYPE_SINT8
-
-#if 0
-
-/* The SGI assembler can't handle this.. */
-
-#define FFI_TYPE_STRUCT_DD (( FFI_ARGS_DD ) << 4) + FFI_TYPE_STRUCT
-
-#else
-
-/* ...so we calculate these by hand! */
-
-#define FFI_TYPE_STRUCT_D      61
-#define FFI_TYPE_STRUCT_F      45
-#define FFI_TYPE_STRUCT_DD     253
-#define FFI_TYPE_STRUCT_FF     173
-#define FFI_TYPE_STRUCT_FD     237
-#define FFI_TYPE_STRUCT_DF     189
-#define FFI_TYPE_STRUCT_SMALL  93
-#define FFI_TYPE_STRUCT_SMALL2 109
-
-#endif
-
-#endif
diff -rNU3 libffi-orig/src/alpha/ffi.c libffi/src/alpha/ffi.c
--- libffi-orig/src/alpha/ffi.c	2001-07-16 18:53:43.000000000 +0200
+++ libffi/src/alpha/ffi.c	2003-10-14 14:23:19.000000000 +0200
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------
-   ffi.c - Copyright (c) 1998, 2001 Cygnus Solutions
+   ffi.c - Copyright (c) 1998, 2001 Red Hat, Inc.
    
    Alpha Foreign Function Interface 
 
@@ -37,8 +37,8 @@
 {
   /* Adjust cif->bytes to represent a minimum 6 words for the temporary
      register argument loading area.  */
-  if (cif->bytes < 6*SIZEOF_ARG)
-    cif->bytes = 6*SIZEOF_ARG;
+  if (cif->bytes < 6*FFI_SIZEOF_ARG)
+    cif->bytes = 6*FFI_SIZEOF_ARG;
 
   /* Set the return type flag */
   switch (cif->rtype->type)
@@ -73,7 +73,7 @@
 
   /* Allocate the space for the arguments, plus 4 words of temp
      space for ffi_call_osf.  */
-  argp = stack = alloca(cif->bytes + 4*SIZEOF_ARG);
+  argp = stack = alloca(cif->bytes + 4*FFI_SIZEOF_ARG);
 
   if (cif->flags == FFI_TYPE_STRUCT)
     *(void **) argp++ = rvalue;
@@ -137,7 +137,7 @@
 	  FFI_ASSERT(0);
 	}
 
-      argp += ALIGN((*arg_types)->size, SIZEOF_ARG) / SIZEOF_ARG;
+      argp += ALIGN((*arg_types)->size, FFI_SIZEOF_ARG) / FFI_SIZEOF_ARG;
       i++, arg_types++, avalue++;
     }
 
@@ -240,7 +240,7 @@
 	  FFI_ASSERT(0);
 	}
 
-      argn += ALIGN(arg_types[i]->size, SIZEOF_ARG) / SIZEOF_ARG;
+      argn += ALIGN(arg_types[i]->size, FFI_SIZEOF_ARG) / FFI_SIZEOF_ARG;
       i++;
     }
 
diff -rNU3 libffi-orig/src/alpha/ffitarget.h libffi/src/alpha/ffitarget.h
--- libffi-orig/src/alpha/ffitarget.h	1970-01-01 01:00:00.000000000 +0100
+++ libffi/src/alpha/ffitarget.h	2003-10-14 14:23:19.000000000 +0200
@@ -0,0 +1,48 @@
+/* -----------------------------------------------------------------*-C-*-
+   ffitarget.h - Copyright (c) 1996-2003  Red Hat, Inc.
+   Target configuration macros for Alpha.
+
+   Permission is hereby granted, free of charge, to any person obtaining
+   a copy of this software and associated documentation files (the
+   ``Software''), to deal in the Software without restriction, including
+   without limitation the rights to use, copy, modify, merge, publish,
+   distribute, sublicense, and/or sell copies of the Software, and to
+   permit persons to whom the Software is furnished to do so, subject to
+   the following conditions:
+
+   The above copyright notice and this permission notice shall be included
+   in all copies or substantial portions of the Software.
+
+   THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
+   OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+   IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+   OTHER DEALINGS IN THE SOFTWARE.
+
+   ----------------------------------------------------------------------- */
+
+#ifndef LIBFFI_TARGET_H
+#define LIBFFI_TARGET_H
+
+#ifndef LIBFFI_ASM
+typedef unsigned long          ffi_arg;
+typedef signed long            ffi_sarg;
+
+typedef enum ffi_abi {
+  FFI_FIRST_ABI = 0,
+  FFI_OSF,
+  FFI_DEFAULT_ABI = FFI_OSF,
+  FFI_LAST_ABI = FFI_DEFAULT_ABI + 1
+} ffi_abi;
+#endif
+
+/* ---- Definitions for closures ----------------------------------------- */
+
+#define FFI_CLOSURES 1
+#define FFI_TRAMPOLINE_SIZE 24
+#define FFI_NATIVE_RAW_API 0
+
+#endif
+
diff -rNU3 libffi-orig/src/alpha/osf.S libffi/src/alpha/osf.S
--- libffi-orig/src/alpha/osf.S	2003-05-17 00:09:21.000000000 +0200
+++ libffi/src/alpha/osf.S	2003-10-14 14:23:19.000000000 +0200
@@ -26,6 +26,7 @@
    ----------------------------------------------------------------------- */
 
 #define LIBFFI_ASM	
+#include <fficonfig.h>
 #include <ffi.h>
 
 	.arch ev6
diff -rNU3 libffi-orig/src/arm/ffi.c libffi/src/arm/ffi.c
--- libffi-orig/src/arm/ffi.c	2002-07-19 01:08:30.000000000 +0200
+++ libffi/src/arm/ffi.c	2003-10-14 14:23:19.000000000 +0200
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------
-   ffi.c - Copyright (c) 1998  Cygnus Solutions
+   ffi.c - Copyright (c) 1998  Red Hat, Inc.
    
    ARM Foreign Function Interface 
 
diff -rNU3 libffi-orig/src/arm/ffitarget.h libffi/src/arm/ffitarget.h
--- libffi-orig/src/arm/ffitarget.h	1970-01-01 01:00:00.000000000 +0100
+++ libffi/src/arm/ffitarget.h	2003-10-14 14:23:19.000000000 +0200
@@ -0,0 +1,47 @@
+/* -----------------------------------------------------------------*-C-*-
+   ffitarget.h - Copyright (c) 1996-2003  Red Hat, Inc.
+   Target configuration macros for ARM.
+
+   Permission is hereby granted, free of charge, to any person obtaining
+   a copy of this software and associated documentation files (the
+   ``Software''), to deal in the Software without restriction, including
+   without limitation the rights to use, copy, modify, merge, publish,
+   distribute, sublicense, and/or sell copies of the Software, and to
+   permit persons to whom the Software is furnished to do so, subject to
+   the following conditions:
+
+   The above copyright notice and this permission notice shall be included
+   in all copies or substantial portions of the Software.
+
+   THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
+   OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+   IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+   OTHER DEALINGS IN THE SOFTWARE.
+
+   ----------------------------------------------------------------------- */
+
+#ifndef LIBFFI_TARGET_H
+#define LIBFFI_TARGET_H
+
+#ifndef LIBFFI_ASM
+typedef unsigned long          ffi_arg;
+typedef signed long            ffi_sarg;
+
+typedef enum ffi_abi {
+  FFI_FIRST_ABI = 0,
+  FFI_SYSV,
+  FFI_DEFAULT_ABI = FFI_SYSV,
+  FFI_LAST_ABI = FFI_DEFAULT_ABI + 1
+} ffi_abi;
+#endif
+
+/* ---- Definitions for closures ----------------------------------------- */
+
+#define FFI_CLOSURES 0
+#define FFI_NATIVE_RAW_API 0
+
+#endif
+
diff -rNU3 libffi-orig/src/arm/sysv.S libffi/src/arm/sysv.S
--- libffi-orig/src/arm/sysv.S	2002-09-29 20:08:58.000000000 +0200
+++ libffi/src/arm/sysv.S	2003-10-14 14:23:19.000000000 +0200
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------
-   sysv.S - Copyright (c) 1998 Cygnus Solutions
+   sysv.S - Copyright (c) 1998 Red Hat, Inc.
    
    ARM Foreign Function Interface 
 
@@ -24,6 +24,7 @@
    ----------------------------------------------------------------------- */
 
 #define LIBFFI_ASM	
+#include <fficonfig.h>
 #include <ffi.h>
 #ifdef HAVE_MACHINE_ASM_H
 #include <machine/asm.h>
diff -rNU3 libffi-orig/src/debug.c libffi/src/debug.c
--- libffi-orig/src/debug.c	2001-03-02 23:21:22.000000000 +0100
+++ libffi/src/debug.c	2003-10-14 14:23:19.000000000 +0200
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------
-   debug.c - Copyright (c) 1996 Cygnus Solutions
+   debug.c - Copyright (c) 1996 Red Hat, Inc.
 
    Permission is hereby granted, free of charge, to any person obtaining
    a copy of this software and associated documentation files (the
@@ -37,29 +37,23 @@
 
 /* This function should only be called via the FFI_ASSERT() macro */
 
-int ffi_assert(char *file, int line)
+void ffi_assert(char *expr, char *file, int line)
 {
-  fprintf(stderr, "ASSERTION FAILURE: %s line %d\n", file, line);
+  fprintf(stderr, "ASSERTION FAILURE: %s at %s:%d\n", expr, file, line);
   ffi_stop_here();
   abort();
-
-  /* This has to return something for the compiler not to complain */
-  /*@notreached@*/
-  return 0;
 }
 
 /* Perform a sanity check on an ffi_type structure */
 
-bool ffi_type_test(ffi_type *a)
+void ffi_type_test(ffi_type *a, char *file, int line)
 {
+  FFI_ASSERT_AT(a != NULL, file, line);
+
   /*@-usedef@*/
-  FFI_ASSERT(a->type <= FFI_TYPE_LAST);
-  FFI_ASSERT(a->type > FFI_TYPE_VOID ? a->size > 0 : 1);
-  FFI_ASSERT(a->type > FFI_TYPE_VOID ? a->alignment > 0 : 1);
-  FFI_ASSERT(a->type == FFI_TYPE_STRUCT ? a->elements != NULL : 1);
+  FFI_ASSERT_AT(a->type <= FFI_TYPE_LAST, file, line);
+  FFI_ASSERT_AT(a->type == FFI_TYPE_VOID || a->size > 0, file, line);
+  FFI_ASSERT_AT(a->type == FFI_TYPE_VOID || a->alignment > 0, file, line);
+  FFI_ASSERT_AT(a->type != FFI_TYPE_STRUCT || a->elements != NULL, file, line);
   /*@=usedef@*/
-
-  /* This is a silly thing to return, but it keeps the compiler from
-     issuing warnings about "a" not being used in non-debug builds. */
-  return (a != NULL);
 }
diff -rNU3 libffi-orig/src/ia64/ffi.c libffi/src/ia64/ffi.c
--- libffi-orig/src/ia64/ffi.c	2002-04-09 01:59:13.000000000 +0200
+++ libffi/src/ia64/ffi.c	2003-10-14 14:23:19.000000000 +0200
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------
-   ffi.c - Copyright (c) 1998 Cygnus Solutions
+   ffi.c - Copyright (c) 1998 Red Hat, Inc.
 	   Copyright (c) 2000 Hewlett Packard Company
    
    IA64 Foreign Function Interface 
@@ -28,6 +28,7 @@
 #include <ffi_common.h>
 
 #include <stdlib.h>
+#include <stdbool.h>
 
 #include "ia64_flags.h"
 
@@ -210,7 +211,7 @@
 	  {
 	      size_t sz = (*p_arg)->size;
 	      unsigned short element_type;
-              z = ((*p_arg)->size + SIZEOF_ARG - 1)/SIZEOF_ARG;
+              z = ((*p_arg)->size + FFI_SIZEOF_ARG - 1)/FFI_SIZEOF_ARG;
 	      if (is_homogeneous_fp_aggregate(*p_arg, 8, &element_type)) {
 		int i;
 		int nelements = sz/float_type_size(element_type);
@@ -596,7 +597,7 @@
 	  {
 	      size_t sz = (*p_arg)->size;
 	      unsigned short element_type;
-              z = ((*p_arg)->size + SIZEOF_ARG - 1)/SIZEOF_ARG;
+              z = ((*p_arg)->size + FFI_SIZEOF_ARG - 1)/FFI_SIZEOF_ARG;
 	      if (is_homogeneous_fp_aggregate(*p_arg, 8, &element_type)) {
 		int nelements = sz/float_type_size(element_type);
 		if (nelements + fp_reg_num >= 8) {
diff -rNU3 libffi-orig/src/ia64/ffitarget.h libffi/src/ia64/ffitarget.h
--- libffi-orig/src/ia64/ffitarget.h	1970-01-01 01:00:00.000000000 +0100
+++ libffi/src/ia64/ffitarget.h	2003-10-14 14:23:19.000000000 +0200
@@ -0,0 +1,58 @@
+/* -----------------------------------------------------------------*-C-*-
+   ffitarget.h - Copyright (c) 1996-2003  Red Hat, Inc.
+   Target configuration macros for IA-64.
+
+   Permission is hereby granted, free of charge, to any person obtaining
+   a copy of this software and associated documentation files (the
+   ``Software''), to deal in the Software without restriction, including
+   without limitation the rights to use, copy, modify, merge, publish,
+   distribute, sublicense, and/or sell copies of the Software, and to
+   permit persons to whom the Software is furnished to do so, subject to
+   the following conditions:
+
+   The above copyright notice and this permission notice shall be included
+   in all copies or substantial portions of the Software.
+
+   THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
+   OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+   IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+   OTHER DEALINGS IN THE SOFTWARE.
+
+   ----------------------------------------------------------------------- */
+
+#ifndef LIBFFI_TARGET_H
+#define LIBFFI_TARGET_H
+
+#ifndef LIBFFI_ASM
+typedef unsigned long          ffi_arg;
+typedef signed long            ffi_sarg;
+
+typedef enum ffi_abi {
+  FFI_FIRST_ABI = 0,
+  FFI_UNIX,   	/* Linux and all Unix variants use the same conventions	*/
+  FFI_DEFAULT_ABI = FFI_UNIX,
+  FFI_LAST_ABI = FFI_DEFAULT_ABI + 1
+} ffi_abi;
+#endif
+
+/* ---- Definitions for closures ----------------------------------------- */
+
+#define FFI_CLOSURES 1
+#define FFI_TRAMPOLINE_SIZE 24  /* Really the following struct, which 	*/
+				/* can be interpreted as a C function	*/
+				/* descriptor:				*/
+
+#ifndef LIBFFI_ASM
+struct ffi_ia64_trampoline_struct {
+    void * code_pointer;	/* Pointer to ffi_closure_UNIX	*/
+    void * fake_gp;		/* Pointer to closure, installed as gp	*/
+    void * real_gp;		/* Real gp value, reinstalled by 	*/
+				/* ffi_closure_UNIX.			*/
+};
+#endif
+
+#endif
+
diff -rNU3 libffi-orig/src/ia64/unix.S libffi/src/ia64/unix.S
--- libffi-orig/src/ia64/unix.S	2002-04-09 01:59:13.000000000 +0200
+++ libffi/src/ia64/unix.S	2003-10-14 14:23:19.000000000 +0200
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------
-   unix.S - Copyright (c) 1998 Cygnus Solutions
+   unix.S - Copyright (c) 1998 Red Hat, Inc.
             Copyright (c) 2000 Hewlett Packard Company
    
    IA64/unix Foreign Function Interface 
@@ -29,6 +29,7 @@
    ----------------------------------------------------------------------- */
 
 #define LIBFFI_ASM	
+#include <fficonfig.h>
 #include <ffi.h>
 #include "ia64_flags.h"
 
diff -rNU3 libffi-orig/src/java_raw_api.c libffi/src/java_raw_api.c
--- libffi-orig/src/java_raw_api.c	2003-09-04 16:53:26.000000000 +0200
+++ libffi/src/java_raw_api.c	2003-10-14 14:23:19.000000000 +0200
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------
-   java_raw_api.c - Copyright (c) 1999  Cygnus Solutions
+   java_raw_api.c - Copyright (c) 1999  Red Hat, Inc.
 
    Cloned from raw_api.c
 
@@ -54,13 +54,13 @@
 	case FFI_TYPE_UINT64:
 	case FFI_TYPE_SINT64:
 	case FFI_TYPE_DOUBLE:
-	  result += 2 * SIZEOF_ARG;
+	  result += 2 * FFI_SIZEOF_ARG;
 	  break;
 	case FFI_TYPE_STRUCT:
 	  /* No structure parameters in Java.	*/
 	  abort();
 	default:
-	  result += SIZEOF_ARG;
+	  result += FFI_SIZEOF_ARG;
       }
     }
 
@@ -90,7 +90,7 @@
 	  *args = (void*) ((char*)(raw++) + 2);
 	  break;
 
-#if SIZEOF_ARG == 8	  
+#if FFI_SIZEOF_ARG == 8	  
 	case FFI_TYPE_UINT64:
 	case FFI_TYPE_SINT64:
 	case FFI_TYPE_DOUBLE:
@@ -105,7 +105,7 @@
 	  
 	default:
 	  *args = raw;
-	  raw += ALIGN ((*tp)->size, SIZEOF_ARG) / SIZEOF_ARG;
+	  raw += ALIGN ((*tp)->size, FFI_SIZEOF_ARG) / FFI_SIZEOF_ARG;
 	}
     }
 
@@ -116,7 +116,7 @@
   /* then assume little endian */
   for (i = 0; i < cif->nargs; i++, tp++, args++)
     {
-#if SIZEOF_ARG == 8
+#if FFI_SIZEOF_ARG == 8
       switch((*tp)->type) {
 	case FFI_TYPE_UINT64:
 	case FFI_TYPE_SINT64:
@@ -127,10 +127,10 @@
 	default:
 	  *args = (void*) raw++;
       }
-#else /* SIZEOF_ARG != 8 */
+#else /* FFI_SIZEOF_ARG != 8 */
 	*args = (void*) raw;
 	raw += ALIGN ((*tp)->size, sizeof (void*)) / sizeof (void*);
-#endif /* SIZEOF_ARG == 8 */
+#endif /* FFI_SIZEOF_ARG == 8 */
     }
 
 #else
@@ -202,7 +202,7 @@
 	  (raw++)->flt = *(FLOAT32*) (*args);
 	  break;
 
-#if SIZEOF_ARG == 8
+#if FFI_SIZEOF_ARG == 8
 	case FFI_TYPE_UINT64:
 	case FFI_TYPE_SINT64:
 	case FFI_TYPE_DOUBLE:
@@ -216,11 +216,11 @@
 	  break;
 
 	default:
-#if SIZEOF_ARG == 8
+#if FFI_SIZEOF_ARG == 8
 	  FFI_ASSERT(FALSE);	/* Should have covered all cases */
 #else	
 	  memcpy ((void*) raw->data, (void*)*args, (*tp)->size);
-	  raw += ALIGN ((*tp)->size, SIZEOF_ARG) / SIZEOF_ARG;
+	  raw += ALIGN ((*tp)->size, FFI_SIZEOF_ARG) / FFI_SIZEOF_ARG;
 #endif
 	}
     }
@@ -231,7 +231,7 @@
 static void
 ffi_java_rvalue_to_raw (ffi_cif *cif, void *rvalue)
 {
-#if WORDS_BIGENDIAN && SIZEOF_ARG == 8
+#if WORDS_BIGENDIAN && FFI_SIZEOF_ARG == 8
   switch (cif->rtype->type)
     {
     case FFI_TYPE_UINT8:
@@ -256,7 +256,7 @@
 static void
 ffi_java_raw_to_rvalue (ffi_cif *cif, void *rvalue)
 {
-#if WORDS_BIGENDIAN && SIZEOF_ARG == 8
+#if WORDS_BIGENDIAN && FFI_SIZEOF_ARG == 8
   switch (cif->rtype->type)
     {
     case FFI_TYPE_UINT8:
diff -rNU3 libffi-orig/src/m68k/ffitarget.h libffi/src/m68k/ffitarget.h
--- libffi-orig/src/m68k/ffitarget.h	1970-01-01 01:00:00.000000000 +0100
+++ libffi/src/m68k/ffitarget.h	2003-10-14 14:23:19.000000000 +0200
@@ -0,0 +1,47 @@
+/* -----------------------------------------------------------------*-C-*-
+   ffitarget.h - Copyright (c) 1996-2003  Red Hat, Inc.
+   Target configuration macros for Motorola 68K.
+
+   Permission is hereby granted, free of charge, to any person obtaining
+   a copy of this software and associated documentation files (the
+   ``Software''), to deal in the Software without restriction, including
+   without limitation the rights to use, copy, modify, merge, publish,
+   distribute, sublicense, and/or sell copies of the Software, and to
+   permit persons to whom the Software is furnished to do so, subject to
+   the following conditions:
+
+   The above copyright notice and this permission notice shall be included
+   in all copies or substantial portions of the Software.
+
+   THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
+   OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+   IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+   OTHER DEALINGS IN THE SOFTWARE.
+
+   ----------------------------------------------------------------------- */
+
+#ifndef LIBFFI_TARGET_H
+#define LIBFFI_TARGET_H
+
+#ifndef LIBFFI_ASM
+typedef unsigned long          ffi_arg;
+typedef signed long            ffi_sarg;
+
+typedef enum ffi_abi {
+  FFI_FIRST_ABI = 0,
+  FFI_SYSV,
+  FFI_DEFAULT_ABI = FFI_SYSV,
+  FFI_LAST_ABI = FFI_DEFAULT_ABI + 1
+} ffi_abi;
+#endif
+
+/* ---- Definitions for closures ----------------------------------------- */
+
+#define FFI_CLOSURES 0
+#define FFI_NATIVE_RAW_API 0
+
+#endif
+
diff -rNU3 libffi-orig/src/m68k/sysv.S libffi/src/m68k/sysv.S
--- libffi-orig/src/m68k/sysv.S	1999-08-08 15:27:19.000000000 +0200
+++ libffi/src/m68k/sysv.S	2003-10-14 14:23:19.000000000 +0200
@@ -5,6 +5,7 @@
    ----------------------------------------------------------------------- */
 
 #define LIBFFI_ASM	
+#include <fficonfig.h>
 #include <ffi.h>
 
 	.text
diff -rNU3 libffi-orig/src/mips/ffi.c libffi/src/mips/ffi.c
--- libffi-orig/src/mips/ffi.c	2002-07-19 01:08:31.000000000 +0200
+++ libffi/src/mips/ffi.c	2003-10-14 14:23:19.000000000 +0200
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------
-   ffi.c - Copyright (c) 1996 Cygnus Solutions
+   ffi.c - Copyright (c) 1996 Red Hat, Inc.
    
    MIPS Foreign Function Interface 
 
@@ -23,7 +23,6 @@
    OTHER DEALINGS IN THE SOFTWARE.
    ----------------------------------------------------------------------- */
 
-#include <sgidefs.h>
 #include <ffi.h>
 #include <ffi_common.h>
 
@@ -59,8 +58,8 @@
   /* If more than 8 double words are used, the remainder go
      on the stack. We reorder stuff on the stack here to 
      support this easily. */
-  if (bytes > 8 * SIZEOF_ARG)
-    argp = &stack[bytes - (8 * SIZEOF_ARG)];
+  if (bytes > 8 * FFI_SIZEOF_ARG)
+    argp = &stack[bytes - (8 * FFI_SIZEOF_ARG)];
   else
     argp = stack;
 #else
@@ -75,8 +74,8 @@
   if ( ecif->cif->rtype->type == FFI_TYPE_STRUCT )
 #endif  
     {
-      *(SLOT_TYPE_UNSIGNED *) argp = (SLOT_TYPE_UNSIGNED) ecif->rvalue;
-      argp += sizeof(SLOT_TYPE_UNSIGNED);
+      *(ffi_arg *) argp = (ffi_arg) ecif->rvalue;
+      argp += sizeof(ffi_arg);
       FIX_ARGP;
     }
 
@@ -99,9 +98,9 @@
 #endif      
 
 	  z = (*p_arg)->size;
-	  if (z < sizeof(SLOT_TYPE_UNSIGNED))
+	  if (z < sizeof(ffi_arg))
 	    {
-	      z = sizeof(SLOT_TYPE_UNSIGNED);
+	      z = sizeof(ffi_arg);
 
 	      switch ((*p_arg)->type)
 		{
diff -rNU3 libffi-orig/src/mips/ffitarget.h libffi/src/mips/ffitarget.h
--- libffi-orig/src/mips/ffitarget.h	1970-01-01 01:00:00.000000000 +0100
+++ libffi/src/mips/ffitarget.h	2003-10-14 14:23:19.000000000 +0200
@@ -0,0 +1,160 @@
+/* -----------------------------------------------------------------*-C-*-
+   ffitarget.h - Copyright (c) 1996-2003  Red Hat, Inc.
+   Target configuration macros for MIPS.
+
+   Permission is hereby granted, free of charge, to any person obtaining
+   a copy of this software and associated documentation files (the
+   ``Software''), to deal in the Software without restriction, including
+   without limitation the rights to use, copy, modify, merge, publish,
+   distribute, sublicense, and/or sell copies of the Software, and to
+   permit persons to whom the Software is furnished to do so, subject to
+   the following conditions:
+
+   The above copyright notice and this permission notice shall be included
+   in all copies or substantial portions of the Software.
+
+   THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
+   OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+   IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+   OTHER DEALINGS IN THE SOFTWARE.
+
+   ----------------------------------------------------------------------- */
+
+#ifndef LIBFFI_TARGET_H
+#define LIBFFI_TARGET_H
+
+#ifndef LIBFFI_ASM
+#include <sgidefs.h>
+#endif
+
+#if !defined(_MIPS_SIM)
+-- something is very wrong --
+#else
+#  if (_MIPS_SIM==_ABIN32 && defined(_ABIN32)) || (_MIPS_SIM==_ABI64 && defined(_ABI64))
+#    define FFI_MIPS_N32
+#  else
+#    if _MIPS_SIM==_ABIO32 && defined(_ABIO32)
+#      define FFI_MIPS_O32
+#    else
+-- this is an unsupported platform --
+#    endif
+#  endif
+#endif
+
+#ifdef FFI_MIPS_O32
+/* O32 stack frames have 32bit integer args */
+#define FFI_SIZEOF_ARG         4
+#else
+/* N32 and N64 frames have 64bit integer args */
+#define FFI_SIZEOF_ARG         8
+#endif
+
+#define FFI_FLAG_BITS 2
+
+/* SGI's strange assembler requires that we multiply by 4 rather 
+   than shift left by FFI_FLAG_BITS */
+
+#define FFI_ARGS_D   FFI_TYPE_DOUBLE
+#define FFI_ARGS_F   FFI_TYPE_FLOAT
+#define FFI_ARGS_DD  FFI_TYPE_DOUBLE * 4 + FFI_TYPE_DOUBLE
+#define FFI_ARGS_FF  FFI_TYPE_FLOAT * 4 +  FFI_TYPE_FLOAT
+#define FFI_ARGS_FD  FFI_TYPE_DOUBLE * 4 + FFI_TYPE_FLOAT
+#define FFI_ARGS_DF  FFI_TYPE_FLOAT * 4 + FFI_TYPE_DOUBLE
+
+/* Needed for N32 structure returns */
+#define FFI_TYPE_SMALLSTRUCT  FFI_TYPE_UINT8
+#define FFI_TYPE_SMALLSTRUCT2 FFI_TYPE_SINT8
+
+#if 0
+/* The SGI assembler can't handle this.. */
+#define FFI_TYPE_STRUCT_DD (( FFI_ARGS_DD ) << 4) + FFI_TYPE_STRUCT
+/* (and so on) */
+#else
+/* ...so we calculate these by hand! */
+#define FFI_TYPE_STRUCT_D      61
+#define FFI_TYPE_STRUCT_F      45
+#define FFI_TYPE_STRUCT_DD     253
+#define FFI_TYPE_STRUCT_FF     173
+#define FFI_TYPE_STRUCT_FD     237
+#define FFI_TYPE_STRUCT_DF     189
+#define FFI_TYPE_STRUCT_SMALL  93
+#define FFI_TYPE_STRUCT_SMALL2 109
+#endif
+
+#ifdef LIBFFI_ASM
+#define v0 $2
+#define v1 $3
+#define a0 $4
+#define a1 $5
+#define a2 $6
+#define a3 $7
+#define a4 $8		
+#define a5 $9		
+#define a6 $10		
+#define a7 $11		
+#define t0 $8
+#define t1 $9
+#define t2 $10
+#define t3 $11
+#define t4 $12		
+#define t5 $13
+#define t6 $14	
+#define t7 $15
+#define t8 $24
+#define t9 $25
+#define ra $31		
+
+#ifdef FFI_MIPS_O32
+#define REG_L	lw
+#define REG_S	sw
+#define SUBU	subu
+#define ADDU	addu
+#define SRL	srl
+#define LI	li
+#else /* !FFI_MIPS_O32 */
+#define REG_L	ld
+#define REG_S	sd
+#define SUBU	dsubu
+#define ADDU	daddu
+#define SRL	dsrl
+#define LI 	dli
+#endif /* !FFI_MIPS_O32 */
+#else /* !LIBFFI_ASM */
+#ifdef FFI_MIPS_O32
+/* O32 stack frames have 32bit integer args */
+typedef UINT32                 ffi_arg;
+typedef SINT32                 ffi_sarg;
+#else
+/* N32 and N64 frames have 64bit integer args */
+typedef UINT64                 ffi_arg;
+typedef SINT64                 ffi_sarg;
+#endif
+
+typedef enum ffi_abi {
+  FFI_FIRST_ABI = 0,
+  FFI_O32,
+  FFI_N32,
+  FFI_N64,
+
+#ifdef FFI_MIPS_O32
+  FFI_DEFAULT_ABI = FFI_O32,
+#else
+  FFI_DEFAULT_ABI = FFI_N32,
+#endif
+
+  FFI_LAST_ABI = FFI_DEFAULT_ABI + 1
+} ffi_abi;
+
+#define FFI_EXTRA_CIF_FIELDS unsigned rstruct_flag
+#endif /* !LIBFFI_ASM */
+
+/* ---- Definitions for closures ----------------------------------------- */
+
+#define FFI_CLOSURES 0
+#define FFI_NATIVE_RAW_API 0
+
+#endif
+
diff -rNU3 libffi-orig/src/mips/n32.S libffi/src/mips/n32.S
--- libffi-orig/src/mips/n32.S	2001-03-02 23:21:23.000000000 +0100
+++ libffi/src/mips/n32.S	2003-10-14 14:23:19.000000000 +0200
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------
-   n32.S - Copyright (c) 1996, 1998  Cygnus Solutions
+   n32.S - Copyright (c) 1996, 1998  Red Hat, Inc.
    
    MIPS Foreign Function Interface 
 
@@ -24,6 +24,7 @@
    ----------------------------------------------------------------------- */
 
 #define LIBFFI_ASM	
+#include <fficonfig.h>
 #include <ffi.h>
 
 /* Only build this code if we are compiling for n32 */	
@@ -36,7 +37,7 @@
 #define raddr    a4
 #define fn       a5
 
-#define SIZEOF_FRAME	( 8 * SIZEOF_ARG )
+#define SIZEOF_FRAME	( 8 * FFI_SIZEOF_ARG )
 
 	.text
 	.align	2
@@ -46,37 +47,37 @@
 
 	# Prologue
 	SUBU	$sp, SIZEOF_FRAME			# Frame size
-	REG_S	$fp, SIZEOF_FRAME - 2*SIZEOF_ARG($sp)	# Save frame pointer
-	REG_S	ra, SIZEOF_FRAME - 1*SIZEOF_ARG($sp)	# Save return address
+	REG_S	$fp, SIZEOF_FRAME - 2*FFI_SIZEOF_ARG($sp)	# Save frame pointer
+	REG_S	ra, SIZEOF_FRAME - 1*FFI_SIZEOF_ARG($sp)	# Save return address
 	move	$fp, $sp
 
 	move	t9, callback	# callback function pointer
-	REG_S	bytes, 2*SIZEOF_ARG($fp) # bytes
-	REG_S	flags, 3*SIZEOF_ARG($fp) # flags
-	REG_S	raddr, 4*SIZEOF_ARG($fp) # raddr
-	REG_S	fn,    5*SIZEOF_ARG($fp) # fn
+	REG_S	bytes, 2*FFI_SIZEOF_ARG($fp) # bytes
+	REG_S	flags, 3*FFI_SIZEOF_ARG($fp) # flags
+	REG_S	raddr, 4*FFI_SIZEOF_ARG($fp) # raddr
+	REG_S	fn,    5*FFI_SIZEOF_ARG($fp) # fn
 
 	# Allocate at least 4 words in the argstack
 	move	v0, bytes
-	bge	bytes, 4 * SIZEOF_ARG, bigger	
-	LI	v0, 4 * SIZEOF_ARG
+	bge	bytes, 4 * FFI_SIZEOF_ARG, bigger	
+	LI	v0, 4 * FFI_SIZEOF_ARG
 	b	sixteen
 
 	bigger:	
-	ADDU	t4, v0, 2 * SIZEOF_ARG -1	# make sure it is aligned 
-	and	v0, t4, -2 * SIZEOF_ARG		# to a proper boundry.
+	ADDU	t4, v0, 2 * FFI_SIZEOF_ARG -1	# make sure it is aligned 
+	and	v0, t4, -2 * FFI_SIZEOF_ARG		# to a proper boundry.
 
 sixteen:
 	SUBU	$sp, $sp, v0	# move the stack pointer to reflect the
 				# arg space
 
-	ADDU	a0, $sp, 0      # 4 * SIZEOF_ARG
-	ADDU	a3, $fp, 3 * SIZEOF_ARG
+	ADDU	a0, $sp, 0      # 4 * FFI_SIZEOF_ARG
+	ADDU	a3, $fp, 3 * FFI_SIZEOF_ARG
 
 	# Call ffi_prep_args
 	jal	t9
 	
-	#	ADDU	$sp, $sp, 4 * SIZEOF_ARG	# adjust $sp to new args
+	#	ADDU	$sp, $sp, 4 * FFI_SIZEOF_ARG	# adjust $sp to new args
 
 	# Copy the stack pointer to t9
 	move	t9, $sp
@@ -85,10 +86,10 @@
 	# of arguments.
 
 	# Load the number of bytes
-	REG_L	t6, 2*SIZEOF_ARG($fp)
+	REG_L	t6, 2*FFI_SIZEOF_ARG($fp)
 
-	# Is it bigger than 8 * SIZEOF_ARG?
-	dadd	t7, $0, 8 * SIZEOF_ARG
+	# Is it bigger than 8 * FFI_SIZEOF_ARG?
+	dadd	t7, $0, 8 * FFI_SIZEOF_ARG
 	dsub	t8, t6, t7
 	bltz	t8, loadregs
 
@@ -96,125 +97,125 @@
 	
 loadregs:	
 
-	REG_L	t4, 3*SIZEOF_ARG($fp)  # load the flags word
+	REG_L	t4, 3*FFI_SIZEOF_ARG($fp)  # load the flags word
 	add	t6, t4, 0			      # and copy it into t6
 
 	and	t4, ((1<<FFI_FLAG_BITS)-1)
 	bnez	t4, arg1_floatp
-	REG_L	a0, 0*SIZEOF_ARG(t9)
+	REG_L	a0, 0*FFI_SIZEOF_ARG(t9)
 	b	arg1_next
 arg1_floatp:	
 	bne	t4, FFI_TYPE_FLOAT, arg1_doublep
-	l.s	$f12, 0*SIZEOF_ARG(t9)
+	l.s	$f12, 0*FFI_SIZEOF_ARG(t9)
 	b	arg1_next
 arg1_doublep:	
-	l.d	$f12, 0*SIZEOF_ARG(t9)
+	l.d	$f12, 0*FFI_SIZEOF_ARG(t9)
 arg1_next:	
 	
 	add	t4, t6, 0
 	SRL	t4, 1*FFI_FLAG_BITS
 	and	t4, ((1<<FFI_FLAG_BITS)-1)
 	bnez	t4, arg2_floatp
-	REG_L	a1, 1*SIZEOF_ARG(t9)
+	REG_L	a1, 1*FFI_SIZEOF_ARG(t9)
 	b	arg2_next
 arg2_floatp:
 	bne	t4, FFI_TYPE_FLOAT, arg2_doublep
-	l.s	$f13, 1*SIZEOF_ARG(t9)	
+	l.s	$f13, 1*FFI_SIZEOF_ARG(t9)	
 	b	arg2_next
 arg2_doublep:	
-	l.d	$f13, 1*SIZEOF_ARG(t9)	
+	l.d	$f13, 1*FFI_SIZEOF_ARG(t9)	
 arg2_next:	
 	
 	add	t4, t6, 0
 	SRL	t4, 2*FFI_FLAG_BITS
 	and	t4, ((1<<FFI_FLAG_BITS)-1)
 	bnez	t4, arg3_floatp
-	REG_L	a2, 2*SIZEOF_ARG(t9)
+	REG_L	a2, 2*FFI_SIZEOF_ARG(t9)
 	b	arg3_next
 arg3_floatp:
 	bne	t4, FFI_TYPE_FLOAT, arg3_doublep
-	l.s	$f14, 2*SIZEOF_ARG(t9)	
+	l.s	$f14, 2*FFI_SIZEOF_ARG(t9)	
 	b	arg3_next
 arg3_doublep:	
-	l.d	$f14, 2*SIZEOF_ARG(t9)	
+	l.d	$f14, 2*FFI_SIZEOF_ARG(t9)	
 arg3_next:	
 	
 	add	t4, t6, 0
 	SRL	t4, 3*FFI_FLAG_BITS
 	and	t4, ((1<<FFI_FLAG_BITS)-1)
 	bnez	t4, arg4_floatp
-	REG_L	a3, 3*SIZEOF_ARG(t9)
+	REG_L	a3, 3*FFI_SIZEOF_ARG(t9)
 	b	arg4_next
 arg4_floatp:
 	bne	t4, FFI_TYPE_FLOAT, arg4_doublep
-	l.s	$f15, 3*SIZEOF_ARG(t9)	
+	l.s	$f15, 3*FFI_SIZEOF_ARG(t9)	
 	b	arg4_next
 arg4_doublep:	
-	l.d	$f15, 3*SIZEOF_ARG(t9)	
+	l.d	$f15, 3*FFI_SIZEOF_ARG(t9)	
 arg4_next:	
 	
 	add	t4, t6, 0
 	SRL	t4, 4*FFI_FLAG_BITS
 	and	t4, ((1<<FFI_FLAG_BITS)-1)
 	bnez	t4, arg5_floatp
-	REG_L	a4, 4*SIZEOF_ARG(t9)
+	REG_L	a4, 4*FFI_SIZEOF_ARG(t9)
 	b	arg5_next
 arg5_floatp:
 	bne	t4, FFI_TYPE_FLOAT, arg5_doublep
-	l.s	$f16, 4*SIZEOF_ARG(t9)	
+	l.s	$f16, 4*FFI_SIZEOF_ARG(t9)	
 	b	arg5_next
 arg5_doublep:	
-	l.d	$f16, 4*SIZEOF_ARG(t9)	
+	l.d	$f16, 4*FFI_SIZEOF_ARG(t9)	
 arg5_next:	
 	
 	add	t4, t6, 0
 	SRL	t4, 5*FFI_FLAG_BITS
 	and	t4, ((1<<FFI_FLAG_BITS)-1)
 	bnez	t4, arg6_floatp
-	REG_L	a5, 5*SIZEOF_ARG(t9)
+	REG_L	a5, 5*FFI_SIZEOF_ARG(t9)
 	b	arg6_next
 arg6_floatp:
 	bne	t4, FFI_TYPE_FLOAT, arg6_doublep
-	l.s	$f17, 5*SIZEOF_ARG(t9)	
+	l.s	$f17, 5*FFI_SIZEOF_ARG(t9)	
 	b	arg6_next
 arg6_doublep:	
-	l.d	$f17, 5*SIZEOF_ARG(t9)	
+	l.d	$f17, 5*FFI_SIZEOF_ARG(t9)	
 arg6_next:	
 	
 	add	t4, t6, 0
 	SRL	t4, 6*FFI_FLAG_BITS
 	and	t4, ((1<<FFI_FLAG_BITS)-1)
 	bnez	t4, arg7_floatp
-	REG_L	a6, 6*SIZEOF_ARG(t9)
+	REG_L	a6, 6*FFI_SIZEOF_ARG(t9)
 	b	arg7_next
 arg7_floatp:
 	bne	t4, FFI_TYPE_FLOAT, arg7_doublep
-	l.s	$f18, 6*SIZEOF_ARG(t9)	
+	l.s	$f18, 6*FFI_SIZEOF_ARG(t9)	
 	b	arg7_next
 arg7_doublep:	
-	l.d	$f18, 6*SIZEOF_ARG(t9)	
+	l.d	$f18, 6*FFI_SIZEOF_ARG(t9)	
 arg7_next:	
 	
 	add	t4, t6, 0
 	SRL	t4, 7*FFI_FLAG_BITS
 	and	t4, ((1<<FFI_FLAG_BITS)-1)
 	bnez	t4, arg8_floatp
-	REG_L	a7, 7*SIZEOF_ARG(t9)
+	REG_L	a7, 7*FFI_SIZEOF_ARG(t9)
 	b	arg8_next
 arg8_floatp:
 	bne	t4, FFI_TYPE_FLOAT, arg8_doublep
- 	l.s	$f19, 7*SIZEOF_ARG(t9)	
+ 	l.s	$f19, 7*FFI_SIZEOF_ARG(t9)	
 	b	arg8_next
 arg8_doublep:	
- 	l.d	$f19, 7*SIZEOF_ARG(t9)	
+ 	l.d	$f19, 7*FFI_SIZEOF_ARG(t9)	
 arg8_next:	
 
 callit:		
 	# Load the function pointer
-	REG_L	t9, 5*SIZEOF_ARG($fp)
+	REG_L	t9, 5*FFI_SIZEOF_ARG($fp)
 
 	# If the return value pointer is NULL, assume no return value.
-	REG_L	t5, 4*SIZEOF_ARG($fp)
+	REG_L	t5, 4*FFI_SIZEOF_ARG($fp)
 	beqz	t5, noretval
 
 	# Shift the return type flag over
@@ -222,42 +223,42 @@
 	
 	bne     t6, FFI_TYPE_INT, retfloat
 	jal	t9
-	REG_L	t4, 4*SIZEOF_ARG($fp)
+	REG_L	t4, 4*FFI_SIZEOF_ARG($fp)
 	REG_S	v0, 0(t4)
 	b	epilogue
 
 retfloat:
 	bne     t6, FFI_TYPE_FLOAT, retdouble
 	jal	t9
-	REG_L	t4, 4*SIZEOF_ARG($fp)
+	REG_L	t4, 4*FFI_SIZEOF_ARG($fp)
 	s.s	$f0, 0(t4)
 	b	epilogue
 
 retdouble:	
 	bne	t6, FFI_TYPE_DOUBLE, retstruct_d
 	jal	t9
-	REG_L	t4, 4*SIZEOF_ARG($fp)
+	REG_L	t4, 4*FFI_SIZEOF_ARG($fp)
 	s.d	$f0, 0(t4)
 	b	epilogue
 
 retstruct_d:	
 	bne	t6, FFI_TYPE_STRUCT_D, retstruct_f
 	jal	t9
-	REG_L	t4, 4*SIZEOF_ARG($fp)
+	REG_L	t4, 4*FFI_SIZEOF_ARG($fp)
 	s.d	$f0, 0(t4)
 	b	epilogue
 	
 retstruct_f:	
 	bne	t6, FFI_TYPE_STRUCT_F, retstruct_d_d
 	jal	t9
-	REG_L	t4, 4*SIZEOF_ARG($fp)
+	REG_L	t4, 4*FFI_SIZEOF_ARG($fp)
 	s.s	$f0, 0(t4)
 	b	epilogue
 	
 retstruct_d_d:	
 	bne	t6, FFI_TYPE_STRUCT_DD, retstruct_f_f
 	jal	t9
-	REG_L	t4, 4*SIZEOF_ARG($fp)
+	REG_L	t4, 4*FFI_SIZEOF_ARG($fp)
 	s.d	$f0, 0(t4)
 	s.d	$f2, 8(t4)
 	b	epilogue
@@ -265,7 +266,7 @@
 retstruct_f_f:	
 	bne	t6, FFI_TYPE_STRUCT_FF, retstruct_d_f
 	jal	t9
-	REG_L	t4, 4*SIZEOF_ARG($fp)
+	REG_L	t4, 4*FFI_SIZEOF_ARG($fp)
 	s.s	$f0, 0(t4)
 	s.s	$f2, 4(t4)
 	b	epilogue
@@ -273,7 +274,7 @@
 retstruct_d_f:	
 	bne	t6, FFI_TYPE_STRUCT_DF, retstruct_f_d
 	jal	t9
-	REG_L	t4, 4*SIZEOF_ARG($fp)
+	REG_L	t4, 4*FFI_SIZEOF_ARG($fp)
 	s.d	$f0, 0(t4)
 	s.s	$f2, 8(t4)
 	b	epilogue
@@ -281,7 +282,7 @@
 retstruct_f_d:	
 	bne	t6, FFI_TYPE_STRUCT_FD, retstruct_small
 	jal	t9
-	REG_L	t4, 4*SIZEOF_ARG($fp)
+	REG_L	t4, 4*FFI_SIZEOF_ARG($fp)
 	s.s	$f0, 0(t4)
 	s.d	$f2, 8(t4)
 	b	epilogue
@@ -289,14 +290,14 @@
 retstruct_small:	
 	bne	t6, FFI_TYPE_STRUCT_SMALL, retstruct_small2
 	jal	t9
-	REG_L	t4, 4*SIZEOF_ARG($fp)
+	REG_L	t4, 4*FFI_SIZEOF_ARG($fp)
 	REG_S	v0, 0(t4)
 	b	epilogue
 	
 retstruct_small2:	
 	bne	t6, FFI_TYPE_STRUCT_SMALL2, retstruct
 	jal	t9
-	REG_L	t4, 4*SIZEOF_ARG($fp)
+	REG_L	t4, 4*FFI_SIZEOF_ARG($fp)
 	REG_S	v0, 0(t4)
 	REG_S	v1, 8(t4)
 	b	epilogue
@@ -308,8 +309,8 @@
 	# Epilogue
 epilogue:	
 	move	$sp, $fp	
-	REG_L	$fp, SIZEOF_FRAME - 2*SIZEOF_ARG($sp) # Restore frame pointer
-	REG_L	ra, SIZEOF_FRAME - 1*SIZEOF_ARG($sp)  # Restore return address
+	REG_L	$fp, SIZEOF_FRAME - 2*FFI_SIZEOF_ARG($sp) # Restore frame pointer
+	REG_L	ra, SIZEOF_FRAME - 1*FFI_SIZEOF_ARG($sp)  # Restore return address
 	ADDU	$sp, SIZEOF_FRAME		      # Fix stack pointer
 	j	ra
 
diff -rNU3 libffi-orig/src/mips/o32.S libffi/src/mips/o32.S
--- libffi-orig/src/mips/o32.S	2001-03-02 23:21:23.000000000 +0100
+++ libffi/src/mips/o32.S	2003-10-14 14:23:19.000000000 +0200
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------
-   o32.S - Copyright (c) 1996, 1998  Cygnus Solutions
+   o32.S - Copyright (c) 1996, 1998  Red Hat, Inc.
    
    MIPS Foreign Function Interface 
 
@@ -24,6 +24,7 @@
    ----------------------------------------------------------------------- */
 
 #define LIBFFI_ASM	
+#include <fficonfig.h>
 #include <ffi.h>
 
 /* Only build this code if we are compiling for o32 */	
@@ -34,7 +35,7 @@
 #define bytes	 a2
 #define flags	 a3
 		
-#define SIZEOF_FRAME	( 4 * SIZEOF_ARG + 2 * SIZEOF_ARG )
+#define SIZEOF_FRAME	( 4 * FFI_SIZEOF_ARG + 2 * FFI_SIZEOF_ARG )
 
 	.text
 	.align	2
@@ -44,114 +45,114 @@
 
 	# Prologue
 	SUBU	$sp, SIZEOF_FRAME			# Frame size
-	REG_S	$fp, SIZEOF_FRAME - 2*SIZEOF_ARG($sp)	# Save frame pointer
-	REG_S	ra, SIZEOF_FRAME - 1*SIZEOF_ARG($sp)	# Save return address
+	REG_S	$fp, SIZEOF_FRAME - 2*FFI_SIZEOF_ARG($sp)	# Save frame pointer
+	REG_S	ra, SIZEOF_FRAME - 1*FFI_SIZEOF_ARG($sp)	# Save return address
 	move	$fp, $sp
 
 	move	t9, callback	# callback function pointer
-	REG_S	flags, SIZEOF_FRAME + 3*SIZEOF_ARG($fp) # flags
+	REG_S	flags, SIZEOF_FRAME + 3*FFI_SIZEOF_ARG($fp) # flags
 
 	# Allocate at least 4 words in the argstack
 	move	v0, bytes
-	bge	bytes, 4 * SIZEOF_ARG, bigger	
-	LI	v0, 4 * SIZEOF_ARG
+	bge	bytes, 4 * FFI_SIZEOF_ARG, bigger	
+	LI	v0, 4 * FFI_SIZEOF_ARG
 	b	sixteen
 
 bigger:	
-	ADDU	t0, v0, 2 * SIZEOF_ARG -1	# make sure it is aligned 
-	and	v0, t0, -2 * SIZEOF_ARG		# to an 8 byte boundry
+	ADDU	t0, v0, 2 * FFI_SIZEOF_ARG -1	# make sure it is aligned 
+	and	v0, t0, -2 * FFI_SIZEOF_ARG		# to an 8 byte boundry
 
 sixteen:
 	SUBU	$sp, $sp, v0	# move the stack pointer to reflect the
 				# arg space
 
-	ADDU	a0, $sp, 4 * SIZEOF_ARG
-	ADDU	a3, $fp, SIZEOF_FRAME + 3*SIZEOF_ARG
+	ADDU	a0, $sp, 4 * FFI_SIZEOF_ARG
+	ADDU	a3, $fp, SIZEOF_FRAME + 3*FFI_SIZEOF_ARG
 
 	jal	t9
 	
-	REG_L	t0, SIZEOF_FRAME + 3*SIZEOF_ARG($fp)  # load the flags word
+	REG_L	t0, SIZEOF_FRAME + 3*FFI_SIZEOF_ARG($fp)  # load the flags word
 	add	t2, t0, 0			   # and copy it into t2
 
 	and     t0, ((1<<4)-1)          # mask out the return type
 	SRL	t2, 4			# shift our arg info
 		
-	ADDU	$sp, $sp, 4 * SIZEOF_ARG	# adjust $sp to new args
+	ADDU	$sp, $sp, 4 * FFI_SIZEOF_ARG	# adjust $sp to new args
 
 	bnez	t0, pass_d			# make it quick for int
-	REG_L	a0, 0*SIZEOF_ARG($sp)		# just go ahead and load the
-	REG_L	a1, 1*SIZEOF_ARG($sp)		# four regs.
-	REG_L	a2, 2*SIZEOF_ARG($sp)
-	REG_L	a3, 3*SIZEOF_ARG($sp)
+	REG_L	a0, 0*FFI_SIZEOF_ARG($sp)		# just go ahead and load the
+	REG_L	a1, 1*FFI_SIZEOF_ARG($sp)		# four regs.
+	REG_L	a2, 2*FFI_SIZEOF_ARG($sp)
+	REG_L	a3, 3*FFI_SIZEOF_ARG($sp)
 	b	call_it
 
 pass_d:
 	bne	t0, FFI_ARGS_D, pass_f
-	l.d	$f12, 0*SIZEOF_ARG($sp)	# load $fp regs from args
-	REG_L	a2,   2*SIZEOF_ARG($sp)	# passing a double
-	REG_L	a3,   3*SIZEOF_ARG($sp)
+	l.d	$f12, 0*FFI_SIZEOF_ARG($sp)	# load $fp regs from args
+	REG_L	a2,   2*FFI_SIZEOF_ARG($sp)	# passing a double
+	REG_L	a3,   3*FFI_SIZEOF_ARG($sp)
 	b	call_it
 
 pass_f:	
 	bne	t0, FFI_ARGS_F, pass_d_d
-	l.s	$f12, 0*SIZEOF_ARG($sp)	# load $fp regs from args
-	REG_L	a1,   1*SIZEOF_ARG($sp)	# passing a float
-	REG_L	a2,   2*SIZEOF_ARG($sp)
-	REG_L	a3,   3*SIZEOF_ARG($sp)
+	l.s	$f12, 0*FFI_SIZEOF_ARG($sp)	# load $fp regs from args
+	REG_L	a1,   1*FFI_SIZEOF_ARG($sp)	# passing a float
+	REG_L	a2,   2*FFI_SIZEOF_ARG($sp)
+	REG_L	a3,   3*FFI_SIZEOF_ARG($sp)
 	b	call_it		
 
 pass_d_d:		
 	bne	t0, FFI_ARGS_DD, pass_f_f
-	l.d	$f12, 0*SIZEOF_ARG($sp)	# load $fp regs from args
-	l.d	$f14, 2*SIZEOF_ARG($sp)	# passing two doubles
+	l.d	$f12, 0*FFI_SIZEOF_ARG($sp)	# load $fp regs from args
+	l.d	$f14, 2*FFI_SIZEOF_ARG($sp)	# passing two doubles
 	b	call_it
 
 pass_f_f:	
 	bne	t0, FFI_ARGS_FF, pass_d_f
-	l.s	$f12, 0*SIZEOF_ARG($sp)	# load $fp regs from args
-	l.s	$f14, 1*SIZEOF_ARG($sp)	# passing two floats
-	REG_L	a2,   2*SIZEOF_ARG($sp)
-	REG_L	a3,   3*SIZEOF_ARG($sp)
+	l.s	$f12, 0*FFI_SIZEOF_ARG($sp)	# load $fp regs from args
+	l.s	$f14, 1*FFI_SIZEOF_ARG($sp)	# passing two floats
+	REG_L	a2,   2*FFI_SIZEOF_ARG($sp)
+	REG_L	a3,   3*FFI_SIZEOF_ARG($sp)
 	b	call_it
 
 pass_d_f:		
 	bne	t0, FFI_ARGS_DF, pass_f_d
-	l.d	$f12, 0*SIZEOF_ARG($sp)	# load $fp regs from args
-	l.s	$f14, 2*SIZEOF_ARG($sp)	# passing double and float
-	REG_L	a3,   3*SIZEOF_ARG($sp)
+	l.d	$f12, 0*FFI_SIZEOF_ARG($sp)	# load $fp regs from args
+	l.s	$f14, 2*FFI_SIZEOF_ARG($sp)	# passing double and float
+	REG_L	a3,   3*FFI_SIZEOF_ARG($sp)
 	b	call_it
 
 pass_f_d:		
  # assume that the only other combination must be float then double
  #	bne	t0, FFI_ARGS_F_D, call_it
-	l.s	$f12, 0*SIZEOF_ARG($sp)	# load $fp regs from args
-	l.d	$f14, 2*SIZEOF_ARG($sp)	# passing double and float
+	l.s	$f12, 0*FFI_SIZEOF_ARG($sp)	# load $fp regs from args
+	l.d	$f14, 2*FFI_SIZEOF_ARG($sp)	# passing double and float
 
 call_it:	
 	# Load the function pointer
-	REG_L	t9, SIZEOF_FRAME + 5*SIZEOF_ARG($fp)
+	REG_L	t9, SIZEOF_FRAME + 5*FFI_SIZEOF_ARG($fp)
 
 	# If the return value pointer is NULL, assume no return value.
-	REG_L	t1, SIZEOF_FRAME + 4*SIZEOF_ARG($fp)
+	REG_L	t1, SIZEOF_FRAME + 4*FFI_SIZEOF_ARG($fp)
 	beqz	t1, noretval
 
 	bne     t2, FFI_TYPE_INT, retfloat
 	jal	t9
-	REG_L	t0, SIZEOF_FRAME + 4*SIZEOF_ARG($fp)
+	REG_L	t0, SIZEOF_FRAME + 4*FFI_SIZEOF_ARG($fp)
 	REG_S	v0, 0(t0)
 	b	epilogue
 
 retfloat:
 	bne     t2, FFI_TYPE_FLOAT, retdouble
 	jal	t9
-	REG_L	t0, SIZEOF_FRAME + 4*SIZEOF_ARG($fp)
+	REG_L	t0, SIZEOF_FRAME + 4*FFI_SIZEOF_ARG($fp)
 	s.s	$f0, 0(t0)
 	b	epilogue
 
 retdouble:	
 	bne	t2, FFI_TYPE_DOUBLE, noretval
 	jal	t9
-	REG_L	t0, SIZEOF_FRAME + 4*SIZEOF_ARG($fp)
+	REG_L	t0, SIZEOF_FRAME + 4*FFI_SIZEOF_ARG($fp)
 	s.d	$f0, 0(t0)
 	b	epilogue
 	
@@ -161,8 +162,8 @@
 	# Epilogue
 epilogue:	
 	move	$sp, $fp	
-	REG_L	$fp, SIZEOF_FRAME - 2*SIZEOF_ARG($sp) # Restore frame pointer
-	REG_L	ra, SIZEOF_FRAME - 1*SIZEOF_ARG($sp)  # Restore return address
+	REG_L	$fp, SIZEOF_FRAME - 2*FFI_SIZEOF_ARG($sp) # Restore frame pointer
+	REG_L	ra, SIZEOF_FRAME - 1*FFI_SIZEOF_ARG($sp)  # Restore return address
 	ADDU	$sp, SIZEOF_FRAME		      # Fix stack pointer
 	j	ra
 
diff -rNU3 libffi-orig/src/powerpc/aix.S libffi/src/powerpc/aix.S
--- libffi-orig/src/powerpc/aix.S	2003-09-18 22:53:19.000000000 +0200
+++ libffi/src/powerpc/aix.S	2003-10-14 14:23:19.000000000 +0200
@@ -80,6 +80,7 @@
         .set f21,21
 
 #define LIBFFI_ASM	
+#include <fficonfig.h>
 #include <ffi.h>
 #define JUMPTARGET(name) name
 #define L(x) x
diff -rNU3 libffi-orig/src/powerpc/darwin.S libffi/src/powerpc/darwin.S
--- libffi-orig/src/powerpc/darwin.S	2003-09-18 21:35:46.000000000 +0200
+++ libffi/src/powerpc/darwin.S	2003-10-14 14:23:19.000000000 +0200
@@ -24,6 +24,7 @@
    ----------------------------------------------------------------------- */
 
 #define LIBFFI_ASM
+#include <fficonfig.h>
 #include <ffi.h>
 #define JUMPTARGET(name) name
 #define L(x) x
diff -rNU3 libffi-orig/src/powerpc/ffi_darwin.c libffi/src/powerpc/ffi_darwin.c
--- libffi-orig/src/powerpc/ffi_darwin.c	2003-09-18 21:35:46.000000000 +0200
+++ libffi/src/powerpc/ffi_darwin.c	2003-10-14 14:23:19.000000000 +0200
@@ -25,6 +25,7 @@
    ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
    OTHER DEALINGS IN THE SOFTWARE.
    ----------------------------------------------------------------------- */
+
 #include <ffi.h>
 #include <ffi_common.h>
 
diff -rNU3 libffi-orig/src/powerpc/ffitarget.h libffi/src/powerpc/ffitarget.h
--- libffi-orig/src/powerpc/ffitarget.h	1970-01-01 01:00:00.000000000 +0100
+++ libffi/src/powerpc/ffitarget.h	2003-10-14 14:23:19.000000000 +0200
@@ -0,0 +1,91 @@
+/* -----------------------------------------------------------------*-C-*-
+   ffitarget.h - Copyright (c) 1996-2003  Red Hat, Inc.
+   Target configuration macros for PowerPC.
+
+   Permission is hereby granted, free of charge, to any person obtaining
+   a copy of this software and associated documentation files (the
+   ``Software''), to deal in the Software without restriction, including
+   without limitation the rights to use, copy, modify, merge, publish,
+   distribute, sublicense, and/or sell copies of the Software, and to
+   permit persons to whom the Software is furnished to do so, subject to
+   the following conditions:
+
+   The above copyright notice and this permission notice shall be included
+   in all copies or substantial portions of the Software.
+
+   THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
+   OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+   IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+   OTHER DEALINGS IN THE SOFTWARE.
+
+   ----------------------------------------------------------------------- */
+
+#ifndef LIBFFI_TARGET_H
+#define LIBFFI_TARGET_H
+
+/* ---- System specific configurations ----------------------------------- */
+
+#if defined (POWERPC) && defined (__powerpc64__)
+#define POWERPC64
+#endif
+
+#ifndef LIBFFI_ASM
+typedef unsigned long          ffi_arg;
+typedef signed long            ffi_sarg;
+
+typedef enum ffi_abi {
+  FFI_FIRST_ABI = 0,
+
+#ifdef POWERPC
+  FFI_SYSV,
+  FFI_GCC_SYSV,
+  FFI_LINUX64,
+# ifdef POWERPC64
+  FFI_DEFAULT_ABI = FFI_LINUX64,
+# else
+  FFI_DEFAULT_ABI = FFI_GCC_SYSV,
+# endif
+#endif
+
+#ifdef POWERPC_AIX
+  FFI_AIX,
+  FFI_DARWIN,
+  FFI_DEFAULT_ABI = FFI_AIX,
+#endif
+
+#ifdef POWERPC_DARWIN
+  FFI_AIX,
+  FFI_DARWIN,
+  FFI_DEFAULT_ABI = FFI_DARWIN,
+#endif
+
+  FFI_LAST_ABI = FFI_DEFAULT_ABI + 1
+} ffi_abi;
+#endif
+
+/* ---- Definitions for closures ----------------------------------------- */
+
+#define FFI_CLOSURES 1
+#define FFI_NATIVE_RAW_API 0
+
+#if defined(POWERPC64) || defined(POWERPC_AIX)
+#define FFI_TRAMPOLINE_SIZE 24
+#else /* POWERPC || POWERPC_AIX */
+#define FFI_TRAMPOLINE_SIZE 40
+#endif
+
+#ifndef LIBFFI_ASM
+#if defined(POWERPC_DARWIN) || defined(POWERPC_AIX)
+struct ffi_aix_trampoline_struct {
+    void * code_pointer;	/* Pointer to ffi_closure_ASM */
+    void * toc;			/* TOC */
+    void * static_chain;	/* Pointer to closure */
+};
+#endif
+#endif
+
+#endif
+
diff -rNU3 libffi-orig/src/powerpc/linux64.S libffi/src/powerpc/linux64.S
--- libffi-orig/src/powerpc/linux64.S	2003-09-11 07:17:57.000000000 +0200
+++ libffi/src/powerpc/linux64.S	2003-10-14 14:23:19.000000000 +0200
@@ -24,6 +24,7 @@
    ----------------------------------------------------------------------- */
 
 #define LIBFFI_ASM	
+#include <fficonfig.h>
 #include <ffi.h>
 
 #ifdef __powerpc64__
diff -rNU3 libffi-orig/src/powerpc/linux64_closure.S libffi/src/powerpc/linux64_closure.S
--- libffi-orig/src/powerpc/linux64_closure.S	2003-09-12 01:54:40.000000000 +0200
+++ libffi/src/powerpc/linux64_closure.S	2003-10-14 14:23:19.000000000 +0200
@@ -1,4 +1,5 @@
 #define LIBFFI_ASM
+#include <fficonfig.h>
 #include <ffi.h>
 
 	.file	"linux64_closure.S"
diff -rNU3 libffi-orig/src/powerpc/ppc_closure.S libffi/src/powerpc/ppc_closure.S
--- libffi-orig/src/powerpc/ppc_closure.S	2003-06-19 13:55:56.000000000 +0200
+++ libffi/src/powerpc/ppc_closure.S	2003-10-14 14:23:19.000000000 +0200
@@ -1,4 +1,5 @@
 #define LIBFFI_ASM
+#include <fficonfig.h>
 #include <ffi.h>
 #include <powerpc/asm.h>
 
diff -rNU3 libffi-orig/src/powerpc/sysv.S libffi/src/powerpc/sysv.S
--- libffi-orig/src/powerpc/sysv.S	2003-05-17 00:09:21.000000000 +0200
+++ libffi/src/powerpc/sysv.S	2003-10-14 14:23:19.000000000 +0200
@@ -26,6 +26,7 @@
    ----------------------------------------------------------------------- */
 
 #define LIBFFI_ASM	
+#include <fficonfig.h>
 #include <ffi.h>
 #include <powerpc/asm.h>
 
diff -rNU3 libffi-orig/src/prep_cif.c libffi/src/prep_cif.c
--- libffi-orig/src/prep_cif.c	2003-09-12 01:54:40.000000000 +0200
+++ libffi/src/prep_cif.c	2003-10-14 14:23:19.000000000 +0200
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------
-   prep_cif.c - Copyright (c) 1996, 1998  Cygnus Solutions
+   prep_cif.c - Copyright (c) 1996, 1998  Red Hat, Inc.
 
    Permission is hereby granted, free of charge, to any person obtaining
    a copy of this software and associated documentation files (the
@@ -26,9 +26,9 @@
 #include <stdlib.h>
 
 
-/* Round up to SIZEOF_ARG. */
+/* Round up to FFI_SIZEOF_ARG. */
 
-#define STACK_ARG_SIZE(x) ALIGN(x, SIZEOF_ARG)
+#define STACK_ARG_SIZE(x) ALIGN(x, FFI_SIZEOF_ARG)
 
 /* Perform machine independent initialization of aggregate type
    specifications. */
@@ -53,7 +53,7 @@
 	return FFI_BAD_TYPEDEF;
       
       /* Perform a sanity check on the argument type */
-      FFI_ASSERT(ffi_type_test((*ptr)));
+      FFI_ASSERT_VALID_TYPE(*ptr);
 
       arg->size = ALIGN(arg->size, (*ptr)->alignment);
       arg->size += (*ptr)->size;
@@ -94,7 +94,7 @@
   ffi_type **ptr;
 
   FFI_ASSERT(cif != NULL);
-  FFI_ASSERT((abi > FFI_FIRST_ABI) && (abi < FFI_LAST_ABI));
+  FFI_ASSERT((abi > FFI_FIRST_ABI) && (abi <= FFI_DEFAULT_ABI));
 
   cif->abi = abi;
   cif->arg_types = atypes;
@@ -110,7 +110,7 @@
   /*@=usedef@*/
 
   /* Perform a sanity check on the return type */
-  FFI_ASSERT(ffi_type_test(cif->rtype));
+  FFI_ASSERT_VALID_TYPE(cif->rtype);
 
   /* x86-64 and s390 stack space allocation is handled in prep_machdep.  */
 #if !defined M68K && !defined __x86_64__ && !defined S390
@@ -126,7 +126,7 @@
   for (ptr = cif->arg_types, i = cif->nargs; i > 0; i--, ptr++)
     {
       /* Perform a sanity check on the argument type */
-      FFI_ASSERT(ffi_type_test(*ptr));
+      FFI_ASSERT_VALID_TYPE(*ptr);
 
       /* Initialize any uninitialized aggregate type definitions */
       if (((*ptr)->size == 0) && (initialize_aggregate((*ptr)) != FFI_OK))
diff -rNU3 libffi-orig/src/raw_api.c libffi/src/raw_api.c
--- libffi-orig/src/raw_api.c	2000-02-25 20:13:44.000000000 +0100
+++ libffi/src/raw_api.c	2003-10-14 14:23:19.000000000 +0200
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------
-   raw_api.c - Copyright (c) 1999  Cygnus Solutions
+   raw_api.c - Copyright (c) 1999  Red Hat, Inc.
 
    Author: Kresten Krab Thorup <krab@gnu.org>
 
@@ -44,10 +44,10 @@
     {
 #if !FFI_NO_STRUCTS
       if ((*at)->type == FFI_TYPE_STRUCT)
-	result += ALIGN (sizeof (void*), SIZEOF_ARG);
+	result += ALIGN (sizeof (void*), FFI_SIZEOF_ARG);
       else
 #endif
-	result += ALIGN ((*at)->size, SIZEOF_ARG);
+	result += ALIGN ((*at)->size, FFI_SIZEOF_ARG);
     }
 
   return result;
@@ -68,18 +68,18 @@
 	{
 	case FFI_TYPE_UINT8:
 	case FFI_TYPE_SINT8:
-	  *args = (void*) ((char*)(raw++) + SIZEOF_ARG - 1);
+	  *args = (void*) ((char*)(raw++) + FFI_SIZEOF_ARG - 1);
 	  break;
 	  
 	case FFI_TYPE_UINT16:
 	case FFI_TYPE_SINT16:
-	  *args = (void*) ((char*)(raw++) + SIZEOF_ARG - 2);
+	  *args = (void*) ((char*)(raw++) + FFI_SIZEOF_ARG - 2);
 	  break;
 
-#if SIZEOF_ARG >= 4	  
+#if FFI_SIZEOF_ARG >= 4	  
 	case FFI_TYPE_UINT32:
 	case FFI_TYPE_SINT32:
-	  *args = (void*) ((char*)(raw++) + SIZEOF_ARG - 4);
+	  *args = (void*) ((char*)(raw++) + FFI_SIZEOF_ARG - 4);
 	  break;
 #endif
 	
@@ -95,7 +95,7 @@
 	  
 	default:
 	  *args = raw;
-	  raw += ALIGN ((*tp)->size, SIZEOF_ARG) / SIZEOF_ARG;
+	  raw += ALIGN ((*tp)->size, FFI_SIZEOF_ARG) / FFI_SIZEOF_ARG;
 	}
     }
 
@@ -152,7 +152,7 @@
 	  (raw++)->sint = *(SINT16*) (*args);
 	  break;
 
-#if SIZEOF_ARG >= 4
+#if FFI_SIZEOF_ARG >= 4
 	case FFI_TYPE_UINT32:
 	  (raw++)->uint = *(UINT32*) (*args);
 	  break;
@@ -174,7 +174,7 @@
 
 	default:
 	  memcpy ((void*) raw->data, (void*)*args, (*tp)->size);
-	  raw += ALIGN ((*tp)->size, SIZEOF_ARG) / SIZEOF_ARG;
+	  raw += ALIGN ((*tp)->size, FFI_SIZEOF_ARG) / FFI_SIZEOF_ARG;
 	}
     }
 }
diff -rNU3 libffi-orig/src/s390/ffitarget.h libffi/src/s390/ffitarget.h
--- libffi-orig/src/s390/ffitarget.h	1970-01-01 01:00:00.000000000 +0100
+++ libffi/src/s390/ffitarget.h	2003-10-14 14:23:19.000000000 +0200
@@ -0,0 +1,59 @@
+/* -----------------------------------------------------------------*-C-*-
+   ffitarget.h - Copyright (c) 1996-2003  Red Hat, Inc.
+   Target configuration macros for S390.
+
+   Permission is hereby granted, free of charge, to any person obtaining
+   a copy of this software and associated documentation files (the
+   ``Software''), to deal in the Software without restriction, including
+   without limitation the rights to use, copy, modify, merge, publish,
+   distribute, sublicense, and/or sell copies of the Software, and to
+   permit persons to whom the Software is furnished to do so, subject to
+   the following conditions:
+
+   The above copyright notice and this permission notice shall be included
+   in all copies or substantial portions of the Software.
+
+   THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
+   OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+   IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+   OTHER DEALINGS IN THE SOFTWARE.
+
+   ----------------------------------------------------------------------- */
+
+#ifndef LIBFFI_TARGET_H
+#define LIBFFI_TARGET_H
+
+#if defined (__s390x__)
+#define S390X
+#endif
+
+/* ---- System specific configurations ----------------------------------- */
+
+#ifndef LIBFFI_ASM
+typedef unsigned long          ffi_arg;
+typedef signed long            ffi_sarg;
+
+typedef enum ffi_abi {
+  FFI_FIRST_ABI = 0,
+  FFI_SYSV,
+  FFI_DEFAULT_ABI = FFI_SYSV,
+  FFI_LAST_ABI = FFI_DEFAULT_ABI + 1
+} ffi_abi;
+#endif
+
+
+/* ---- Definitions for closures ----------------------------------------- */
+
+#define FFI_CLOSURES 1
+#ifdef S390X
+#define FFI_TRAMPOLINE_SIZE 32
+#else
+#define FFI_TRAMPOLINE_SIZE 16
+#endif
+#define FFI_NATIVE_RAW_API 0
+
+#endif
+
diff -rNU3 libffi-orig/src/s390/sysv.S libffi/src/s390/sysv.S
--- libffi-orig/src/s390/sysv.S	2003-05-17 00:09:21.000000000 +0200
+++ libffi/src/s390/sysv.S	2003-10-14 14:23:19.000000000 +0200
@@ -24,6 +24,7 @@
    ----------------------------------------------------------------------- */
 
 #define LIBFFI_ASM
+#include <fficonfig.h>
 #include <ffi.h>
 
 #ifndef __s390x__
diff -rNU3 libffi-orig/src/sh/ffitarget.h libffi/src/sh/ffitarget.h
--- libffi-orig/src/sh/ffitarget.h	1970-01-01 01:00:00.000000000 +0100
+++ libffi/src/sh/ffitarget.h	2003-10-14 14:23:19.000000000 +0200
@@ -0,0 +1,48 @@
+/* -----------------------------------------------------------------*-C-*-
+   ffitarget.h - Copyright (c) 1996-2003  Red Hat, Inc.
+   Target configuration macros for SuperH.
+
+   Permission is hereby granted, free of charge, to any person obtaining
+   a copy of this software and associated documentation files (the
+   ``Software''), to deal in the Software without restriction, including
+   without limitation the rights to use, copy, modify, merge, publish,
+   distribute, sublicense, and/or sell copies of the Software, and to
+   permit persons to whom the Software is furnished to do so, subject to
+   the following conditions:
+
+   The above copyright notice and this permission notice shall be included
+   in all copies or substantial portions of the Software.
+
+   THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
+   OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+   IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+   OTHER DEALINGS IN THE SOFTWARE.
+
+   ----------------------------------------------------------------------- */
+
+#ifndef LIBFFI_TARGET_H
+#define LIBFFI_TARGET_H
+
+/* ---- Generic type definitions ----------------------------------------- */
+
+#ifndef LIBFFI_ASM
+typedef unsigned long          ffi_arg;
+typedef signed long            ffi_sarg;
+
+typedef enum ffi_abi {
+  FFI_FIRST_ABI = 0,
+  FFI_SYSV,
+  FFI_DEFAULT_ABI = FFI_SYSV,
+  FFI_LAST_ABI = FFI_DEFAULT_ABI + 1
+} ffi_abi;
+#endif
+
+#define FFI_CLOSURES 1
+#define FFI_TRAMPOLINE_SIZE 16
+#define FFI_NATIVE_RAW_API 0
+
+#endif
+
diff -rNU3 libffi-orig/src/sh/sysv.S libffi/src/sh/sysv.S
--- libffi-orig/src/sh/sysv.S	2003-09-18 16:08:20.000000000 +0200
+++ libffi/src/sh/sysv.S	2003-10-14 14:23:19.000000000 +0200
@@ -24,6 +24,7 @@
    ----------------------------------------------------------------------- */
 
 #define LIBFFI_ASM	
+#include <fficonfig.h>
 #include <ffi.h>
 #ifdef HAVE_MACHINE_ASM_H
 #include <machine/asm.h>
diff -rNU3 libffi-orig/src/sh64/ffitarget.h libffi/src/sh64/ffitarget.h
--- libffi-orig/src/sh64/ffitarget.h	1970-01-01 01:00:00.000000000 +0100
+++ libffi/src/sh64/ffitarget.h	2003-10-14 14:23:19.000000000 +0200
@@ -0,0 +1,52 @@
+/* -----------------------------------------------------------------*-C-*-
+   ffitarget.h - Copyright (c) 1996-2003  Red Hat, Inc.
+   Target configuration macros for SuperH - SHmedia.
+
+   Permission is hereby granted, free of charge, to any person obtaining
+   a copy of this software and associated documentation files (the
+   ``Software''), to deal in the Software without restriction, including
+   without limitation the rights to use, copy, modify, merge, publish,
+   distribute, sublicense, and/or sell copies of the Software, and to
+   permit persons to whom the Software is furnished to do so, subject to
+   the following conditions:
+
+   The above copyright notice and this permission notice shall be included
+   in all copies or substantial portions of the Software.
+
+   THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
+   OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+   IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+   OTHER DEALINGS IN THE SOFTWARE.
+
+   ----------------------------------------------------------------------- */
+
+#ifndef LIBFFI_TARGET_H
+#define LIBFFI_TARGET_H
+
+/* ---- Generic type definitions ----------------------------------------- */
+
+#ifndef LIBFFI_ASM
+typedef unsigned long          ffi_arg;
+typedef signed long            ffi_sarg;
+
+typedef enum ffi_abi {
+  FFI_FIRST_ABI = 0,
+  FFI_SYSV,
+  FFI_DEFAULT_ABI = FFI_SYSV,
+  FFI_LAST_ABI = FFI_DEFAULT_ABI + 1
+} ffi_abi;
+
+#define FFI_EXTRA_CIF_FIELDS long long flags2
+#endif
+
+/* ---- Definitions for closures ----------------------------------------- */
+
+#define FFI_CLOSURES 1
+#define FFI_TRAMPOLINE_SIZE 32
+#define FFI_NATIVE_RAW_API 0
+
+#endif
+
diff -rNU3 libffi-orig/src/sh64/sysv.S libffi/src/sh64/sysv.S
--- libffi-orig/src/sh64/sysv.S	2003-06-13 04:23:26.000000000 +0200
+++ libffi/src/sh64/sysv.S	2003-10-14 14:23:19.000000000 +0200
@@ -24,6 +24,7 @@
    ----------------------------------------------------------------------- */
 
 #define LIBFFI_ASM	
+#include <fficonfig.h>
 #include <ffi.h>
 #ifdef HAVE_MACHINE_ASM_H
 #include <machine/asm.h>
diff -rNU3 libffi-orig/src/sparc/ffi.c libffi/src/sparc/ffi.c
--- libffi-orig/src/sparc/ffi.c	2003-07-30 06:04:24.000000000 +0200
+++ libffi/src/sparc/ffi.c	2003-10-14 14:23:19.000000000 +0200
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------
-   ffi.c - Copyright (c) 1996, 2003 Cygnus Solutions
+   ffi.c - Copyright (c) 1996, 2003 Red Hat, Inc.
    
    Sparc Foreign Function Interface 
 
@@ -491,7 +491,7 @@
   while (i < avn)
     {
       /* Assume big-endian.  FIXME */
-      argn += ALIGN(arg_types[i]->size, SIZEOF_ARG) / SIZEOF_ARG;
+      argn += ALIGN(arg_types[i]->size, FFI_SIZEOF_ARG) / FFI_SIZEOF_ARG;
 
 #ifdef SPARC64
       if (i < 16 && (arg_types[i]->type == FFI_TYPE_FLOAT
diff -rNU3 libffi-orig/src/sparc/ffitarget.h libffi/src/sparc/ffitarget.h
--- libffi-orig/src/sparc/ffitarget.h	1970-01-01 01:00:00.000000000 +0100
+++ libffi/src/sparc/ffitarget.h	2003-10-14 14:23:19.000000000 +0200
@@ -0,0 +1,65 @@
+/* -----------------------------------------------------------------*-C-*-
+   ffitarget.h - Copyright (c) 1996-2003  Red Hat, Inc.
+   Target configuration macros for SPARC.
+
+   Permission is hereby granted, free of charge, to any person obtaining
+   a copy of this software and associated documentation files (the
+   ``Software''), to deal in the Software without restriction, including
+   without limitation the rights to use, copy, modify, merge, publish,
+   distribute, sublicense, and/or sell copies of the Software, and to
+   permit persons to whom the Software is furnished to do so, subject to
+   the following conditions:
+
+   The above copyright notice and this permission notice shall be included
+   in all copies or substantial portions of the Software.
+
+   THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
+   OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+   IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+   OTHER DEALINGS IN THE SOFTWARE.
+
+   ----------------------------------------------------------------------- */
+
+#ifndef LIBFFI_TARGET_H
+#define LIBFFI_TARGET_H
+
+/* ---- System specific configurations ----------------------------------- */
+
+#if defined(__arch64__) || defined(__sparcv9)
+#define SPARC64
+#endif
+
+#ifndef LIBFFI_ASM
+typedef unsigned long          ffi_arg;
+typedef signed long            ffi_sarg;
+
+typedef enum ffi_abi {
+  FFI_FIRST_ABI = 0,
+  FFI_V8,
+  FFI_V8PLUS,
+  FFI_V9,
+#ifdef SPARC64
+  FFI_DEFAULT_ABI = FFI_V9,
+#else
+  FFI_DEFAULT_ABI = FFI_V8,
+#endif
+  FFI_LAST_ABI = FFI_DEFAULT_ABI + 1
+} ffi_abi;
+#endif
+
+/* ---- Definitions for closures ----------------------------------------- */
+
+#define FFI_CLOSURES 1
+#define FFI_NATIVE_RAW_API 0
+
+#ifdef SPARC64
+#define FFI_TRAMPOLINE_SIZE 24
+#else
+#define FFI_TRAMPOLINE_SIZE 16
+#endif
+
+#endif
+
diff -rNU3 libffi-orig/src/sparc/v8.S libffi/src/sparc/v8.S
--- libffi-orig/src/sparc/v8.S	2003-05-17 00:09:22.000000000 +0200
+++ libffi/src/sparc/v8.S	2003-10-14 14:23:19.000000000 +0200
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------
-   v8.S - Copyright (c) 1996, 1997, 2003 Cygnus Solutions
+   v8.S - Copyright (c) 1996, 1997, 2003 Red Hat, Inc.
    
    Sparc Foreign Function Interface 
 
@@ -24,6 +24,7 @@
    ----------------------------------------------------------------------- */
 
 #define LIBFFI_ASM	
+#include <fficonfig.h>
 #include <ffi.h>
 
 #define STACKFRAME 96		/* Minimum stack framesize for SPARC */
diff -rNU3 libffi-orig/src/sparc/v9.S libffi/src/sparc/v9.S
--- libffi-orig/src/sparc/v9.S	2003-07-30 06:04:24.000000000 +0200
+++ libffi/src/sparc/v9.S	2003-10-14 14:23:19.000000000 +0200
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------
-   v9.S - Copyright (c) 2000, 2003 Cygnus Solutions
+   v9.S - Copyright (c) 2000, 2003 Red Hat, Inc.
    
    Sparc 64bit Foreign Function Interface 
 
@@ -24,6 +24,7 @@
    ----------------------------------------------------------------------- */
 
 #define LIBFFI_ASM	
+#include <fficonfig.h>
 #include <ffi.h>
 
 #ifdef SPARC64
diff -rNU3 libffi-orig/src/types.c libffi/src/types.c
--- libffi-orig/src/types.c	2003-10-13 18:37:44.000000000 +0200
+++ libffi/src/types.c	2003-10-14 14:23:19.000000000 +0200
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------
-   types.c - Copyright (c) 1996, 1998  Cygnus Solutions
+   types.c - Copyright (c) 1996, 1998  Red Hat, Inc.
    
    Predefined ffi_types needed by libffi.
 
diff -rNU3 libffi-orig/src/x86/ffi64.c libffi/src/x86/ffi64.c
--- libffi-orig/src/x86/ffi64.c	2003-01-28 16:54:28.000000000 +0100
+++ libffi/src/x86/ffi64.c	2003-10-14 14:23:19.000000000 +0200
@@ -689,7 +689,7 @@
 	  FFI_ASSERT(0);
 	}
 
-      argn += ALIGN(arg_types[i]->size, SIZEOF_ARG) / SIZEOF_ARG;
+      argn += ALIGN(arg_types[i]->size, FFI_SIZEOF_ARG) / FFI_SIZEOF_ARG;
       i++;
     }
 
diff -rNU3 libffi-orig/src/x86/ffitarget.h libffi/src/x86/ffitarget.h
--- libffi-orig/src/x86/ffitarget.h	1970-01-01 01:00:00.000000000 +0100
+++ libffi/src/x86/ffitarget.h	2003-10-14 14:23:19.000000000 +0200
@@ -0,0 +1,81 @@
+/* -----------------------------------------------------------------*-C-*-
+   ffitarget.h - Copyright (c) 1996-2003  Red Hat, Inc.
+   Target configuration macros for x86 and x86-64.
+
+   Permission is hereby granted, free of charge, to any person obtaining
+   a copy of this software and associated documentation files (the
+   ``Software''), to deal in the Software without restriction, including
+   without limitation the rights to use, copy, modify, merge, publish,
+   distribute, sublicense, and/or sell copies of the Software, and to
+   permit persons to whom the Software is furnished to do so, subject to
+   the following conditions:
+
+   The above copyright notice and this permission notice shall be included
+   in all copies or substantial portions of the Software.
+
+   THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
+   OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+   IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+   OTHER DEALINGS IN THE SOFTWARE.
+
+   ----------------------------------------------------------------------- */
+
+#ifndef LIBFFI_TARGET_H
+#define LIBFFI_TARGET_H
+
+/* ---- System specific configurations ----------------------------------- */
+
+#if defined (X86_64) && defined (__i386__)
+#undef X86_64
+#define X86
+#endif
+
+/* ---- Generic type definitions ----------------------------------------- */
+
+#ifndef LIBFFI_ASM
+typedef unsigned long          ffi_arg;
+typedef signed long            ffi_sarg;
+
+typedef enum ffi_abi {
+  FFI_FIRST_ABI = 0,
+
+  /* ---- Intel x86 Win32 ---------- */
+#ifdef X86_WIN32
+  FFI_SYSV,
+  FFI_STDCALL,
+  /* TODO: Add fastcall support for the sake of completeness */
+  FFI_DEFAULT_ABI = FFI_SYSV,
+#endif
+
+  /* ---- Intel x86 and AMD x86-64 - */
+#if !defined(X86_WIN32) && (defined(__i386__) || defined(__x86_64__))
+  FFI_SYSV,
+  FFI_UNIX64,   /* Unix variants all use the same ABI for x86-64  */
+#ifdef __i386__
+  FFI_DEFAULT_ABI = FFI_SYSV,
+#else
+  FFI_DEFAULT_ABI = FFI_UNIX64,
+#endif
+#endif
+
+  FFI_LAST_ABI = FFI_DEFAULT_ABI + 1
+} ffi_abi;
+#endif
+
+/* ---- Definitions for closures ----------------------------------------- */
+
+#define FFI_CLOSURES 1
+
+#ifdef X86_64
+#define FFI_TRAMPOLINE_SIZE 24
+#define FFI_NATIVE_RAW_API 0
+#else
+#define FFI_TRAMPOLINE_SIZE 10
+#define FFI_NATIVE_RAW_API 1	/* x86 has native raw api support */
+#endif
+
+#endif
+
diff -rNU3 libffi-orig/src/x86/sysv.S libffi/src/x86/sysv.S
--- libffi-orig/src/x86/sysv.S	2003-06-13 13:59:53.000000000 +0200
+++ libffi/src/x86/sysv.S	2003-10-14 14:23:19.000000000 +0200
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------
-   sysv.S - Copyright (c) 1996, 1998, 2001, 2002, 2003  Cygnus Solutions
+   sysv.S - Copyright (c) 1996, 1998, 2001, 2002, 2003  Red Hat, Inc.
    
    X86 Foreign Function Interface 
 
@@ -26,6 +26,7 @@
 #ifndef __x86_64__
 
 #define LIBFFI_ASM	
+#include <fficonfig.h>
 #include <ffi.h>
 
 .text
diff -rNU3 libffi-orig/src/x86/unix64.S libffi/src/x86/unix64.S
--- libffi-orig/src/x86/unix64.S	2003-05-17 00:09:22.000000000 +0200
+++ libffi/src/x86/unix64.S	2003-10-14 14:23:19.000000000 +0200
@@ -25,6 +25,7 @@
 
 #ifdef __x86_64__
 #define LIBFFI_ASM	
+#include <fficonfig.h>
 #include <ffi.h>
 
 	.section	.rodata
diff -rNU3 libffi-orig/src/x86/win32.S libffi/src/x86/win32.S
--- libffi-orig/src/x86/win32.S	2002-12-06 02:16:45.000000000 +0100
+++ libffi/src/x86/win32.S	2003-10-14 14:23:19.000000000 +0200
@@ -27,6 +27,7 @@
    ----------------------------------------------------------------------- */
  
 #define LIBFFI_ASM
+#include <fficonfig.h>
 #include <ffi.h>
  
 .text

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]