patches/gcc/3.2.3/140-libffi-1.patch
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Mon Jul 28 21:08:01 2008 +0000 (2008-07-28)
changeset 746 b150d6f590fc
parent 402 patches/gcc/3.2.3/140-gcc-3.2.3-libffi-1.patch@197e1b49586e
permissions -rw-r--r--
Third go at renaming patches to contain neither the package name nor the package version.
     1 diff -ruN --exclude=CVS gcc-3.2.2.orig/libffi/Makefile.am gcc/libffi/Makefile.am
     2 --- gcc-3.2.2.orig/libffi/Makefile.am	Tue Jan 28 10:43:56 2003
     3 +++ gcc/libffi/Makefile.am	Tue Jan 28 10:48:33 2003
     4 @@ -8,14 +8,17 @@
     5  		src/mips/n32.s src/mips/o32.S src/mips/o32.s \
     6  		src/sparc/ffi.c src/sparc/v8.S src/sparc/v9.S \
     7  		src/x86/ffi.c src/x86/sysv.S src/x86/win32.S \
     8 +		src/x86/ffi64.c src/x86/unix64.S \
     9  		src/alpha/ffi.c src/alpha/osf.S \
    10  		src/m68k/ffi.c src/m68k/sysv.S \
    11  		src/powerpc/ffi.c src/powerpc/sysv.S \
    12  		src/powerpc/ppc_closure.S src/powerpc/asm.h \
    13  		src/powerpc/ffi_darwin.c \
    14  		src/powerpc/darwin.S src/powerpc/aix.S \
    15 -		src/powerpc/darwin_closure.S src/powerpc/aix_closures.S \
    16 -		src/arm/ffi.c src/arm/sysv.S
    17 +		src/powerpc/darwin_closure.S src/powerpc/aix_closure.S \
    18 +		src/arm/ffi.c src/arm/sysv.S \
    19 +		src/s390/ffi.c src/s390/sysv.S \
    20 +		src/sh/ffi.c src/sh/sysv.S
    21  
    22  VPATH = @srcdir@:@srcdir@/src:@srcdir@/src/@TARGETDIR@
    23  
    24 @@ -83,6 +86,7 @@
    25  ffitest_LDFLAGS = -shared-libgcc
    26  
    27  TARGET_SRC_MIPS_GCC = src/mips/ffi.c src/mips/o32.S src/mips/n32.S
    28 +TARGET_SRC_MIPS_LINUX = src/mips/ffi.c src/mips/o32.S
    29  TARGET_SRC_MIPS_SGI = src/mips/ffi.c src/mips/o32.s src/mips/n32.s
    30  TARGET_SRC_X86 = src/x86/ffi.c src/x86/sysv.S
    31  TARGET_SRC_X86_WIN32 = src/x86/ffi.c src/x86/win32.S
    32 @@ -91,9 +95,12 @@
    33  TARGET_SRC_IA64 = src/ia64/ffi.c src/ia64/unix.S
    34  TARGET_SRC_M68K = src/m68k/ffi.c src/m68k/sysv.S
    35  TARGET_SRC_POWERPC = src/powerpc/ffi.c src/powerpc/sysv.S src/powerpc/ppc_closure.S
    36 -TARGET_SRC_POWERPC_AIX = src/powerpc/ffi_darwin.c src/powerpc/aix.S src/powerpc/aix_closures.S
    37 +TARGET_SRC_POWERPC_AIX = src/powerpc/ffi_darwin.c src/powerpc/aix.S src/powerpc/aix_closure.S
    38  TARGET_SRC_POWERPC_DARWIN = src/powerpc/ffi_darwin.c src/powerpc/darwin.S src/powerpc/darwin_closure.S
    39  TARGET_SRC_ARM =  src/arm/sysv.S src/arm/ffi.c
    40 +TARGET_SRC_S390 =  src/s390/sysv.S src/s390/ffi.c
    41 +TARGET_SRC_X86_64 = src/x86/ffi64.c src/x86/unix64.S src/x86/ffi.c src/x86/sysv.S
    42 +TARGET_SRC_SH =  src/sh/sysv.S src/sh/ffi.c
    43  
    44  ##libffi_la_SOURCES = src/debug.c src/prep_cif.c src/types.c $(TARGET_SRC_@TARGET@)
    45  ## Work around automake deficiency
    46 @@ -103,6 +110,10 @@
    47  libffi_la_SOURCES = $(libffi_la_common_SOURCES) $(TARGET_SRC_MIPS_GCC)
    48  libffi_convenience_la_SOURCES = $(libffi_la_common_SOURCES) $(TARGET_SRC_MIPS_GCC)
    49  endif
    50 +if MIPS_LINUX
    51 +libffi_la_SOURCES = $(libffi_la_common_SOURCES) $(TARGET_SRC_MIPS_LINUX)
    52 +libffi_convenience_la_SOURCES = $(libffi_la_common_SOURCES) $(TARGET_SRC_MIPS_LINUX)
    53 +endif
    54  if MIPS_SGI
    55  libffi_la_SOURCES = $(libffi_la_common_SOURCES) $(TARGET_SRC_MIPS_SGI)
    56  libffi_convenience_la_SOURCES = $(libffi_la_common_SOURCES) $(TARGET_SRC_MIPS_SGI)
    57 @@ -147,6 +158,18 @@
    58  libffi_la_SOURCES = $(libffi_la_common_SOURCES) $(TARGET_SRC_ARM)
    59  libffi_convenience_la_SOURCES = $(libffi_la_common_SOURCES) $(TARGET_SRC_ARM)
    60  endif
    61 +if S390
    62 +libffi_la_SOURCES = $(libffi_la_common_SOURCES) $(TARGET_SRC_S390)
    63 +libffi_convenience_la_SOURCES = $(libffi_la_common_SOURCES) $(TARGET_SRC_S390)
    64 +endif
    65 +if X86_64
    66 +libffi_la_SOURCES = $(libffi_la_common_SOURCES) $(TARGET_SRC_X86_64)
    67 +libffi_convenience_la_SOURCES = $(libffi_la_common_SOURCES) $(TARGET_SRC_X86_64)
    68 +endif
    69 +if SH
    70 +libffi_la_SOURCES = $(libffi_la_common_SOURCES) $(TARGET_SRC_SH)
    71 +libfficonvenience_la_SOURCES = $(libffi_la_common_SOURCES) $(TARGET_SRC_SH)
    72 +endif
    73  
    74  AM_CFLAGS = -fexceptions
    75  
    76 diff -ruN --exclude=CVS gcc-3.2.2.orig/libffi/Makefile.in gcc/libffi/Makefile.in
    77 --- gcc-3.2.2.orig/libffi/Makefile.in	Wed Jan 29 07:59:05 2003
    78 +++ gcc/libffi/Makefile.in	Wed Jan 29 07:58:58 2003
    79 @@ -91,14 +91,17 @@
    80  		src/mips/n32.s src/mips/o32.S src/mips/o32.s \
    81  		src/sparc/ffi.c src/sparc/v8.S src/sparc/v9.S \
    82  		src/x86/ffi.c src/x86/sysv.S src/x86/win32.S \
    83 +		src/x86/ffi64.c src/x86/unix64.S \
    84  		src/alpha/ffi.c src/alpha/osf.S \
    85  		src/m68k/ffi.c src/m68k/sysv.S \
    86  		src/powerpc/ffi.c src/powerpc/sysv.S \
    87  		src/powerpc/ppc_closure.S src/powerpc/asm.h \
    88  		src/powerpc/ffi_darwin.c \
    89  		src/powerpc/darwin.S src/powerpc/aix.S \
    90 -		src/powerpc/darwin_closure.S src/powerpc/aix_closures.S \
    91 -		src/arm/ffi.c src/arm/sysv.S
    92 +		src/powerpc/darwin_closure.S src/powerpc/aix_closure.S \
    93 +		src/arm/ffi.c src/arm/sysv.S \
    94 +		src/s390/ffi.c src/s390/sysv.S \
    95 +		src/sh/ffi.c src/sh/sysv.S
    96  
    97  
    98  VPATH = @srcdir@:@srcdir@/src:@srcdir@/src/@TARGETDIR@
    99 @@ -162,6 +165,7 @@
   100  ffitest_LDFLAGS = -shared-libgcc
   101  
   102  TARGET_SRC_MIPS_GCC = src/mips/ffi.c src/mips/o32.S src/mips/n32.S
   103 +TARGET_SRC_MIPS_LINUX = src/mips/ffi.c src/mips/o32.S
   104  TARGET_SRC_MIPS_SGI = src/mips/ffi.c src/mips/o32.s src/mips/n32.s
   105  TARGET_SRC_X86 = src/x86/ffi.c src/x86/sysv.S
   106  TARGET_SRC_X86_WIN32 = src/x86/ffi.c src/x86/win32.S
   107 @@ -170,14 +174,18 @@
   108  TARGET_SRC_IA64 = src/ia64/ffi.c src/ia64/unix.S
   109  TARGET_SRC_M68K = src/m68k/ffi.c src/m68k/sysv.S
   110  TARGET_SRC_POWERPC = src/powerpc/ffi.c src/powerpc/sysv.S src/powerpc/ppc_closure.S
   111 -TARGET_SRC_POWERPC_AIX = src/powerpc/ffi_darwin.c src/powerpc/aix.S src/powerpc/aix_closures.S
   112 +TARGET_SRC_POWERPC_AIX = src/powerpc/ffi_darwin.c src/powerpc/aix.S src/powerpc/aix_closure.S
   113  TARGET_SRC_POWERPC_DARWIN = src/powerpc/ffi_darwin.c src/powerpc/darwin.S src/powerpc/darwin_closure.S
   114  TARGET_SRC_ARM = src/arm/sysv.S src/arm/ffi.c
   115 +TARGET_SRC_S390 = src/s390/sysv.S src/s390/ffi.c
   116 +TARGET_SRC_X86_64 = src/x86/ffi64.c src/x86/unix64.S src/x86/ffi.c src/x86/sysv.S
   117 +TARGET_SRC_SH = src/sh/sysv.S src/sh/ffi.c
   118  
   119  libffi_la_common_SOURCES = src/debug.c src/prep_cif.c src/types.c \
   120  		src/raw_api.c src/java_raw_api.c
   121  
   122  @MIPS_GCC_TRUE@libffi_la_SOURCES = @MIPS_GCC_TRUE@$(libffi_la_common_SOURCES) $(TARGET_SRC_MIPS_GCC)
   123 +@MIPS_LINUX_TRUE@libffi_la_SOURCES = @MIPS_LINUX_TRUE@$(libffi_la_common_SOURCES) $(TARGET_SRC_MIPS_LINUX)
   124  @MIPS_SGI_TRUE@libffi_la_SOURCES = @MIPS_SGI_TRUE@$(libffi_la_common_SOURCES) $(TARGET_SRC_MIPS_SGI)
   125  @X86_TRUE@libffi_la_SOURCES = @X86_TRUE@$(libffi_la_common_SOURCES) $(TARGET_SRC_X86)
   126  @X86_WIN32_TRUE@libffi_la_SOURCES = @X86_WIN32_TRUE@$(libffi_la_common_SOURCES) $(TARGET_SRC_X86_WIN32)
   127 @@ -189,7 +197,11 @@
   128  @POWERPC_AIX_TRUE@libffi_la_SOURCES = @POWERPC_AIX_TRUE@$(libffi_la_common_SOURCES) $(TARGET_SRC_POWERPC_AIX)
   129  @POWERPC_DARWIN_TRUE@libffi_la_SOURCES = @POWERPC_DARWIN_TRUE@$(libffi_la_common_SOURCES) $(TARGET_SRC_POWERPC_DARWIN)
   130  @ARM_TRUE@libffi_la_SOURCES = @ARM_TRUE@$(libffi_la_common_SOURCES) $(TARGET_SRC_ARM)
   131 +@S390_TRUE@libffi_la_SOURCES = @S390_TRUE@$(libffi_la_common_SOURCES) $(TARGET_SRC_S390)
   132 +@X86_64_TRUE@libffi_la_SOURCES = @X86_64_TRUE@$(libffi_la_common_SOURCES) $(TARGET_SRC_X86_64)
   133 +@SH_TRUE@libffi_la_SOURCES = @SH_TRUE@$(libffi_la_common_SOURCES) $(TARGET_SRC_SH)
   134  @MIPS_GCC_TRUE@libffi_convenience_la_SOURCES = @MIPS_GCC_TRUE@$(libffi_la_common_SOURCES) $(TARGET_SRC_MIPS_GCC)
   135 +@MIPS_LINUX_TRUE@libffi_convenience_la_SOURCES = @MIPS_LINUX_TRUE@$(libffi_la_common_SOURCES) $(TARGET_SRC_MIPS_LINUX)
   136  @MIPS_SGI_TRUE@libffi_convenience_la_SOURCES = @MIPS_SGI_TRUE@$(libffi_la_common_SOURCES) $(TARGET_SRC_MIPS_SGI)
   137  @X86_TRUE@libffi_convenience_la_SOURCES = @X86_TRUE@$(libffi_la_common_SOURCES) $(TARGET_SRC_X86)
   138  @X86_WIN32_TRUE@libffi_convenience_la_SOURCES = @X86_WIN32_TRUE@$(libffi_la_common_SOURCES) $(TARGET_SRC_X86_WIN32)
   139 @@ -201,6 +213,9 @@
   140  @POWERPC_AIX_TRUE@libffi_convenience_la_SOURCES = @POWERPC_AIX_TRUE@$(libffi_la_common_SOURCES) $(TARGET_SRC_POWERPC_AIX)
   141  @POWERPC_DARWIN_TRUE@libffi_convenience_la_SOURCES = @POWERPC_DARWIN_TRUE@$(libffi_la_common_SOURCES) $(TARGET_SRC_POWERPC_DARWIN)
   142  @ARM_TRUE@libffi_convenience_la_SOURCES = @ARM_TRUE@$(libffi_la_common_SOURCES) $(TARGET_SRC_ARM)
   143 +@S390_TRUE@libffi_convenience_la_SOURCES = @S390_TRUE@$(libffi_la_common_SOURCES) $(TARGET_SRC_S390)
   144 +@X86_64_TRUE@libffi_convenience_la_SOURCES = @X86_64_TRUE@$(libffi_la_common_SOURCES) $(TARGET_SRC_X86_64)
   145 +@SH_TRUE@libfficonvenience_la_SOURCES = @SH_TRUE@$(libffi_la_common_SOURCES) $(TARGET_SRC_SH)
   146  
   147  AM_CFLAGS = -fexceptions
   148  
   149 @@ -208,7 +223,7 @@
   150  
   151  INCLUDES = -I$(top_srcdir)/include -Iinclude -I$(top_srcdir)/src
   152  ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
   153 -mkinstalldirs = $(SHELL) $(top_srcdir)/../mkinstalldirs
   154 +mkinstalldirs = $(SHELL) $(top_srcdir)/${libffi_basedir}/../mkinstalldirs
   155  CONFIG_HEADER = fficonfig.h
   156  CONFIG_CLEAN_FILES = 
   157  LTLIBRARIES =  $(noinst_LTLIBRARIES) $(toolexeclib_LTLIBRARIES)
   158 @@ -220,10 +235,6 @@
   159  LIBS = @LIBS@
   160  libffi_convenience_la_LDFLAGS = 
   161  libffi_convenience_la_LIBADD = 
   162 -@POWERPC_TRUE@libffi_convenience_la_OBJECTS =  src/debug.lo \
   163 -@POWERPC_TRUE@src/prep_cif.lo src/types.lo src/raw_api.lo \
   164 -@POWERPC_TRUE@src/java_raw_api.lo src/powerpc/ffi.lo \
   165 -@POWERPC_TRUE@src/powerpc/sysv.lo src/powerpc/ppc_closure.lo
   166  @ALPHA_TRUE@libffi_convenience_la_OBJECTS =  src/debug.lo \
   167  @ALPHA_TRUE@src/prep_cif.lo src/types.lo src/raw_api.lo \
   168  @ALPHA_TRUE@src/java_raw_api.lo src/alpha/ffi.lo src/alpha/osf.lo
   169 @@ -234,12 +245,29 @@
   170  @MIPS_GCC_TRUE@src/prep_cif.lo src/types.lo src/raw_api.lo \
   171  @MIPS_GCC_TRUE@src/java_raw_api.lo src/mips/ffi.lo src/mips/o32.lo \
   172  @MIPS_GCC_TRUE@src/mips/n32.lo
   173 -@X86_WIN32_TRUE@libffi_convenience_la_OBJECTS =  src/debug.lo \
   174 -@X86_WIN32_TRUE@src/prep_cif.lo src/types.lo src/raw_api.lo \
   175 -@X86_WIN32_TRUE@src/java_raw_api.lo src/x86/ffi.lo src/x86/win32.lo
   176 +@S390_TRUE@libffi_convenience_la_OBJECTS =  src/debug.lo src/prep_cif.lo \
   177 +@S390_TRUE@src/types.lo src/raw_api.lo src/java_raw_api.lo \
   178 +@S390_TRUE@src/s390/sysv.lo src/s390/ffi.lo
   179  @M68K_TRUE@libffi_convenience_la_OBJECTS =  src/debug.lo src/prep_cif.lo \
   180  @M68K_TRUE@src/types.lo src/raw_api.lo src/java_raw_api.lo \
   181  @M68K_TRUE@src/m68k/ffi.lo src/m68k/sysv.lo
   182 +@X86_TRUE@libffi_convenience_la_OBJECTS =  src/debug.lo src/prep_cif.lo \
   183 +@X86_TRUE@src/types.lo src/raw_api.lo src/java_raw_api.lo \
   184 +@X86_TRUE@src/x86/ffi.lo src/x86/sysv.lo
   185 +@POWERPC_TRUE@libffi_convenience_la_OBJECTS =  src/debug.lo \
   186 +@POWERPC_TRUE@src/prep_cif.lo src/types.lo src/raw_api.lo \
   187 +@POWERPC_TRUE@src/java_raw_api.lo src/powerpc/ffi.lo \
   188 +@POWERPC_TRUE@src/powerpc/sysv.lo src/powerpc/ppc_closure.lo
   189 +@MIPS_LINUX_TRUE@libffi_convenience_la_OBJECTS =  src/debug.lo \
   190 +@MIPS_LINUX_TRUE@src/prep_cif.lo src/types.lo src/raw_api.lo \
   191 +@MIPS_LINUX_TRUE@src/java_raw_api.lo src/mips/ffi.lo src/mips/o32.lo
   192 +@X86_WIN32_TRUE@libffi_convenience_la_OBJECTS =  src/debug.lo \
   193 +@X86_WIN32_TRUE@src/prep_cif.lo src/types.lo src/raw_api.lo \
   194 +@X86_WIN32_TRUE@src/java_raw_api.lo src/x86/ffi.lo src/x86/win32.lo
   195 +@X86_64_TRUE@libffi_convenience_la_OBJECTS =  src/debug.lo \
   196 +@X86_64_TRUE@src/prep_cif.lo src/types.lo src/raw_api.lo \
   197 +@X86_64_TRUE@src/java_raw_api.lo src/x86/ffi64.lo src/x86/unix64.lo \
   198 +@X86_64_TRUE@src/x86/ffi.lo src/x86/sysv.lo
   199  @SPARC_TRUE@libffi_convenience_la_OBJECTS =  src/debug.lo \
   200  @SPARC_TRUE@src/prep_cif.lo src/types.lo src/raw_api.lo \
   201  @SPARC_TRUE@src/java_raw_api.lo src/sparc/ffi.lo src/sparc/v8.lo \
   202 @@ -247,62 +275,75 @@
   203  @POWERPC_AIX_TRUE@libffi_convenience_la_OBJECTS =  src/debug.lo \
   204  @POWERPC_AIX_TRUE@src/prep_cif.lo src/types.lo src/raw_api.lo \
   205  @POWERPC_AIX_TRUE@src/java_raw_api.lo src/powerpc/ffi_darwin.lo \
   206 -@POWERPC_AIX_TRUE@src/powerpc/aix.lo src/powerpc/aix_closures.lo
   207 -@X86_TRUE@libffi_convenience_la_OBJECTS =  src/debug.lo src/prep_cif.lo \
   208 -@X86_TRUE@src/types.lo src/raw_api.lo src/java_raw_api.lo \
   209 -@X86_TRUE@src/x86/ffi.lo src/x86/sysv.lo
   210 -@ARM_TRUE@libffi_convenience_la_OBJECTS =  src/debug.lo src/prep_cif.lo \
   211 -@ARM_TRUE@src/types.lo src/raw_api.lo src/java_raw_api.lo \
   212 -@ARM_TRUE@src/arm/sysv.lo src/arm/ffi.lo
   213 +@POWERPC_AIX_TRUE@src/powerpc/aix.lo src/powerpc/aix_closure.lo
   214 +@MIPS_SGI_TRUE@libffi_convenience_la_OBJECTS =  src/debug.lo \
   215 +@MIPS_SGI_TRUE@src/prep_cif.lo src/types.lo src/raw_api.lo \
   216 +@MIPS_SGI_TRUE@src/java_raw_api.lo src/mips/ffi.lo src/mips/o32.lo \
   217 +@MIPS_SGI_TRUE@src/mips/n32.lo
   218  @POWERPC_DARWIN_TRUE@libffi_convenience_la_OBJECTS =  src/debug.lo \
   219  @POWERPC_DARWIN_TRUE@src/prep_cif.lo src/types.lo src/raw_api.lo \
   220  @POWERPC_DARWIN_TRUE@src/java_raw_api.lo src/powerpc/ffi_darwin.lo \
   221  @POWERPC_DARWIN_TRUE@src/powerpc/darwin.lo \
   222  @POWERPC_DARWIN_TRUE@src/powerpc/darwin_closure.lo
   223 -@MIPS_SGI_TRUE@libffi_convenience_la_OBJECTS =  src/debug.lo \
   224 -@MIPS_SGI_TRUE@src/prep_cif.lo src/types.lo src/raw_api.lo \
   225 -@MIPS_SGI_TRUE@src/java_raw_api.lo src/mips/ffi.lo src/mips/o32.lo \
   226 -@MIPS_SGI_TRUE@src/mips/n32.lo
   227 +@ARM_TRUE@libffi_convenience_la_OBJECTS =  src/debug.lo src/prep_cif.lo \
   228 +@ARM_TRUE@src/types.lo src/raw_api.lo src/java_raw_api.lo \
   229 +@ARM_TRUE@src/arm/sysv.lo src/arm/ffi.lo
   230 +@SH_TRUE@libffi_convenience_la_OBJECTS =  src/debug.lo src/prep_cif.lo \
   231 +@SH_TRUE@src/types.lo src/raw_api.lo src/java_raw_api.lo \
   232 +@SH_TRUE@src/sh/sysv.lo src/sh/ffi.lo
   233  libffi_la_LIBADD = 
   234 +@SH_TRUE@libffi_la_OBJECTS =  src/debug.lo src/prep_cif.lo src/types.lo \
   235 +@SH_TRUE@src/raw_api.lo src/java_raw_api.lo src/sh/sysv.lo \
   236 +@SH_TRUE@src/sh/ffi.lo
   237 +@IA64_TRUE@libffi_la_OBJECTS =  src/debug.lo src/prep_cif.lo \
   238 +@IA64_TRUE@src/types.lo src/raw_api.lo src/java_raw_api.lo \
   239 +@IA64_TRUE@src/ia64/ffi.lo src/ia64/unix.lo
   240 +@X86_TRUE@libffi_la_OBJECTS =  src/debug.lo src/prep_cif.lo src/types.lo \
   241 +@X86_TRUE@src/raw_api.lo src/java_raw_api.lo src/x86/ffi.lo \
   242 +@X86_TRUE@src/x86/sysv.lo
   243  @POWERPC_TRUE@libffi_la_OBJECTS =  src/debug.lo src/prep_cif.lo \
   244  @POWERPC_TRUE@src/types.lo src/raw_api.lo src/java_raw_api.lo \
   245  @POWERPC_TRUE@src/powerpc/ffi.lo src/powerpc/sysv.lo \
   246  @POWERPC_TRUE@src/powerpc/ppc_closure.lo
   247 -@ALPHA_TRUE@libffi_la_OBJECTS =  src/debug.lo src/prep_cif.lo \
   248 -@ALPHA_TRUE@src/types.lo src/raw_api.lo src/java_raw_api.lo \
   249 -@ALPHA_TRUE@src/alpha/ffi.lo src/alpha/osf.lo
   250 -@IA64_TRUE@libffi_la_OBJECTS =  src/debug.lo src/prep_cif.lo \
   251 -@IA64_TRUE@src/types.lo src/raw_api.lo src/java_raw_api.lo \
   252 -@IA64_TRUE@src/ia64/ffi.lo src/ia64/unix.lo
   253 -@MIPS_GCC_TRUE@libffi_la_OBJECTS =  src/debug.lo src/prep_cif.lo \
   254 -@MIPS_GCC_TRUE@src/types.lo src/raw_api.lo src/java_raw_api.lo \
   255 -@MIPS_GCC_TRUE@src/mips/ffi.lo src/mips/o32.lo src/mips/n32.lo
   256 -@X86_WIN32_TRUE@libffi_la_OBJECTS =  src/debug.lo src/prep_cif.lo \
   257 -@X86_WIN32_TRUE@src/types.lo src/raw_api.lo src/java_raw_api.lo \
   258 -@X86_WIN32_TRUE@src/x86/ffi.lo src/x86/win32.lo
   259 -@M68K_TRUE@libffi_la_OBJECTS =  src/debug.lo src/prep_cif.lo \
   260 -@M68K_TRUE@src/types.lo src/raw_api.lo src/java_raw_api.lo \
   261 -@M68K_TRUE@src/m68k/ffi.lo src/m68k/sysv.lo
   262 +@MIPS_LINUX_TRUE@libffi_la_OBJECTS =  src/debug.lo src/prep_cif.lo \
   263 +@MIPS_LINUX_TRUE@src/types.lo src/raw_api.lo src/java_raw_api.lo \
   264 +@MIPS_LINUX_TRUE@src/mips/ffi.lo src/mips/o32.lo
   265  @SPARC_TRUE@libffi_la_OBJECTS =  src/debug.lo src/prep_cif.lo \
   266  @SPARC_TRUE@src/types.lo src/raw_api.lo src/java_raw_api.lo \
   267  @SPARC_TRUE@src/sparc/ffi.lo src/sparc/v8.lo src/sparc/v9.lo
   268  @POWERPC_AIX_TRUE@libffi_la_OBJECTS =  src/debug.lo src/prep_cif.lo \
   269  @POWERPC_AIX_TRUE@src/types.lo src/raw_api.lo src/java_raw_api.lo \
   270  @POWERPC_AIX_TRUE@src/powerpc/ffi_darwin.lo src/powerpc/aix.lo \
   271 -@POWERPC_AIX_TRUE@src/powerpc/aix_closures.lo
   272 -@X86_TRUE@libffi_la_OBJECTS =  src/debug.lo src/prep_cif.lo src/types.lo \
   273 -@X86_TRUE@src/raw_api.lo src/java_raw_api.lo src/x86/ffi.lo \
   274 -@X86_TRUE@src/x86/sysv.lo
   275 +@POWERPC_AIX_TRUE@src/powerpc/aix_closure.lo
   276 +@MIPS_SGI_TRUE@libffi_la_OBJECTS =  src/debug.lo src/prep_cif.lo \
   277 +@MIPS_SGI_TRUE@src/types.lo src/raw_api.lo src/java_raw_api.lo \
   278 +@MIPS_SGI_TRUE@src/mips/ffi.lo src/mips/o32.lo src/mips/n32.lo
   279  @ARM_TRUE@libffi_la_OBJECTS =  src/debug.lo src/prep_cif.lo src/types.lo \
   280  @ARM_TRUE@src/raw_api.lo src/java_raw_api.lo src/arm/sysv.lo \
   281  @ARM_TRUE@src/arm/ffi.lo
   282 +@ALPHA_TRUE@libffi_la_OBJECTS =  src/debug.lo src/prep_cif.lo \
   283 +@ALPHA_TRUE@src/types.lo src/raw_api.lo src/java_raw_api.lo \
   284 +@ALPHA_TRUE@src/alpha/ffi.lo src/alpha/osf.lo
   285 +@MIPS_GCC_TRUE@libffi_la_OBJECTS =  src/debug.lo src/prep_cif.lo \
   286 +@MIPS_GCC_TRUE@src/types.lo src/raw_api.lo src/java_raw_api.lo \
   287 +@MIPS_GCC_TRUE@src/mips/ffi.lo src/mips/o32.lo src/mips/n32.lo
   288 +@S390_TRUE@libffi_la_OBJECTS =  src/debug.lo src/prep_cif.lo \
   289 +@S390_TRUE@src/types.lo src/raw_api.lo src/java_raw_api.lo \
   290 +@S390_TRUE@src/s390/sysv.lo src/s390/ffi.lo
   291 +@M68K_TRUE@libffi_la_OBJECTS =  src/debug.lo src/prep_cif.lo \
   292 +@M68K_TRUE@src/types.lo src/raw_api.lo src/java_raw_api.lo \
   293 +@M68K_TRUE@src/m68k/ffi.lo src/m68k/sysv.lo
   294 +@X86_WIN32_TRUE@libffi_la_OBJECTS =  src/debug.lo src/prep_cif.lo \
   295 +@X86_WIN32_TRUE@src/types.lo src/raw_api.lo src/java_raw_api.lo \
   296 +@X86_WIN32_TRUE@src/x86/ffi.lo src/x86/win32.lo
   297 +@X86_64_TRUE@libffi_la_OBJECTS =  src/debug.lo src/prep_cif.lo \
   298 +@X86_64_TRUE@src/types.lo src/raw_api.lo src/java_raw_api.lo \
   299 +@X86_64_TRUE@src/x86/ffi64.lo src/x86/unix64.lo src/x86/ffi.lo \
   300 +@X86_64_TRUE@src/x86/sysv.lo
   301  @POWERPC_DARWIN_TRUE@libffi_la_OBJECTS =  src/debug.lo src/prep_cif.lo \
   302  @POWERPC_DARWIN_TRUE@src/types.lo src/raw_api.lo src/java_raw_api.lo \
   303  @POWERPC_DARWIN_TRUE@src/powerpc/ffi_darwin.lo src/powerpc/darwin.lo \
   304  @POWERPC_DARWIN_TRUE@src/powerpc/darwin_closure.lo
   305 -@MIPS_SGI_TRUE@libffi_la_OBJECTS =  src/debug.lo src/prep_cif.lo \
   306 -@MIPS_SGI_TRUE@src/types.lo src/raw_api.lo src/java_raw_api.lo \
   307 -@MIPS_SGI_TRUE@src/mips/ffi.lo src/mips/o32.lo src/mips/n32.lo
   308  noinst_PROGRAMS =  ffitest$(EXEEXT)
   309  PROGRAMS =  $(noinst_PROGRAMS)
   310  
   311 @@ -578,8 +616,8 @@
   312  	-chmod 777 $(distdir)
   313  	$(mkinstalldirs) $(distdir)/src/alpha $(distdir)/src/arm \
   314  	   $(distdir)/src/m68k $(distdir)/src/mips \
   315 -	   $(distdir)/src/powerpc $(distdir)/src/sparc \
   316 -	   $(distdir)/src/x86
   317 +	   $(distdir)/src/powerpc $(distdir)/src/s390 $(distdir)/src/sh \
   318 +	   $(distdir)/src/sparc $(distdir)/src/x86
   319  	@for file in $(DISTFILES); do \
   320  	  if test -f $$file; then d=.; else d=$(srcdir); fi; \
   321  	  if test -d $$d/$$file; then \
   322 diff -ruN --exclude=CVS gcc-3.2.2.orig/libffi/acinclude.m4 gcc/libffi/acinclude.m4
   323 --- gcc-3.2.2.orig/libffi/acinclude.m4	Sun Sep 10 16:43:14 2000
   324 +++ gcc/libffi/acinclude.m4	Tue Dec 17 03:22:47 2002
   325 @@ -4,5 +4,8 @@
   326  dnl to add a definition of LIBTOOL to Makefile.in.
   327  ifelse(yes,no,[
   328  AC_DEFUN([AC_PROG_LIBTOOL],)
   329 +AC_DEFUN([AM_PROG_LIBTOOL],)
   330  AC_SUBST(LIBTOOL)
   331  ])
   332 +
   333 +sinclude(../config/accross.m4)
   334 diff -ruN --exclude=CVS gcc-3.2.2.orig/libffi/aclocal.m4 gcc/libffi/aclocal.m4
   335 --- gcc-3.2.2.orig/libffi/aclocal.m4	Fri Feb  1 07:25:31 2002
   336 +++ gcc/libffi/aclocal.m4	Tue Dec 17 03:22:47 2002
   337 @@ -1,6 +1,6 @@
   338 -dnl aclocal.m4 generated automatically by aclocal 1.4
   339 +dnl aclocal.m4 generated automatically by aclocal 1.4-p5
   340  
   341 -dnl Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
   342 +dnl Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
   343  dnl This file is free software; the Free Software Foundation
   344  dnl gives unlimited permission to copy and/or distribute it,
   345  dnl with or without modifications, as long as this notice is preserved.
   346 @@ -16,108 +16,15 @@
   347  dnl to add a definition of LIBTOOL to Makefile.in.
   348  ifelse(yes,no,[
   349  AC_DEFUN([AC_PROG_LIBTOOL],)
   350 +AC_DEFUN([AM_PROG_LIBTOOL],)
   351  AC_SUBST(LIBTOOL)
   352  ])
   353  
   354 -AC_DEFUN([AC_COMPILE_CHECK_SIZEOF],
   355 -[changequote(<<, >>)dnl
   356 -dnl The name to #define.
   357 -define(<<AC_TYPE_NAME>>, translit(sizeof_$1, [a-z *], [A-Z_P]))dnl
   358 -dnl The cache variable name.
   359 -define(<<AC_CV_NAME>>, translit(ac_cv_sizeof_$1, [ *], [_p]))dnl
   360 -changequote([, ])dnl
   361 -AC_MSG_CHECKING(size of $1)
   362 -AC_CACHE_VAL(AC_CV_NAME,
   363 -[for ac_size in 4 8 1 2 16 12 $2 ; do # List sizes in rough order of prevalence.
   364 -  AC_TRY_COMPILE([#include "confdefs.h"
   365 -#include <sys/types.h>
   366 -$2
   367 -], [switch (0) case 0: case (sizeof ($1) == $ac_size):;], AC_CV_NAME=$ac_size)
   368 -  if test x$AC_CV_NAME != x ; then break; fi
   369 -done
   370 -])
   371 -if test x$AC_CV_NAME = x ; then
   372 -  AC_MSG_ERROR([cannot determine a size for $1])
   373 -fi
   374 -AC_MSG_RESULT($AC_CV_NAME)
   375 -AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME, [The number of bytes in type $1])
   376 -undefine([AC_TYPE_NAME])dnl
   377 -undefine([AC_CV_NAME])dnl
   378 -])
   379 -
   380 -AC_DEFUN([AC_C_BIGENDIAN_CROSS],
   381 -[AC_CACHE_CHECK(whether byte ordering is bigendian, ac_cv_c_bigendian,
   382 -[ac_cv_c_bigendian=unknown
   383 -# See if sys/param.h defines the BYTE_ORDER macro.
   384 -AC_TRY_COMPILE([#include <sys/types.h>
   385 -#include <sys/param.h>], [
   386 -#if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN
   387 - bogus endian macros
   388 -#endif], [# It does; now see whether it defined to BIG_ENDIAN or not.
   389 -AC_TRY_COMPILE([#include <sys/types.h>
   390 -#include <sys/param.h>], [
   391 -#if BYTE_ORDER != BIG_ENDIAN
   392 - not big endian
   393 -#endif], ac_cv_c_bigendian=yes, ac_cv_c_bigendian=no)])
   394 -if test $ac_cv_c_bigendian = unknown; then
   395 -AC_TRY_RUN([main () {
   396 -  /* Are we little or big endian?  From Harbison&Steele.  */
   397 -  union
   398 -  {
   399 -    long l;
   400 -    char c[sizeof (long)];
   401 -  } u;
   402 -  u.l = 1;
   403 -  exit (u.c[sizeof (long) - 1] == 1);
   404 -}], ac_cv_c_bigendian=no, ac_cv_c_bigendian=yes,
   405 -[ echo $ac_n "cross-compiling... " 2>&AC_FD_MSG ])
   406 -fi])
   407 -if test $ac_cv_c_bigendian = unknown; then
   408 -AC_MSG_CHECKING(to probe for byte ordering)
   409 -[
   410 -cat >conftest.c <<EOF
   411 -short ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 };
   412 -short ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 };
   413 -void _ascii() { char* s = (char*) ascii_mm; s = (char*) ascii_ii; }
   414 -short ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 };
   415 -short ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 };
   416 -void _ebcdic() { char* s = (char*) ebcdic_mm; s = (char*) ebcdic_ii; }
   417 -int main() { _ascii (); _ebcdic (); return 0; }
   418 -EOF
   419 -] if test -f conftest.c ; then
   420 -     if ${CC-cc} ${CFLAGS} conftest.c -o conftest.o && test -f conftest.o ; then
   421 -        if test `grep -l BIGenDianSyS conftest.o` ; then
   422 -           echo $ac_n ' big endian probe OK, ' 1>&AC_FD_MSG
   423 -           ac_cv_c_bigendian=yes
   424 -        fi
   425 -        if test `grep -l LiTTleEnDian conftest.o` ; then
   426 -           echo $ac_n ' little endian probe OK, ' 1>&AC_FD_MSG
   427 -           if test $ac_cv_c_bigendian = yes ; then
   428 -            ac_cv_c_bigendian=unknown;
   429 -           else
   430 -            ac_cv_c_bigendian=no
   431 -           fi
   432 -        fi
   433 -        echo $ac_n 'guessing bigendian ...  ' >&AC_FD_MSG
   434 -     fi
   435 -  fi
   436 -AC_MSG_RESULT($ac_cv_c_bigendian)
   437 -fi
   438 -if test $ac_cv_c_bigendian = yes; then
   439 -  AC_DEFINE(WORDS_BIGENDIAN, 1, [whether byteorder is bigendian])
   440 -  BYTEORDER=4321
   441 -else
   442 -  BYTEORDER=1234
   443 -fi
   444 -AC_DEFINE_UNQUOTED(BYTEORDER, $BYTEORDER, [1234 = LIL_ENDIAN, 4321 = BIGENDIAN])
   445 -if test $ac_cv_c_bigendian = unknown; then
   446 -  AC_MSG_ERROR(unknown endianess - sorry, please pre-set ac_cv_c_bigendian)
   447 -fi
   448 -])
   449 +sinclude(../config/accross.m4)
   450  
   451  # Like AC_CONFIG_HEADER, but automatically create stamp file.
   452  
   453 -AC_DEFUN(AM_CONFIG_HEADER,
   454 +AC_DEFUN([AM_CONFIG_HEADER],
   455  [AC_PREREQ([2.12])
   456  AC_CONFIG_HEADER([$1])
   457  dnl When config.status generates a header, we must update the stamp-h file.
   458 @@ -147,7 +54,7 @@
   459  dnl Usage:
   460  dnl AM_INIT_AUTOMAKE(package,version, [no-define])
   461  
   462 -AC_DEFUN(AM_INIT_AUTOMAKE,
   463 +AC_DEFUN([AM_INIT_AUTOMAKE],
   464  [AC_REQUIRE([AC_PROG_INSTALL])
   465  PACKAGE=[$1]
   466  AC_SUBST(PACKAGE)
   467 @@ -175,7 +82,7 @@
   468  # Check to make sure that the build environment is sane.
   469  #
   470  
   471 -AC_DEFUN(AM_SANITY_CHECK,
   472 +AC_DEFUN([AM_SANITY_CHECK],
   473  [AC_MSG_CHECKING([whether build environment is sane])
   474  # Just in case
   475  sleep 1
   476 @@ -216,7 +123,7 @@
   477  
   478  dnl AM_MISSING_PROG(NAME, PROGRAM, DIRECTORY)
   479  dnl The program must properly implement --version.
   480 -AC_DEFUN(AM_MISSING_PROG,
   481 +AC_DEFUN([AM_MISSING_PROG],
   482  [AC_MSG_CHECKING(for working $2)
   483  # Run test in a subshell; some versions of sh will print an error if
   484  # an executable is not found, even if stderr is redirected.
   485 @@ -235,7 +142,7 @@
   486  
   487  # serial 1
   488  
   489 -AC_DEFUN(AM_MAINTAINER_MODE,
   490 +AC_DEFUN([AM_MAINTAINER_MODE],
   491  [AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
   492    dnl maintainer-mode is disabled by default
   493    AC_ARG_ENABLE(maintainer-mode,
   494 @@ -252,7 +159,7 @@
   495  
   496  # Define a conditional.
   497  
   498 -AC_DEFUN(AM_CONDITIONAL,
   499 +AC_DEFUN([AM_CONDITIONAL],
   500  [AC_SUBST($1_TRUE)
   501  AC_SUBST($1_FALSE)
   502  if $2; then
   503 diff -ruN --exclude=CVS gcc-3.2.2.orig/libffi/configure gcc/libffi/configure
   504 --- gcc-3.2.2.orig/libffi/configure	Wed Jan 29 07:59:05 2003
   505 +++ gcc/libffi/configure	Sat Feb  1 20:16:19 2003
   506 @@ -633,17 +633,16 @@
   507  
   508  if test "${srcdir}" = "."; then
   509    if test "${with_target_subdir}" != "."; then
   510 -    libffi_basedir="${srcdir}/${with_multisrctop}.."
   511 +    libffi_basedir="${with_multisrctop}../"
   512    else
   513 -    libffi_basedir="${srcdir}/${with_multisrctop}"
   514 +    libffi_basedir="${with_multisrctop}"
   515    fi
   516  else
   517 -  libffi_basedir="${srcdir}"
   518 +  libffi_basedir=
   519  fi
   520  
   521 -
   522  ac_aux_dir=
   523 -for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do
   524 +for ac_dir in ${libffi_basedir}.. $srcdir/${libffi_basedir}..; do
   525    if test -f $ac_dir/install-sh; then
   526      ac_aux_dir=$ac_dir
   527      ac_install_sh="$ac_aux_dir/install-sh -c"
   528 @@ -655,13 +654,14 @@
   529    fi
   530  done
   531  if test -z "$ac_aux_dir"; then
   532 -  { echo "configure: error: can not find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." 1>&2; exit 1; }
   533 +  { echo "configure: error: can not find install-sh or install.sh in ${libffi_basedir}.. $srcdir/${libffi_basedir}.." 1>&2; exit 1; }
   534  fi
   535  ac_config_guess=$ac_aux_dir/config.guess
   536  ac_config_sub=$ac_aux_dir/config.sub
   537  ac_configure=$ac_aux_dir/configure # This should be Cygnus configure.
   538  
   539  
   540 +
   541  # Make sure we can run config.sub.
   542  if ${CONFIG_SHELL-/bin/sh} $ac_config_sub sun4 >/dev/null 2>&1; then :
   543  else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; }
   544 @@ -1238,9 +1238,18 @@
   545    ;;
   546  
   547  hpux10.20*|hpux11*)
   548 -  lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9].[0-9]) shared library'
   549 -  lt_cv_file_magic_cmd=/usr/bin/file
   550 -  lt_cv_file_magic_test_file=/usr/lib/libc.sl
   551 +  case $host_cpu in
   552 +  hppa*)
   553 +    lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9].[0-9]) shared library'
   554 +    lt_cv_file_magic_cmd=/usr/bin/file
   555 +    lt_cv_file_magic_test_file=/usr/lib/libc.sl
   556 +    ;;
   557 +  ia64*)
   558 +    lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64'
   559 +    lt_cv_file_magic_cmd=/usr/bin/file
   560 +    lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so
   561 +    ;;
   562 +  esac
   563    ;;
   564  
   565  irix5* | irix6*)
   566 @@ -1267,7 +1276,7 @@
   567  # This must be Linux ELF.
   568  linux-gnu*)
   569    case $host_cpu in
   570 -  alpha* | hppa* | i*86 | powerpc* | sparc* | ia64* )
   571 +  alpha* | hppa* | i*86 | powerpc* | sparc* | ia64* | sh* )
   572      lt_cv_deplibs_check_method=pass_all ;;
   573    *)
   574      # glibc up to 2.1.1 does not perform some relocations on ARM
   575 @@ -1330,13 +1339,13 @@
   576  deplibs_check_method=$lt_cv_deplibs_check_method
   577  
   578  echo $ac_n "checking for object suffix""... $ac_c" 1>&6
   579 -echo "configure:1334: checking for object suffix" >&5
   580 +echo "configure:1343: checking for object suffix" >&5
   581  if eval "test \"`echo '$''{'ac_cv_objext'+set}'`\" = set"; then
   582    echo $ac_n "(cached) $ac_c" 1>&6
   583  else
   584    rm -f conftest*
   585  echo 'int i = 1;' > conftest.$ac_ext
   586 -if { (eval echo configure:1340: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   587 +if { (eval echo configure:1349: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   588    for ac_file in conftest.*; do
   589      case $ac_file in
   590      *.c) ;;
   591 @@ -1356,7 +1365,7 @@
   592  
   593  
   594  echo $ac_n "checking for executable suffix""... $ac_c" 1>&6
   595 -echo "configure:1360: checking for executable suffix" >&5
   596 +echo "configure:1369: checking for executable suffix" >&5
   597  if eval "test \"`echo '$''{'ac_cv_exeext'+set}'`\" = set"; then
   598    echo $ac_n "(cached) $ac_c" 1>&6
   599  else
   600 @@ -1366,7 +1375,7 @@
   601    rm -f conftest*
   602    echo 'int main () { return 0; }' > conftest.$ac_ext
   603    ac_cv_exeext=
   604 -  if { (eval echo configure:1370: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then
   605 +  if { (eval echo configure:1379: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then
   606      for file in conftest.*; do
   607        case $file in
   608        *.c | *.o | *.obj) ;;
   609 @@ -1399,7 +1408,7 @@
   610  file_magic*)
   611    if test "$file_magic_cmd" = '$MAGIC_CMD'; then
   612      echo $ac_n "checking for ${ac_tool_prefix}file""... $ac_c" 1>&6
   613 -echo "configure:1403: checking for ${ac_tool_prefix}file" >&5
   614 +echo "configure:1412: checking for ${ac_tool_prefix}file" >&5
   615  if eval "test \"`echo '$''{'lt_cv_path_MAGIC_CMD'+set}'`\" = set"; then
   616    echo $ac_n "(cached) $ac_c" 1>&6
   617  else
   618 @@ -1461,7 +1470,7 @@
   619  if test -z "$lt_cv_path_MAGIC_CMD"; then
   620    if test -n "$ac_tool_prefix"; then
   621      echo $ac_n "checking for file""... $ac_c" 1>&6
   622 -echo "configure:1465: checking for file" >&5
   623 +echo "configure:1474: checking for file" >&5
   624  if eval "test \"`echo '$''{'lt_cv_path_MAGIC_CMD'+set}'`\" = set"; then
   625    echo $ac_n "(cached) $ac_c" 1>&6
   626  else
   627 @@ -1532,7 +1541,7 @@
   628  # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
   629  set dummy ${ac_tool_prefix}ranlib; ac_word=$2
   630  echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
   631 -echo "configure:1536: checking for $ac_word" >&5
   632 +echo "configure:1545: checking for $ac_word" >&5
   633  if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
   634    echo $ac_n "(cached) $ac_c" 1>&6
   635  else
   636 @@ -1564,7 +1573,7 @@
   637    # Extract the first word of "ranlib", so it can be a program name with args.
   638  set dummy ranlib; ac_word=$2
   639  echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
   640 -echo "configure:1568: checking for $ac_word" >&5
   641 +echo "configure:1577: checking for $ac_word" >&5
   642  if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
   643    echo $ac_n "(cached) $ac_c" 1>&6
   644  else
   645 @@ -1599,7 +1608,7 @@
   646  # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
   647  set dummy ${ac_tool_prefix}strip; ac_word=$2
   648  echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
   649 -echo "configure:1603: checking for $ac_word" >&5
   650 +echo "configure:1612: checking for $ac_word" >&5
   651  if eval "test \"`echo '$''{'ac_cv_prog_STRIP'+set}'`\" = set"; then
   652    echo $ac_n "(cached) $ac_c" 1>&6
   653  else
   654 @@ -1631,7 +1640,7 @@
   655    # Extract the first word of "strip", so it can be a program name with args.
   656  set dummy strip; ac_word=$2
   657  echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
   658 -echo "configure:1635: checking for $ac_word" >&5
   659 +echo "configure:1644: checking for $ac_word" >&5
   660  if eval "test \"`echo '$''{'ac_cv_prog_STRIP'+set}'`\" = set"; then
   661    echo $ac_n "(cached) $ac_c" 1>&6
   662  else
   663 @@ -1698,8 +1707,8 @@
   664  case $host in
   665  *-*-irix6*)
   666    # Find out which ABI we are using.
   667 -  echo '#line 1702 "configure"' > conftest.$ac_ext
   668 -  if { (eval echo configure:1703: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   669 +  echo '#line 1711 "configure"' > conftest.$ac_ext
   670 +  if { (eval echo configure:1712: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   671      case `/usr/bin/file conftest.$ac_objext` in
   672      *32-bit*)
   673        LD="${LD-ld} -32"
   674 @@ -1715,12 +1724,70 @@
   675    rm -rf conftest*
   676    ;;
   677  
   678 +ia64-*-hpux*)
   679 +  # Find out which ABI we are using.
   680 +  echo 'int i;' > conftest.$ac_ext
   681 +  if { (eval echo configure:1731: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   682 +    case "`/usr/bin/file conftest.o`" in
   683 +    *ELF-32*)
   684 +      HPUX_IA64_MODE="32"
   685 +      ;;
   686 +    *ELF-64*)
   687 +      HPUX_IA64_MODE="64"
   688 +      ;;
   689 +    esac
   690 +  fi
   691 +  rm -rf conftest*
   692 +  ;;
   693 +
   694 +x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*|s390*-*linux*|sparc*-*linux*)
   695 +  # Find out which ABI we are using.
   696 +  echo 'int i;' > conftest.$ac_ext
   697 +  if { (eval echo configure:1747: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   698 +    case "`/usr/bin/file conftest.o`" in
   699 +    *32-bit*)
   700 +      case $host in
   701 +        x86_64-*linux*)
   702 +          LD="${LD-ld} -m elf_i386"
   703 +          ;;
   704 +        ppc64-*linux*)
   705 +          LD="${LD-ld} -m elf32ppclinux"
   706 +          ;;
   707 +        s390x-*linux*)
   708 +          LD="${LD-ld} -m elf_s390"
   709 +          ;;
   710 +        sparc64-*linux*)
   711 +          LD="${LD-ld} -m elf32_sparc"
   712 +          ;;
   713 +      esac
   714 +      ;;
   715 +    *64-bit*)
   716 +      case $host in
   717 +        x86_64-*linux*)
   718 +          LD="${LD-ld} -m elf_x86_64"
   719 +          ;;
   720 +        ppc*-*linux*|powerpc*-*linux*)
   721 +          LD="${LD-ld} -m elf64ppc"
   722 +          ;;
   723 +        s390*-*linux*)
   724 +          LD="${LD-ld} -m elf64_s390"
   725 +          ;;
   726 +        sparc*-*linux*)
   727 +          LD="${LD-ld} -m elf64_sparc"
   728 +          ;;
   729 +      esac
   730 +      ;;
   731 +    esac
   732 +  fi
   733 +  rm -rf conftest*
   734 +  ;;
   735 +
   736  *-*-sco3.2v5*)
   737    # On SCO OpenServer 5, we need -belf to get full-featured binaries.
   738    SAVE_CFLAGS="$CFLAGS"
   739    CFLAGS="$CFLAGS -belf"
   740    echo $ac_n "checking whether the C compiler needs -belf""... $ac_c" 1>&6
   741 -echo "configure:1724: checking whether the C compiler needs -belf" >&5
   742 +echo "configure:1791: checking whether the C compiler needs -belf" >&5
   743  if eval "test \"`echo '$''{'lt_cv_cc_needs_belf'+set}'`\" = set"; then
   744    echo $ac_n "(cached) $ac_c" 1>&6
   745  else
   746 @@ -1733,14 +1800,14 @@
   747  cross_compiling=$ac_cv_prog_cc_cross
   748  
   749       cat > conftest.$ac_ext <<EOF
   750 -#line 1737 "configure"
   751 +#line 1804 "configure"
   752  #include "confdefs.h"
   753  
   754  int main() {
   755  
   756  ; return 0; }
   757  EOF
   758 -if { (eval echo configure:1744: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   759 +if { (eval echo configure:1811: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   760    rm -rf conftest*
   761    lt_cv_cc_needs_belf=yes
   762  else
   763 @@ -1868,7 +1935,7 @@
   764  # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
   765  # ./install, which can be erroneously created by make from ./install.sh.
   766  echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
   767 -echo "configure:1872: checking for a BSD compatible install" >&5
   768 +echo "configure:1939: checking for a BSD compatible install" >&5
   769  if test -z "$INSTALL"; then
   770  if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
   771    echo $ac_n "(cached) $ac_c" 1>&6
   772 @@ -1921,7 +1988,7 @@
   773  test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
   774  
   775  echo $ac_n "checking whether build environment is sane""... $ac_c" 1>&6
   776 -echo "configure:1925: checking whether build environment is sane" >&5
   777 +echo "configure:1992: checking whether build environment is sane" >&5
   778  # Just in case
   779  sleep 1
   780  echo timestamp > conftestfile
   781 @@ -1978,7 +2045,7 @@
   782  test "$program_transform_name" = "" && program_transform_name="s,x,x,"
   783  
   784  echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6
   785 -echo "configure:1982: checking whether ${MAKE-make} sets \${MAKE}" >&5
   786 +echo "configure:2049: checking whether ${MAKE-make} sets \${MAKE}" >&5
   787  set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'`
   788  if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then
   789    echo $ac_n "(cached) $ac_c" 1>&6
   790 @@ -2017,7 +2084,7 @@
   791  
   792  missing_dir=`cd $ac_aux_dir && pwd`
   793  echo $ac_n "checking for working aclocal""... $ac_c" 1>&6
   794 -echo "configure:2021: checking for working aclocal" >&5
   795 +echo "configure:2088: checking for working aclocal" >&5
   796  # Run test in a subshell; some versions of sh will print an error if
   797  # an executable is not found, even if stderr is redirected.
   798  # Redirect stdin to placate older versions of autoconf.  Sigh.
   799 @@ -2030,7 +2097,7 @@
   800  fi
   801  
   802  echo $ac_n "checking for working autoconf""... $ac_c" 1>&6
   803 -echo "configure:2034: checking for working autoconf" >&5
   804 +echo "configure:2101: checking for working autoconf" >&5
   805  # Run test in a subshell; some versions of sh will print an error if
   806  # an executable is not found, even if stderr is redirected.
   807  # Redirect stdin to placate older versions of autoconf.  Sigh.
   808 @@ -2043,7 +2110,7 @@
   809  fi
   810  
   811  echo $ac_n "checking for working automake""... $ac_c" 1>&6
   812 -echo "configure:2047: checking for working automake" >&5
   813 +echo "configure:2114: checking for working automake" >&5
   814  # Run test in a subshell; some versions of sh will print an error if
   815  # an executable is not found, even if stderr is redirected.
   816  # Redirect stdin to placate older versions of autoconf.  Sigh.
   817 @@ -2056,7 +2123,7 @@
   818  fi
   819  
   820  echo $ac_n "checking for working autoheader""... $ac_c" 1>&6
   821 -echo "configure:2060: checking for working autoheader" >&5
   822 +echo "configure:2127: checking for working autoheader" >&5
   823  # Run test in a subshell; some versions of sh will print an error if
   824  # an executable is not found, even if stderr is redirected.
   825  # Redirect stdin to placate older versions of autoconf.  Sigh.
   826 @@ -2069,7 +2136,7 @@
   827  fi
   828  
   829  echo $ac_n "checking for working makeinfo""... $ac_c" 1>&6
   830 -echo "configure:2073: checking for working makeinfo" >&5
   831 +echo "configure:2140: checking for working makeinfo" >&5
   832  # Run test in a subshell; some versions of sh will print an error if
   833  # an executable is not found, even if stderr is redirected.
   834  # Redirect stdin to placate older versions of autoconf.  Sigh.
   835 @@ -2086,7 +2153,7 @@
   836  
   837  
   838  echo $ac_n "checking for executable suffix""... $ac_c" 1>&6
   839 -echo "configure:2090: checking for executable suffix" >&5
   840 +echo "configure:2157: checking for executable suffix" >&5
   841  if eval "test \"`echo '$''{'ac_cv_exeext'+set}'`\" = set"; then
   842    echo $ac_n "(cached) $ac_c" 1>&6
   843  else
   844 @@ -2096,7 +2163,7 @@
   845    rm -f conftest*
   846    echo 'int main () { return 0; }' > conftest.$ac_ext
   847    ac_cv_exeext=
   848 -  if { (eval echo configure:2100: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then
   849 +  if { (eval echo configure:2167: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then
   850      for file in conftest.*; do
   851        case $file in
   852        *.c | *.o | *.obj) ;;
   853 @@ -2117,7 +2184,7 @@
   854  ac_exeext=$EXEEXT
   855  
   856  echo $ac_n "checking whether to enable maintainer-specific portions of Makefiles""... $ac_c" 1>&6
   857 -echo "configure:2121: checking whether to enable maintainer-specific portions of Makefiles" >&5
   858 +echo "configure:2188: checking whether to enable maintainer-specific portions of Makefiles" >&5
   859      # Check whether --enable-maintainer-mode or --disable-maintainer-mode was given.
   860  if test "${enable_maintainer_mode+set}" = set; then
   861    enableval="$enable_maintainer_mode"
   862 @@ -2143,7 +2210,7 @@
   863  # Extract the first word of "gcc", so it can be a program name with args.
   864  set dummy gcc; ac_word=$2
   865  echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
   866 -echo "configure:2147: checking for $ac_word" >&5
   867 +echo "configure:2214: checking for $ac_word" >&5
   868  if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
   869    echo $ac_n "(cached) $ac_c" 1>&6
   870  else
   871 @@ -2173,7 +2240,7 @@
   872    # Extract the first word of "cc", so it can be a program name with args.
   873  set dummy cc; ac_word=$2
   874  echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
   875 -echo "configure:2177: checking for $ac_word" >&5
   876 +echo "configure:2244: checking for $ac_word" >&5
   877  if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
   878    echo $ac_n "(cached) $ac_c" 1>&6
   879  else
   880 @@ -2224,7 +2291,7 @@
   881        # Extract the first word of "cl", so it can be a program name with args.
   882  set dummy cl; ac_word=$2
   883  echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
   884 -echo "configure:2228: checking for $ac_word" >&5
   885 +echo "configure:2295: checking for $ac_word" >&5
   886  if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
   887    echo $ac_n "(cached) $ac_c" 1>&6
   888  else
   889 @@ -2256,7 +2323,7 @@
   890  fi
   891  
   892  echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
   893 -echo "configure:2260: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
   894 +echo "configure:2327: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
   895  
   896  ac_ext=c
   897  # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
   898 @@ -2267,12 +2334,12 @@
   899  
   900  cat > conftest.$ac_ext << EOF
   901  
   902 -#line 2271 "configure"
   903 +#line 2338 "configure"
   904  #include "confdefs.h"
   905  
   906  main(){return(0);}
   907  EOF
   908 -if { (eval echo configure:2276: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   909 +if { (eval echo configure:2343: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   910    ac_cv_prog_cc_works=yes
   911    # If we can't run a trivial program, we are probably using a cross compiler.
   912    if (./conftest; exit) 2>/dev/null; then
   913 @@ -2298,12 +2365,12 @@
   914    { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
   915  fi
   916  echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
   917 -echo "configure:2302: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
   918 +echo "configure:2369: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
   919  echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6
   920  cross_compiling=$ac_cv_prog_cc_cross
   921  
   922  echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
   923 -echo "configure:2307: checking whether we are using GNU C" >&5
   924 +echo "configure:2374: checking whether we are using GNU C" >&5
   925  if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
   926    echo $ac_n "(cached) $ac_c" 1>&6
   927  else
   928 @@ -2312,7 +2379,7 @@
   929    yes;
   930  #endif
   931  EOF
   932 -if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:2316: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
   933 +if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:2383: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
   934    ac_cv_prog_gcc=yes
   935  else
   936    ac_cv_prog_gcc=no
   937 @@ -2331,7 +2398,7 @@
   938  ac_save_CFLAGS="$CFLAGS"
   939  CFLAGS=
   940  echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
   941 -echo "configure:2335: checking whether ${CC-cc} accepts -g" >&5
   942 +echo "configure:2402: checking whether ${CC-cc} accepts -g" >&5
   943  if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
   944    echo $ac_n "(cached) $ac_c" 1>&6
   945  else
   946 @@ -2381,17 +2448,23 @@
   947  i*86-*-mingw*) TARGET=X86_WIN32; TARGETDIR=x86;;
   948  sparc-sun-4*) TARGET=SPARC; TARGETDIR=sparc;;
   949  sparc*-sun-*) TARGET=SPARC; TARGETDIR=sparc;;
   950 -sparc-*-linux*) TARGET=SPARC; TARGETDIR=sparc;;
   951 -sparc64-*-linux*) TARGET=SPARC; TARGETDIR=sparc;;
   952 -alpha*-*-linux* | alpha*-*-osf* | alpha*-*-freebsd*) TARGET=ALPHA; TARGETDIR=alpha;;
   953 +sparc-*-linux* | sparc-*-netbsdelf*) TARGET=SPARC; TARGETDIR=sparc;;
   954 +sparc64-*-linux* | sparc64-*-netbsd*) TARGET=SPARC; TARGETDIR=sparc;;
   955 +alpha*-*-linux* | alpha*-*-osf* | alpha*-*-freebsd* | alpha*-*-netbsd*) TARGET=ALPHA; TARGETDIR=alpha;;
   956  ia64*-*-*) TARGET=IA64; TARGETDIR=ia64;;
   957  m68k-*-linux*) TARGET=M68K; TARGETDIR=m68k;;
   958 +mips64*-*);;
   959 +mips*-*-linux*) TARGET=MIPS_LINUX; TARGETDIR=mips;;
   960  powerpc-*-linux* | powerpc-*-sysv*) TARGET=POWERPC; TARGETDIR=powerpc;;
   961  powerpc-*-beos*) TARGET=POWERPC; TARGETDIR=powerpc;;
   962  powerpc-*-darwin*) TARGET=POWERPC_DARWIN; TARGETDIR=powerpc;;
   963  powerpc-*-aix*) TARGET=POWERPC_AIX; TARGETDIR=powerpc;;
   964  rs6000-*-aix*) TARGET=POWERPC_AIX; TARGETDIR=powerpc;;
   965  arm*-*-linux-*) TARGET=ARM; TARGETDIR=arm;;
   966 +s390-*-linux-*) TARGET=S390; TARGETDIR=s390;;
   967 +s390x-*-linux-*) TARGET=S390; TARGETDIR=s390;;
   968 +x86_64-*-linux*) TARGET=X86_64; TARGETDIR=x86;;
   969 +sh-*-linux* | sh[34]*-*-linux*) TARGET=SH; TARGETDIR=sh;;
   970  esac
   971  
   972  if test $TARGETDIR = unknown; then
   973 @@ -2418,6 +2491,15 @@
   974  fi
   975  
   976  
   977 +if test x$TARGET = xMIPS_LINUX; then
   978 +  MIPS_LINUX_TRUE=
   979 +  MIPS_LINUX_FALSE='#'
   980 +else
   981 +  MIPS_LINUX_TRUE='#'
   982 +  MIPS_LINUX_FALSE=
   983 +fi
   984 +
   985 +
   986  if test x$TARGET = xSPARC; then
   987    SPARC_TRUE=
   988    SPARC_FALSE='#'
   989 @@ -2507,8 +2589,39 @@
   990    ARM_FALSE=
   991  fi
   992  
   993 +
   994 +if test x$TARGET = xS390; then
   995 +  S390_TRUE=
   996 +  S390_FALSE='#'
   997 +else
   998 +  S390_TRUE='#'
   999 +  S390_FALSE=
  1000 +fi
  1001 +
  1002 +
  1003 +if test x$TARGET = xX86_64; then
  1004 +  X86_64_TRUE=
  1005 +  X86_64_FALSE='#'
  1006 +else
  1007 +  X86_64_TRUE='#'
  1008 +  X86_64_FALSE=
  1009 +fi
  1010 +
  1011 +
  1012 +if test x$TARGET = xSH; then
  1013 +  SH_TRUE=
  1014 +  SH_FALSE='#'
  1015 +else
  1016 +  SH_TRUE='#'
  1017 +  SH_FALSE=
  1018 +fi
  1019 +
  1020 +if test x$TARGET = xMIPS_LINUX; then
  1021 +  TARGET=MIPS
  1022 +fi
  1023 +
  1024  echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
  1025 -echo "configure:2512: checking how to run the C preprocessor" >&5
  1026 +echo "configure:2625: checking how to run the C preprocessor" >&5
  1027  # On Suns, sometimes $CPP names a directory.
  1028  if test -n "$CPP" && test -d "$CPP"; then
  1029    CPP=
  1030 @@ -2523,13 +2636,13 @@
  1031    # On the NeXT, cc -E runs the code through the compiler's parser,
  1032    # not just through cpp.
  1033    cat > conftest.$ac_ext <<EOF
  1034 -#line 2527 "configure"
  1035 +#line 2640 "configure"
  1036  #include "confdefs.h"
  1037  #include <assert.h>
  1038  Syntax Error
  1039  EOF
  1040  ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
  1041 -{ (eval echo configure:2533: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
  1042 +{ (eval echo configure:2646: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
  1043  ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
  1044  if test -z "$ac_err"; then
  1045    :
  1046 @@ -2540,13 +2653,13 @@
  1047    rm -rf conftest*
  1048    CPP="${CC-cc} -E -traditional-cpp"
  1049    cat > conftest.$ac_ext <<EOF
  1050 -#line 2544 "configure"
  1051 +#line 2657 "configure"
  1052  #include "confdefs.h"
  1053  #include <assert.h>
  1054  Syntax Error
  1055  EOF
  1056  ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
  1057 -{ (eval echo configure:2550: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
  1058 +{ (eval echo configure:2663: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
  1059  ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
  1060  if test -z "$ac_err"; then
  1061    :
  1062 @@ -2557,13 +2670,13 @@
  1063    rm -rf conftest*
  1064    CPP="${CC-cc} -nologo -E"
  1065    cat > conftest.$ac_ext <<EOF
  1066 -#line 2561 "configure"
  1067 +#line 2674 "configure"
  1068  #include "confdefs.h"
  1069  #include <assert.h>
  1070  Syntax Error
  1071  EOF
  1072  ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
  1073 -{ (eval echo configure:2567: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
  1074 +{ (eval echo configure:2680: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
  1075  ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
  1076  if test -z "$ac_err"; then
  1077    :
  1078 @@ -2588,12 +2701,12 @@
  1079  echo "$ac_t""$CPP" 1>&6
  1080  
  1081  echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
  1082 -echo "configure:2592: checking for ANSI C header files" >&5
  1083 +echo "configure:2705: checking for ANSI C header files" >&5
  1084  if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
  1085    echo $ac_n "(cached) $ac_c" 1>&6
  1086  else
  1087    cat > conftest.$ac_ext <<EOF
  1088 -#line 2597 "configure"
  1089 +#line 2710 "configure"
  1090  #include "confdefs.h"
  1091  #include <stdlib.h>
  1092  #include <stdarg.h>
  1093 @@ -2601,7 +2714,7 @@
  1094  #include <float.h>
  1095  EOF
  1096  ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
  1097 -{ (eval echo configure:2605: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
  1098 +{ (eval echo configure:2718: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
  1099  ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
  1100  if test -z "$ac_err"; then
  1101    rm -rf conftest*
  1102 @@ -2618,7 +2731,7 @@
  1103  if test $ac_cv_header_stdc = yes; then
  1104    # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
  1105  cat > conftest.$ac_ext <<EOF
  1106 -#line 2622 "configure"
  1107 +#line 2735 "configure"
  1108  #include "confdefs.h"
  1109  #include <string.h>
  1110  EOF
  1111 @@ -2636,7 +2749,7 @@
  1112  if test $ac_cv_header_stdc = yes; then
  1113    # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
  1114  cat > conftest.$ac_ext <<EOF
  1115 -#line 2640 "configure"
  1116 +#line 2753 "configure"
  1117  #include "confdefs.h"
  1118  #include <stdlib.h>
  1119  EOF
  1120 @@ -2657,7 +2770,7 @@
  1121    :
  1122  else
  1123    cat > conftest.$ac_ext <<EOF
  1124 -#line 2661 "configure"
  1125 +#line 2774 "configure"
  1126  #include "confdefs.h"
  1127  #include <ctype.h>
  1128  #define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
  1129 @@ -2668,7 +2781,7 @@
  1130  exit (0); }
  1131  
  1132  EOF
  1133 -if { (eval echo configure:2672: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
  1134 +if { (eval echo configure:2785: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
  1135  then
  1136    :
  1137  else
  1138 @@ -2694,12 +2807,12 @@
  1139  for ac_func in memcpy
  1140  do
  1141  echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
  1142 -echo "configure:2698: checking for $ac_func" >&5
  1143 +echo "configure:2811: checking for $ac_func" >&5
  1144  if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
  1145    echo $ac_n "(cached) $ac_c" 1>&6
  1146  else
  1147    cat > conftest.$ac_ext <<EOF
  1148 -#line 2703 "configure"
  1149 +#line 2816 "configure"
  1150  #include "confdefs.h"
  1151  /* System header to define __stub macros and hopefully few prototypes,
  1152      which can conflict with char $ac_func(); below.  */
  1153 @@ -2722,7 +2835,7 @@
  1154  
  1155  ; return 0; }
  1156  EOF
  1157 -if { (eval echo configure:2726: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
  1158 +if { (eval echo configure:2839: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
  1159    rm -rf conftest*
  1160    eval "ac_cv_func_$ac_func=yes"
  1161  else
  1162 @@ -2749,19 +2862,19 @@
  1163  # The Ultrix 4.2 mips builtin alloca declared by alloca.h only works
  1164  # for constant arguments.  Useless!
  1165  echo $ac_n "checking for working alloca.h""... $ac_c" 1>&6
  1166 -echo "configure:2753: checking for working alloca.h" >&5
  1167 +echo "configure:2866: checking for working alloca.h" >&5
  1168  if eval "test \"`echo '$''{'ac_cv_header_alloca_h'+set}'`\" = set"; then
  1169    echo $ac_n "(cached) $ac_c" 1>&6
  1170  else
  1171    cat > conftest.$ac_ext <<EOF
  1172 -#line 2758 "configure"
  1173 +#line 2871 "configure"
  1174  #include "confdefs.h"
  1175  #include <alloca.h>
  1176  int main() {
  1177  char *p = alloca(2 * sizeof(int));
  1178  ; return 0; }
  1179  EOF
  1180 -if { (eval echo configure:2765: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
  1181 +if { (eval echo configure:2878: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
  1182    rm -rf conftest*
  1183    ac_cv_header_alloca_h=yes
  1184  else
  1185 @@ -2782,12 +2895,12 @@
  1186  fi
  1187  
  1188  echo $ac_n "checking for alloca""... $ac_c" 1>&6
  1189 -echo "configure:2786: checking for alloca" >&5
  1190 +echo "configure:2899: checking for alloca" >&5
  1191  if eval "test \"`echo '$''{'ac_cv_func_alloca_works'+set}'`\" = set"; then
  1192    echo $ac_n "(cached) $ac_c" 1>&6
  1193  else
  1194    cat > conftest.$ac_ext <<EOF
  1195 -#line 2791 "configure"
  1196 +#line 2904 "configure"
  1197  #include "confdefs.h"
  1198  
  1199  #ifdef __GNUC__
  1200 @@ -2815,7 +2928,7 @@
  1201  char *p = (char *) alloca(1);
  1202  ; return 0; }
  1203  EOF
  1204 -if { (eval echo configure:2819: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
  1205 +if { (eval echo configure:2932: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
  1206    rm -rf conftest*
  1207    ac_cv_func_alloca_works=yes
  1208  else
  1209 @@ -2847,12 +2960,12 @@
  1210  
  1211  
  1212  echo $ac_n "checking whether alloca needs Cray hooks""... $ac_c" 1>&6
  1213 -echo "configure:2851: checking whether alloca needs Cray hooks" >&5
  1214 +echo "configure:2964: checking whether alloca needs Cray hooks" >&5
  1215  if eval "test \"`echo '$''{'ac_cv_os_cray'+set}'`\" = set"; then
  1216    echo $ac_n "(cached) $ac_c" 1>&6
  1217  else
  1218    cat > conftest.$ac_ext <<EOF
  1219 -#line 2856 "configure"
  1220 +#line 2969 "configure"
  1221  #include "confdefs.h"
  1222  #if defined(CRAY) && ! defined(CRAY2)
  1223  webecray
  1224 @@ -2877,12 +2990,12 @@
  1225  if test $ac_cv_os_cray = yes; then
  1226  for ac_func in _getb67 GETB67 getb67; do
  1227    echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
  1228 -echo "configure:2881: checking for $ac_func" >&5
  1229 +echo "configure:2994: checking for $ac_func" >&5
  1230  if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
  1231    echo $ac_n "(cached) $ac_c" 1>&6
  1232  else
  1233    cat > conftest.$ac_ext <<EOF
  1234 -#line 2886 "configure"
  1235 +#line 2999 "configure"
  1236  #include "confdefs.h"
  1237  /* System header to define __stub macros and hopefully few prototypes,
  1238      which can conflict with char $ac_func(); below.  */
  1239 @@ -2905,7 +3018,7 @@
  1240  
  1241  ; return 0; }
  1242  EOF
  1243 -if { (eval echo configure:2909: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
  1244 +if { (eval echo configure:3022: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
  1245    rm -rf conftest*
  1246    eval "ac_cv_func_$ac_func=yes"
  1247  else
  1248 @@ -2932,7 +3045,7 @@
  1249  fi
  1250  
  1251  echo $ac_n "checking stack direction for C alloca""... $ac_c" 1>&6
  1252 -echo "configure:2936: checking stack direction for C alloca" >&5
  1253 +echo "configure:3049: checking stack direction for C alloca" >&5
  1254  if eval "test \"`echo '$''{'ac_cv_c_stack_direction'+set}'`\" = set"; then
  1255    echo $ac_n "(cached) $ac_c" 1>&6
  1256  else
  1257 @@ -2940,7 +3053,7 @@
  1258    ac_cv_c_stack_direction=0
  1259  else
  1260    cat > conftest.$ac_ext <<EOF
  1261 -#line 2944 "configure"
  1262 +#line 3057 "configure"
  1263  #include "confdefs.h"
  1264  find_stack_direction ()
  1265  {
  1266 @@ -2959,7 +3072,7 @@
  1267    exit (find_stack_direction() < 0);
  1268  }
  1269  EOF
  1270 -if { (eval echo configure:2963: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
  1271 +if { (eval echo configure:3076: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
  1272  then
  1273    ac_cv_c_stack_direction=1
  1274  else
  1275 @@ -2982,13 +3095,13 @@
  1276  
  1277  
  1278  echo $ac_n "checking size of short""... $ac_c" 1>&6
  1279 -echo "configure:2986: checking size of short" >&5
  1280 +echo "configure:3099: checking size of short" >&5
  1281  if eval "test \"`echo '$''{'ac_cv_sizeof_short'+set}'`\" = set"; then
  1282    echo $ac_n "(cached) $ac_c" 1>&6
  1283  else
  1284    for ac_size in 4 8 1 2 16 12  ; do # List sizes in rough order of prevalence.
  1285    cat > conftest.$ac_ext <<EOF
  1286 -#line 2992 "configure"
  1287 +#line 3105 "configure"
  1288  #include "confdefs.h"
  1289  #include "confdefs.h"
  1290  #include <sys/types.h>
  1291 @@ -2998,7 +3111,7 @@
  1292  switch (0) case 0: case (sizeof (short) == $ac_size):;
  1293  ; return 0; }
  1294  EOF
  1295 -if { (eval echo configure:3002: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
  1296 +if { (eval echo configure:3115: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
  1297    rm -rf conftest*
  1298    ac_cv_sizeof_short=$ac_size
  1299  else
  1300 @@ -3021,13 +3134,13 @@
  1301  
  1302  
  1303  echo $ac_n "checking size of int""... $ac_c" 1>&6
  1304 -echo "configure:3025: checking size of int" >&5
  1305 +echo "configure:3138: checking size of int" >&5
  1306  if eval "test \"`echo '$''{'ac_cv_sizeof_int'+set}'`\" = set"; then
  1307    echo $ac_n "(cached) $ac_c" 1>&6
  1308  else
  1309    for ac_size in 4 8 1 2 16 12  ; do # List sizes in rough order of prevalence.
  1310    cat > conftest.$ac_ext <<EOF
  1311 -#line 3031 "configure"
  1312 +#line 3144 "configure"
  1313  #include "confdefs.h"
  1314  #include "confdefs.h"
  1315  #include <sys/types.h>
  1316 @@ -3037,7 +3150,7 @@
  1317  switch (0) case 0: case (sizeof (int) == $ac_size):;
  1318  ; return 0; }
  1319  EOF
  1320 -if { (eval echo configure:3041: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
  1321 +if { (eval echo configure:3154: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
  1322    rm -rf conftest*
  1323    ac_cv_sizeof_int=$ac_size
  1324  else
  1325 @@ -3060,13 +3173,13 @@
  1326  
  1327  
  1328  echo $ac_n "checking size of long""... $ac_c" 1>&6
  1329 -echo "configure:3064: checking size of long" >&5
  1330 +echo "configure:3177: checking size of long" >&5
  1331  if eval "test \"`echo '$''{'ac_cv_sizeof_long'+set}'`\" = set"; then
  1332    echo $ac_n "(cached) $ac_c" 1>&6
  1333  else
  1334    for ac_size in 4 8 1 2 16 12  ; do # List sizes in rough order of prevalence.
  1335    cat > conftest.$ac_ext <<EOF
  1336 -#line 3070 "configure"
  1337 +#line 3183 "configure"
  1338  #include "confdefs.h"
  1339  #include "confdefs.h"
  1340  #include <sys/types.h>
  1341 @@ -3076,7 +3189,7 @@
  1342  switch (0) case 0: case (sizeof (long) == $ac_size):;
  1343  ; return 0; }
  1344  EOF
  1345 -if { (eval echo configure:3080: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
  1346 +if { (eval echo configure:3193: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
  1347    rm -rf conftest*
  1348    ac_cv_sizeof_long=$ac_size
  1349  else
  1350 @@ -3099,13 +3212,13 @@
  1351  
  1352  
  1353  echo $ac_n "checking size of long long""... $ac_c" 1>&6
  1354 -echo "configure:3103: checking size of long long" >&5
  1355 +echo "configure:3216: checking size of long long" >&5
  1356  if eval "test \"`echo '$''{'ac_cv_sizeof_long_long'+set}'`\" = set"; then
  1357    echo $ac_n "(cached) $ac_c" 1>&6
  1358  else
  1359    for ac_size in 4 8 1 2 16 12  ; do # List sizes in rough order of prevalence.
  1360    cat > conftest.$ac_ext <<EOF
  1361 -#line 3109 "configure"
  1362 +#line 3222 "configure"
  1363  #include "confdefs.h"
  1364  #include "confdefs.h"
  1365  #include <sys/types.h>
  1366 @@ -3115,7 +3228,7 @@
  1367  switch (0) case 0: case (sizeof (long long) == $ac_size):;
  1368  ; return 0; }
  1369  EOF
  1370 -if { (eval echo configure:3119: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
  1371 +if { (eval echo configure:3232: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
  1372    rm -rf conftest*
  1373    ac_cv_sizeof_long_long=$ac_size
  1374  else
  1375 @@ -3138,13 +3251,13 @@
  1376  
  1377  
  1378  echo $ac_n "checking size of float""... $ac_c" 1>&6
  1379 -echo "configure:3142: checking size of float" >&5
  1380 +echo "configure:3255: checking size of float" >&5
  1381  if eval "test \"`echo '$''{'ac_cv_sizeof_float'+set}'`\" = set"; then
  1382    echo $ac_n "(cached) $ac_c" 1>&6
  1383  else
  1384    for ac_size in 4 8 1 2 16 12  ; do # List sizes in rough order of prevalence.
  1385    cat > conftest.$ac_ext <<EOF
  1386 -#line 3148 "configure"
  1387 +#line 3261 "configure"
  1388  #include "confdefs.h"
  1389  #include "confdefs.h"
  1390  #include <sys/types.h>
  1391 @@ -3154,7 +3267,7 @@
  1392  switch (0) case 0: case (sizeof (float) == $ac_size):;
  1393  ; return 0; }
  1394  EOF
  1395 -if { (eval echo configure:3158: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
  1396 +if { (eval echo configure:3271: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
  1397    rm -rf conftest*
  1398    ac_cv_sizeof_float=$ac_size
  1399  else
  1400 @@ -3177,13 +3290,13 @@
  1401  
  1402  
  1403  echo $ac_n "checking size of double""... $ac_c" 1>&6
  1404 -echo "configure:3181: checking size of double" >&5
  1405 +echo "configure:3294: checking size of double" >&5
  1406  if eval "test \"`echo '$''{'ac_cv_sizeof_double'+set}'`\" = set"; then
  1407    echo $ac_n "(cached) $ac_c" 1>&6
  1408  else
  1409    for ac_size in 4 8 1 2 16 12  ; do # List sizes in rough order of prevalence.
  1410    cat > conftest.$ac_ext <<EOF
  1411 -#line 3187 "configure"
  1412 +#line 3300 "configure"
  1413  #include "confdefs.h"
  1414  #include "confdefs.h"
  1415  #include <sys/types.h>
  1416 @@ -3193,7 +3306,7 @@
  1417  switch (0) case 0: case (sizeof (double) == $ac_size):;
  1418  ; return 0; }
  1419  EOF
  1420 -if { (eval echo configure:3197: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
  1421 +if { (eval echo configure:3310: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
  1422    rm -rf conftest*
  1423    ac_cv_sizeof_double=$ac_size
  1424  else
  1425 @@ -3216,13 +3329,13 @@
  1426  
  1427  
  1428  echo $ac_n "checking size of long double""... $ac_c" 1>&6
  1429 -echo "configure:3220: checking size of long double" >&5
  1430 +echo "configure:3333: checking size of long double" >&5
  1431  if eval "test \"`echo '$''{'ac_cv_sizeof_long_double'+set}'`\" = set"; then
  1432    echo $ac_n "(cached) $ac_c" 1>&6
  1433  else
  1434    for ac_size in 4 8 1 2 16 12  ; do # List sizes in rough order of prevalence.
  1435    cat > conftest.$ac_ext <<EOF
  1436 -#line 3226 "configure"
  1437 +#line 3339 "configure"
  1438  #include "confdefs.h"
  1439  #include "confdefs.h"
  1440  #include <sys/types.h>
  1441 @@ -3232,7 +3345,7 @@
  1442  switch (0) case 0: case (sizeof (long double) == $ac_size):;
  1443  ; return 0; }
  1444  EOF
  1445 -if { (eval echo configure:3236: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
  1446 +if { (eval echo configure:3349: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
  1447    rm -rf conftest*
  1448    ac_cv_sizeof_long_double=$ac_size
  1449  else
  1450 @@ -3256,13 +3369,13 @@
  1451  
  1452  
  1453  echo $ac_n "checking size of void *""... $ac_c" 1>&6
  1454 -echo "configure:3260: checking size of void *" >&5
  1455 +echo "configure:3373: checking size of void *" >&5
  1456  if eval "test \"`echo '$''{'ac_cv_sizeof_void_p'+set}'`\" = set"; then
  1457    echo $ac_n "(cached) $ac_c" 1>&6
  1458  else
  1459    for ac_size in 4 8 1 2 16 12  ; do # List sizes in rough order of prevalence.
  1460    cat > conftest.$ac_ext <<EOF
  1461 -#line 3266 "configure"
  1462 +#line 3379 "configure"
  1463  #include "confdefs.h"
  1464  #include "confdefs.h"
  1465  #include <sys/types.h>
  1466 @@ -3272,7 +3385,7 @@
  1467  switch (0) case 0: case (sizeof (void *) == $ac_size):;
  1468  ; return 0; }
  1469  EOF
  1470 -if { (eval echo configure:3276: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
  1471 +if { (eval echo configure:3389: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
  1472    rm -rf conftest*
  1473    ac_cv_sizeof_void_p=$ac_size
  1474  else
  1475 @@ -3295,14 +3408,14 @@
  1476  
  1477  
  1478  echo $ac_n "checking whether byte ordering is bigendian""... $ac_c" 1>&6
  1479 -echo "configure:3299: checking whether byte ordering is bigendian" >&5
  1480 +echo "configure:3412: checking whether byte ordering is bigendian" >&5
  1481  if eval "test \"`echo '$''{'ac_cv_c_bigendian'+set}'`\" = set"; then
  1482    echo $ac_n "(cached) $ac_c" 1>&6
  1483  else
  1484    ac_cv_c_bigendian=unknown
  1485  # See if sys/param.h defines the BYTE_ORDER macro.
  1486  cat > conftest.$ac_ext <<EOF
  1487 -#line 3306 "configure"
  1488 +#line 3419 "configure"
  1489  #include "confdefs.h"
  1490  #include <sys/types.h>
  1491  #include <sys/param.h>
  1492 @@ -3313,11 +3426,11 @@
  1493  #endif
  1494  ; return 0; }
  1495  EOF
  1496 -if { (eval echo configure:3317: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
  1497 +if { (eval echo configure:3430: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
  1498    rm -rf conftest*
  1499    # It does; now see whether it defined to BIG_ENDIAN or not.
  1500  cat > conftest.$ac_ext <<EOF
  1501 -#line 3321 "configure"
  1502 +#line 3434 "configure"
  1503  #include "confdefs.h"
  1504  #include <sys/types.h>
  1505  #include <sys/param.h>
  1506 @@ -3328,7 +3441,7 @@
  1507  #endif
  1508  ; return 0; }
  1509  EOF
  1510 -if { (eval echo configure:3332: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
  1511 +if { (eval echo configure:3445: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
  1512    rm -rf conftest*
  1513    ac_cv_c_bigendian=yes
  1514  else
  1515 @@ -3348,7 +3461,7 @@
  1516     echo $ac_n "cross-compiling... " 2>&6 
  1517  else
  1518    cat > conftest.$ac_ext <<EOF
  1519 -#line 3352 "configure"
  1520 +#line 3465 "configure"
  1521  #include "confdefs.h"
  1522  main () {
  1523    /* Are we little or big endian?  From Harbison&Steele.  */
  1524 @@ -3361,7 +3474,7 @@
  1525    exit (u.c[sizeof (long) - 1] == 1);
  1526  }
  1527  EOF
  1528 -if { (eval echo configure:3365: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
  1529 +if { (eval echo configure:3478: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
  1530  then
  1531    ac_cv_c_bigendian=no
  1532  else
  1533 @@ -3379,7 +3492,7 @@
  1534  echo "$ac_t""$ac_cv_c_bigendian" 1>&6
  1535  if test $ac_cv_c_bigendian = unknown; then
  1536  echo $ac_n "checking to probe for byte ordering""... $ac_c" 1>&6
  1537 -echo "configure:3383: checking to probe for byte ordering" >&5
  1538 +echo "configure:3496: checking to probe for byte ordering" >&5
  1539  
  1540  cat >conftest.c <<EOF
  1541  short ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 };
  1542 @@ -3414,6 +3527,10 @@
  1543  #define WORDS_BIGENDIAN 1
  1544  EOF
  1545  
  1546 +  cat >> confdefs.h <<\EOF
  1547 +#define HOST_WORDS_BIG_ENDIAN 1
  1548 +EOF
  1549 +
  1550    BYTEORDER=4321
  1551  else
  1552    BYTEORDER=1234
  1553 @@ -3429,7 +3546,7 @@
  1554  
  1555  if test x$TARGET = xSPARC; then
  1556      echo $ac_n "checking assembler and linker support unaligned pc related relocs""... $ac_c" 1>&6
  1557 -echo "configure:3433: checking assembler and linker support unaligned pc related relocs" >&5
  1558 +echo "configure:3550: checking assembler and linker support unaligned pc related relocs" >&5
  1559  if eval "test \"`echo '$''{'libffi_cv_as_sparc_ua_pcrel'+set}'`\" = set"; then
  1560    echo $ac_n "(cached) $ac_c" 1>&6
  1561  else
  1562 @@ -3439,14 +3556,14 @@
  1563  	CFLAGS="$CFLAGS -fpic"
  1564  	LDFLAGS="$LDFLAGS -shared"
  1565  	cat > conftest.$ac_ext <<EOF
  1566 -#line 3443 "configure"
  1567 +#line 3560 "configure"
  1568  #include "confdefs.h"
  1569  asm (".text; foo: nop; .data; .align 4; .byte 0; .uaword %r_disp32(foo); .text");
  1570  int main() {
  1571  
  1572  ; return 0; }
  1573  EOF
  1574 -if { (eval echo configure:3450: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
  1575 +if { (eval echo configure:3567: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
  1576    rm -rf conftest*
  1577    libffi_cv_as_sparc_ua_pcrel=yes
  1578  else
  1579 @@ -3709,6 +3826,8 @@
  1580  s%@MIPS_GCC_FALSE@%$MIPS_GCC_FALSE%g
  1581  s%@MIPS_SGI_TRUE@%$MIPS_SGI_TRUE%g
  1582  s%@MIPS_SGI_FALSE@%$MIPS_SGI_FALSE%g
  1583 +s%@MIPS_LINUX_TRUE@%$MIPS_LINUX_TRUE%g
  1584 +s%@MIPS_LINUX_FALSE@%$MIPS_LINUX_FALSE%g
  1585  s%@SPARC_TRUE@%$SPARC_TRUE%g
  1586  s%@SPARC_FALSE@%$SPARC_FALSE%g
  1587  s%@X86_TRUE@%$X86_TRUE%g
  1588 @@ -3729,6 +3848,12 @@
  1589  s%@POWERPC_DARWIN_FALSE@%$POWERPC_DARWIN_FALSE%g
  1590  s%@ARM_TRUE@%$ARM_TRUE%g
  1591  s%@ARM_FALSE@%$ARM_FALSE%g
  1592 +s%@S390_TRUE@%$S390_TRUE%g
  1593 +s%@S390_FALSE@%$S390_FALSE%g
  1594 +s%@X86_64_TRUE@%$X86_64_TRUE%g
  1595 +s%@X86_64_FALSE@%$X86_64_FALSE%g
  1596 +s%@SH_TRUE@%$SH_TRUE%g
  1597 +s%@SH_FALSE@%$SH_FALSE%g
  1598  s%@CPP@%$CPP%g
  1599  s%@ALLOCA@%$ALLOCA%g
  1600  s%@TARGET@%$TARGET%g
  1601 @@ -3969,7 +4094,7 @@
  1602  
  1603  if test -n "$CONFIG_FILES"; then
  1604     LD="${ORIGINAL_LD_FOR_MULTILIBS}"
  1605 -   ac_file=Makefile . ${libffi_basedir}/../config-ml.in
  1606 +   ac_file=Makefile . ${srcdir}/${libffi_basedir}../config-ml.in
  1607  fi
  1608  
  1609  exit 0
  1610 diff -ruN --exclude=CVS gcc-3.2.2.orig/libffi/configure.in gcc/libffi/configure.in
  1611 --- gcc-3.2.2.orig/libffi/configure.in	Tue Jan 28 10:43:56 2003
  1612 +++ gcc/libffi/configure.in	Sat Feb  1 20:16:19 2003
  1613 @@ -22,14 +22,15 @@
  1614  
  1615  if test "${srcdir}" = "."; then
  1616    if test "${with_target_subdir}" != "."; then
  1617 -    libffi_basedir="${srcdir}/${with_multisrctop}.."
  1618 +    libffi_basedir="${with_multisrctop}../"
  1619    else
  1620 -    libffi_basedir="${srcdir}/${with_multisrctop}"
  1621 +    libffi_basedir="${with_multisrctop}"
  1622    fi
  1623  else
  1624 -  libffi_basedir="${srcdir}"
  1625 +  libffi_basedir=
  1626  fi
  1627  AC_SUBST(libffi_basedir)
  1628 +AC_CONFIG_AUX_DIR(${libffi_basedir}..)
  1629  
  1630  AC_CANONICAL_HOST
  1631  
  1632 @@ -56,17 +57,23 @@
  1633  i*86-*-mingw*) TARGET=X86_WIN32; TARGETDIR=x86;;
  1634  sparc-sun-4*) TARGET=SPARC; TARGETDIR=sparc;;
  1635  sparc*-sun-*) TARGET=SPARC; TARGETDIR=sparc;;
  1636 -sparc-*-linux*) TARGET=SPARC; TARGETDIR=sparc;;
  1637 -sparc64-*-linux*) TARGET=SPARC; TARGETDIR=sparc;;
  1638 -alpha*-*-linux* | alpha*-*-osf* | alpha*-*-freebsd*) TARGET=ALPHA; TARGETDIR=alpha;;
  1639 +sparc-*-linux* | sparc-*-netbsdelf*) TARGET=SPARC; TARGETDIR=sparc;;
  1640 +sparc64-*-linux* | sparc64-*-netbsd*) TARGET=SPARC; TARGETDIR=sparc;;
  1641 +alpha*-*-linux* | alpha*-*-osf* | alpha*-*-freebsd* | alpha*-*-netbsd*) TARGET=ALPHA; TARGETDIR=alpha;;
  1642  ia64*-*-*) TARGET=IA64; TARGETDIR=ia64;;
  1643  m68k-*-linux*) TARGET=M68K; TARGETDIR=m68k;;
  1644 +mips64*-*);;
  1645 +mips*-*-linux*) TARGET=MIPS_LINUX; TARGETDIR=mips;;
  1646  powerpc-*-linux* | powerpc-*-sysv*) TARGET=POWERPC; TARGETDIR=powerpc;;
  1647  powerpc-*-beos*) TARGET=POWERPC; TARGETDIR=powerpc;;
  1648  powerpc-*-darwin*) TARGET=POWERPC_DARWIN; TARGETDIR=powerpc;;
  1649  powerpc-*-aix*) TARGET=POWERPC_AIX; TARGETDIR=powerpc;;
  1650  rs6000-*-aix*) TARGET=POWERPC_AIX; TARGETDIR=powerpc;;
  1651  arm*-*-linux-*) TARGET=ARM; TARGETDIR=arm;;
  1652 +s390-*-linux-*) TARGET=S390; TARGETDIR=s390;;
  1653 +s390x-*-linux-*) TARGET=S390; TARGETDIR=s390;;
  1654 +x86_64-*-linux*) TARGET=X86_64; TARGETDIR=x86;;
  1655 +sh-*-linux* | sh[[34]]*-*-linux*) TARGET=SH; TARGETDIR=sh;;
  1656  esac
  1657  
  1658  if test $TARGETDIR = unknown; then
  1659 @@ -75,6 +82,7 @@
  1660  
  1661  AM_CONDITIONAL(MIPS_GCC, test ${TARGET}${ac_cv_prog_gcc} = MIPSyes)
  1662  AM_CONDITIONAL(MIPS_SGI, test ${TARGET}${ac_cv_prog_gcc} = MIPSno)
  1663 +AM_CONDITIONAL(MIPS_LINUX, test x$TARGET = xMIPS_LINUX)
  1664  AM_CONDITIONAL(SPARC, test x$TARGET = xSPARC)
  1665  AM_CONDITIONAL(X86, test x$TARGET = xX86)
  1666  AM_CONDITIONAL(X86_WIN32, test x$TARGET = xX86_WIN32)
  1667 @@ -85,6 +93,13 @@
  1668  AM_CONDITIONAL(POWERPC_AIX, test x$TARGET = xPOWERPC_AIX)
  1669  AM_CONDITIONAL(POWERPC_DARWIN, test x$TARGET = xPOWERPC_DARWIN)
  1670  AM_CONDITIONAL(ARM, test x$TARGET = xARM)
  1671 +AM_CONDITIONAL(S390, test x$TARGET = xS390)
  1672 +AM_CONDITIONAL(X86_64, test x$TARGET = xX86_64)
  1673 +AM_CONDITIONAL(SH, test x$TARGET = xSH)
  1674 +
  1675 +if test x$TARGET = xMIPS_LINUX; then
  1676 +  TARGET=MIPS
  1677 +fi
  1678  
  1679  AC_HEADER_STDC
  1680  AC_CHECK_FUNCS(memcpy)
  1681 @@ -171,7 +186,7 @@
  1682  [
  1683  if test -n "$CONFIG_FILES"; then
  1684     LD="${ORIGINAL_LD_FOR_MULTILIBS}"
  1685 -   ac_file=Makefile . ${libffi_basedir}/../config-ml.in
  1686 +   ac_file=Makefile . ${srcdir}/${libffi_basedir}../config-ml.in
  1687  fi
  1688  ],
  1689  srcdir=${srcdir}
  1690 diff -ruN --exclude=CVS gcc-3.2.2.orig/libffi/include/Makefile.in gcc/libffi/include/Makefile.in
  1691 --- gcc-3.2.2.orig/libffi/include/Makefile.in	Tue Oct  9 14:32:16 2001
  1692 +++ gcc/libffi/include/Makefile.in	Mon Apr 29 13:14:44 2002
  1693 @@ -99,7 +99,7 @@
  1694  
  1695  DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
  1696  
  1697 -TAR = gnutar
  1698 +TAR = gtar
  1699  GZIP_ENV = --best
  1700  all: all-redirect
  1701  .SUFFIXES:
  1702 diff -ruN --exclude=CVS gcc-3.2.2.orig/libffi/include/ffi.h.in gcc/libffi/include/ffi.h.in
  1703 --- gcc-3.2.2.orig/libffi/include/ffi.h.in	Wed Mar 13 07:35:56 2002
  1704 +++ gcc/libffi/include/ffi.h.in	Wed Jan 29 00:54:28 2003
  1705 @@ -1,5 +1,5 @@
  1706  /* -----------------------------------------------------------------*-C-*-
  1707 -   libffi @VERSION@ - Copyright (c) 1996-2002  Cygnus Solutions
  1708 +   libffi @VERSION@ - Copyright (c) 1996-2003  Cygnus Solutions
  1709  
  1710     Permission is hereby granted, free of charge, to any person obtaining
  1711     a copy of this software and associated documentation files (the
  1712 @@ -164,6 +164,12 @@
  1713  #endif
  1714  #endif
  1715  
  1716 +#ifdef S390
  1717 +#if defined (__s390x__)
  1718 +#define S390X
  1719 +#endif
  1720 +#endif
  1721 +
  1722  #ifndef LIBFFI_ASM
  1723  
  1724  /* ---- Generic type definitions ----------------------------------------- */
  1725 @@ -189,16 +195,23 @@
  1726  #endif
  1727  #endif
  1728  
  1729 -  /* ---- Intel x86 ---------------- */
  1730 -#ifdef X86
  1731 +  /* ---- Intel x86 Win32 ---------- */
  1732 +#ifdef X86_WIN32
  1733    FFI_SYSV,
  1734 +  FFI_STDCALL,
  1735 +  /* TODO: Add fastcall support for the sake of completeness */
  1736    FFI_DEFAULT_ABI = FFI_SYSV,
  1737  #endif
  1738  
  1739 -  /* ---- Intel x86 Win32 ---------- */
  1740 -#ifdef X86_WIN32
  1741 +  /* ---- Intel x86 and AMD x86-64 - */
  1742 +#if !defined(X86_WIN32) && (defined(__i386__) || defined(__x86_64__))
  1743    FFI_SYSV,
  1744 +  FFI_UNIX64,   /* Unix variants all use the same ABI for x86-64  */
  1745 +#ifdef __i386__
  1746    FFI_DEFAULT_ABI = FFI_SYSV,
  1747 +#else
  1748 +  FFI_DEFAULT_ABI = FFI_UNIX64,
  1749 +#endif
  1750  #endif
  1751  
  1752    /* ---- Intel ia64 ---------------- */
  1753 @@ -251,6 +264,18 @@
  1754    FFI_DEFAULT_ABI = FFI_SYSV,
  1755  #endif
  1756  
  1757 +  /* ---- S390 --------------------- */
  1758 +#ifdef S390
  1759 +  FFI_SYSV,
  1760 +  FFI_DEFAULT_ABI = FFI_SYSV,
  1761 +#endif
  1762 +
  1763 +  /* ---- SuperH ------------------- */
  1764 +#ifdef SH
  1765 +  FFI_SYSV,
  1766 +  FFI_DEFAULT_ABI = FFI_SYSV,
  1767 +#endif
  1768 +
  1769    /* Leave this for debugging purposes */
  1770    FFI_LAST_ABI
  1771  
  1772 @@ -264,7 +289,7 @@
  1773    /*@null@*/ struct _ffi_type **elements;
  1774  } ffi_type;
  1775  
  1776 -/* These are defined in ffi.c */
  1777 +/* These are defined in types.c */
  1778  extern ffi_type ffi_type_void;
  1779  extern ffi_type ffi_type_uint8;
  1780  extern ffi_type ffi_type_sint8;
  1781 @@ -373,13 +398,7 @@
  1782  
  1783  /* ---- Definitions for closures ----------------------------------------- */
  1784  
  1785 -#ifdef X86
  1786 -
  1787 -#define FFI_CLOSURES 1		/* x86 supports closures */
  1788 -#define FFI_TRAMPOLINE_SIZE 10
  1789 -#define FFI_NATIVE_RAW_API 1	/* and has native raw api support */
  1790 -
  1791 -#elif defined(X86_WIN32)
  1792 +#ifdef __i386__
  1793  
  1794  #define FFI_CLOSURES 1		/* x86 supports closures */
  1795  #define FFI_TRAMPOLINE_SIZE 10
  1796 @@ -424,6 +443,40 @@
  1797  #define FFI_TRAMPOLINE_SIZE 24 /* see struct below */ 
  1798  #define FFI_NATIVE_RAW_API 0
  1799  
  1800 +#elif defined(SPARC64)
  1801 +
  1802 +#define FFI_CLOSURES 1
  1803 +#define FFI_TRAMPOLINE_SIZE 24
  1804 +#define FFI_NATIVE_RAW_API 0
  1805 +
  1806 +#elif defined(SPARC)
  1807 +
  1808 +#define FFI_CLOSURES 1
  1809 +#define FFI_TRAMPOLINE_SIZE 16
  1810 +#define FFI_NATIVE_RAW_API 0
  1811 +
  1812 +#elif defined(S390)
  1813 +
  1814 +#define FFI_CLOSURES 1
  1815 +#ifdef S390X
  1816 +#define FFI_TRAMPOLINE_SIZE 32
  1817 +#else
  1818 +#define FFI_TRAMPOLINE_SIZE 16
  1819 +#endif
  1820 +#define FFI_NATIVE_RAW_API 0
  1821 +
  1822 +#elif defined(SH)
  1823 +
  1824 +#define FFI_CLOSURES 1
  1825 +#define FFI_TRAMPOLINE_SIZE 16
  1826 +#define FFI_NATIVE_RAW_API 0
  1827 +
  1828 +#elif defined(__x86_64__)
  1829 +
  1830 +#define FFI_CLOSURES 1
  1831 +#define FFI_TRAMPOLINE_SIZE 24
  1832 +#define FFI_NATIVE_RAW_API 0
  1833 +
  1834  #else 
  1835  
  1836  #define FFI_CLOSURES 0
  1837 diff -ruN --exclude=CVS gcc-3.2.2.orig/libffi/src/arm/ffi.c gcc/libffi/src/arm/ffi.c
  1838 --- gcc-3.2.2.orig/libffi/src/arm/ffi.c	Sat Mar  3 07:21:23 2001
  1839 +++ gcc/libffi/src/arm/ffi.c	Fri Jul 19 08:08:30 2002
  1840 @@ -36,13 +36,10 @@
  1841  /*@=exportheader@*/
  1842  {
  1843    register unsigned int i;
  1844 -  register int tmp;
  1845 -  register unsigned int avn;
  1846    register void **p_argv;
  1847    register char *argp;
  1848    register ffi_type **p_arg;
  1849  
  1850 -  tmp = 0;
  1851    argp = stack;
  1852  
  1853    if ( ecif->cif->rtype->type == FFI_TYPE_STRUCT ) {
  1854 @@ -50,11 +47,10 @@
  1855      argp += 4;
  1856    }
  1857  
  1858 -  avn = ecif->cif->nargs;
  1859    p_argv = ecif->avalue;
  1860  
  1861    for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types;
  1862 -       (i != 0) && (avn != 0);
  1863 +       (i != 0);
  1864         i--, p_arg++)
  1865      {
  1866        size_t z;
  1867 @@ -64,9 +60,6 @@
  1868  	argp = (char *) ALIGN(argp, (*p_arg)->alignment);
  1869        }
  1870  
  1871 -      if (avn != 0) 
  1872 -	{
  1873 -	  avn--;
  1874  	  z = (*p_arg)->size;
  1875  	  if (z < sizeof(int))
  1876  	    {
  1877 @@ -107,7 +100,6 @@
  1878  	    }
  1879  	  p_argv++;
  1880  	  argp += z;
  1881 -	}
  1882      }
  1883    
  1884    return;
  1885 diff -ruN --exclude=CVS gcc-3.2.2.orig/libffi/src/arm/sysv.S gcc/libffi/src/arm/sysv.S
  1886 --- gcc-3.2.2.orig/libffi/src/arm/sysv.S	Sat Mar  3 07:21:23 2001
  1887 +++ gcc/libffi/src/arm/sysv.S	Mon Sep 30 03:08:58 2002
  1888 @@ -28,8 +28,15 @@
  1889  #ifdef HAVE_MACHINE_ASM_H
  1890  #include <machine/asm.h>
  1891  #else
  1892 -/* XXX these lose for some platforms, I'm sure. */
  1893 +#ifdef __USER_LABEL_PREFIX__
  1894 +#define CONCAT1(a, b) CONCAT2(a, b)
  1895 +#define CONCAT2(a, b) a ## b
  1896 +
  1897 +/* Use the right prefix for global labels.  */
  1898 +#define CNAME(x) CONCAT1 (__USER_LABEL_PREFIX__, x)
  1899 +#else
  1900  #define CNAME(x) x
  1901 +#endif
  1902  #define ENTRY(x) .globl CNAME(x); .type CNAME(x),%function; CNAME(x):
  1903  #endif
  1904  	
  1905 @@ -96,12 +103,20 @@
  1906  
  1907  # return FLOAT
  1908  	cmp     a4, #FFI_TYPE_FLOAT
  1909 +#ifdef __SOFTFP__
  1910 +	streq	a1, [a3]
  1911 +#else
  1912  	stfeqs  f0, [a3]
  1913 +#endif
  1914  	beq     epilogue
  1915  
  1916  # return DOUBLE or LONGDOUBLE
  1917  	cmp     a4, #FFI_TYPE_DOUBLE
  1918 +#ifdef __SOFTFP__
  1919 +	stmeqia	a3, {a1, a2}
  1920 +#else
  1921  	stfeqd  f0, [a3]
  1922 +#endif
  1923  
  1924  epilogue:
  1925          ldmfd sp!, {a1-a4, fp, pc}
  1926 diff -ruN --exclude=CVS gcc-3.2.2.orig/libffi/src/java_raw_api.c gcc/libffi/src/java_raw_api.c
  1927 --- gcc-3.2.2.orig/libffi/src/java_raw_api.c	Tue Apr  9 07:31:14 2002
  1928 +++ gcc/libffi/src/java_raw_api.c	Tue Oct  8 23:55:02 2002
  1929 @@ -81,21 +81,14 @@
  1930  	{
  1931  	case FFI_TYPE_UINT8:
  1932  	case FFI_TYPE_SINT8:
  1933 -	  *args = (void*) ((char*)(raw++) + SIZEOF_ARG - 1);
  1934 +	  *args = (void*) ((char*)(raw++) + 3);
  1935  	  break;
  1936  	  
  1937  	case FFI_TYPE_UINT16:
  1938  	case FFI_TYPE_SINT16:
  1939 -	  *args = (void*) ((char*)(raw++) + SIZEOF_ARG - 2);
  1940 +	  *args = (void*) ((char*)(raw++) + 2);
  1941  	  break;
  1942  
  1943 -#if SIZEOF_ARG >= 4	  
  1944 -	case FFI_TYPE_UINT32:
  1945 -	case FFI_TYPE_SINT32:
  1946 -	  *args = (void*) ((char*)(raw++) + SIZEOF_ARG - 4);
  1947 -	  break;
  1948 -#endif
  1949 -	
  1950  #if SIZEOF_ARG == 8	  
  1951  	case FFI_TYPE_UINT64:
  1952  	case FFI_TYPE_SINT64:
  1953 @@ -157,31 +150,54 @@
  1954        switch ((*tp)->type)
  1955  	{
  1956  	case FFI_TYPE_UINT8:
  1957 +#if WORDS_BIGENDIAN
  1958 +	  *(UINT32*)(raw++) = *(UINT8*) (*args);
  1959 +#else
  1960  	  (raw++)->uint = *(UINT8*) (*args);
  1961 +#endif
  1962  	  break;
  1963  
  1964  	case FFI_TYPE_SINT8:
  1965 +#if WORDS_BIGENDIAN
  1966 +	  *(SINT32*)(raw++) = *(SINT8*) (*args);
  1967 +#else
  1968  	  (raw++)->sint = *(SINT8*) (*args);
  1969 +#endif
  1970  	  break;
  1971  
  1972  	case FFI_TYPE_UINT16:
  1973 +#if WORDS_BIGENDIAN
  1974 +	  *(UINT32*)(raw++) = *(UINT16*) (*args);
  1975 +#else
  1976  	  (raw++)->uint = *(UINT16*) (*args);
  1977 +#endif
  1978  	  break;
  1979  
  1980  	case FFI_TYPE_SINT16:
  1981 +#if WORDS_BIGENDIAN
  1982 +	  *(SINT32*)(raw++) = *(SINT16*) (*args);
  1983 +#else
  1984  	  (raw++)->sint = *(SINT16*) (*args);
  1985 +#endif
  1986  	  break;
  1987  
  1988 -#if SIZEOF_ARG >= 4
  1989  	case FFI_TYPE_UINT32:
  1990 +#if WORDS_BIGENDIAN
  1991 +	  *(UINT32*)(raw++) = *(UINT32*) (*args);
  1992 +#else
  1993  	  (raw++)->uint = *(UINT32*) (*args);
  1994 +#endif
  1995  	  break;
  1996  
  1997  	case FFI_TYPE_SINT32:
  1998 +#if WORDS_BIGENDIAN
  1999 +	  *(SINT32*)(raw++) = *(SINT32*) (*args);
  2000 +#else
  2001  	  (raw++)->sint = *(SINT32*) (*args);
  2002 -	  break;
  2003  #endif
  2004 -        case FFI_TYPE_FLOAT:
  2005 +	  break;
  2006 +
  2007 +	case FFI_TYPE_FLOAT:
  2008  	  (raw++)->flt = *(FLOAT32*) (*args);
  2009  	  break;
  2010  
  2011 @@ -211,6 +227,55 @@
  2012  
  2013  #if !FFI_NATIVE_RAW_API
  2014  
  2015 +static void
  2016 +ffi_java_rvalue_to_raw (ffi_cif *cif, void *rvalue)
  2017 +{
  2018 +#if WORDS_BIGENDIAN && SIZEOF_ARG == 8
  2019 +  switch (cif->rtype->type)
  2020 +    {
  2021 +    case FFI_TYPE_UINT8:
  2022 +    case FFI_TYPE_UINT16:
  2023 +    case FFI_TYPE_UINT32:
  2024 +      *(UINT64 *)rvalue <<= 32;
  2025 +      break;
  2026 +
  2027 +    case FFI_TYPE_SINT8:
  2028 +    case FFI_TYPE_SINT16:
  2029 +    case FFI_TYPE_SINT32:
  2030 +    case FFI_TYPE_INT:
  2031 +      *(SINT64 *)rvalue <<= 32;
  2032 +      break;
  2033 +
  2034 +    default:
  2035 +      break;
  2036 +    }
  2037 +#endif
  2038 +}
  2039 +
  2040 +static void
  2041 +ffi_java_raw_to_rvalue (ffi_cif *cif, void *rvalue)
  2042 +{
  2043 +#if WORDS_BIGENDIAN && SIZEOF_ARG == 8
  2044 +  switch (cif->rtype->type)
  2045 +    {
  2046 +    case FFI_TYPE_UINT8:
  2047 +    case FFI_TYPE_UINT16:
  2048 +    case FFI_TYPE_UINT32:
  2049 +      *(UINT64 *)rvalue >>= 32;
  2050 +      break;
  2051 +
  2052 +    case FFI_TYPE_SINT8:
  2053 +    case FFI_TYPE_SINT16:
  2054 +    case FFI_TYPE_SINT32:
  2055 +    case FFI_TYPE_INT:
  2056 +      *(SINT64 *)rvalue >>= 32;
  2057 +      break;
  2058 +
  2059 +    default:
  2060 +      break;
  2061 +    }
  2062 +#endif
  2063 +}
  2064  
  2065  /* This is a generic definition of ffi_raw_call, to be used if the
  2066   * native system does not provide a machine-specific implementation.
  2067 @@ -227,6 +292,7 @@
  2068    void **avalue = (void**) alloca (cif->nargs * sizeof (void*));
  2069    ffi_java_raw_to_ptrarray (cif, raw, avalue);
  2070    ffi_call (cif, fn, rvalue, avalue);
  2071 +  ffi_java_rvalue_to_raw (cif, rvalue);
  2072  }
  2073  
  2074  #if FFI_CLOSURES		/* base system provides closures */
  2075 @@ -240,6 +306,7 @@
  2076  
  2077    ffi_java_ptrarray_to_raw (cif, avalue, raw);
  2078    (*cl->fun) (cif, rvalue, raw, cl->user_data);
  2079 +  ffi_java_raw_to_rvalue (cif, rvalue);
  2080  }
  2081  
  2082  /* Again, here is the generic version of ffi_prep_raw_closure, which
  2083 diff -ruN --exclude=CVS gcc-3.2.2.orig/libffi/src/m68k/ffi.c gcc/libffi/src/m68k/ffi.c
  2084 --- gcc-3.2.2.orig/libffi/src/m68k/ffi.c	Sun Aug  8 22:27:19 1999
  2085 +++ gcc/libffi/src/m68k/ffi.c	Fri Jul 19 08:08:30 2002
  2086 @@ -16,14 +16,11 @@
  2087  ffi_prep_args (void *stack, extended_cif *ecif)
  2088  {
  2089    unsigned int i;
  2090 -  int tmp;
  2091 -  unsigned int avn;
  2092    void **p_argv;
  2093    char *argp;
  2094    ffi_type **p_arg;
  2095    void *struct_value_ptr;
  2096  
  2097 -  tmp = 0;
  2098    argp = stack;
  2099  
  2100    if (ecif->cif->rtype->type == FFI_TYPE_STRUCT
  2101 @@ -32,11 +29,10 @@
  2102    else
  2103      struct_value_ptr = NULL;
  2104  
  2105 -  avn = ecif->cif->nargs;
  2106    p_argv = ecif->avalue;
  2107  
  2108    for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types;
  2109 -       i != 0 && avn != 0;
  2110 +       i != 0;
  2111         i--, p_arg++)
  2112      {
  2113        size_t z;
  2114 @@ -45,9 +41,6 @@
  2115        if (((*p_arg)->alignment - 1) & (unsigned) argp)
  2116  	argp = (char *) ALIGN (argp, (*p_arg)->alignment);
  2117  
  2118 -      if (avn != 0) 
  2119 -	{
  2120 -	  avn--;
  2121  	  z = (*p_arg)->size;
  2122  	  if (z < sizeof (int))
  2123  	    {
  2124 @@ -82,7 +75,6 @@
  2125  	    memcpy (argp, *p_argv, z);
  2126  	  p_argv++;
  2127  	  argp += z;
  2128 -	}
  2129      }
  2130  
  2131    return struct_value_ptr;
  2132 diff -ruN --exclude=CVS gcc-3.2.2.orig/libffi/src/mips/ffi.c gcc/libffi/src/mips/ffi.c
  2133 --- gcc-3.2.2.orig/libffi/src/mips/ffi.c	Sat Mar  3 07:21:23 2001
  2134 +++ gcc/libffi/src/mips/ffi.c	Fri Jul 19 08:08:31 2002
  2135 @@ -23,6 +23,7 @@
  2136     OTHER DEALINGS IN THE SOFTWARE.
  2137     ----------------------------------------------------------------------- */
  2138  
  2139 +#include <sgidefs.h>
  2140  #include <ffi.h>
  2141  #include <ffi_common.h>
  2142  
  2143 @@ -50,7 +51,6 @@
  2144  			  int flags)
  2145  {
  2146    register int i;
  2147 -  register int avn;
  2148    register void **p_argv;
  2149    register char *argp;
  2150    register ffi_type **p_arg;
  2151 @@ -80,12 +80,9 @@
  2152        FIX_ARGP;
  2153      }
  2154  
  2155 -  avn = ecif->cif->nargs;
  2156    p_argv = ecif->avalue;
  2157  
  2158 -  for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types;
  2159 -       i && avn;
  2160 -       i--, p_arg++)
  2161 +  for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types; i; i--, p_arg++)
  2162      {
  2163        size_t z;
  2164  
  2165 @@ -101,9 +98,6 @@
  2166  #define OFFSET sizeof(int)
  2167  #endif      
  2168  
  2169 -      if (avn) 
  2170 -	{
  2171 -	  avn--;
  2172  	  z = (*p_arg)->size;
  2173  	  if (z < sizeof(SLOT_TYPE_UNSIGNED))
  2174  	    {
  2175 @@ -179,7 +173,6 @@
  2176  	  p_argv++;
  2177  	  argp += z;
  2178  	  FIX_ARGP;
  2179 -	}
  2180      }
  2181    
  2182    return;
  2183 diff -ruN --exclude=CVS gcc-3.2.2.orig/libffi/src/powerpc/darwin.S gcc/libffi/src/powerpc/darwin.S
  2184 --- gcc-3.2.2.orig/libffi/src/powerpc/darwin.S	Sat Jan 19 01:22:34 2002
  2185 +++ gcc/libffi/src/powerpc/darwin.S	Thu Jan 23 03:21:55 2003
  2186 @@ -3,8 +3,6 @@
  2187     
  2188     PowerPC Assembly glue.
  2189  
  2190 -   $Id: darwin.S,v 1.2 2002/01/18 16:22:34 dje Exp $
  2191 -
  2192     Permission is hereby granted, free of charge, to any person obtaining
  2193     a copy of this software and associated documentation files (the
  2194     ``Software''), to deal in the Software without restriction, including
  2195 @@ -39,30 +37,34 @@
  2196  .text
  2197  	.align 2
  2198  _ffi_call_DARWIN:
  2199 -	mr      r12,r8 // We only need r12 until the call, so it doesn't have to be saved...
  2200 +LFB0:	
  2201 +	mr      r12,r8		/* We only need r12 until the call,
  2202 +				so it doesn't have to be saved...  */
  2203 +LFB1:	
  2204  	/* Save the old stack pointer as AP.  */
  2205  	mr	r8,r1
  2206 -
  2207 +LCFI0:	
  2208  	/* Allocate the stack space we need.  */
  2209  	stwux	r1,r1,r4	
  2210  	
  2211  	/* Save registers we use.  */
  2212  	mflr	r9
  2213  
  2214 -	stw	r28,-16(r8)
  2215 +	stw	r28,-16(r8)	
  2216  	stw	r29,-12(r8)
  2217  	stw	r30, -8(r8)
  2218  	stw	r31, -4(r8)
  2219 -	
  2220 -	stw	r9,  8(r8)
  2221 +
  2222 +	stw	r9,  8(r8)	
  2223  	stw	r2, 20(r1)
  2224 +LCFI1:	
  2225  
  2226  	/* Save arguments over call...  */
  2227 -	mr	r31,r5	/* flags, */
  2228 -	mr	r30,r6	/* rvalue, */
  2229 -	mr	r29,r7	/* function address, */
  2230 -	mr	r28,r8	/* our AP. */
  2231 -		
  2232 +	mr	r31,r5	/* flags,  */
  2233 +	mr	r30,r6	/* rvalue,  */
  2234 +	mr	r29,r7	/* function address,  */
  2235 +	mr	r28,r8	/* our AP.  */
  2236 +LCFI2:		
  2237  	/* Call ffi_prep_args.  */
  2238  	mr	r4,r1
  2239  	li	r9,0
  2240 @@ -145,7 +147,8 @@
  2241  L(float_return_value):
  2242  	stfs	f1,0(r30)
  2243  	b	L(done_return_value)
  2244 -//END(_ffi_call_DARWIN)
  2245 +LFE1:	
  2246 +/* END(_ffi_call_DARWIN)  */
  2247  
  2248  /* Provide a null definition of _ffi_call_AIX.  */
  2249  .text
  2250 @@ -155,5 +158,61 @@
  2251  	.align 2
  2252  _ffi_call_AIX:
  2253  	blr
  2254 -//END(_ffi_call_AIX)
  2255 +/* END(_ffi_call_AIX)  */
  2256  
  2257 +.data
  2258 +.section __TEXT,__eh_frame
  2259 +Lframe1:
  2260 +	.set	L$set$0,LECIE1-LSCIE1
  2261 +	.long	L$set$0	; Length of Common Information Entry
  2262 +LSCIE1:
  2263 +	.long	0x0	; CIE Identifier Tag
  2264 +	.byte	0x1	; CIE Version
  2265 +	.ascii	"zR\0"	; CIE Augmentation
  2266 +	.byte	0x1	; uleb128 0x1; CIE Code Alignment Factor
  2267 +	.byte	0x7c	; sleb128 -4; CIE Data Alignment Factor
  2268 +	.byte	0x41	; CIE RA Column
  2269 +	.byte   0x1     ; uleb128 0x1; Augmentation size
  2270 +	.byte   0x10    ; FDE Encoding (pcrel)
  2271 +	.byte	0xc	; DW_CFA_def_cfa
  2272 +	.byte	0x1	; uleb128 0x1
  2273 +	.byte	0x0	; uleb128 0x0
  2274 +	.align	2
  2275 +LECIE1:
  2276 +LSFDE1:
  2277 +	.set	L$set$1,LEFDE1-LASFDE1
  2278 +	.long	L$set$1	; FDE Length
  2279 +LASFDE1:
  2280 +	.set	L$set$2,LASFDE1-Lframe1
  2281 +	.long	L$set$2	; FDE CIE offset
  2282 +	.long	LFB0-.	; FDE initial location
  2283 +	.set	L$set$3,LFE1-LFB0
  2284 +	.long	L$set$3	; FDE address range
  2285 +	.byte   0x0     ; uleb128 0x0; Augmentation size
  2286 +	.byte	0x4	; DW_CFA_advance_loc4
  2287 +	.set	L$set$4,LCFI0-LFB1
  2288 +	.long	L$set$4
  2289 +	.byte	0xd	; DW_CFA_def_cfa_register
  2290 +	.byte	0x08	; uleb128 0x08 
  2291 +	.byte	0x4	; DW_CFA_advance_loc4
  2292 +	.set	L$set$5,LCFI1-LCFI0
  2293 +	.long	L$set$5
  2294 +	.byte   0x11    ; DW_CFA_offset_extended_sf
  2295 +	.byte	0x41	; uleb128 0x41
  2296 +	.byte   0x7e    ; sleb128 -2
  2297 +	.byte	0x9f	; DW_CFA_offset, column 0x1f 
  2298 +	.byte	0x1	; uleb128 0x1 
  2299 +	.byte	0x9e	; DW_CFA_offset, column 0x1e
  2300 +	.byte	0x2	; uleb128 0x2
  2301 +	.byte	0x9d	; DW_CFA_offset, column 0x1d 
  2302 +	.byte	0x3	; uleb128 0x3 
  2303 +	.byte	0x9c	; DW_CFA_offset, column 0x1c 
  2304 +	.byte	0x4	; uleb128 0x4
  2305 +	.byte	0x4	; DW_CFA_advance_loc4 
  2306 +	.set	L$set$6,LCFI2-LCFI1
  2307 +	.long	L$set$6
  2308 +	.byte	0xd	; DW_CFA_def_cfa_register 
  2309 +	.byte	0x1c	; uleb128 0x1c 
  2310 +	.align 2
  2311 +LEFDE1:
  2312 +	
  2313 diff -ruN --exclude=CVS gcc-3.2.2.orig/libffi/src/prep_cif.c gcc/libffi/src/prep_cif.c
  2314 --- gcc-3.2.2.orig/libffi/src/prep_cif.c	Sat Mar  3 07:21:22 2001
  2315 +++ gcc/libffi/src/prep_cif.c	Mon Sep 30 20:59:42 2002
  2316 @@ -103,7 +103,8 @@
  2317    /* Perform a sanity check on the return type */
  2318    FFI_ASSERT(ffi_type_test(cif->rtype));
  2319  
  2320 -#ifndef M68K
  2321 +  /* x86-64 and s390 stack space allocation is handled in prep_machdep.  */
  2322 +#if !defined M68K && !defined __x86_64__ && !defined S390
  2323    /* Make space for the return structure pointer */
  2324    if (cif->rtype->type == FFI_TYPE_STRUCT
  2325  #ifdef SPARC
  2326 @@ -122,6 +123,7 @@
  2327        if (((*ptr)->size == 0) && (initialize_aggregate((*ptr)) != FFI_OK))
  2328  	return FFI_BAD_TYPEDEF;
  2329  
  2330 +#if !defined __x86_64__ && !defined S390
  2331  #ifdef SPARC
  2332        if (((*ptr)->type == FFI_TYPE_STRUCT
  2333  	   && ((*ptr)->size > 16 || cif->abi != FFI_V9))
  2334 @@ -137,6 +139,7 @@
  2335  	  
  2336  	  bytes += STACK_ARG_SIZE((*ptr)->size);
  2337  	}
  2338 +#endif
  2339      }
  2340  
  2341    cif->bytes = bytes;
  2342 diff -ruN --exclude=CVS gcc-3.2.2.orig/libffi/src/s390/ffi.c gcc/libffi/src/s390/ffi.c
  2343 --- gcc-3.2.2.orig/libffi/src/s390/ffi.c	Thu Jan  1 09:00:00 1970
  2344 +++ gcc/libffi/src/s390/ffi.c	Thu Feb  6 08:58:57 2003
  2345 @@ -0,0 +1,753 @@
  2346 +/* -----------------------------------------------------------------------
  2347 +   ffi.c - Copyright (c) 2000 Software AG
  2348 + 
  2349 +   S390 Foreign Function Interface
  2350 + 
  2351 +   Permission is hereby granted, free of charge, to any person obtaining
  2352 +   a copy of this software and associated documentation files (the
  2353 +   ``Software''), to deal in the Software without restriction, including
  2354 +   without limitation the rights to use, copy, modify, merge, publish,
  2355 +   distribute, sublicense, and/or sell copies of the Software, and to
  2356 +   permit persons to whom the Software is furnished to do so, subject to
  2357 +   the following conditions:
  2358 + 
  2359 +   The above copyright notice and this permission notice shall be included
  2360 +   in all copies or substantial portions of the Software.
  2361 + 
  2362 +   THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
  2363 +   OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  2364 +   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  2365 +   IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR
  2366 +   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  2367 +   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  2368 +   OTHER DEALINGS IN THE SOFTWARE.
  2369 +   ----------------------------------------------------------------------- */
  2370 +/*====================================================================*/
  2371 +/*                          Includes                                  */
  2372 +/*                          --------                                  */
  2373 +/*====================================================================*/
  2374 + 
  2375 +#include <ffi.h>
  2376 +#include <ffi_common.h>
  2377 + 
  2378 +#include <stdlib.h>
  2379 +#include <stdio.h>
  2380 + 
  2381 +/*====================== End of Includes =============================*/
  2382 + 
  2383 +/*====================================================================*/
  2384 +/*                           Defines                                  */
  2385 +/*                           -------                                  */
  2386 +/*====================================================================*/
  2387 +
  2388 +/* Maximum number of GPRs available for argument passing.  */ 
  2389 +#define MAX_GPRARGS 5
  2390 +
  2391 +/* Maximum number of FPRs available for argument passing.  */ 
  2392 +#ifdef __s390x__
  2393 +#define MAX_FPRARGS 4
  2394 +#else
  2395 +#define MAX_FPRARGS 2
  2396 +#endif
  2397 +
  2398 +/* Round to multiple of 16.  */
  2399 +#define ROUND_SIZE(size) (((size) + 15) & ~15)
  2400 +
  2401 +/* If these values change, sysv.S must be adapted!  */
  2402 +#define FFI390_RET_VOID		0
  2403 +#define FFI390_RET_STRUCT	1
  2404 +#define FFI390_RET_FLOAT	2
  2405 +#define FFI390_RET_DOUBLE	3
  2406 +#define FFI390_RET_INT32	4
  2407 +#define FFI390_RET_INT64	5
  2408 +
  2409 +/*===================== End of Defines ===============================*/
  2410 + 
  2411 +/*====================================================================*/
  2412 +/*                          Prototypes                                */
  2413 +/*                          ----------                                */
  2414 +/*====================================================================*/
  2415 + 
  2416 +static void ffi_prep_args (unsigned char *, extended_cif *);
  2417 +static int ffi_check_float_struct (ffi_type *);
  2418 +void
  2419 +#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 2)
  2420 +__attribute__ ((visibility ("hidden")))
  2421 +#endif
  2422 +ffi_closure_helper_SYSV (ffi_closure *, unsigned long *, 
  2423 +			 unsigned long long *, unsigned long *);
  2424 +
  2425 +/*====================== End of Prototypes ===========================*/
  2426 + 
  2427 +/*====================================================================*/
  2428 +/*                          Externals                                 */
  2429 +/*                          ---------                                 */
  2430 +/*====================================================================*/
  2431 + 
  2432 +extern void ffi_call_SYSV(unsigned,
  2433 +			  extended_cif *,
  2434 +			  void (*)(unsigned char *, extended_cif *),
  2435 +			  unsigned,
  2436 +			  void *,
  2437 +			  void (*fn)());
  2438 +
  2439 +extern void ffi_closure_SYSV(void);
  2440 + 
  2441 +/*====================== End of Externals ============================*/
  2442 + 
  2443 +/*====================================================================*/
  2444 +/*                                                                    */
  2445 +/* Name     - ffi_check_struct_type.                                  */
  2446 +/*                                                                    */
  2447 +/* Function - Determine if a structure can be passed within a         */
  2448 +/*            general purpose or floating point register.             */
  2449 +/*                                                                    */
  2450 +/*====================================================================*/
  2451 + 
  2452 +static int
  2453 +ffi_check_struct_type (ffi_type *arg)
  2454 +{
  2455 +  size_t size = arg->size;
  2456 +
  2457 +  /* If the struct has just one element, look at that element
  2458 +     to find out whether to consider the struct as floating point.  */
  2459 +  while (arg->type == FFI_TYPE_STRUCT 
  2460 +         && arg->elements[0] && !arg->elements[1])
  2461 +    arg = arg->elements[0];
  2462 +
  2463 +  /* Structs of size 1, 2, 4, and 8 are passed in registers,
  2464 +     just like the corresponding int/float types.  */
  2465 +  switch (size)
  2466 +    {
  2467 +      case 1:
  2468 +        return FFI_TYPE_UINT8;
  2469 +
  2470 +      case 2:
  2471 +        return FFI_TYPE_UINT16;
  2472 +
  2473 +      case 4:
  2474 +	if (arg->type == FFI_TYPE_FLOAT)
  2475 +          return FFI_TYPE_FLOAT;
  2476 +	else
  2477 +	  return FFI_TYPE_UINT32;
  2478 +
  2479 +      case 8:
  2480 +	if (arg->type == FFI_TYPE_DOUBLE)
  2481 +          return FFI_TYPE_DOUBLE;
  2482 +	else
  2483 +	  return FFI_TYPE_UINT64;
  2484 +
  2485 +      default:
  2486 +	break;
  2487 +    }
  2488 +
  2489 +  /* Other structs are passed via a pointer to the data.  */
  2490 +  return FFI_TYPE_POINTER;
  2491 +}
  2492 + 
  2493 +/*======================== End of Routine ============================*/
  2494 + 
  2495 +/*====================================================================*/
  2496 +/*                                                                    */
  2497 +/* Name     - ffi_prep_args.                                          */
  2498 +/*                                                                    */
  2499 +/* Function - Prepare parameters for call to function.                */
  2500 +/*                                                                    */
  2501 +/* ffi_prep_args is called by the assembly routine once stack space   */
  2502 +/* has been allocated for the function's arguments.                   */
  2503 +/*                                                                    */
  2504 +/*====================================================================*/
  2505 + 
  2506 +static void
  2507 +ffi_prep_args (unsigned char *stack, extended_cif *ecif)
  2508 +{
  2509 +  /* The stack space will be filled with those areas:
  2510 +
  2511 +	FPR argument register save area     (highest addresses)
  2512 +	GPR argument register save area
  2513 +	temporary struct copies
  2514 +	overflow argument area              (lowest addresses)
  2515 +
  2516 +     We set up the following pointers:
  2517 +
  2518 +        p_fpr: bottom of the FPR area (growing upwards)
  2519 +	p_gpr: bottom of the GPR area (growing upwards)
  2520 +	p_ov: bottom of the overflow area (growing upwards)
  2521 +	p_struct: top of the struct copy area (growing downwards)
  2522 +
  2523 +     All areas are kept aligned to twice the word size.  */
  2524 +
  2525 +  int gpr_off = ecif->cif->bytes;
  2526 +  int fpr_off = gpr_off + ROUND_SIZE (MAX_GPRARGS * sizeof (long));
  2527 +
  2528 +  unsigned long long *p_fpr = (unsigned long long *)(stack + fpr_off);
  2529 +  unsigned long *p_gpr = (unsigned long *)(stack + gpr_off);
  2530 +  unsigned char *p_struct = (unsigned char *)p_gpr;
  2531 +  unsigned long *p_ov = (unsigned long *)stack;
  2532 +
  2533 +  int n_fpr = 0;
  2534 +  int n_gpr = 0;
  2535 +  int n_ov = 0;
  2536 +
  2537 +  ffi_type **ptr;
  2538 +  void **p_argv = ecif->avalue;
  2539 +  int i;
  2540 + 
  2541 +  /* If we returning a structure then we set the first parameter register
  2542 +     to the address of where we are returning this structure.  */
  2543 +
  2544 +  if (ecif->cif->flags == FFI390_RET_STRUCT)
  2545 +    p_gpr[n_gpr++] = (unsigned long) ecif->rvalue;
  2546 +
  2547 +  /* Now for the arguments.  */
  2548 + 
  2549 +  for (ptr = ecif->cif->arg_types, i = ecif->cif->nargs;
  2550 +       i > 0;
  2551 +       i--, ptr++, p_argv++)
  2552 +    {
  2553 +      void *arg = *p_argv;
  2554 +      int type = (*ptr)->type;
  2555 +
  2556 +      /* Check how a structure type is passed.  */
  2557 +      if (type == FFI_TYPE_STRUCT)
  2558 +	{
  2559 +	  type = ffi_check_struct_type (*ptr);
  2560 +
  2561 +	  /* If we pass the struct via pointer, copy the data.  */
  2562 +	  if (type == FFI_TYPE_POINTER)
  2563 +	    {
  2564 +	      p_struct -= ROUND_SIZE ((*ptr)->size);
  2565 +	      memcpy (p_struct, (char *)arg, (*ptr)->size);
  2566 +	      arg = &p_struct;
  2567 +	    }
  2568 +	}
  2569 +
  2570 +      /* Pointers are passed like UINTs of the same size.  */
  2571 +      if (type == FFI_TYPE_POINTER)
  2572 +#ifdef __s390x__
  2573 +	type = FFI_TYPE_UINT64;
  2574 +#else
  2575 +	type = FFI_TYPE_UINT32;
  2576 +#endif
  2577 +
  2578 +      /* Now handle all primitive int/float data types.  */
  2579 +      switch (type) 
  2580 +	{
  2581 +	  case FFI_TYPE_DOUBLE:
  2582 +	    if (n_fpr < MAX_FPRARGS)
  2583 +	      p_fpr[n_fpr++] = *(unsigned long long *) arg;
  2584 +	    else
  2585 +#ifdef __s390x__
  2586 +	      p_ov[n_ov++] = *(unsigned long *) arg;
  2587 +#else
  2588 +	      p_ov[n_ov++] = ((unsigned long *) arg)[0],
  2589 +	      p_ov[n_ov++] = ((unsigned long *) arg)[1];
  2590 +#endif
  2591 +	    break;
  2592 +	
  2593 +	  case FFI_TYPE_FLOAT:
  2594 +	    if (n_fpr < MAX_FPRARGS)
  2595 +	      p_fpr[n_fpr++] = (long long) *(unsigned int *) arg << 32;
  2596 +	    else
  2597 +	      p_ov[n_ov++] = *(unsigned int *) arg;
  2598 +	    break;
  2599 + 
  2600 +	  case FFI_TYPE_UINT64:
  2601 +	  case FFI_TYPE_SINT64:
  2602 +#ifdef __s390x__
  2603 +	    if (n_gpr < MAX_GPRARGS)
  2604 +	      p_gpr[n_gpr++] = *(unsigned long *) arg;
  2605 +	    else
  2606 +	      p_ov[n_ov++] = *(unsigned long *) arg;
  2607 +#else
  2608 +	    if (n_gpr == MAX_GPRARGS-1)
  2609 +	      n_gpr = MAX_GPRARGS;
  2610 +	    if (n_gpr < MAX_GPRARGS)
  2611 +	      p_gpr[n_gpr++] = ((unsigned long *) arg)[0],
  2612 +	      p_gpr[n_gpr++] = ((unsigned long *) arg)[1];
  2613 +	    else
  2614 +	      p_ov[n_ov++] = ((unsigned long *) arg)[0],
  2615 +	      p_ov[n_ov++] = ((unsigned long *) arg)[1];
  2616 +#endif
  2617 +	    break;
  2618 + 
  2619 +	  case FFI_TYPE_UINT32:
  2620 +	    if (n_gpr < MAX_GPRARGS)
  2621 +	      p_gpr[n_gpr++] = *(unsigned int *) arg;
  2622 +	    else
  2623 +	      p_ov[n_ov++] = *(unsigned int *) arg;
  2624 +	    break;
  2625 + 
  2626 +	  case FFI_TYPE_INT:
  2627 +	  case FFI_TYPE_SINT32:
  2628 +	    if (n_gpr < MAX_GPRARGS)
  2629 +	      p_gpr[n_gpr++] = *(signed int *) arg;
  2630 +	    else
  2631 +	      p_ov[n_ov++] = *(signed int *) arg;
  2632 +	    break;
  2633 + 
  2634 +	  case FFI_TYPE_UINT16:
  2635 +	    if (n_gpr < MAX_GPRARGS)
  2636 +	      p_gpr[n_gpr++] = *(unsigned short *) arg;
  2637 +	    else
  2638 +	      p_ov[n_ov++] = *(unsigned short *) arg;
  2639 +	    break;
  2640 + 
  2641 +	  case FFI_TYPE_SINT16:
  2642 +	    if (n_gpr < MAX_GPRARGS)
  2643 +	      p_gpr[n_gpr++] = *(signed short *) arg;
  2644 +	    else
  2645 +	      p_ov[n_ov++] = *(signed short *) arg;
  2646 +	    break;
  2647 +
  2648 +	  case FFI_TYPE_UINT8:
  2649 +	    if (n_gpr < MAX_GPRARGS)
  2650 +	      p_gpr[n_gpr++] = *(unsigned char *) arg;
  2651 +	    else
  2652 +	      p_ov[n_ov++] = *(unsigned char *) arg;
  2653 +	    break;
  2654 + 
  2655 +	  case FFI_TYPE_SINT8:
  2656 +	    if (n_gpr < MAX_GPRARGS)
  2657 +	      p_gpr[n_gpr++] = *(signed char *) arg;
  2658 +	    else
  2659 +	      p_ov[n_ov++] = *(signed char *) arg;
  2660 +	    break;
  2661 + 
  2662 +	  default:
  2663 +	    FFI_ASSERT (0);
  2664 +	    break;
  2665 +        }
  2666 +    }
  2667 +}
  2668 +
  2669 +/*======================== End of Routine ============================*/
  2670 + 
  2671 +/*====================================================================*/
  2672 +/*                                                                    */
  2673 +/* Name     - ffi_prep_cif_machdep.                                   */
  2674 +/*                                                                    */
  2675 +/* Function - Perform machine dependent CIF processing.               */
  2676 +/*                                                                    */
  2677 +/*====================================================================*/
  2678 + 
  2679 +ffi_status
  2680 +ffi_prep_cif_machdep(ffi_cif *cif)
  2681 +{
  2682 +  size_t struct_size = 0;
  2683 +  int n_gpr = 0;
  2684 +  int n_fpr = 0;
  2685 +  int n_ov = 0;
  2686 +
  2687 +  ffi_type **ptr;
  2688 +  int i;
  2689 +
  2690 +  /* Determine return value handling.  */ 
  2691 +
  2692 +  switch (cif->rtype->type)
  2693 +    {
  2694 +      /* Void is easy.  */
  2695 +      case FFI_TYPE_VOID:
  2696 +	cif->flags = FFI390_RET_VOID;
  2697 +	break;
  2698 +
  2699 +      /* Structures are returned via a hidden pointer.  */
  2700 +      case FFI_TYPE_STRUCT:
  2701 +	cif->flags = FFI390_RET_STRUCT;
  2702 +	n_gpr++;  /* We need one GPR to pass the pointer.  */
  2703 +	break; 
  2704 +
  2705 +      /* Floating point values are returned in fpr 0.  */
  2706 +      case FFI_TYPE_FLOAT:
  2707 +	cif->flags = FFI390_RET_FLOAT;
  2708 +	break;
  2709 +
  2710 +      case FFI_TYPE_DOUBLE:
  2711 +	cif->flags = FFI390_RET_DOUBLE;
  2712 +	break;
  2713 +
  2714 +      /* Integer values are returned in gpr 2 (and gpr 3
  2715 +	 for 64-bit values on 31-bit machines).  */
  2716 +      case FFI_TYPE_UINT64:
  2717 +      case FFI_TYPE_SINT64:
  2718 +	cif->flags = FFI390_RET_INT64;
  2719 +	break;
  2720 +
  2721 +      case FFI_TYPE_POINTER:
  2722 +      case FFI_TYPE_INT:
  2723 +      case FFI_TYPE_UINT32:
  2724 +      case FFI_TYPE_SINT32:
  2725 +      case FFI_TYPE_UINT16:
  2726 +      case FFI_TYPE_SINT16:
  2727 +      case FFI_TYPE_UINT8:
  2728 +      case FFI_TYPE_SINT8:
  2729 +	/* These are to be extended to word size.  */
  2730 +#ifdef __s390x__
  2731 +	cif->flags = FFI390_RET_INT64;
  2732 +#else
  2733 +	cif->flags = FFI390_RET_INT32;
  2734 +#endif
  2735 +	break;
  2736 + 
  2737 +      default:
  2738 +        FFI_ASSERT (0);
  2739 +        break;
  2740 +    }
  2741 +
  2742 +  /* Now for the arguments.  */
  2743 + 
  2744 +  for (ptr = cif->arg_types, i = cif->nargs;
  2745 +       i > 0;
  2746 +       i--, ptr++)
  2747 +    {
  2748 +      int type = (*ptr)->type;
  2749 +
  2750 +      /* Check how a structure type is passed.  */
  2751 +      if (type == FFI_TYPE_STRUCT)
  2752 +	{
  2753 +	  type = ffi_check_struct_type (*ptr);
  2754 +
  2755 +	  /* If we pass the struct via pointer, we must reserve space
  2756 +	     to copy its data for proper call-by-value semantics.  */
  2757 +	  if (type == FFI_TYPE_POINTER)
  2758 +	    struct_size += ROUND_SIZE ((*ptr)->size);
  2759 +	}
  2760 +
  2761 +      /* Now handle all primitive int/float data types.  */
  2762 +      switch (type) 
  2763 +	{
  2764 +	  /* The first MAX_FPRARGS floating point arguments
  2765 +	     go in FPRs, the rest overflow to the stack.  */
  2766 +
  2767 +	  case FFI_TYPE_DOUBLE:
  2768 +	    if (n_fpr < MAX_FPRARGS)
  2769 +	      n_fpr++;
  2770 +	    else
  2771 +	      n_ov += sizeof (double) / sizeof (long);
  2772 +	    break;
  2773 +	
  2774 +	  case FFI_TYPE_FLOAT:
  2775 +	    if (n_fpr < MAX_FPRARGS)
  2776 +	      n_fpr++;
  2777 +	    else
  2778 +	      n_ov++;
  2779 +	    break;
  2780 +
  2781 +	  /* On 31-bit machines, 64-bit integers are passed in GPR pairs,
  2782 +	     if one is still available, or else on the stack.  If only one
  2783 +	     register is free, skip the register (it won't be used for any 
  2784 +	     subsequent argument either).  */
  2785 +	      
  2786 +#ifndef __s390x__
  2787 +	  case FFI_TYPE_UINT64:
  2788 +	  case FFI_TYPE_SINT64:
  2789 +	    if (n_gpr == MAX_GPRARGS-1)
  2790 +	      n_gpr = MAX_GPRARGS;
  2791 +	    if (n_gpr < MAX_GPRARGS)
  2792 +	      n_gpr += 2;
  2793 +	    else
  2794 +	      n_ov += 2;
  2795 +	    break;
  2796 +#endif
  2797 +
  2798 +	  /* Everything else is passed in GPRs (until MAX_GPRARGS
  2799 +	     have been used) or overflows to the stack.  */
  2800 +
  2801 +	  default: 
  2802 +	    if (n_gpr < MAX_GPRARGS)
  2803 +	      n_gpr++;
  2804 +	    else
  2805 +	      n_ov++;
  2806 +	    break;
  2807 +        }
  2808 +    }
  2809 +
  2810 +  /* Total stack space as required for overflow arguments
  2811 +     and temporary structure copies.  */
  2812 +
  2813 +  cif->bytes = ROUND_SIZE (n_ov * sizeof (long)) + struct_size;
  2814 + 
  2815 +  return FFI_OK;
  2816 +}
  2817 + 
  2818 +/*======================== End of Routine ============================*/
  2819 + 
  2820 +/*====================================================================*/
  2821 +/*                                                                    */
  2822 +/* Name     - ffi_call.                                               */
  2823 +/*                                                                    */
  2824 +/* Function - Call the FFI routine.                                   */
  2825 +/*                                                                    */
  2826 +/*====================================================================*/
  2827 + 
  2828 +void
  2829 +ffi_call(ffi_cif *cif,
  2830 +	 void (*fn)(),
  2831 +	 void *rvalue,
  2832 +	 void **avalue)
  2833 +{
  2834 +  int ret_type = cif->flags;
  2835 +  extended_cif ecif;
  2836 + 
  2837 +  ecif.cif    = cif;
  2838 +  ecif.avalue = avalue;
  2839 +  ecif.rvalue = rvalue;
  2840 +
  2841 +  /* If we don't have a return value, we need to fake one.  */
  2842 +  if (rvalue == NULL)
  2843 +    {
  2844 +      if (ret_type == FFI390_RET_STRUCT)
  2845 +	ecif.rvalue = alloca (cif->rtype->size);
  2846 +      else
  2847 +	ret_type = FFI390_RET_VOID;
  2848 +    } 
  2849 +
  2850 +  switch (cif->abi)
  2851 +    {
  2852 +      case FFI_SYSV:
  2853 +        ffi_call_SYSV (cif->bytes, &ecif, ffi_prep_args,
  2854 +		       ret_type, ecif.rvalue, fn);
  2855 +        break;
  2856 + 
  2857 +      default:
  2858 +        FFI_ASSERT (0);
  2859 +        break;
  2860 +    }
  2861 +}
  2862 + 
  2863 +/*======================== End of Routine ============================*/
  2864 +
  2865 +/*====================================================================*/
  2866 +/*                                                                    */
  2867 +/* Name     - ffi_closure_helper_SYSV.                                */
  2868 +/*                                                                    */
  2869 +/* Function - Call a FFI closure target function.                     */
  2870 +/*                                                                    */
  2871 +/*====================================================================*/
  2872 + 
  2873 +void
  2874 +ffi_closure_helper_SYSV (ffi_closure *closure,
  2875 +			 unsigned long *p_gpr,
  2876 +			 unsigned long long *p_fpr,
  2877 +			 unsigned long *p_ov)
  2878 +{
  2879 +  unsigned long long ret_buffer;
  2880 +
  2881 +  void *rvalue = &ret_buffer;
  2882 +  void **avalue;
  2883 +  void **p_arg;
  2884 +
  2885 +  int n_gpr = 0;
  2886 +  int n_fpr = 0;
  2887 +  int n_ov = 0;
  2888 +
  2889 +  ffi_type **ptr;
  2890 +  int i;
  2891 +
  2892 +  /* Allocate buffer for argument list pointers.  */
  2893 +
  2894 +  p_arg = avalue = alloca (closure->cif->nargs * sizeof (void *));
  2895 +
  2896 +  /* If we returning a structure, pass the structure address 
  2897 +     directly to the target function.  Otherwise, have the target 
  2898 +     function store the return value to the GPR save area.  */
  2899 +
  2900 +  if (closure->cif->flags == FFI390_RET_STRUCT)
  2901 +    rvalue = (void *) p_gpr[n_gpr++];
  2902 +
  2903 +  /* Now for the arguments.  */
  2904 +
  2905 +  for (ptr = closure->cif->arg_types, i = closure->cif->nargs;
  2906 +       i > 0;
  2907 +       i--, p_arg++, ptr++)
  2908 +    {
  2909 +      int deref_struct_pointer = 0;
  2910 +      int type = (*ptr)->type;
  2911 +
  2912 +      /* Check how a structure type is passed.  */
  2913 +      if (type == FFI_TYPE_STRUCT)
  2914 +	{
  2915 +	  type = ffi_check_struct_type (*ptr);
  2916 +
  2917 +	  /* If we pass the struct via pointer, remember to 
  2918 +	     retrieve the pointer later.  */
  2919 +	  if (type == FFI_TYPE_POINTER)
  2920 +	    deref_struct_pointer = 1;
  2921 +	}
  2922 +
  2923 +      /* Pointers are passed like UINTs of the same size.  */
  2924 +      if (type == FFI_TYPE_POINTER)
  2925 +#ifdef __s390x__
  2926 +	type = FFI_TYPE_UINT64;
  2927 +#else
  2928 +	type = FFI_TYPE_UINT32;
  2929 +#endif
  2930 +
  2931 +      /* Now handle all primitive int/float data types.  */
  2932 +      switch (type) 
  2933 +	{
  2934 +	  case FFI_TYPE_DOUBLE:
  2935 +	    if (n_fpr < MAX_FPRARGS)
  2936 +	      *p_arg = &p_fpr[n_fpr++];
  2937 +	    else
  2938 +	      *p_arg = &p_ov[n_ov], 
  2939 +	      n_ov += sizeof (double) / sizeof (long);
  2940 +	    break;
  2941 +	
  2942 +	  case FFI_TYPE_FLOAT:
  2943 +	    if (n_fpr < MAX_FPRARGS)
  2944 +	      *p_arg = &p_fpr[n_fpr++];
  2945 +	    else
  2946 +	      *p_arg = (char *)&p_ov[n_ov++] + sizeof (long) - 4;
  2947 +	    break;
  2948 + 
  2949 +	  case FFI_TYPE_UINT64:
  2950 +	  case FFI_TYPE_SINT64:
  2951 +#ifdef __s390x__
  2952 +	    if (n_gpr < MAX_GPRARGS)
  2953 +	      *p_arg = &p_gpr[n_gpr++];
  2954 +	    else
  2955 +	      *p_arg = &p_ov[n_ov++];
  2956 +#else
  2957 +	    if (n_gpr == MAX_GPRARGS-1)
  2958 +	      n_gpr = MAX_GPRARGS;
  2959 +	    if (n_gpr < MAX_GPRARGS)
  2960 +	      *p_arg = &p_gpr[n_gpr], n_gpr += 2;
  2961 +	    else
  2962 +	      *p_arg = &p_ov[n_ov], n_ov += 2;
  2963 +#endif
  2964 +	    break;
  2965 + 
  2966 +	  case FFI_TYPE_INT:
  2967 +	  case FFI_TYPE_UINT32:
  2968 +	  case FFI_TYPE_SINT32:
  2969 +	    if (n_gpr < MAX_GPRARGS)
  2970 +	      *p_arg = (char *)&p_gpr[n_gpr++] + sizeof (long) - 4;
  2971 +	    else
  2972 +	      *p_arg = (char *)&p_ov[n_ov++] + sizeof (long) - 4;
  2973 +	    break;
  2974 + 
  2975 +	  case FFI_TYPE_UINT16:
  2976 +	  case FFI_TYPE_SINT16:
  2977 +	    if (n_gpr < MAX_GPRARGS)
  2978 +	      *p_arg = (char *)&p_gpr[n_gpr++] + sizeof (long) - 2;
  2979 +	    else
  2980 +	      *p_arg = (char *)&p_ov[n_ov++] + sizeof (long) - 2;
  2981 +	    break;
  2982 +
  2983 +	  case FFI_TYPE_UINT8:
  2984 +	  case FFI_TYPE_SINT8:
  2985 +	    if (n_gpr < MAX_GPRARGS)
  2986 +	      *p_arg = (char *)&p_gpr[n_gpr++] + sizeof (long) - 1;
  2987 +	    else
  2988 +	      *p_arg = (char *)&p_ov[n_ov++] + sizeof (long) - 1;
  2989 +	    break;
  2990 + 
  2991 +	  default:
  2992 +	    FFI_ASSERT (0);
  2993 +	    break;
  2994 +        }
  2995 +
  2996 +      /* If this is a struct passed via pointer, we need to
  2997 +	 actually retrieve that pointer.  */
  2998 +      if (deref_struct_pointer)
  2999 +	*p_arg = *(void **)*p_arg;
  3000 +    }
  3001 +
  3002 +
  3003 +  /* Call the target function.  */
  3004 +  (closure->fun) (closure->cif, rvalue, avalue, closure->user_data);
  3005 +
  3006 +  /* Convert the return value.  */
  3007 +  switch (closure->cif->rtype->type)
  3008 +    {
  3009 +      /* Void is easy, and so is struct.  */
  3010 +      case FFI_TYPE_VOID:
  3011 +      case FFI_TYPE_STRUCT:
  3012 +	break;
  3013 +
  3014 +      /* Floating point values are returned in fpr 0.  */
  3015 +      case FFI_TYPE_FLOAT:
  3016 +	p_fpr[0] = (long long) *(unsigned int *) rvalue << 32;
  3017 +	break;
  3018 +
  3019 +      case FFI_TYPE_DOUBLE:
  3020 +	p_fpr[0] = *(unsigned long long *) rvalue;
  3021 +	break;
  3022 +
  3023 +      /* Integer values are returned in gpr 2 (and gpr 3
  3024 +	 for 64-bit values on 31-bit machines).  */
  3025 +      case FFI_TYPE_UINT64:
  3026 +      case FFI_TYPE_SINT64:
  3027 +#ifdef __s390x__
  3028 +	p_gpr[0] = *(unsigned long *) rvalue;
  3029 +#else
  3030 +	p_gpr[0] = ((unsigned long *) rvalue)[0],
  3031 +	p_gpr[1] = ((unsigned long *) rvalue)[1];
  3032 +#endif
  3033 +	break;
  3034 +
  3035 +      case FFI_TYPE_POINTER:
  3036 +      case FFI_TYPE_UINT32:
  3037 +      case FFI_TYPE_UINT16:
  3038 +      case FFI_TYPE_UINT8:
  3039 +	p_gpr[0] = *(unsigned long *) rvalue;
  3040 +	break;
  3041 +
  3042 +      case FFI_TYPE_INT:
  3043 +      case FFI_TYPE_SINT32:
  3044 +      case FFI_TYPE_SINT16:
  3045 +      case FFI_TYPE_SINT8:
  3046 +	p_gpr[0] = *(signed long *) rvalue;
  3047 +	break;
  3048 +
  3049 +      default:
  3050 +        FFI_ASSERT (0);
  3051 +        break;
  3052 +    }
  3053 +}
  3054 + 
  3055 +/*======================== End of Routine ============================*/
  3056 +
  3057 +/*====================================================================*/
  3058 +/*                                                                    */
  3059 +/* Name     - ffi_prep_closure.                                       */
  3060 +/*                                                                    */
  3061 +/* Function - Prepare a FFI closure.                                  */
  3062 +/*                                                                    */
  3063 +/*====================================================================*/
  3064 + 
  3065 +ffi_status
  3066 +ffi_prep_closure (ffi_closure *closure,
  3067 +                  ffi_cif *cif,
  3068 +                  void (*fun) (ffi_cif *, void *, void **, void *),
  3069 +                  void *user_data)
  3070 +{
  3071 +  FFI_ASSERT (cif->abi == FFI_SYSV);
  3072 +
  3073 +#ifndef __s390x__
  3074 +  *(short *)&closure->tramp [0] = 0x0d10;   /* basr %r1,0 */
  3075 +  *(short *)&closure->tramp [2] = 0x9801;   /* lm %r0,%r1,6(%r1) */
  3076 +  *(short *)&closure->tramp [4] = 0x1006;
  3077 +  *(short *)&closure->tramp [6] = 0x07f1;   /* br %r1 */
  3078 +  *(long  *)&closure->tramp [8] = (long)closure;
  3079 +  *(long  *)&closure->tramp[12] = (long)&ffi_closure_SYSV;
  3080 +#else
  3081 +  *(short *)&closure->tramp [0] = 0x0d10;   /* basr %r1,0 */
  3082 +  *(short *)&closure->tramp [2] = 0xeb01;   /* lmg %r0,%r1,14(%r1) */
  3083 +  *(short *)&closure->tramp [4] = 0x100e;
  3084 +  *(short *)&closure->tramp [6] = 0x0004;
  3085 +  *(short *)&closure->tramp [8] = 0x07f1;   /* br %r1 */
  3086 +  *(long  *)&closure->tramp[16] = (long)closure;
  3087 +  *(long  *)&closure->tramp[24] = (long)&ffi_closure_SYSV;
  3088 +#endif 
  3089 + 
  3090 +  closure->cif = cif;
  3091 +  closure->user_data = user_data;
  3092 +  closure->fun = fun;
  3093 + 
  3094 +  return FFI_OK;
  3095 +}
  3096 +
  3097 +/*======================== End of Routine ============================*/
  3098 + 
  3099 diff -ruN --exclude=CVS gcc-3.2.2.orig/libffi/src/s390/sysv.S gcc/libffi/src/s390/sysv.S
  3100 --- gcc-3.2.2.orig/libffi/src/s390/sysv.S	Thu Jan  1 09:00:00 1970
  3101 +++ gcc/libffi/src/s390/sysv.S	Thu Nov 28 01:44:35 2002
  3102 @@ -0,0 +1,425 @@
  3103 +/* -----------------------------------------------------------------------
  3104 +   sysv.S - Copyright (c) 2000 Software AG
  3105 + 
  3106 +   S390 Foreign Function Interface
  3107 + 
  3108 +   Permission is hereby granted, free of charge, to any person obtaining
  3109 +   a copy of this software and associated documentation files (the
  3110 +   ``Software''), to deal in the Software without restriction, including
  3111 +   without limitation the rights to use, copy, modify, merge, publish,
  3112 +   distribute, sublicense, and/or sell copies of the Software, and to
  3113 +   permit persons to whom the Software is furnished to do so, subject to
  3114 +   the following conditions:
  3115 + 
  3116 +   The above copyright notice and this permission notice shall be included
  3117 +   in all copies or substantial portions of the Software.
  3118 + 
  3119 +   THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
  3120 +   OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  3121 +   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  3122 +   IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
  3123 +   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  3124 +   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  3125 +   OTHER DEALINGS IN THE SOFTWARE.
  3126 +   ----------------------------------------------------------------------- */
  3127 +
  3128 +#ifndef __s390x__
  3129 + 
  3130 +.text
  3131 +
  3132 +	# r2:	cif->bytes
  3133 +	# r3:	&ecif
  3134 +	# r4:	ffi_prep_args
  3135 +	# r5:	ret_type
  3136 +	# r6:	ecif.rvalue
  3137 +	# ov:	fn 
  3138 + 
  3139 +	# This assumes we are using gas.
  3140 +	.globl	ffi_call_SYSV
  3141 +	.type	ffi_call_SYSV,%function
  3142 +ffi_call_SYSV:
  3143 +.LFB1:
  3144 +	stm	%r6,%r15,24(%r15)		# Save registers
  3145 +.LCFI0:
  3146 +	basr	%r13,0				# Set up base register
  3147 +.Lbase:
  3148 +	lr	%r11,%r15			# Set up frame pointer
  3149 +.LCFI1:
  3150 +	sr	%r15,%r2
  3151 +	ahi	%r15,-96-48			# Allocate stack
  3152 +	lr	%r8,%r6				# Save ecif.rvalue
  3153 +	sr	%r9,%r9
  3154 +	ic	%r9,.Ltable-.Lbase(%r13,%r5)	# Load epilog address
  3155 +	l	%r7,96(%r11)			# Load function address
  3156 +	st	%r11,0(%r15)			# Set up back chain
  3157 +	ahi	%r11,-48			# Register save area
  3158 +.LCFI2:
  3159 +
  3160 +	la	%r2,96(%r15)			# Save area
  3161 +						# r3 already holds &ecif
  3162 +	basr	%r14,%r4			# Call ffi_prep_args
  3163 +
  3164 +	lm	%r2,%r6,0(%r11)			# Load arguments
  3165 +	ld	%f0,32(%r11)
  3166 +	ld	%f2,40(%r11)
  3167 +	la	%r14,0(%r13,%r9)		# Set return address
  3168 +	br	%r7				# ... and call function
  3169 +
  3170 +.LretNone:					# Return void
  3171 +	l	%r4,48+56(%r11)
  3172 +	lm	%r6,%r15,48+24(%r11)
  3173 +	br	%r4
  3174 +
  3175 +.LretFloat:
  3176 +	l	%r4,48+56(%r11)
  3177 +	ste	%f0,0(%r8)			# Return float
  3178 +	lm	%r6,%r15,48+24(%r11)
  3179 +	br	%r4
  3180 + 
  3181 +.LretDouble:
  3182 +	l	%r4,48+56(%r11)
  3183 +	std	%f0,0(%r8)			# Return double
  3184 +	lm	%r6,%r15,48+24(%r11)
  3185 +	br	%r4
  3186 +
  3187 +.LretInt32:
  3188 +	l	%r4,48+56(%r11)
  3189 +	st	%r2,0(%r8)			# Return int
  3190 +	lm	%r6,%r15,48+24(%r11)
  3191 +	br	%r4
  3192 + 
  3193 +.LretInt64:
  3194 +	l	%r4,48+56(%r11)
  3195 +	stm	%r2,%r3,0(%r8)			# Return long long
  3196 +	lm	%r6,%r15,48+24(%r11)
  3197 +	br	%r4
  3198 + 
  3199 +.Ltable:
  3200 +	.byte	.LretNone-.Lbase		# FFI390_RET_VOID
  3201 +	.byte	.LretNone-.Lbase		# FFI390_RET_STRUCT
  3202 +	.byte	.LretFloat-.Lbase		# FFI390_RET_FLOAT
  3203 +	.byte	.LretDouble-.Lbase		# FFI390_RET_DOUBLE
  3204 +	.byte	.LretInt32-.Lbase		# FFI390_RET_INT32
  3205 +	.byte	.LretInt64-.Lbase		# FFI390_RET_INT64
  3206 +
  3207 +.LFE1: 
  3208 +.ffi_call_SYSV_end:
  3209 +	.size	 ffi_call_SYSV,.ffi_call_SYSV_end-ffi_call_SYSV
  3210 +
  3211 +
  3212 +	.globl	ffi_closure_SYSV
  3213 +	.type	ffi_closure_SYSV,%function
  3214 +ffi_closure_SYSV:
  3215 +.LFB2:
  3216 +	stm	%r12,%r15,48(%r15)		# Save registers
  3217 +.LCFI10:
  3218 +	basr	%r13,0				# Set up base register
  3219 +.Lcbase:
  3220 +	stm	%r2,%r6,8(%r15)			# Save arguments
  3221 +	std	%f0,64(%r15)
  3222 +	std	%f2,72(%r15)
  3223 +	lr	%r1,%r15			# Set up stack frame
  3224 +	ahi	%r15,-96
  3225 +.LCFI11:
  3226 +	l	%r12,.Lchelper-.Lcbase(%r13)	# Get helper function
  3227 +	lr	%r2,%r0				# Closure
  3228 +	la	%r3,8(%r1)			# GPRs
  3229 +	la	%r4,64(%r1)			# FPRs
  3230 +	la	%r5,96(%r1)			# Overflow
  3231 +	st	%r1,0(%r15)			# Set up back chain
  3232 +
  3233 +	bas	%r14,0(%r12,%r13)		# Call helper
  3234 +
  3235 +	l	%r4,96+56(%r15)
  3236 +	ld	%f0,96+64(%r15)			# Load return registers
  3237 +	lm	%r2,%r3,96+8(%r15)
  3238 +	lm	%r12,%r15,96+48(%r15)
  3239 +	br	%r4
  3240 +
  3241 +	.align 4
  3242 +.Lchelper:
  3243 +	.long	ffi_closure_helper_SYSV-.Lcbase
  3244 +
  3245 +.LFE2: 
  3246 +
  3247 +.ffi_closure_SYSV_end:
  3248 +	.size	 ffi_closure_SYSV,.ffi_closure_SYSV_end-ffi_closure_SYSV
  3249 +
  3250 +
  3251 +	.section	.eh_frame,"a",@progbits
  3252 +.Lframe1:
  3253 +	.4byte	.LECIE1-.LSCIE1	# Length of Common Information Entry
  3254 +.LSCIE1:
  3255 +	.4byte	0x0	# CIE Identifier Tag
  3256 +	.byte	0x1	# CIE Version
  3257 +	.ascii "zR\0"	# CIE Augmentation
  3258 +	.uleb128 0x1	# CIE Code Alignment Factor
  3259 +	.sleb128 -4	# CIE Data Alignment Factor
  3260 +	.byte	0xe	# CIE RA Column
  3261 +	.uleb128 0x1	# Augmentation size
  3262 +	.byte	0x1b	# FDE Encoding (pcrel sdata4)
  3263 +	.byte	0xc	# DW_CFA_def_cfa
  3264 +	.uleb128 0xf
  3265 +	.uleb128 0x60
  3266 +	.align	4
  3267 +.LECIE1:
  3268 +.LSFDE1:
  3269 +	.4byte	.LEFDE1-.LASFDE1	# FDE Length
  3270 +.LASFDE1:
  3271 +	.4byte	.LASFDE1-.Lframe1	# FDE CIE offset
  3272 +	.4byte	.LFB1-.	# FDE initial location
  3273 +	.4byte	.LFE1-.LFB1	# FDE address range
  3274 +	.uleb128 0x0	# Augmentation size
  3275 +	.byte	0x4	# DW_CFA_advance_loc4
  3276 +	.4byte	.LCFI0-.LFB1
  3277 +	.byte	0x8f	# DW_CFA_offset, column 0xf
  3278 +	.uleb128 0x9
  3279 +	.byte	0x8e	# DW_CFA_offset, column 0xe
  3280 +	.uleb128 0xa
  3281 +	.byte	0x8d	# DW_CFA_offset, column 0xd
  3282 +	.uleb128 0xb
  3283 +	.byte	0x8c	# DW_CFA_offset, column 0xc
  3284 +	.uleb128 0xc
  3285 +	.byte	0x8b	# DW_CFA_offset, column 0xb
  3286 +	.uleb128 0xd
  3287 +	.byte	0x8a	# DW_CFA_offset, column 0xa
  3288 +	.uleb128 0xe
  3289 +	.byte	0x89	# DW_CFA_offset, column 0x9
  3290 +	.uleb128 0xf
  3291 +	.byte	0x88	# DW_CFA_offset, column 0x8
  3292 +	.uleb128 0x10
  3293 +	.byte	0x87	# DW_CFA_offset, column 0x7
  3294 +	.uleb128 0x11
  3295 +	.byte	0x86	# DW_CFA_offset, column 0x6
  3296 +	.uleb128 0x12
  3297 +	.byte	0x4	# DW_CFA_advance_loc4
  3298 +	.4byte	.LCFI1-.LCFI0
  3299 +	.byte	0xd	# DW_CFA_def_cfa_register
  3300 +	.uleb128 0xb
  3301 +	.byte	0x4	# DW_CFA_advance_loc4
  3302 +	.4byte	.LCFI2-.LCFI1
  3303 +	.byte	0xe	# DW_CFA_def_cfa_offset
  3304 +	.uleb128 0x90
  3305 +	.align	4
  3306 +.LEFDE1:
  3307 +.LSFDE2:
  3308 +	.4byte	.LEFDE2-.LASFDE2	# FDE Length
  3309 +.LASFDE2:
  3310 +	.4byte	.LASFDE2-.Lframe1	# FDE CIE offset
  3311 +	.4byte	.LFB2-.	# FDE initial location
  3312 +	.4byte	.LFE2-.LFB2	# FDE address range
  3313 +	.uleb128 0x0	# Augmentation size
  3314 +	.byte	0x4	# DW_CFA_advance_loc4
  3315 +	.4byte	.LCFI10-.LFB2
  3316 +	.byte	0x8f	# DW_CFA_offset, column 0xf
  3317 +	.uleb128 0x9
  3318 +	.byte	0x8e	# DW_CFA_offset, column 0xe
  3319 +	.uleb128 0xa
  3320 +	.byte	0x8d	# DW_CFA_offset, column 0xd
  3321 +	.uleb128 0xb
  3322 +	.byte	0x8c	# DW_CFA_offset, column 0xc
  3323 +	.uleb128 0xc
  3324 +	.byte	0x4	# DW_CFA_advance_loc4
  3325 +	.4byte	.LCFI11-.LCFI10
  3326 +	.byte	0xe	# DW_CFA_def_cfa_offset
  3327 +	.uleb128 0xc0
  3328 +	.align	4
  3329 +.LEFDE2:
  3330 +
  3331 +#else
  3332 + 
  3333 +.text
  3334 + 
  3335 +	# r2:	cif->bytes
  3336 +	# r3:	&ecif
  3337 +	# r4:	ffi_prep_args
  3338 +	# r5:	ret_type
  3339 +	# r6:	ecif.rvalue
  3340 +	# ov:	fn 
  3341 + 
  3342 +	# This assumes we are using gas.
  3343 +	.globl	ffi_call_SYSV
  3344 +	.type	ffi_call_SYSV,%function
  3345 +ffi_call_SYSV:
  3346 +.LFB1:
  3347 +	stmg	%r6,%r15,48(%r15)		# Save registers
  3348 +.LCFI0:
  3349 +	larl	%r13,.Lbase			# Set up base register
  3350 +	lgr	%r11,%r15			# Set up frame pointer
  3351 +.LCFI1:
  3352 +	sgr	%r15,%r2
  3353 +	aghi	%r15,-160-80			# Allocate stack
  3354 +	lgr	%r8,%r6				# Save ecif.rvalue
  3355 +	llgc	%r9,.Ltable-.Lbase(%r13,%r5)	# Load epilog address
  3356 +	lg	%r7,160(%r11)			# Load function address
  3357 +	stg	%r11,0(%r15)			# Set up back chain
  3358 +	aghi	%r11,-80			# Register save area
  3359 +.LCFI2:
  3360 +
  3361 +	la	%r2,160(%r15)			# Save area
  3362 +						# r3 already holds &ecif
  3363 +	basr	%r14,%r4			# Call ffi_prep_args
  3364 +
  3365 +	lmg	%r2,%r6,0(%r11)			# Load arguments
  3366 +	ld	%f0,48(%r11)
  3367 +	ld	%f2,56(%r11)
  3368 +	ld	%f4,64(%r11)
  3369 +	ld	%f6,72(%r11)
  3370 +	la	%r14,0(%r13,%r9)		# Set return address
  3371 +	br	%r7				# ... and call function
  3372 +
  3373 +.Lbase:
  3374 +.LretNone:					# Return void
  3375 +	lg	%r4,80+112(%r11)
  3376 +	lmg	%r6,%r15,80+48(%r11)
  3377 +	br	%r4
  3378 +
  3379 +.LretFloat:
  3380 +	lg	%r4,80+112(%r11)
  3381 +	ste	%f0,0(%r8)			# Return float
  3382 +	lmg	%r6,%r15,80+48(%r11)
  3383 +	br	%r4
  3384 + 
  3385 +.LretDouble:
  3386 +	lg	%r4,80+112(%r11)
  3387 +	std	%f0,0(%r8)			# Return double
  3388 +	lmg	%r6,%r15,80+48(%r11)
  3389 +	br	%r4
  3390 +
  3391 +.LretInt32:
  3392 +	lg	%r4,80+112(%r11)
  3393 +	st	%r2,0(%r8)			# Return int
  3394 +	lmg	%r6,%r15,80+48(%r11)
  3395 +	br	%r4
  3396 + 
  3397 +.LretInt64:
  3398 +	lg	%r4,80+112(%r11)
  3399 +	stg	%r2,0(%r8)			# Return long
  3400 +	lmg	%r6,%r15,80+48(%r11)
  3401 +	br	%r4
  3402 + 
  3403 +.Ltable:
  3404 +	.byte	.LretNone-.Lbase		# FFI390_RET_VOID
  3405 +	.byte	.LretNone-.Lbase		# FFI390_RET_STRUCT
  3406 +	.byte	.LretFloat-.Lbase		# FFI390_RET_FLOAT
  3407 +	.byte	.LretDouble-.Lbase		# FFI390_RET_DOUBLE
  3408 +	.byte	.LretInt32-.Lbase		# FFI390_RET_INT32
  3409 +	.byte	.LretInt64-.Lbase		# FFI390_RET_INT64
  3410 +
  3411 +.LFE1: 
  3412 +.ffi_call_SYSV_end:
  3413 +	.size	 ffi_call_SYSV,.ffi_call_SYSV_end-ffi_call_SYSV
  3414 +
  3415 +
  3416 +	.globl	ffi_closure_SYSV
  3417 +	.type	ffi_closure_SYSV,%function
  3418 +ffi_closure_SYSV:
  3419 +.LFB2:
  3420 +	stmg	%r14,%r15,112(%r15)		# Save registers
  3421 +.LCFI10:
  3422 +	stmg	%r2,%r6,16(%r15)		# Save arguments
  3423 +	std	%f0,128(%r15)
  3424 +	std	%f2,136(%r15)
  3425 +	std	%f4,144(%r15)
  3426 +	std	%f6,152(%r15)
  3427 +	lgr	%r1,%r15			# Set up stack frame
  3428 +	aghi	%r15,-160
  3429 +.LCFI11:
  3430 +	lgr	%r2,%r0				# Closure
  3431 +	la	%r3,16(%r1)			# GPRs
  3432 +	la	%r4,128(%r1)			# FPRs
  3433 +	la	%r5,160(%r1)			# Overflow
  3434 +	stg	%r1,0(%r15)			# Set up back chain
  3435 +
  3436 +	brasl	%r14,ffi_closure_helper_SYSV	# Call helper
  3437 +
  3438 +	lg	%r14,160+112(%r15)
  3439 +	ld	%f0,160+128(%r15)		# Load return registers
  3440 +	lg	%r2,160+16(%r15)
  3441 +	la	%r15,160(%r15)
  3442 +	br	%r14
  3443 +.LFE2: 
  3444 +
  3445 +.ffi_closure_SYSV_end:
  3446 +	.size	 ffi_closure_SYSV,.ffi_closure_SYSV_end-ffi_closure_SYSV
  3447 +
  3448 +
  3449 +
  3450 +	.section	.eh_frame,"a",@progbits
  3451 +.Lframe1:
  3452 +	.4byte	.LECIE1-.LSCIE1	# Length of Common Information Entry
  3453 +.LSCIE1:
  3454 +	.4byte	0x0	# CIE Identifier Tag
  3455 +	.byte	0x1	# CIE Version
  3456 +	.ascii "zR\0"	# CIE Augmentation
  3457 +	.uleb128 0x1	# CIE Code Alignment Factor
  3458 +	.sleb128 -8	# CIE Data Alignment Factor
  3459 +	.byte	0xe	# CIE RA Column
  3460 +	.uleb128 0x1	# Augmentation size
  3461 +	.byte	0x1b	# FDE Encoding (pcrel sdata4)
  3462 +	.byte	0xc	# DW_CFA_def_cfa
  3463 +	.uleb128 0xf
  3464 +	.uleb128 0xa0
  3465 +	.align	8
  3466 +.LECIE1:
  3467 +.LSFDE1:
  3468 +	.4byte	.LEFDE1-.LASFDE1	# FDE Length
  3469 +.LASFDE1:
  3470 +	.4byte	.LASFDE1-.Lframe1	# FDE CIE offset
  3471 +	.4byte	.LFB1-.	# FDE initial location
  3472 +	.4byte	.LFE1-.LFB1	# FDE address range
  3473 +	.uleb128 0x0	# Augmentation size
  3474 +	.byte	0x4	# DW_CFA_advance_loc4
  3475 +	.4byte	.LCFI0-.LFB1
  3476 +	.byte	0x8f	# DW_CFA_offset, column 0xf
  3477 +	.uleb128 0x5
  3478 +	.byte	0x8e	# DW_CFA_offset, column 0xe
  3479 +	.uleb128 0x6
  3480 +	.byte	0x8d	# DW_CFA_offset, column 0xd
  3481 +	.uleb128 0x7
  3482 +	.byte	0x8c	# DW_CFA_offset, column 0xc
  3483 +	.uleb128 0x8
  3484 +	.byte	0x8b	# DW_CFA_offset, column 0xb
  3485 +	.uleb128 0x9
  3486 +	.byte	0x8a	# DW_CFA_offset, column 0xa
  3487 +	.uleb128 0xa
  3488 +	.byte	0x89	# DW_CFA_offset, column 0x9
  3489 +	.uleb128 0xb
  3490 +	.byte	0x88	# DW_CFA_offset, column 0x8
  3491 +	.uleb128 0xc
  3492 +	.byte	0x87	# DW_CFA_offset, column 0x7
  3493 +	.uleb128 0xd
  3494 +	.byte	0x86	# DW_CFA_offset, column 0x6
  3495 +	.uleb128 0xe
  3496 +	.byte	0x4	# DW_CFA_advance_loc4
  3497 +	.4byte	.LCFI1-.LCFI0
  3498 +	.byte	0xd	# DW_CFA_def_cfa_register
  3499 +	.uleb128 0xb
  3500 +	.byte	0x4	# DW_CFA_advance_loc4
  3501 +	.4byte	.LCFI2-.LCFI1
  3502 +	.byte	0xe	# DW_CFA_def_cfa_offset
  3503 +	.uleb128 0xf0
  3504 +	.align	8
  3505 +.LEFDE1:
  3506 +.LSFDE2:
  3507 +	.4byte	.LEFDE2-.LASFDE2	# FDE Length
  3508 +.LASFDE2:
  3509 +	.4byte	.LASFDE2-.Lframe1	# FDE CIE offset
  3510 +	.4byte	.LFB2-.	# FDE initial location
  3511 +	.4byte	.LFE2-.LFB2	# FDE address range
  3512 +	.uleb128 0x0	# Augmentation size
  3513 +	.byte	0x4	# DW_CFA_advance_loc4
  3514 +	.4byte	.LCFI10-.LFB2
  3515 +	.byte	0x8f	# DW_CFA_offset, column 0xf
  3516 +	.uleb128 0x5
  3517 +	.byte	0x8e	# DW_CFA_offset, column 0xe
  3518 +	.uleb128 0x6
  3519 +	.byte	0x4	# DW_CFA_advance_loc4
  3520 +	.4byte	.LCFI11-.LCFI10
  3521 +	.byte	0xe	# DW_CFA_def_cfa_offset
  3522 +	.uleb128 0x140
  3523 +	.align	8
  3524 +.LEFDE2:
  3525 +
  3526 +#endif
  3527 +
  3528 diff -ruN --exclude=CVS gcc-3.2.2.orig/libffi/src/sh/ffi.c gcc/libffi/src/sh/ffi.c
  3529 --- gcc-3.2.2.orig/libffi/src/sh/ffi.c	Thu Jan  1 09:00:00 1970
  3530 +++ gcc/libffi/src/sh/ffi.c	Fri Jul 19 10:08:43 2002
  3531 @@ -0,0 +1,722 @@
  3532 +/* -----------------------------------------------------------------------
  3533 +   ffi.c - Copyright (c) 2002 Kaz Kojima
  3534 +   
  3535 +   SuperH Foreign Function Interface 
  3536 +
  3537 +   Permission is hereby granted, free of charge, to any person obtaining
  3538 +   a copy of this software and associated documentation files (the
  3539 +   ``Software''), to deal in the Software without restriction, including
  3540 +   without limitation the rights to use, copy, modify, merge, publish,
  3541 +   distribute, sublicense, and/or sell copies of the Software, and to
  3542 +   permit persons to whom the Software is furnished to do so, subject to
  3543 +   the following conditions:
  3544 +
  3545 +   The above copyright notice and this permission notice shall be included
  3546 +   in all copies or substantial portions of the Software.
  3547 +
  3548 +   THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
  3549 +   OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  3550 +   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  3551 +   IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
  3552 +   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  3553 +   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  3554 +   OTHER DEALINGS IN THE SOFTWARE.
  3555 +   ----------------------------------------------------------------------- */
  3556 +
  3557 +#include <ffi.h>
  3558 +#include <ffi_common.h>
  3559 +
  3560 +#include <stdlib.h>
  3561 +
  3562 +#define NGREGARG 4
  3563 +#if defined(__SH4__)
  3564 +#define NFREGARG 8
  3565 +#endif
  3566 +
  3567 +#if defined(__HITACHI__)
  3568 +#define STRUCT_VALUE_ADDRESS_WITH_ARG 1
  3569 +#else
  3570 +#define STRUCT_VALUE_ADDRESS_WITH_ARG 0
  3571 +#endif
  3572 +
  3573 +/* If the structure has essentialy an unique element, return its type.  */
  3574 +static int
  3575 +simple_type (ffi_type *arg)
  3576 +{
  3577 +  if (arg->type != FFI_TYPE_STRUCT)
  3578 +    return arg->type;
  3579 +  else if (arg->elements[1])
  3580 +    return FFI_TYPE_STRUCT;
  3581 +
  3582 +  return simple_type (arg->elements[0]);
  3583 +}
  3584 +
  3585 +static int
  3586 +return_type (ffi_type *arg)
  3587 +{
  3588 +  unsigned short type;
  3589 +
  3590 +  if (arg->type != FFI_TYPE_STRUCT)
  3591 +    return arg->type;
  3592 +
  3593 +  type = simple_type (arg->elements[0]);
  3594 +  if (! arg->elements[1])
  3595 +    {
  3596 +      switch (type)
  3597 +	{
  3598 +	case FFI_TYPE_SINT8:
  3599 +	case FFI_TYPE_UINT8:
  3600 +	case FFI_TYPE_SINT16:
  3601 +	case FFI_TYPE_UINT16:
  3602 +	case FFI_TYPE_SINT32:
  3603 +	case FFI_TYPE_UINT32:
  3604 +	  return FFI_TYPE_INT;
  3605 +
  3606 +	default:
  3607 +	  return type;
  3608 +	}
  3609 +    }
  3610 +
  3611 +  /* gcc uses r0/r1 pair for some kind of structures.  */
  3612 +  if (arg->size <= 2 * sizeof (int))
  3613 +    {
  3614 +      int i = 0;
  3615 +      ffi_type *e;
  3616 +
  3617 +      while ((e = arg->elements[i++]))
  3618 +	{
  3619 +	  type = simple_type (e);
  3620 +	  switch (type)
  3621 +	    {
  3622 +	    case FFI_TYPE_SINT32:
  3623 +	    case FFI_TYPE_UINT32:
  3624 +	    case FFI_TYPE_INT:
  3625 +	    case FFI_TYPE_FLOAT:
  3626 +	      return FFI_TYPE_UINT64;
  3627 +
  3628 +	    default:
  3629 +	      break;
  3630 +	    }
  3631 +	}
  3632 +    }
  3633 +
  3634 +  return FFI_TYPE_STRUCT;
  3635 +}
  3636 +
  3637 +/* ffi_prep_args is called by the assembly routine once stack space
  3638 +   has been allocated for the function's arguments */
  3639 +
  3640 +/*@-exportheader@*/
  3641 +void ffi_prep_args(char *stack, extended_cif *ecif)
  3642 +/*@=exportheader@*/
  3643 +{
  3644 +  register unsigned int i;
  3645 +  register int tmp;
  3646 +  register unsigned int avn;
  3647 +  register void **p_argv;
  3648 +  register char *argp;
  3649 +  register ffi_type **p_arg;
  3650 +  int greg, ireg;
  3651 +#if defined(__SH4__)
  3652 +  int freg = 0;
  3653 +#endif
  3654 +
  3655 +  tmp = 0;
  3656 +  argp = stack;
  3657 +
  3658 +  if (return_type (ecif->cif->rtype) == FFI_TYPE_STRUCT)
  3659 +    {
  3660 +      *(void **) argp = ecif->rvalue;
  3661 +      argp += 4;
  3662 +      ireg = STRUCT_VALUE_ADDRESS_WITH_ARG ? 1 : 0;
  3663 +    }
  3664 +  else
  3665 +    ireg = 0;
  3666 +
  3667 +  /* Set arguments for registers.  */
  3668 +  greg = ireg;
  3669 +  avn = ecif->cif->nargs;
  3670 +  p_argv = ecif->avalue;
  3671 +
  3672 +  for (i = 0, p_arg = ecif->cif->arg_types; i < avn; i++, p_arg++, p_argv++)
  3673 +    {
  3674 +      size_t z;
  3675 +
  3676 +      z = (*p_arg)->size;
  3677 +      if (z < sizeof(int))
  3678 +	{
  3679 +	  if (greg++ >= NGREGARG)
  3680 +	    continue;
  3681 +
  3682 +	  z = sizeof(int);
  3683 +	  switch ((*p_arg)->type)
  3684 +	    {
  3685 +	    case FFI_TYPE_SINT8:
  3686 +	      *(signed int *) argp = (signed int)*(SINT8 *)(* p_argv);
  3687 +	      break;
  3688 +  
  3689 +	    case FFI_TYPE_UINT8:
  3690 +	      *(unsigned int *) argp = (unsigned int)*(UINT8 *)(* p_argv);
  3691 +	      break;
  3692 +  
  3693 +	    case FFI_TYPE_SINT16:
  3694 +	      *(signed int *) argp = (signed int)*(SINT16 *)(* p_argv);
  3695 +	      break;
  3696 +  
  3697 +	    case FFI_TYPE_UINT16:
  3698 +	      *(unsigned int *) argp = (unsigned int)*(UINT16 *)(* p_argv);
  3699 +	      break;
  3700 +  
  3701 +	    case FFI_TYPE_STRUCT:
  3702 +	      *(unsigned int *) argp = (unsigned int)*(UINT32 *)(* p_argv);
  3703 +	      break;
  3704 +
  3705 +	    default:
  3706 +	      FFI_ASSERT(0);
  3707 +	    }
  3708 +	  argp += z;
  3709 +	}
  3710 +      else if (z == sizeof(int))
  3711 +	{
  3712 +#if defined(__SH4__)
  3713 +	  if ((*p_arg)->type == FFI_TYPE_FLOAT)
  3714 +	    {
  3715 +	      if (freg++ >= NFREGARG)
  3716 +		continue;
  3717 +	    }
  3718 +	  else
  3719 +#endif
  3720 +	    {
  3721 +	      if (greg++ >= NGREGARG)
  3722 +		continue;
  3723 +	    }
  3724 +	  *(unsigned int *) argp = (unsigned int)*(UINT32 *)(* p_argv);
  3725 +	  argp += z;
  3726 +	}
  3727 +#if defined(__SH4__)
  3728 +      else if ((*p_arg)->type == FFI_TYPE_DOUBLE)
  3729 +	{
  3730 +	  if (freg + 1 >= NFREGARG)
  3731 +	    continue;
  3732 +	  freg = (freg + 1) & ~1;
  3733 +	  freg += 2;
  3734 +	  memcpy (argp, *p_argv, z);
  3735 +	  argp += z;
  3736 +	}
  3737 +#endif
  3738 +      else
  3739 +	{
  3740 +	  int n = (z + sizeof (int) - 1) / sizeof (int);
  3741 +#if defined(__SH4__)
  3742 +	  if (greg + n - 1 >= NGREGARG)
  3743 +	    continue;
  3744 +	  greg += n;
  3745 +#else
  3746 +	  if (greg >= NGREGARG)
  3747 +	    continue;
  3748 +	  else if (greg + n - 1 >= NGREGARG)
  3749 +	    greg = NGREGARG;
  3750 +	  else
  3751 +	    greg += n;
  3752 +#endif
  3753 +	  memcpy (argp, *p_argv, z);
  3754 +	  argp += z;
  3755 +	}
  3756 +    }
  3757 +
  3758 +  /* Set arguments on stack.  */
  3759 +  greg = ireg;
  3760 +#if defined(__SH4__)
  3761 +  freg = 0;
  3762 +#endif
  3763 +  p_argv = ecif->avalue;
  3764 +
  3765 +  for (i = 0, p_arg = ecif->cif->arg_types; i < avn; i++, p_arg++, p_argv++)
  3766 +    {
  3767 +      size_t z;
  3768 +
  3769 +      z = (*p_arg)->size;
  3770 +      if (z < sizeof(int))
  3771 +	{
  3772 +	  if (greg++ < NGREGARG)
  3773 +	    continue;
  3774 +
  3775 +	  z = sizeof(int);
  3776 +	  switch ((*p_arg)->type)
  3777 +	    {
  3778 +	    case FFI_TYPE_SINT8:
  3779 +	      *(signed int *) argp = (signed int)*(SINT8 *)(* p_argv);
  3780 +	      break;
  3781 +  
  3782 +	    case FFI_TYPE_UINT8:
  3783 +	      *(unsigned int *) argp = (unsigned int)*(UINT8 *)(* p_argv);
  3784 +	      break;
  3785 +  
  3786 +	    case FFI_TYPE_SINT16:
  3787 +	      *(signed int *) argp = (signed int)*(SINT16 *)(* p_argv);
  3788 +	      break;
  3789 +  
  3790 +	    case FFI_TYPE_UINT16:
  3791 +	      *(unsigned int *) argp = (unsigned int)*(UINT16 *)(* p_argv);
  3792 +	      break;
  3793 +  
  3794 +	    case FFI_TYPE_STRUCT:
  3795 +	      *(unsigned int *) argp = (unsigned int)*(UINT32 *)(* p_argv);
  3796 +	      break;
  3797 +
  3798 +	    default:
  3799 +	      FFI_ASSERT(0);
  3800 +	    }
  3801 +	  argp += z;
  3802 +	}
  3803 +      else if (z == sizeof(int))
  3804 +	{
  3805 +#if defined(__SH4__)
  3806 +	  if ((*p_arg)->type == FFI_TYPE_FLOAT)
  3807 +	    {
  3808 +	      if (freg++ < NFREGARG)
  3809 +		continue;
  3810 +	    }
  3811 +	  else
  3812 +#endif
  3813 +	    {
  3814 +	      if (greg++ < NGREGARG)
  3815 +		continue;
  3816 +	    }
  3817 +	  *(unsigned int *) argp = (unsigned int)*(UINT32 *)(* p_argv);
  3818 +	  argp += z;
  3819 +	}
  3820 +#if defined(__SH4__)
  3821 +      else if ((*p_arg)->type == FFI_TYPE_DOUBLE)
  3822 +	{
  3823 +	  if (freg + 1 < NFREGARG)
  3824 +	    {
  3825 +	      freg = (freg + 1) & ~1;
  3826 +	      freg += 2;
  3827 +	      continue;
  3828 +	    }
  3829 +	  memcpy (argp, *p_argv, z);
  3830 +	  argp += z;
  3831 +	}
  3832 +#endif
  3833 +      else
  3834 +	{
  3835 +	  int n = (z + sizeof (int) - 1) / sizeof (int);
  3836 +	  if (greg + n - 1 < NGREGARG)
  3837 +	    {
  3838 +	      greg += n;
  3839 +	      continue;
  3840 +	    }
  3841 +#if (! defined(__SH4__))
  3842 +	  else if (greg < NGREGARG)
  3843 +	    {
  3844 +	      greg = NGREGARG;
  3845 +	      continue;
  3846 +	    }
  3847 +#endif
  3848 +	  memcpy (argp, *p_argv, z);
  3849 +	  argp += z;
  3850 +	}
  3851 +    }
  3852 +
  3853 +  return;
  3854 +}
  3855 +
  3856 +/* Perform machine dependent cif processing */
  3857 +ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
  3858 +{
  3859 +  int i, j;
  3860 +  int size, type;
  3861 +  int n, m;
  3862 +  int greg;
  3863 +#if defined(__SH4__)
  3864 +  int freg = 0;
  3865 +#endif
  3866 +
  3867 +  cif->flags = 0;
  3868 +
  3869 +  greg = ((return_type (cif->rtype) == FFI_TYPE_STRUCT) &&
  3870 +	  STRUCT_VALUE_ADDRESS_WITH_ARG) ? 1 : 0;
  3871 +
  3872 +#if defined(__SH4__)
  3873 +  for (i = j = 0; i < cif->nargs && j < 12; i++)
  3874 +    {
  3875 +      type = (cif->arg_types)[i]->type;
  3876 +      switch (type)
  3877 +	{
  3878 +	case FFI_TYPE_FLOAT:
  3879 +	  if (freg >= NFREGARG)
  3880 +	    continue;
  3881 +	  freg++;
  3882 +	  cif->flags += ((cif->arg_types)[i]->type) << (2 * j);
  3883 +	  j++;
  3884 +	  break;
  3885 +
  3886 +	case FFI_TYPE_DOUBLE:
  3887 +	  if ((freg + 1) >= NFREGARG)
  3888 +	    continue;
  3889 +	  freg = (freg + 1) & ~1;
  3890 +	  freg += 2;
  3891 +	  cif->flags += ((cif->arg_types)[i]->type) << (2 * j);
  3892 +	  j++;
  3893 +	  break;
  3894 +	      
  3895 +	default:
  3896 +	  size = (cif->arg_types)[i]->size;
  3897 +	  n = (size + sizeof (int) - 1) / sizeof (int);
  3898 +	  if (greg + n - 1 >= NGREGARG)
  3899 +		continue;
  3900 +	  greg += n;
  3901 +	  for (m = 0; m < n; m++)
  3902 +	    cif->flags += FFI_TYPE_INT << (2 * j++);
  3903 +	  break;
  3904 +	}
  3905 +    }
  3906 +#else
  3907 +  for (i = j = 0; i < cif->nargs && j < 4; i++)
  3908 +    {
  3909 +      size = (cif->arg_types)[i]->size;
  3910 +      n = (size + sizeof (int) - 1) / sizeof (int);
  3911 +      if (greg >= NGREGARG)
  3912 +	continue;
  3913 +      else if (greg + n - 1 >= NGREGARG)
  3914 +	greg = NGREGARG;
  3915 +      else
  3916 +	greg += n;
  3917 +      for (m = 0; m < n; m++)
  3918 +        cif->flags += FFI_TYPE_INT << (2 * j++);
  3919 +    }
  3920 +#endif
  3921 +
  3922 +  /* Set the return type flag */
  3923 +  switch (cif->rtype->type)
  3924 +    {
  3925 +    case FFI_TYPE_STRUCT:
  3926 +      cif->flags += (unsigned) (return_type (cif->rtype)) << 24;
  3927 +      break;
  3928 +
  3929 +    case FFI_TYPE_VOID:
  3930 +    case FFI_TYPE_FLOAT:
  3931 +    case FFI_TYPE_DOUBLE:
  3932 +    case FFI_TYPE_SINT64:
  3933 +    case FFI_TYPE_UINT64:
  3934 +      cif->flags += (unsigned) cif->rtype->type << 24;
  3935 +      break;
  3936 +
  3937 +    default:
  3938 +      cif->flags += FFI_TYPE_INT << 24;
  3939 +      break;
  3940 +    }
  3941 +
  3942 +  return FFI_OK;
  3943 +}
  3944 +
  3945 +/*@-declundef@*/
  3946 +/*@-exportheader@*/
  3947 +extern void ffi_call_SYSV(void (*)(char *, extended_cif *), 
  3948 +			  /*@out@*/ extended_cif *, 
  3949 +			  unsigned, unsigned, 
  3950 +			  /*@out@*/ unsigned *, 
  3951 +			  void (*fn)());
  3952 +/*@=declundef@*/
  3953 +/*@=exportheader@*/
  3954 +
  3955 +void ffi_call(/*@dependent@*/ ffi_cif *cif, 
  3956 +	      void (*fn)(), 
  3957 +	      /*@out@*/ void *rvalue, 
  3958 +	      /*@dependent@*/ void **avalue)
  3959 +{
  3960 +  extended_cif ecif;
  3961 +
  3962 +  ecif.cif = cif;
  3963 +  ecif.avalue = avalue;
  3964 +  
  3965 +  /* If the return value is a struct and we don't have a return	*/
  3966 +  /* value address then we need to make one		        */
  3967 +
  3968 +  if ((rvalue == NULL) && 
  3969 +      (cif->rtype->type == FFI_TYPE_STRUCT))
  3970 +    {
  3971 +      /*@-sysunrecog@*/
  3972 +      ecif.rvalue = alloca(cif->rtype->size);
  3973 +      /*@=sysunrecog@*/
  3974 +    }
  3975 +  else
  3976 +    ecif.rvalue = rvalue;
  3977 +    
  3978 +
  3979 +  switch (cif->abi) 
  3980 +    {
  3981 +    case FFI_SYSV:
  3982 +      /*@-usedef@*/
  3983 +      ffi_call_SYSV(ffi_prep_args, &ecif, cif->bytes, 
  3984 +		    cif->flags, ecif.rvalue, fn);
  3985 +      /*@=usedef@*/
  3986 +      break;
  3987 +    default:
  3988 +      FFI_ASSERT(0);
  3989 +      break;
  3990 +    }
  3991 +}
  3992 +
  3993 +extern void ffi_closure_SYSV (void);
  3994 +#if defined(__SH4__)
  3995 +extern void __ic_invalidate (void *line);
  3996 +#endif
  3997 +
  3998 +ffi_status
  3999 +ffi_prep_closure (ffi_closure* closure,
  4000 +		  ffi_cif* cif,
  4001 +		  void (*fun)(ffi_cif*, void*, void**, void*),
  4002 +		  void *user_data)
  4003 +{
  4004 +  unsigned int *tramp;
  4005 +
  4006 +  FFI_ASSERT (cif->abi == FFI_GCC_SYSV);
  4007 +
  4008 +  tramp = (unsigned int *) &closure->tramp[0];
  4009 +#ifdef __LITTLE_ENDIAN__
  4010 +  tramp[0] = 0xd301d202;
  4011 +  tramp[1] = 0x0009422b;
  4012 +#else
  4013 +  tramp[0] = 0xd202d301;
  4014 +  tramp[1] = 0x422b0009;
  4015 +#endif
  4016 +  *(void **) &tramp[2] = (void *)closure;          /* ctx */
  4017 +  *(void **) &tramp[3] = (void *)ffi_closure_SYSV; /* funaddr */
  4018 +
  4019 +  closure->cif = cif;
  4020 +  closure->fun = fun;
  4021 +  closure->user_data = user_data;
  4022 +
  4023 +#if defined(__SH4__)
  4024 +  /* Flush the icache.  */
  4025 +  __ic_invalidate(&closure->tramp[0]);
  4026 +#endif
  4027 +
  4028 +  return FFI_OK;
  4029 +}
  4030 +
  4031 +/* Basically the trampoline invokes ffi_closure_SYSV, and on 
  4032 + * entry, r3 holds the address of the closure.
  4033 + * After storing the registers that could possibly contain
  4034 + * parameters to be passed into the stack frame and setting
  4035 + * up space for a return value, ffi_closure_SYSV invokes the 
  4036 + * following helper function to do most of the work.
  4037 + */
  4038 +
  4039 +#ifdef __LITTLE_ENDIAN__
  4040 +#define OFS_INT8	0
  4041 +#define OFS_INT16	2
  4042 +#else
  4043 +#define OFS_INT8	3
  4044 +#define OFS_INT16	2
  4045 +#endif
  4046 +
  4047 +int
  4048 +ffi_closure_helper_SYSV (ffi_closure *closure, void *rvalue, 
  4049 +			 unsigned long *pgr, unsigned long *pfr, 
  4050 +			 unsigned long *pst)
  4051 +{
  4052 +  void **avalue;
  4053 +  ffi_type **p_arg;
  4054 +  int i, avn;
  4055 +  int ireg, greg = 0;
  4056 +#if defined(__SH4__)
  4057 +  int freg = 0;
  4058 +#endif
  4059 +  ffi_cif *cif; 
  4060 +  double temp; 
  4061 +
  4062 +  cif = closure->cif;
  4063 +  avalue = alloca(cif->nargs * sizeof(void *));
  4064 +
  4065 +  /* Copy the caller's structure return value address so that the closure
  4066 +     returns the data directly to the caller.  */
  4067 +  if (cif->rtype->type == FFI_TYPE_STRUCT)
  4068 +    {
  4069 +      rvalue = *pgr++;
  4070 +      ireg = STRUCT_VALUE_ADDRESS_WITH_ARG ? 1 : 0;
  4071 +    }
  4072 +  else
  4073 +    ireg = 0;
  4074 +
  4075 +  cif = closure->cif;
  4076 +  greg = ireg;
  4077 +  avn = cif->nargs;
  4078 +
  4079 +  /* Grab the addresses of the arguments from the stack frame.  */
  4080 +  for (i = 0, p_arg = cif->arg_types; i < avn; i++, p_arg++)
  4081 +    {
  4082 +      size_t z;
  4083 +
  4084 +      z = (*p_arg)->size;
  4085 +      if (z < sizeof(int))
  4086 +	{
  4087 +	  if (greg++ >= NGREGARG)
  4088 +	    continue;
  4089 +
  4090 +	  z = sizeof(int);
  4091 +	  switch ((*p_arg)->type)
  4092 +	    {
  4093 +	    case FFI_TYPE_SINT8:
  4094 +	    case FFI_TYPE_UINT8:
  4095 +	      avalue[i] = (((char *)pgr) + OFS_INT8);
  4096 +	      break;
  4097 +  
  4098 +	    case FFI_TYPE_SINT16:
  4099 +	    case FFI_TYPE_UINT16:
  4100 +	      avalue[i] = (((char *)pgr) + OFS_INT16);
  4101 +	      break;
  4102 +  
  4103 +	    case FFI_TYPE_STRUCT:
  4104 +	      avalue[i] = pgr;
  4105 +	      break;
  4106 +
  4107 +	    default:
  4108 +	      FFI_ASSERT(0);
  4109 +	    }
  4110 +	  pgr++;
  4111 +	}
  4112 +      else if (z == sizeof(int))
  4113 +	{
  4114 +#if defined(__SH4__)
  4115 +	  if ((*p_arg)->type == FFI_TYPE_FLOAT)
  4116 +	    {
  4117 +	      if (freg++ >= NFREGARG)
  4118 +		continue;
  4119 +	      avalue[i] = pfr;
  4120 +	      pfr++;
  4121 +	    }
  4122 +	  else
  4123 +#endif
  4124 +	    {
  4125 +	      if (greg++ >= NGREGARG)
  4126 +		continue;
  4127 +	      avalue[i] = pgr;
  4128 +	      pgr++;
  4129 +	    }
  4130 +	}
  4131 +#if defined(__SH4__)
  4132 +      else if ((*p_arg)->type == FFI_TYPE_DOUBLE)
  4133 +	{
  4134 +	  if (freg + 1 >= NFREGARG)
  4135 +	    continue;
  4136 +	  freg = (freg + 1) & ~1;
  4137 +	  freg += 2;
  4138 +	  avalue[i] = pfr;
  4139 +	  pfr += 2;
  4140 +	}
  4141 +#endif
  4142 +      else
  4143 +	{
  4144 +	  int n = (z + sizeof (int) - 1) / sizeof (int);
  4145 +#if defined(__SH4__)
  4146 +	  if (greg + n - 1 >= NGREGARG)
  4147 +	    continue;
  4148 +	  greg += n;
  4149 +#else
  4150 +	  if (greg >= NGREGARG)
  4151 +	    continue;
  4152 +	  else if (greg + n - 1 >= NGREGARG)
  4153 +	    greg = NGREGARG;
  4154 +	  else
  4155 +	    greg += n;
  4156 +#endif
  4157 +	  avalue[i] = pgr;
  4158 +	  pgr += n;
  4159 +	}
  4160 +    }
  4161 +
  4162 +  greg = ireg;
  4163 +#if defined(__SH4__)
  4164 +  freg = 0;
  4165 +#endif
  4166 +
  4167 +  for (i = 0, p_arg = cif->arg_types; i < avn; i++, p_arg++)
  4168 +    {
  4169 +      size_t z;
  4170 +
  4171 +      z = (*p_arg)->size;
  4172 +      if (z < sizeof(int))
  4173 +	{
  4174 +	  if (greg++ < NGREGARG)
  4175 +	    continue;
  4176 +
  4177 +	  z = sizeof(int);
  4178 +	  switch ((*p_arg)->type)
  4179 +	    {
  4180 +	    case FFI_TYPE_SINT8:
  4181 +	    case FFI_TYPE_UINT8:
  4182 +	      avalue[i] = (((char *)pst) + OFS_INT8);
  4183 +	      break;
  4184 +  
  4185 +	    case FFI_TYPE_SINT16:
  4186 +	    case FFI_TYPE_UINT16:
  4187 +	      avalue[i] = (((char *)pst) + OFS_INT16);
  4188 +	      break;
  4189 +  
  4190 +	    case FFI_TYPE_STRUCT:
  4191 +	      avalue[i] = pst;
  4192 +	      break;
  4193 +
  4194 +	    default:
  4195 +	      FFI_ASSERT(0);
  4196 +	    }
  4197 +	  pst++;
  4198 +	}
  4199 +      else if (z == sizeof(int))
  4200 +	{
  4201 +#if defined(__SH4__)
  4202 +	  if ((*p_arg)->type == FFI_TYPE_FLOAT)
  4203 +	    {
  4204 +	      if (freg++ < NFREGARG)
  4205 +		continue;
  4206 +	    }
  4207 +	  else
  4208 +#endif
  4209 +	    {
  4210 +	      if (greg++ < NGREGARG)
  4211 +		continue;
  4212 +	    }
  4213 +	  avalue[i] = pst;
  4214 +	  pst++;
  4215 +	}
  4216 +#if defined(__SH4__)
  4217 +      else if ((*p_arg)->type == FFI_TYPE_DOUBLE)
  4218 +	{
  4219 +	  if (freg + 1 < NFREGARG)
  4220 +	    {
  4221 +	      freg = (freg + 1) & ~1;
  4222 +	      freg += 2;
  4223 +	      continue;
  4224 +	    }
  4225 +	  avalue[i] = pst;
  4226 +	  pst += 2;
  4227 +	}
  4228 +#endif
  4229 +      else
  4230 +	{
  4231 +	  int n = (z + sizeof (int) - 1) / sizeof (int);
  4232 +	  if (greg + n - 1 < NGREGARG)
  4233 +	    {
  4234 +	      greg += n;
  4235 +	      continue;
  4236 +	    }
  4237 +#if (! defined(__SH4__))
  4238 +	  else if (greg < NGREGARG)
  4239 +	    {
  4240 +	      greg = NGREGARG;
  4241 +	      continue;
  4242 +	    }
  4243 +#endif
  4244 +	  avalue[i] = pst;
  4245 +	  pst += n;
  4246 +	}
  4247 +    }
  4248 +
  4249 +  (closure->fun) (cif, rvalue, avalue, closure->user_data);
  4250 +
  4251 +  /* Tell ffi_closure_osf how to perform return type promotions.  */
  4252 +  return cif->rtype->type;
  4253 +}
  4254 diff -ruN --exclude=CVS gcc-3.2.2.orig/libffi/src/sh/sysv.S gcc/libffi/src/sh/sysv.S
  4255 --- gcc-3.2.2.orig/libffi/src/sh/sysv.S	Thu Jan  1 09:00:00 1970
  4256 +++ gcc/libffi/src/sh/sysv.S	Tue Dec 17 03:22:48 2002
  4257 @@ -0,0 +1,773 @@
  4258 +/* -----------------------------------------------------------------------
  4259 +   sysv.S - Copyright (c) 2002 Kaz Kojima
  4260 +   
  4261 +   SuperH Foreign Function Interface 
  4262 +
  4263 +   Permission is hereby granted, free of charge, to any person obtaining
  4264 +   a copy of this software and associated documentation files (the
  4265 +   ``Software''), to deal in the Software without restriction, including
  4266 +   without limitation the rights to use, copy, modify, merge, publish,
  4267 +   distribute, sublicense, and/or sell copies of the Software, and to
  4268 +   permit persons to whom the Software is furnished to do so, subject to
  4269 +   the following conditions:
  4270 +
  4271 +   The above copyright notice and this permission notice shall be included
  4272 +   in all copies or substantial portions of the Software.
  4273 +
  4274 +   THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
  4275 +   OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  4276 +   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  4277 +   IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
  4278 +   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  4279 +   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  4280 +   OTHER DEALINGS IN THE SOFTWARE.
  4281 +   ----------------------------------------------------------------------- */
  4282 +
  4283 +#define LIBFFI_ASM	
  4284 +#include <ffi.h>
  4285 +#ifdef HAVE_MACHINE_ASM_H
  4286 +#include <machine/asm.h>
  4287 +#else
  4288 +/* XXX these lose for some platforms, I'm sure. */
  4289 +#define CNAME(x) x
  4290 +#define ENTRY(x) .globl CNAME(x); .type CNAME(x),%function; CNAME(x):
  4291 +#endif
  4292 +
  4293 +#if defined(__HITACHI__)
  4294 +#define STRUCT_VALUE_ADDRESS_WITH_ARG 1
  4295 +#else
  4296 +#define STRUCT_VALUE_ADDRESS_WITH_ARG 0
  4297 +#endif
  4298 +
  4299 +.text
  4300 +
  4301 +	# r4:	ffi_prep_args
  4302 +	# r5:	&ecif
  4303 +	# r6:	bytes
  4304 +	# r7:	flags
  4305 +	# sp+0: rvalue
  4306 +	# sp+4: fn
  4307 +
  4308 +	# This assumes we are using gas.
  4309 +ENTRY(ffi_call_SYSV)
  4310 +	# Save registers
  4311 +.LFB1:
  4312 +	mov.l	r8,@-r15
  4313 +.LCFI0:
  4314 +	mov.l	r9,@-r15
  4315 +.LCFI1:
  4316 +	mov.l	r10,@-r15
  4317 +.LCFI2:
  4318 +	mov.l	r12,@-r15
  4319 +.LCFI3:
  4320 +	mov.l	r14,@-r15
  4321 +.LCFI4:
  4322 +	sts.l	pr,@-r15
  4323 +.LCFI5:
  4324 +	mov	r15,r14
  4325 +.LCFI6:
  4326 +#if defined(__SH4__)
  4327 +	mov	r6,r8
  4328 +	mov	r7,r9
  4329 +
  4330 +	sub	r6,r15
  4331 +	add	#-16,r15
  4332 +	mov	#~7,r0
  4333 +	and	r0,r15
  4334 +
  4335 +	mov	r4,r0
  4336 +	jsr	@r0
  4337 +	 mov	r15,r4
  4338 +
  4339 +	mov	r9,r1
  4340 +	shlr8	r9
  4341 +	shlr8	r9
  4342 +	shlr8	r9
  4343 +
  4344 +	mov	#FFI_TYPE_STRUCT,r2
  4345 +	cmp/eq	r2,r9
  4346 +	bf	1f
  4347 +#if STRUCT_VALUE_ADDRESS_WITH_ARG
  4348 + 	mov.l	@r15+,r4
  4349 +	bra	2f
  4350 +	 mov	#5,r2
  4351 +#else
  4352 + 	mov.l	@r15+,r10
  4353 +#endif
  4354 +1:
  4355 +	mov	#4,r2
  4356 +2:
  4357 +	mov	#4,r3
  4358 +
  4359 +L_pass:
  4360 +	cmp/pl	r8
  4361 +	bf	L_call_it
  4362 +
  4363 +	mov	r1,r0
  4364 +	and	#3,r0
  4365 +
  4366 +L_pass_d:
  4367 +	cmp/eq	#FFI_TYPE_DOUBLE,r0
  4368 +	bf	L_pass_f
  4369 +
  4370 +	mov	r3,r0
  4371 +	and	#1,r0
  4372 +	tst	r0,r0
  4373 +	bt	1f
  4374 +	add	#1,r3
  4375 +1:
  4376 +	mov	r15,r0
  4377 +	and	#7,r0
  4378 +	tst	r0,r0
  4379 +	bt	2f
  4380 +	add	#4,r15
  4381 +2:
  4382 +	mov	#12,r0
  4383 +	cmp/hs	r0,r3
  4384 +	bt/s	3f
  4385 +	 shlr2	r1
  4386 +	bsr	L_pop_d
  4387 +	 nop
  4388 +3:
  4389 +	add	#2,r3
  4390 +	bra	L_pass
  4391 +	 add	#-8,r8
  4392 +
  4393 +L_pop_d:
  4394 +	mov	r3,r0
  4395 +	add	r0,r0
  4396 +	add	r3,r0
  4397 +	add	#-12,r0
  4398 +	braf	r0
  4399 +	 nop
  4400 +#ifdef __LITTLE_ENDIAN__
  4401 +	fmov.s	@r15+,fr5
  4402 +	rts
  4403 +	 fmov.s	@r15+,fr4
  4404 +	fmov.s	@r15+,fr7
  4405 +	rts
  4406 +	 fmov.s	@r15+,fr6
  4407 +	fmov.s	@r15+,fr9
  4408 +	rts
  4409 +	 fmov.s	@r15+,fr8
  4410 +	fmov.s	@r15+,fr11
  4411 +	rts
  4412 +	 fmov.s	@r15+,fr10
  4413 +#else
  4414 +	fmov.s	@r15+,fr4
  4415 +	rts
  4416 +	 fmov.s	@r15+,fr5
  4417 +	fmov.s	@r15+,fr6
  4418 +	rts
  4419 +	 fmov.s	@r15+,fr7
  4420 +	fmov.s	@r15+,fr8
  4421 +	rts
  4422 +	 fmov.s	@r15+,fr9
  4423 +	fmov.s	@r15+,fr10
  4424 +	rts
  4425 +	 fmov.s	@r15+,fr11
  4426 +#endif
  4427 +
  4428 +L_pass_f:
  4429 +	cmp/eq	#FFI_TYPE_FLOAT,r0
  4430 +	bf	L_pass_i
  4431 +
  4432 +	mov	#12,r0
  4433 +	cmp/hs	r0,r3
  4434 +	bt/s	2f
  4435 +	 shlr2	r1
  4436 +	bsr	L_pop_f
  4437 +	 nop
  4438 +2:
  4439 +	add	#1,r3
  4440 +	bra	L_pass
  4441 +	 add	#-4,r8
  4442 +
  4443 +L_pop_f:
  4444 +	mov	r3,r0
  4445 +	shll2	r0
  4446 +	add	#-16,r0
  4447 +	braf	r0
  4448 +	 nop
  4449 +#ifdef __LITTLE_ENDIAN__
  4450 +	rts
  4451 +	 fmov.s	@r15+,fr5
  4452 +	rts
  4453 +	 fmov.s	@r15+,fr4
  4454 +	rts
  4455 +	 fmov.s	@r15+,fr7
  4456 +	rts
  4457 +	 fmov.s	@r15+,fr6
  4458 +	rts
  4459 +	 fmov.s	@r15+,fr9
  4460 +	rts
  4461 +	 fmov.s	@r15+,fr8
  4462 +	rts
  4463 +	 fmov.s	@r15+,fr11
  4464 +	rts
  4465 +	 fmov.s	@r15+,fr10
  4466 +#else
  4467 +	rts
  4468 +	 fmov.s	@r15+,fr4
  4469 +	rts
  4470 +	 fmov.s	@r15+,fr5
  4471 +	rts
  4472 +	 fmov.s	@r15+,fr6
  4473 +	rts
  4474 +	 fmov.s	@r15+,fr7
  4475 +	rts
  4476 +	 fmov.s	@r15+,fr8
  4477 +	rts
  4478 +	 fmov.s	@r15+,fr9
  4479 +	rts
  4480 +	 fmov.s	@r15+,fr10
  4481 +	rts
  4482 +	 fmov.s	@r15+,fr11
  4483 +#endif
  4484 +
  4485 +L_pass_i:
  4486 +	cmp/eq	#FFI_TYPE_INT,r0
  4487 +	bf	L_call_it
  4488 +
  4489 +	mov	#8,r0
  4490 +	cmp/hs	r0,r2
  4491 +	bt/s	2f
  4492 +	 shlr2	r1
  4493 +	bsr	L_pop_i
  4494 +	 nop
  4495 +2:
  4496 +	add	#1,r2
  4497 +	bra	L_pass
  4498 +	 add	#-4,r8
  4499 +
  4500 +L_pop_i:
  4501 +	mov	r2,r0
  4502 +	shll2	r0
  4503 +	add	#-16,r0
  4504 +	braf	r0
  4505 +	 nop
  4506 +	rts
  4507 +	 mov.l	@r15+,r4
  4508 +	rts
  4509 +	 mov.l	@r15+,r5
  4510 +	rts
  4511 +	 mov.l	@r15+,r6
  4512 +	rts
  4513 +	 mov.l	@r15+,r7
  4514 +
  4515 +L_call_it:
  4516 +	# call function
  4517 +#if (! STRUCT_VALUE_ADDRESS_WITH_ARG)
  4518 +	mov	r10, r2
  4519 +#endif
  4520 +	mov.l  @(28,r14),r1
  4521 +	jsr    @r1
  4522 +	 nop
  4523 +
  4524 +L_ret_d:
  4525 +	mov	#FFI_TYPE_DOUBLE,r2
  4526 +	cmp/eq	r2,r9
  4527 +	bf	L_ret_ll
  4528 +
  4529 +	mov.l	@(24,r14),r1
  4530 +#ifdef __LITTLE_ENDIAN__
  4531 +	fmov.s	fr1,@r1
  4532 +	add	#4,r1
  4533 +	bra	L_epilogue
  4534 +	 fmov.s	fr0,@r1
  4535 +#else
  4536 +	fmov.s	fr0,@r1
  4537 +	add	#4,r1
  4538 +	bra	L_epilogue
  4539 +	 fmov.s	fr1,@r1
  4540 +#endif
  4541 +
  4542 +L_ret_ll:
  4543 +	mov	#FFI_TYPE_SINT64,r2
  4544 +	cmp/eq	r2,r9
  4545 +	bt/s	1f
  4546 +	 mov	#FFI_TYPE_UINT64,r2
  4547 +	cmp/eq	r2,r9
  4548 +	bf	L_ret_f
  4549 +
  4550 +1:
  4551 +	mov.l	@(24,r14),r2
  4552 +	mov.l	r0,@r2
  4553 +	bra	L_epilogue
  4554 +	 mov.l	r1,@(4,r2)
  4555 +
  4556 +L_ret_f:
  4557 +	mov	#FFI_TYPE_FLOAT,r2
  4558 +	cmp/eq	r2,r9
  4559 +	bf	L_ret_i
  4560 +
  4561 +	mov.l	@(24,r14),r1
  4562 +	bra	L_epilogue
  4563 +	 fmov.s	fr0,@r1
  4564 +
  4565 +L_ret_i:
  4566 +	mov	#FFI_TYPE_INT,r2
  4567 +	cmp/eq	r2,r9
  4568 +	bf	L_epilogue
  4569 +
  4570 +	mov.l	@(24,r14),r1
  4571 +	bra	L_epilogue
  4572 +	 mov.l	r0,@r1
  4573 +
  4574 +L_epilogue:
  4575 +	# Remove the space we pushed for the args
  4576 +	mov   r14,r15
  4577 +
  4578 +	lds.l  @r15+,pr
  4579 +	mov.l  @r15+,r14
  4580 +	mov.l  @r15+,r12
  4581 +	mov.l  @r15+,r10
  4582 +	mov.l  @r15+,r9
  4583 +	rts
  4584 +	 mov.l  @r15+,r8
  4585 +#else
  4586 +	mov	r6,r8
  4587 +	mov	r7,r9
  4588 +
  4589 +	sub	r6,r15
  4590 +	add	#-16,r15
  4591 +	mov	#~7,r0
  4592 +	and	r0,r15
  4593 +
  4594 +	mov	r4,r0
  4595 +	jsr	@r0
  4596 +	 mov	r15,r4
  4597 +
  4598 +	mov	r9,r3
  4599 +	shlr8	r9
  4600 +	shlr8	r9
  4601 +	shlr8	r9
  4602 +
  4603 +	mov	#FFI_TYPE_STRUCT,r2
  4604 +	cmp/eq	r2,r9
  4605 +	bf	1f
  4606 +#if STRUCT_VALUE_ADDRESS_WITH_ARG
  4607 +	mov.l	@r15+,r4
  4608 +	bra	2f
  4609 +	 mov	#5,r2
  4610 +#else
  4611 +	mov.l	@r15+,r10
  4612 +#endif
  4613 +1:
  4614 +	mov	#4,r2
  4615 +2:
  4616 +
  4617 +L_pass:
  4618 +	cmp/pl	r8
  4619 +	bf	L_call_it
  4620 +
  4621 +	mov	r3,r0
  4622 +	and	#3,r0
  4623 +
  4624 +L_pass_d:
  4625 +	cmp/eq	#FFI_TYPE_DOUBLE,r0
  4626 +	bf	L_pass_i
  4627 +
  4628 +	mov	r15,r0
  4629 +	and	#7,r0
  4630 +	tst	r0,r0
  4631 +	bt	1f
  4632 +	add	#4,r15
  4633 +1:
  4634 +	mov	#8,r0
  4635 +	cmp/hs	r0,r2
  4636 +	bt/s	2f
  4637 +	 shlr2	r3
  4638 +	bsr	L_pop_d
  4639 +	 nop
  4640 +2:
  4641 +	add	#2,r2
  4642 +	bra	L_pass
  4643 +	 add	#-8,r8
  4644 +
  4645 +L_pop_d:
  4646 +	mov	r2,r0
  4647 +	add	r0,r0
  4648 +	add	r2,r0
  4649 +	add	#-12,r0
  4650 +	add	r0,r0
  4651 +	braf	r0
  4652 +	 nop
  4653 +	mov.l	@r15+,r4
  4654 +	rts
  4655 +	 mov.l	@r15+,r5
  4656 +	mov.l	@r15+,r5
  4657 +	rts
  4658 +	 mov.l	@r15+,r6
  4659 +	mov.l	@r15+,r6
  4660 +	rts
  4661 +	 mov.l	@r15+,r7
  4662 +	rts
  4663 +	 mov.l	@r15+,r7
  4664 +
  4665 +L_pass_i:
  4666 +	mov	#8,r0
  4667 +	cmp/hs	r0,r2
  4668 +	bt/s	2f
  4669 +	 shlr2	r3
  4670 +	bsr	L_pop_i
  4671 +	 nop
  4672 +2:
  4673 +	add	#1,r2
  4674 +	bra	L_pass
  4675 +	 add	#-4,r8
  4676 +
  4677 +L_pop_i:
  4678 +	mov	r2,r0
  4679 +	shll2	r0
  4680 +	add	#-16,r0
  4681 +	braf	r0
  4682 +	 nop
  4683 +	rts
  4684 +	 mov.l	@r15+,r4
  4685 +	rts
  4686 +	 mov.l	@r15+,r5
  4687 +	rts
  4688 +	 mov.l	@r15+,r6
  4689 +	rts
  4690 +	 mov.l	@r15+,r7
  4691 +
  4692 +L_call_it:
  4693 +	# call function
  4694 +#if (! STRUCT_VALUE_ADDRESS_WITH_ARG)
  4695 +	mov	r10, r2
  4696 +#endif
  4697 +	mov.l  @(28,r14),r1
  4698 +	jsr    @r1
  4699 +	 nop
  4700 +
  4701 +L_ret_d:
  4702 +	mov	#FFI_TYPE_DOUBLE,r2
  4703 +	cmp/eq	r2,r9
  4704 +	bf	L_ret_ll
  4705 +
  4706 +	mov.l	@(24,r14),r2
  4707 +	mov.l	r0,@r2
  4708 +	bra	L_epilogue
  4709 +	 mov.l	r1,@(4,r2)
  4710 +
  4711 +L_ret_ll:
  4712 +	mov	#FFI_TYPE_SINT64,r2
  4713 +	cmp/eq	r2,r9
  4714 +	bt/s	1f
  4715 +	 mov	#FFI_TYPE_UINT64,r2
  4716 +	cmp/eq	r2,r9
  4717 +	bf	L_ret_i
  4718 +
  4719 +1:
  4720 +	mov.l	@(24,r14),r2
  4721 +	mov.l	r0,@r2
  4722 +	bra	L_epilogue
  4723 +	 mov.l	r1,@(4,r2)
  4724 +
  4725 +L_ret_i:
  4726 +	mov	#FFI_TYPE_FLOAT,r2
  4727 +	cmp/eq	r2,r9
  4728 +	bt	1f
  4729 +	mov	#FFI_TYPE_INT,r2
  4730 +	cmp/eq	r2,r9
  4731 +	bf	L_epilogue
  4732 +1:
  4733 +	mov.l	@(24,r14),r1
  4734 +	bra	L_epilogue
  4735 +	 mov.l	r0,@r1
  4736 +
  4737 +L_epilogue:
  4738 +	# Remove the space we pushed for the args
  4739 +	mov   r14,r15
  4740 +
  4741 +	lds.l  @r15+,pr
  4742 +	mov.l  @r15+,r14
  4743 +	mov.l  @r15+,r12
  4744 +	mov.l  @r15+,r10
  4745 +	mov.l  @r15+,r9
  4746 +	rts
  4747 +	 mov.l  @r15+,r8
  4748 +#endif
  4749 +.LFE1:
  4750 +.ffi_call_SYSV_end:
  4751 +        .size    CNAME(ffi_call_SYSV),.ffi_call_SYSV_end-CNAME(ffi_call_SYSV)
  4752 +
  4753 +.globl	ffi_closure_helper_SYSV
  4754 +
  4755 +ENTRY(ffi_closure_SYSV)
  4756 +.LFB2:
  4757 +	mov.l	r14,@-r15
  4758 +.LCFI7:
  4759 +	sts.l	pr,@-r15
  4760 +
  4761 +	/* Stack layout:	
  4762 +	   ...
  4763 +	   32 bytes (floating register parameters, SH-4 only)
  4764 +	   16 bytes (register parameters)
  4765 +	    4 bytes (result)
  4766 +	    4 bytes (5th arg)
  4767 +	   <- new stack pointer
  4768 +	*/
  4769 +.LCFI8:
  4770 +#if defined(__SH4__)
  4771 +	add	#-56,r15
  4772 +#else
  4773 +	add	#-24,r15
  4774 +#endif
  4775 +.LCFI9:
  4776 +	mov	r15,r14
  4777 +.LCFIA:
  4778 +	mov	r14,r1
  4779 +	add	#24,r1
  4780 +	mov.l	r7,@-r1
  4781 +	mov.l	r6,@-r1
  4782 +	mov.l	r5,@-r1
  4783 +	mov.l	r4,@-r1
  4784 +	mov	r1,r6
  4785 +
  4786 +#if defined(__SH4__)
  4787 +	mov	r14,r1
  4788 +	add	#56,r1
  4789 +#ifdef __LITTLE_ENDIAN__
  4790 +	fmov.s	fr10,@-r1
  4791 +	fmov.s	fr11,@-r1
  4792 +	fmov.s	fr8,@-r1
  4793 +	fmov.s	fr9,@-r1
  4794 +	fmov.s	fr6,@-r1
  4795 +	fmov.s	fr7,@-r1
  4796 +	fmov.s	fr4,@-r1
  4797 +	fmov.s	fr5,@-r1
  4798 +#else
  4799 +	fmov.s	fr11,@-r1
  4800 +	fmov.s	fr10,@-r1
  4801 +	fmov.s	fr9,@-r1
  4802 +	fmov.s	fr8,@-r1
  4803 +	fmov.s	fr7,@-r1
  4804 +	fmov.s	fr6,@-r1
  4805 +	fmov.s	fr5,@-r1
  4806 +	fmov.s	fr4,@-r1
  4807 +#endif
  4808 +	mov	r1,r7
  4809 +#endif
  4810 +
  4811 +	mov	r14,r1
  4812 +	add	#4,r1
  4813 +	mov	r1,r5
  4814 +
  4815 +	mov	r14,r1
  4816 +#if defined(__SH4__)
  4817 +	add	#64,r1
  4818 +#else
  4819 +	add	#32,r1
  4820 +#endif
  4821 +	mov.l	r1,@r14
  4822 +
  4823 +	mov.l	L_helper,r0
  4824 +	jsr	@r0
  4825 +	 mov	r3,r4
  4826 +
  4827 +	shll	r0
  4828 +	mov	r0,r1
  4829 +	mova	L_table,r0
  4830 +	add	r1,r0
  4831 +	mov.w	@r0,r0
  4832 +	mov	r14,r2
  4833 +	braf	r0
  4834 +	 add	#4,r2
  4835 +0:
  4836 +	.align 2
  4837 +L_helper:
  4838 +	.long	ffi_closure_helper_SYSV
  4839 +L_table:
  4840 +	.short L_case_v - 0b	/* FFI_TYPE_VOID */
  4841 +	.short L_case_i - 0b	/* FFI_TYPE_INT */
  4842 +#if defined(__SH4__)
  4843 +	.short L_case_f - 0b	/* FFI_TYPE_FLOAT */
  4844 +	.short L_case_d - 0b	/* FFI_TYPE_DOUBLE */
  4845 +	.short L_case_d - 0b	/* FFI_TYPE_LONGDOUBLE */
  4846 +#else
  4847 +	.short L_case_i - 0b	/* FFI_TYPE_FLOAT */
  4848 +	.short L_case_ll - 0b	/* FFI_TYPE_DOUBLE */
  4849 +	.short L_case_ll - 0b	/* FFI_TYPE_LONGDOUBLE */
  4850 +#endif
  4851 +	.short L_case_uq - 0b	/* FFI_TYPE_UINT8 */
  4852 +	.short L_case_q - 0b	/* FFI_TYPE_SINT8 */
  4853 +	.short L_case_uh - 0b	/* FFI_TYPE_UINT16 */
  4854 +	.short L_case_h - 0b	/* FFI_TYPE_SINT16 */
  4855 +	.short L_case_i - 0b	/* FFI_TYPE_UINT32 */
  4856 +	.short L_case_i - 0b	/* FFI_TYPE_SINT32 */
  4857 +	.short L_case_ll - 0b	/* FFI_TYPE_UINT64 */
  4858 +	.short L_case_ll - 0b	/* FFI_TYPE_SINT64 */
  4859 +	.short L_case_v - 0b	/* FFI_TYPE_STRUCT */
  4860 +	.short L_case_i - 0b	/* FFI_TYPE_POINTER */
  4861 +
  4862 +#if defined(__SH4__)
  4863 +L_case_d:
  4864 +#ifdef __LITTLE_ENDIAN__
  4865 +	fmov.s	@r2+,fr1
  4866 +	bra	L_case_v
  4867 +	 fmov.s	@r2,fr0
  4868 +#else
  4869 +	fmov.s	@r2+,fr0
  4870 +	bra	L_case_v
  4871 +	 fmov.s	@r2,fr1
  4872 +#endif
  4873 +
  4874 +L_case_f:
  4875 +	bra	L_case_v
  4876 +	 fmov.s	@r2,fr0
  4877 +#endif
  4878 +	
  4879 +L_case_ll:
  4880 +	mov.l	@r2+,r0
  4881 +	bra	L_case_v
  4882 +	 mov.l	@r2,r1
  4883 +	
  4884 +L_case_i:
  4885 +	bra	L_case_v
  4886 +	 mov.l	@r2,r0
  4887 +	
  4888 +L_case_q:
  4889 +#ifdef __LITTLE_ENDIAN__
  4890 +#else
  4891 +	add	#3,r2
  4892 +#endif
  4893 +	bra	L_case_v
  4894 +	 mov.b	@r2,r0
  4895 +
  4896 +L_case_uq:
  4897 +#ifdef __LITTLE_ENDIAN__
  4898 +#else
  4899 +	add	#3,r2
  4900 +#endif
  4901 +	mov.b	@r2,r0
  4902 +	bra	L_case_v
  4903 +	 extu.b r0,r0
  4904 +
  4905 +L_case_h:
  4906 +#ifdef __LITTLE_ENDIAN__
  4907 +#else
  4908 +	add	#2,r2
  4909 +#endif
  4910 +	bra	L_case_v
  4911 +	 mov.w	@r2,r0
  4912 +
  4913 +L_case_uh:
  4914 +#ifdef __LITTLE_ENDIAN__
  4915 +#else
  4916 +	add	#2,r2
  4917 +#endif
  4918 +	mov.w	@r2,r0
  4919 +	extu.w	r0,r0
  4920 +	/* fall through */
  4921 +
  4922 +L_case_v:
  4923 +#if defined(__SH4__)
  4924 +	add	#56,r15
  4925 +#else
  4926 +	add	#24,r15
  4927 +#endif
  4928 +	lds.l	@r15+,pr
  4929 +	rts
  4930 +	 mov.l	@r15+,r14
  4931 +.LFE2:
  4932 +.ffi_closure_SYSV_end:
  4933 +        .size    CNAME(ffi_closure_SYSV),.ffi_closure_SYSV_end-CNAME(ffi_closure_SYSV)
  4934 +
  4935 +	.section	".eh_frame","aw",@progbits
  4936 +__FRAME_BEGIN__:
  4937 +	.4byte	.LECIE1-.LSCIE1	/* Length of Common Information Entry */
  4938 +.LSCIE1:
  4939 +	.4byte	0x0	/* CIE Identifier Tag */
  4940 +	.byte	0x1	/* CIE Version */
  4941 +	.byte	0x0	/* CIE Augmentation */
  4942 +	.byte	0x1	/* uleb128 0x1; CIE Code Alignment Factor */
  4943 +	.byte	0x7c	/* sleb128 -4; CIE Data Alignment Factor */
  4944 +	.byte	0x11	/* CIE RA Column */
  4945 +	.byte	0xc	/* DW_CFA_def_cfa */
  4946 +	.byte	0xf	/* uleb128 0xf */
  4947 +	.byte	0x0	/* uleb128 0x0 */
  4948 +	.align	2
  4949 +.LECIE1:
  4950 +.LSFDE1:
  4951 +	.4byte	.LEFDE1-.LASFDE1	/* FDE Length */
  4952 +.LASFDE1:
  4953 +	.4byte	.LASFDE1-__FRAME_BEGIN__	/* FDE CIE offset */
  4954 +	.4byte	.LFB1	/* FDE initial location */
  4955 +	.4byte	.LFE1-.LFB1	 /* FDE address range */
  4956 +	.byte	0x4	/* DW_CFA_advance_loc4 */
  4957 +	.4byte	.LCFI0-.LFB1
  4958 +	.byte	0xe	/* DW_CFA_def_cfa_offset */
  4959 +	.byte	0x4	/* uleb128 0x4 */
  4960 +	.byte	0x4	/* DW_CFA_advance_loc4 */
  4961 +	.4byte	.LCFI1-.LCFI0
  4962 +	.byte	0xe	/* DW_CFA_def_cfa_offset */
  4963 +	.byte	0x8	/* uleb128 0x4 */
  4964 +	.byte	0x4	/* DW_CFA_advance_loc4 */
  4965 +	.4byte	.LCFI2-.LCFI1
  4966 +	.byte	0xe	/* DW_CFA_def_cfa_offset */
  4967 +	.byte	0xc	/* uleb128 0x4 */
  4968 +	.byte	0x4	/* DW_CFA_advance_loc4 */
  4969 +	.4byte	.LCFI3-.LCFI2
  4970 +	.byte	0xe	/* DW_CFA_def_cfa_offset */
  4971 +	.byte	0x10	/* uleb128 0x4 */
  4972 +	.byte	0x4	/* DW_CFA_advance_loc4 */
  4973 +	.4byte	.LCFI4-.LCFI3
  4974 +	.byte	0xe	/* DW_CFA_def_cfa_offset */
  4975 +	.byte	0x14	/* uleb128 0x4 */
  4976 +	.byte	0x4	/* DW_CFA_advance_loc4 */
  4977 +	.4byte	.LCFI5-.LCFI4
  4978 +	.byte	0xe	/* DW_CFA_def_cfa_offset */
  4979 +	.byte	0x18	/* uleb128 0x4 */
  4980 +	.byte	0x91	/* DW_CFA_offset, column 0x11 */
  4981 +	.byte	0x6	/* uleb128 0x6 */
  4982 +	.byte	0x8e	/* DW_CFA_offset, column 0xe */
  4983 +	.byte	0x5	/* uleb128 0x5 */
  4984 +	.byte	0x8c	/* DW_CFA_offset, column 0xc */
  4985 +	.byte	0x4	/* uleb128 0x4 */
  4986 +	.byte	0x8a	/* DW_CFA_offset, column 0xa */
  4987 +	.byte	0x3	/* uleb128 0x3 */
  4988 +	.byte	0x89	/* DW_CFA_offset, column 0x9 */
  4989 +	.byte	0x2	/* uleb128 0x2 */
  4990 +	.byte	0x88	/* DW_CFA_offset, column 0x8 */
  4991 +	.byte	0x1	/* uleb128 0x1 */
  4992 +	.byte	0x4	/* DW_CFA_advance_loc4 */
  4993 +	.4byte	.LCFI6-.LCFI5
  4994 +	.byte	0xd	/* DW_CFA_def_cfa_register */
  4995 +	.byte	0xe	/* uleb128 0xe */
  4996 +	.align	2
  4997 +.LEFDE1:
  4998 +
  4999 +.LSFDE3:
  5000 +	.4byte	.LEFDE3-.LASFDE3	/* FDE Length */
  5001 +.LASFDE3:
  5002 +	.4byte	.LASFDE3-__FRAME_BEGIN__	/* FDE CIE offset */
  5003 +	.4byte	.LFB2	/* FDE initial location */
  5004 +	.4byte	.LFE2-.LFB2	 /* FDE address range */
  5005 +	.byte	0x4	/* DW_CFA_advance_loc4 */
  5006 +	.4byte	.LCFI7-.LFB2
  5007 +	.byte	0xe	/* DW_CFA_def_cfa_offset */
  5008 +	.byte	0x4	/* uleb128 0x4 */
  5009 +	.byte	0x4	/* DW_CFA_advance_loc4 */
  5010 +	.4byte	.LCFI8-.LCFI7
  5011 +	.byte	0xe	/* DW_CFA_def_cfa_offset */
  5012 +	.byte	0x8	/* uleb128 0x8 */
  5013 +	.byte	0x4	/* DW_CFA_advance_loc4 */
  5014 +	.4byte	.LCFI9-.LCFI8
  5015 +	.byte	0xe	/* DW_CFA_def_cfa_offset */
  5016 +#if defined(__SH4__)
  5017 +	.byte	8+56	/* uleb128 8+56 */
  5018 +#else
  5019 +	.byte	8+24	/* uleb128 8+24 */
  5020 +#endif
  5021 +	.byte	0x91	/* DW_CFA_offset, column 0x11 */
  5022 +        .byte	0x2
  5023 +        .byte	0x8e	/* DW_CFA_offset, column 0xe */
  5024 +        .byte	0x1
  5025 +	.byte	0x4	/* DW_CFA_advance_loc4 */
  5026 +	.4byte	.LCFIA-.LCFI9
  5027 +	.byte	0xd	/* DW_CFA_def_cfa_register */
  5028 +	.byte	0xe	/* uleb128 0xe */
  5029 +	.align	2
  5030 +.LEFDE3:
  5031 diff -ruN --exclude=CVS gcc-3.2.2.orig/libffi/src/sparc/ffi.c gcc/libffi/src/sparc/ffi.c
  5032 --- gcc-3.2.2.orig/libffi/src/sparc/ffi.c	Sat Mar  3 07:21:23 2001
  5033 +++ gcc/libffi/src/sparc/ffi.c	Sat Jan  4 08:08:56 2003
  5034 @@ -1,5 +1,5 @@
  5035  /* -----------------------------------------------------------------------
  5036 -   ffi.c - Copyright (c) 1996 Cygnus Solutions
  5037 +   ffi.c - Copyright (c) 1996, 2003 Cygnus Solutions
  5038     
  5039     Sparc Foreign Function Interface 
  5040  
  5041 @@ -28,20 +28,22 @@
  5042  
  5043  #include <stdlib.h>
  5044  
  5045 +#ifdef SPARC64
  5046 +extern void ffi_closure_v9(void);
  5047 +#else
  5048 +extern void ffi_closure_v8(void);
  5049 +#endif
  5050 +
  5051  /* ffi_prep_args is called by the assembly routine once stack space
  5052     has been allocated for the function's arguments */
  5053  
  5054  void ffi_prep_args_v8(char *stack, extended_cif *ecif)
  5055  {
  5056    int i;
  5057 -  int tmp;
  5058 -  int avn;
  5059    void **p_argv;
  5060    char *argp;
  5061    ffi_type **p_arg;
  5062  
  5063 -  tmp = 0;
  5064 -
  5065    /* Skip 16 words for the window save area */
  5066    argp = stack + 16*sizeof(int);
  5067  
  5068 @@ -66,18 +68,12 @@
  5069    ((int*)argp)[5] = 0;
  5070  #endif
  5071  
  5072 -  avn = ecif->cif->nargs;
  5073    p_argv = ecif->avalue;
  5074  
  5075 -  for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types;
  5076 -       i && avn;
  5077 -       i--, p_arg++)
  5078 +  for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types; i; i--, p_arg++)
  5079      {
  5080        size_t z;
  5081  
  5082 -      if (avn) 
  5083 -	{
  5084 -	  avn--;
  5085  	  if ((*p_arg)->type == FFI_TYPE_STRUCT
  5086  #if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
  5087  	      || (*p_arg)->type == FFI_TYPE_LONGDOUBLE
  5088 @@ -122,7 +118,6 @@
  5089  	    }
  5090  	  p_argv++;
  5091  	  argp += z;
  5092 -	}
  5093      }
  5094    
  5095    return;
  5096 @@ -420,3 +415,101 @@
  5097      }
  5098  
  5099  }
  5100 +
  5101 +ffi_status
  5102 +ffi_prep_closure (ffi_closure* closure,
  5103 +		  ffi_cif* cif,
  5104 +		  void (*fun)(ffi_cif*, void*, void**, void*),
  5105 +		  void *user_data)
  5106 +{
  5107 +  unsigned int *tramp = (unsigned int *) &closure->tramp[0];
  5108 +  unsigned long fn;
  5109 +  unsigned long ctx = (unsigned long) closure;
  5110 +
  5111 +#ifdef SPARC64
  5112 +  /* Trampoline address is equal to the closure address.  We take advantage
  5113 +     of that to reduce the trampoline size by 8 bytes. */
  5114 +  FFI_ASSERT (cif->abi == FFI_V9);
  5115 +  fn = (unsigned long) ffi_closure_v9;
  5116 +  tramp[0] = 0x83414000;	/* rd	%pc, %g1	*/
  5117 +  tramp[1] = 0xca586010;	/* ldx	[%g1+16], %g5	*/
  5118 +  tramp[2] = 0x81c14000;	/* jmp	%g5		*/
  5119 +  tramp[3] = 0x01000000;	/* nop			*/
  5120 +  *((unsigned long *) &tramp[4]) = fn;
  5121 +#else
  5122 +  FFI_ASSERT (cif->abi == FFI_V8);
  5123 +  fn = (unsigned long) ffi_closure_v8;
  5124 +  tramp[0] = 0x03000000 | fn >> 10;	/* sethi %hi(fn), %g1	*/
  5125 +  tramp[1] = 0x05000000 | ctx >> 10;	/* sethi %hi(ctx), %g2	*/
  5126 +  tramp[2] = 0x81c06000 | (fn & 0x3ff);	/* jmp   %g1+%lo(fn)	*/
  5127 +  tramp[3] = 0x8410a000 | (ctx & 0x3ff);/* or    %g2, %lo(ctx)	*/
  5128 +#endif
  5129 +
  5130 +  closure->cif = cif;
  5131 +  closure->fun = fun;
  5132 +  closure->user_data = user_data;
  5133 +
  5134 +  /* Flush the Icache.  FIXME: alignment isn't certain, assume 8 bytes */
  5135 +#ifdef SPARC64
  5136 +  asm volatile ("flush	%0" : : "r" (closure) : "memory");
  5137 +  asm volatile ("flush	%0" : : "r" (((char *) closure) + 8) : "memory");
  5138 +#else
  5139 +  asm volatile ("iflush	%0" : : "r" (closure) : "memory");
  5140 +  asm volatile ("iflush	%0" : : "r" (((char *) closure) + 8) : "memory");
  5141 +#endif
  5142 +
  5143 +  return FFI_OK;
  5144 +}
  5145 +
  5146 +int
  5147 +ffi_closure_sparc_inner(ffi_closure *closure,
  5148 +  void *rvalue, unsigned long *gpr, double *fpr)
  5149 +{
  5150 +  ffi_cif *cif;
  5151 +  void **avalue;
  5152 +  ffi_type **arg_types;
  5153 +  int i, avn, argn;
  5154 +
  5155 +  cif = closure->cif;
  5156 +  avalue = alloca(cif->nargs * sizeof(void *));
  5157 +
  5158 +  argn = 0;
  5159 +
  5160 +  /* Copy the caller's structure return address to that the closure
  5161 +     returns the data directly to the caller.  */
  5162 +  if (cif->flags == FFI_TYPE_STRUCT)
  5163 +    {
  5164 +      rvalue = (void *) gpr[0];
  5165 +      argn = 1;
  5166 +    }
  5167 +
  5168 +  i = 0;
  5169 +  avn = cif->nargs;
  5170 +  arg_types = cif->arg_types;
  5171 +  
  5172 +  /* Grab the addresses of the arguments from the stack frame.  */
  5173 +  while (i < avn)
  5174 +    {
  5175 +      /* Assume big-endian.  FIXME */
  5176 +      argn += ALIGN(arg_types[i]->size, SIZEOF_ARG) / SIZEOF_ARG;
  5177 +
  5178 +#ifdef SPARC64
  5179 +      if (i < 6 && (arg_types[i]->type == FFI_TYPE_FLOAT
  5180 +		 || arg_types[i]->type == FFI_TYPE_DOUBLE
  5181 +#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
  5182 +		 || arg_types[i]->type == FFI_TYPE_LONGDOUBLE
  5183 +#endif
  5184 +		))
  5185 +        avalue[i] = ((char *) &fpr[argn]) - arg_types[i]->size;
  5186 +      else
  5187 +#endif
  5188 +        avalue[i] = ((char *) &gpr[argn]) - arg_types[i]->size;
  5189 +      i++;
  5190 +    }
  5191 +
  5192 +  /* Invoke the closure.  */
  5193 +  (closure->fun) (cif, rvalue, avalue, closure->user_data);
  5194 +
  5195 +  /* Tell ffi_closure_sparc how to perform return type promotions.  */
  5196 +  return cif->rtype->type;
  5197 +}
  5198 diff -ruN --exclude=CVS gcc-3.2.2.orig/libffi/src/sparc/v8.S gcc/libffi/src/sparc/v8.S
  5199 --- gcc-3.2.2.orig/libffi/src/sparc/v8.S	Mon Apr 29 05:12:04 2002
  5200 +++ gcc/libffi/src/sparc/v8.S	Sat Jan  4 08:08:56 2003
  5201 @@ -1,5 +1,5 @@
  5202  /* -----------------------------------------------------------------------
  5203 -   v8.S - Copyright (c) 1996, 1997 Cygnus Solutions
  5204 +   v8.S - Copyright (c) 1996, 1997, 2003 Cygnus Solutions
  5205     
  5206     Sparc Foreign Function Interface 
  5207  
  5208 @@ -94,6 +94,72 @@
  5209  .ffi_call_V8_end:
  5210  	.size	ffi_call_V8,.ffi_call_V8_end-ffi_call_V8
  5211  
  5212 +
  5213 +#define	STACKFRAME	104	/* 16*4 register window +
  5214 +				   1*4 struct return +	
  5215 +				   6*4 args backing store +
  5216 +				   3*4 locals */
  5217 +
  5218 +/* ffi_closure_v8(...)
  5219 +
  5220 +   Receives the closure argument in %g2.   */
  5221 +
  5222 +	.text
  5223 +	.align 8
  5224 +	.globl ffi_closure_v8
  5225 +
  5226 +ffi_closure_v8:
  5227 +	.register	%g2, #scratch
  5228 +.LLFB2:
  5229 +	save	%sp, -STACKFRAME, %sp
  5230 +.LLCFI1:
  5231 +
  5232 +	! Store all of the potential argument registers in va_list format.
  5233 +	st	%i0, [%fp+68+0]
  5234 +	st	%i1, [%fp+68+4]
  5235 +	st	%i2, [%fp+68+8]
  5236 +	st	%i3, [%fp+68+12]
  5237 +	st	%i4, [%fp+68+16]
  5238 +	st	%i5, [%fp+68+20]
  5239 +
  5240 +	! Call ffi_closure_sparc_inner to do the bulk of the work.
  5241 +	mov	%g2, %o0
  5242 +	add	%fp, -8, %o1
  5243 +	add	%fp,  68, %o2
  5244 +	call	ffi_closure_sparc_inner
  5245 +	 mov	0, %o3
  5246 +
  5247 +	! Load up the return value in the proper type.
  5248 +	cmp	%o0, FFI_TYPE_VOID
  5249 +	be	done1
  5250 +
  5251 +	cmp	%o0, FFI_TYPE_FLOAT
  5252 +	be,a	done1
  5253 +	 ld	[%fp-8], %f0
  5254 +
  5255 +	cmp	%o0, FFI_TYPE_DOUBLE
  5256 +	be,a	done1
  5257 +	 ldd	[%fp-8], %f0
  5258 +
  5259 +	cmp	%o0, FFI_TYPE_SINT64
  5260 +	be,a	integer
  5261 +	 ld	[%fp-4], %i1
  5262 +
  5263 +	cmp	%o0, FFI_TYPE_UINT64
  5264 +	be,a	integer
  5265 +	 ld	[%fp-4], %i1
  5266 +
  5267 +integer:
  5268 +	ld	[%fp-8], %i0
  5269 +
  5270 +done1:
  5271 +	ret
  5272 +	 restore
  5273 +.LLFE2:
  5274 +
  5275 +.ffi_closure_v8_end:
  5276 +	.size	ffi_closure_v8,.ffi_closure_v8_end-ffi_closure_v8
  5277 +
  5278  #ifdef SPARC64
  5279  #define WS 8
  5280  #define nword	xword
  5281 @@ -148,3 +214,26 @@
  5282  	.byte	0x1f	! uleb128 0x1f
  5283  	.align	WS
  5284  .LLEFDE1:
  5285 +.LLSFDE2:
  5286 +	.uaword	.LLEFDE2-.LLASFDE2	! FDE Length
  5287 +.LLASFDE2:
  5288 +	.uaword	.LLASFDE2-.LLframe1	! FDE CIE offset
  5289 +#ifdef HAVE_AS_SPARC_UA_PCREL
  5290 +	.uaword	%r_disp32(.LLFB2)
  5291 +	.uaword	.LLFE2-.LLFB2	! FDE address range
  5292 +#else
  5293 +	.align	WS
  5294 +	.nword	.LLFB2
  5295 +	.uanword .LLFE2-.LLFB2	! FDE address range
  5296 +#endif
  5297 +	.byte	0x0	! uleb128 0x0; Augmentation size
  5298 +	.byte	0x4	! DW_CFA_advance_loc4
  5299 +	.uaword	.LLCFI1-.LLFB2
  5300 +	.byte	0xd	! DW_CFA_def_cfa_register
  5301 +	.byte	0x1e	! uleb128 0x1e
  5302 +	.byte	0x2d	! DW_CFA_GNU_window_save
  5303 +	.byte	0x9	! DW_CFA_register
  5304 +	.byte	0xf	! uleb128 0xf
  5305 +	.byte	0x1f	! uleb128 0x1f
  5306 +	.align	WS
  5307 +.LLEFDE2:
  5308 diff -ruN --exclude=CVS gcc-3.2.2.orig/libffi/src/sparc/v9.S gcc/libffi/src/sparc/v9.S
  5309 --- gcc-3.2.2.orig/libffi/src/sparc/v9.S	Mon Apr 29 05:12:04 2002
  5310 +++ gcc/libffi/src/sparc/v9.S	Sat Jan  4 08:08:56 2003
  5311 @@ -1,5 +1,5 @@
  5312  /* -----------------------------------------------------------------------
  5313 -   v9.S - Copyright (c) 2000 Cygnus Solutions
  5314 +   v9.S - Copyright (c) 2000, 2003 Cygnus Solutions
  5315     
  5316     Sparc 64bit Foreign Function Interface 
  5317  
  5318 @@ -99,7 +99,7 @@
  5319  	cmp	%i3, FFI_TYPE_STRUCT
  5320  	be,pn	%icc, dostruct
  5321  
  5322 -	 cmp	%i3, FFI_TYPE_LONGDOUBLE
  5323 +	cmp	%i3, FFI_TYPE_LONGDOUBLE
  5324  	bne,pt	%icc, done
  5325  	 nop
  5326  	std	%f0, [%i4+0]
  5327 @@ -125,6 +125,88 @@
  5328  .ffi_call_V9_end:
  5329  	.size	ffi_call_V9,.ffi_call_V9_end-ffi_call_V9
  5330  
  5331 +
  5332 +#define	STACKFRAME	 240	/* 16*8 register window +
  5333 +				   6*8 args backing store +
  5334 +				   8*8 locals */
  5335 +#define	FP		%fp+STACK_BIAS
  5336 +
  5337 +/* ffi_closure_v9(...)
  5338 +
  5339 +   Receives the closure argument in %g1.   */
  5340 +
  5341 +	.text
  5342 +	.align 8
  5343 +	.globl ffi_closure_v9
  5344 +
  5345 +ffi_closure_v9:
  5346 +.LLFB2:
  5347 +	save	%sp, -STACKFRAME, %sp
  5348 +.LLCFI1:
  5349 +
  5350 +	! Store all of the potential argument registers in va_list format.
  5351 +	stx	%i0, [FP+128+0]
  5352 +	stx	%i1, [FP+128+8]
  5353 +	stx	%i2, [FP+128+16]
  5354 +	stx	%i3, [FP+128+24]
  5355 +	stx	%i4, [FP+128+32]
  5356 +	stx	%i5, [FP+128+40]
  5357 +
  5358 +	! Store possible floating point argument registers too.
  5359 +	std	%f0, [FP-48]
  5360 +	std	%f2, [FP-40]
  5361 +	std	%f4, [FP-32]
  5362 +	std	%f6, [FP-24]
  5363 +	std	%f8, [FP-16]
  5364 +	std	%f10, [FP-8]
  5365 +
  5366 +	! Call ffi_closure_sparc_inner to do the bulk of the work.
  5367 +	mov	%g1, %o0
  5368 +	add	%fp, STACK_BIAS-64, %o1
  5369 +	add	%fp, STACK_BIAS+128, %o2
  5370 +	call	ffi_closure_sparc_inner
  5371 +	 add	%fp, STACK_BIAS-48, %o3
  5372 +
  5373 +	! Load up the return value in the proper type.
  5374 +	cmp	%o0, FFI_TYPE_VOID
  5375 +	be,pn	%icc, done1
  5376 +
  5377 +	cmp	%o0, FFI_TYPE_FLOAT
  5378 +	be,a,pn	%icc, done1
  5379 +	 ld	[FP-64], %f0
  5380 +
  5381 +	cmp	%o0, FFI_TYPE_DOUBLE
  5382 +	be,a,pn	%icc, done1
  5383 +	 ldd	[FP-64], %f0
  5384 +
  5385 +	cmp	%o0, FFI_TYPE_LONGDOUBLE
  5386 +	be,a,pn	%icc, longdouble1
  5387 +	 ldd	[FP-64], %f0
  5388 +
  5389 +	cmp	%o0, FFI_TYPE_STRUCT
  5390 +	be,pn	%icc, struct1
  5391 +
  5392 +	! FFI_TYPE_UINT64 | FFI_TYPE_SINT64 | FFI_TYPE_POINTER
  5393 +	ldx	[FP-64], %i0
  5394 +
  5395 +done1:
  5396 +	ret
  5397 +	 restore
  5398 +
  5399 +struct1:
  5400 +	ldx [FP-56], %i2
  5401 +	ret
  5402 +	 restore
  5403 +
  5404 +longdouble1:
  5405 +	ldd	[FP-56], %f2
  5406 +	ret
  5407 +	 restore
  5408 +.LLFE2:
  5409 +
  5410 +.ffi_closure_v9_end:
  5411 +	.size	ffi_closure_v9,.ffi_closure_v9_end-ffi_closure_v9
  5412 +
  5413  	.section	".eh_frame",#alloc,#write
  5414  .LLframe1:
  5415  	.uaword	.LLECIE1-.LLSCIE1	! Length of Common Information Entry
  5416 @@ -169,5 +251,27 @@
  5417  	.byte	0x1f	! uleb128 0x1f
  5418  	.align 8
  5419  .LLEFDE1:
  5420 -
  5421 +.LLSFDE2:
  5422 +	.uaword	.LLEFDE2-.LLASFDE2	! FDE Length
  5423 +.LLASFDE2:
  5424 +	.uaword	.LLASFDE2-.LLframe1	! FDE CIE offset
  5425 +#ifdef HAVE_AS_SPARC_UA_PCREL
  5426 +	.uaword	%r_disp32(.LLFB2)
  5427 +	.uaword	.LLFE2-.LLFB2		! FDE address range
  5428 +#else
  5429 +	.align 8
  5430 +	.xword	.LLFB2
  5431 +	.uaxword	.LLFE2-.LLFB2	! FDE address range
  5432 +#endif
  5433 +	.byte	0x0	! uleb128 0x0; Augmentation size
  5434 +	.byte	0x4	! DW_CFA_advance_loc4
  5435 +	.uaword	.LLCFI1-.LLFB2
  5436 +	.byte	0xd	! DW_CFA_def_cfa_register
  5437 +	.byte	0x1e	! uleb128 0x1e
  5438 +	.byte	0x2d	! DW_CFA_GNU_window_save
  5439 +	.byte	0x9	! DW_CFA_register
  5440 +	.byte	0xf	! uleb128 0xf
  5441 +	.byte	0x1f	! uleb128 0x1f
  5442 +	.align 8
  5443 +.LLEFDE2:
  5444  #endif
  5445 diff -ruN --exclude=CVS gcc-3.2.2.orig/libffi/src/types.c gcc/libffi/src/types.c
  5446 --- gcc-3.2.2.orig/libffi/src/types.c	Tue Mar 27 11:39:16 2001
  5447 +++ gcc/libffi/src/types.c	Wed Nov 27 07:24:05 2002
  5448 @@ -42,7 +42,8 @@
  5449  FFI_INTEGRAL_TYPEDEF(sint32, 4, 4, FFI_TYPE_SINT32);
  5450  FFI_INTEGRAL_TYPEDEF(float, 4, 4, FFI_TYPE_FLOAT);
  5451  
  5452 -#if defined ALPHA || defined SPARC64
  5453 +#if defined ALPHA || defined SPARC64 || defined X86_64 || defined S390X \
  5454 +    || defined IA64
  5455  
  5456  FFI_INTEGRAL_TYPEDEF(pointer, 8, 8, FFI_TYPE_POINTER);
  5457  
  5458 @@ -52,22 +53,12 @@
  5459  
  5460  #endif
  5461  
  5462 -#ifdef X86
  5463 +#if defined X86 || defined X86_WIN32 || defined ARM || defined M68K
  5464  
  5465  FFI_INTEGRAL_TYPEDEF(uint64, 8, 4, FFI_TYPE_UINT64);
  5466  FFI_INTEGRAL_TYPEDEF(sint64, 8, 4, FFI_TYPE_SINT64);
  5467  
  5468 -#elif defined X86_WIN32
  5469 -
  5470 -FFI_INTEGRAL_TYPEDEF(uint64, 8, 4, FFI_TYPE_UINT64);
  5471 -FFI_INTEGRAL_TYPEDEF(sint64, 8, 4, FFI_TYPE_SINT64);
  5472 -
  5473 -#elif defined ARM
  5474 -
  5475 -FFI_INTEGRAL_TYPEDEF(uint64, 8, 4, FFI_TYPE_UINT64);
  5476 -FFI_INTEGRAL_TYPEDEF(sint64, 8, 4, FFI_TYPE_SINT64);
  5477 -
  5478 -#elif defined M68K
  5479 +#elif defined SH
  5480  
  5481  FFI_INTEGRAL_TYPEDEF(uint64, 8, 4, FFI_TYPE_UINT64);
  5482  FFI_INTEGRAL_TYPEDEF(sint64, 8, 4, FFI_TYPE_SINT64);
  5483 @@ -80,12 +71,7 @@
  5484  #endif
  5485  
  5486  
  5487 -#ifdef X86
  5488 -
  5489 -FFI_INTEGRAL_TYPEDEF(double, 8, 4, FFI_TYPE_DOUBLE);
  5490 -FFI_INTEGRAL_TYPEDEF(longdouble, 12, 4, FFI_TYPE_LONGDOUBLE);
  5491 -
  5492 -#elif defined X86_WIN32
  5493 +#if defined X86 || defined X86_WIN32 || defined M68K
  5494  
  5495  FFI_INTEGRAL_TYPEDEF(double, 8, 4, FFI_TYPE_DOUBLE);
  5496  FFI_INTEGRAL_TYPEDEF(longdouble, 12, 4, FFI_TYPE_LONGDOUBLE);
  5497 @@ -95,25 +81,25 @@
  5498  FFI_INTEGRAL_TYPEDEF(double, 8, 4, FFI_TYPE_DOUBLE);
  5499  FFI_INTEGRAL_TYPEDEF(longdouble, 8, 4, FFI_TYPE_LONGDOUBLE);
  5500  
  5501 -#elif defined M68K
  5502 +#elif defined SH
  5503  
  5504  FFI_INTEGRAL_TYPEDEF(double, 8, 4, FFI_TYPE_DOUBLE);
  5505 -FFI_INTEGRAL_TYPEDEF(longdouble, 12, 4, FFI_TYPE_LONGDOUBLE);
  5506 +FFI_INTEGRAL_TYPEDEF(longdouble, 8, 4, FFI_TYPE_LONGDOUBLE);
  5507  
  5508  #elif defined SPARC
  5509  
  5510  FFI_INTEGRAL_TYPEDEF(double, 8, 8, FFI_TYPE_DOUBLE);
  5511 -
  5512  #ifdef SPARC64
  5513 -
  5514  FFI_INTEGRAL_TYPEDEF(longdouble, 16, 16, FFI_TYPE_LONGDOUBLE);
  5515 -
  5516  #else
  5517 -
  5518  FFI_INTEGRAL_TYPEDEF(longdouble, 16, 8, FFI_TYPE_LONGDOUBLE);
  5519 -
  5520  #endif
  5521  
  5522 +#elif defined X86_64
  5523 +
  5524 +FFI_INTEGRAL_TYPEDEF(double, 8, 8, FFI_TYPE_DOUBLE);
  5525 +FFI_INTEGRAL_TYPEDEF(longdouble, 16, 16, FFI_TYPE_LONGDOUBLE);
  5526 +
  5527  #else
  5528  
  5529  FFI_INTEGRAL_TYPEDEF(double, 8, 8, FFI_TYPE_DOUBLE);
  5530 diff -ruN --exclude=CVS gcc-3.2.2.orig/libffi/src/x86/ffi.c gcc/libffi/src/x86/ffi.c
  5531 --- gcc-3.2.2.orig/libffi/src/x86/ffi.c	Tue May 28 18:22:08 2002
  5532 +++ gcc/libffi/src/x86/ffi.c	Fri Dec  6 10:16:45 2002
  5533 @@ -1,5 +1,8 @@
  5534  /* -----------------------------------------------------------------------
  5535 -   ffi.c - Copyright (c) 1996, 1998, 1999  Cygnus Solutions
  5536 +   ffi.c - Copyright (c) 1996, 1998, 1999, 2001  Red Hat, Inc.
  5537 +           Copyright (c) 2002  Ranjit Mathew
  5538 +           Copyright (c) 2002  Bo Thorsen
  5539 +           Copyright (c) 2002  Roger Sayle
  5540     
  5541     x86 Foreign Function Interface 
  5542  
  5543 @@ -23,6 +26,8 @@
  5544     OTHER DEALINGS IN THE SOFTWARE.
  5545     ----------------------------------------------------------------------- */
  5546  
  5547 +#ifndef __x86_64__
  5548 +
  5549  #include <ffi.h>
  5550  #include <ffi_common.h>
  5551  
  5552 @@ -36,12 +41,10 @@
  5553  /*@=exportheader@*/
  5554  {
  5555    register unsigned int i;
  5556 -  register int tmp;
  5557    register void **p_argv;
  5558    register char *argp;
  5559    register ffi_type **p_arg;
  5560  
  5561 -  tmp = 0;
  5562    argp = stack;
  5563  
  5564    if (ecif->cif->rtype->type == FFI_TYPE_STRUCT)
  5565 @@ -148,6 +151,18 @@
  5566  /*@=declundef@*/
  5567  /*@=exportheader@*/
  5568  
  5569 +#ifdef X86_WIN32
  5570 +/*@-declundef@*/
  5571 +/*@-exportheader@*/
  5572 +extern void ffi_call_STDCALL(void (*)(char *, extended_cif *),
  5573 +			  /*@out@*/ extended_cif *,
  5574 +			  unsigned, unsigned,
  5575 +			  /*@out@*/ unsigned *,
  5576 +			  void (*fn)());
  5577 +/*@=declundef@*/
  5578 +/*@=exportheader@*/
  5579 +#endif /* X86_WIN32 */
  5580 +
  5581  void ffi_call(/*@dependent@*/ ffi_cif *cif, 
  5582  	      void (*fn)(), 
  5583  	      /*@out@*/ void *rvalue, 
  5584 @@ -180,6 +195,14 @@
  5585  		    cif->flags, ecif.rvalue, fn);
  5586        /*@=usedef@*/
  5587        break;
  5588 +#ifdef X86_WIN32
  5589 +    case FFI_STDCALL:
  5590 +      /*@-usedef@*/
  5591 +      ffi_call_STDCALL(ffi_prep_args, &ecif, cif->bytes,
  5592 +		    cif->flags, ecif.rvalue, fn);
  5593 +      /*@=usedef@*/
  5594 +      break;
  5595 +#endif /* X86_WIN32 */
  5596      default:
  5597        FFI_ASSERT(0);
  5598        break;
  5599 @@ -266,12 +289,10 @@
  5600  /*@=exportheader@*/
  5601  {
  5602    register unsigned int i;
  5603 -  register int tmp;
  5604    register void **p_argv;
  5605    register char *argp;
  5606    register ffi_type **p_arg;
  5607  
  5608 -  tmp = 0;
  5609    argp = stack;
  5610  
  5611    if ( cif->rtype->type == FFI_TYPE_STRUCT ) {
  5612 @@ -281,13 +302,14 @@
  5613  
  5614    p_argv = avalue;
  5615  
  5616 -  for (i = cif->nargs, p_arg = cif->arg_types; i != 0; i--, p_arg++)
  5617 +  for (i = cif->nargs, p_arg = cif->arg_types; (i != 0); i--, p_arg++)
  5618      {
  5619        size_t z;
  5620  
  5621        /* Align if necessary */
  5622 -      if (((*p_arg)->alignment - 1) & (unsigned) argp)
  5623 +      if (((*p_arg)->alignment - 1) & (unsigned) argp) {
  5624  	argp = (char *) ALIGN(argp, (*p_arg)->alignment);
  5625 +      }
  5626  
  5627        z = (*p_arg)->size;
  5628  
  5629 @@ -298,7 +320,7 @@
  5630        p_argv++;
  5631        argp += z;
  5632      }
  5633 -
  5634 +  
  5635    return;
  5636  }
  5637  
  5638 @@ -449,6 +471,15 @@
  5639  	      /*@out@*/ unsigned *, 
  5640  	      void (*fn)());
  5641  
  5642 +#ifdef X86_WIN32
  5643 +extern void
  5644 +ffi_call_STDCALL(void (*)(char *, extended_cif *),
  5645 +	      /*@out@*/ extended_cif *,
  5646 +	      unsigned, unsigned,
  5647 +	      /*@out@*/ unsigned *,
  5648 +	      void (*fn)());
  5649 +#endif /* X86_WIN32 */
  5650 +
  5651  void
  5652  ffi_raw_call(/*@dependent@*/ ffi_cif *cif, 
  5653  	     void (*fn)(), 
  5654 @@ -483,6 +514,14 @@
  5655  		    cif->flags, ecif.rvalue, fn);
  5656        /*@=usedef@*/
  5657        break;
  5658 +#ifdef X86_WIN32
  5659 +    case FFI_STDCALL:
  5660 +      /*@-usedef@*/
  5661 +      ffi_call_STDCALL(ffi_prep_args_raw, &ecif, cif->bytes,
  5662 +		    cif->flags, ecif.rvalue, fn);
  5663 +      /*@=usedef@*/
  5664 +      break;
  5665 +#endif /* X86_WIN32 */
  5666      default:
  5667        FFI_ASSERT(0);
  5668        break;
  5669 @@ -490,3 +529,5 @@
  5670  }
  5671  
  5672  #endif
  5673 +
  5674 +#endif /* __x86_64__  */
  5675 diff -ruN --exclude=CVS gcc-3.2.2.orig/libffi/src/x86/ffi64.c gcc/libffi/src/x86/ffi64.c
  5676 --- gcc-3.2.2.orig/libffi/src/x86/ffi64.c	Thu Jan  1 09:00:00 1970
  5677 +++ gcc/libffi/src/x86/ffi64.c	Wed Jan 29 00:54:28 2003
  5678 @@ -0,0 +1,706 @@
  5679 +/* -----------------------------------------------------------------------
  5680 +   ffi.c - Copyright (c) 2002  Bo Thorsen <bo@suse.de>
  5681 +   
  5682 +   x86-64 Foreign Function Interface 
  5683 +
  5684 +   Permission is hereby granted, free of charge, to any person obtaining
  5685 +   a copy of this software and associated documentation files (the
  5686 +   ``Software''), to deal in the Software without restriction, including
  5687 +   without limitation the rights to use, copy, modify, merge, publish,
  5688 +   distribute, sublicense, and/or sell copies of the Software, and to
  5689 +   permit persons to whom the Software is furnished to do so, subject to
  5690 +   the following conditions:
  5691 +
  5692 +   The above copyright notice and this permission notice shall be included
  5693 +   in all copies or substantial portions of the Software.
  5694 +
  5695 +   THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
  5696 +   OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  5697 +   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  5698 +   IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
  5699 +   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  5700 +   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  5701 +   OTHER DEALINGS IN THE SOFTWARE.
  5702 +   ----------------------------------------------------------------------- */
  5703 +
  5704 +#include <ffi.h>
  5705 +#include <ffi_common.h>
  5706 +
  5707 +#include <stdlib.h>
  5708 +#include <stdarg.h>
  5709 +
  5710 +/* ffi_prep_args is called by the assembly routine once stack space
  5711 +   has been allocated for the function's arguments */
  5712 +
  5713 +#ifdef __x86_64__
  5714 +
  5715 +#define MAX_GPR_REGS 6
  5716 +#define MAX_SSE_REGS 8
  5717 +typedef struct
  5718 +{
  5719 +  /* Registers for argument passing.  */
  5720 +  long gpr[MAX_GPR_REGS];
  5721 +  __int128_t sse[MAX_SSE_REGS];
  5722 +
  5723 +  /* Stack space for arguments.  */
  5724 +  char argspace[0];
  5725 +} stackLayout;
  5726 +
  5727 +/* All reference to register classes here is identical to the code in
  5728 +   gcc/config/i386/i386.c. Do *not* change one without the other.  */
  5729 +
  5730 +/* Register class used for passing given 64bit part of the argument.
  5731 +   These represent classes as documented by the PS ABI, with the exception
  5732 +   of SSESF, SSEDF classes, that are basically SSE class, just gcc will
  5733 +   use SF or DFmode move instead of DImode to avoid reformating penalties.
  5734 +
  5735 +   Similary we play games with INTEGERSI_CLASS to use cheaper SImode moves
  5736 +   whenever possible (upper half does contain padding).
  5737 + */
  5738 +enum x86_64_reg_class
  5739 +  {
  5740 +    X86_64_NO_CLASS,
  5741 +    X86_64_INTEGER_CLASS,
  5742 +    X86_64_INTEGERSI_CLASS,
  5743 +    X86_64_SSE_CLASS,
  5744 +    X86_64_SSESF_CLASS,
  5745 +    X86_64_SSEDF_CLASS,
  5746 +    X86_64_SSEUP_CLASS,
  5747 +    X86_64_X87_CLASS,
  5748 +    X86_64_X87UP_CLASS,
  5749 +    X86_64_MEMORY_CLASS
  5750 +  };
  5751 +
  5752 +#define MAX_CLASSES 4
  5753 +
  5754 +/* x86-64 register passing implementation.  See x86-64 ABI for details.  Goal
  5755 +   of this code is to classify each 8bytes of incoming argument by the register
  5756 +   class and assign registers accordingly.  */
  5757 +
  5758 +/* Return the union class of CLASS1 and CLASS2.
  5759 +   See the x86-64 PS ABI for details.  */
  5760 +
  5761 +static enum x86_64_reg_class
  5762 +merge_classes (enum x86_64_reg_class class1, enum x86_64_reg_class class2)
  5763 +{
  5764 +  /* Rule #1: If both classes are equal, this is the resulting class.  */
  5765 +  if (class1 == class2)
  5766 +    return class1;
  5767 +
  5768 +  /* Rule #2: If one of the classes is NO_CLASS, the resulting class is
  5769 +     the other class.  */
  5770 +  if (class1 == X86_64_NO_CLASS)
  5771 +    return class2;
  5772 +  if (class2 == X86_64_NO_CLASS)
  5773 +    return class1;
  5774 +
  5775 +  /* Rule #3: If one of the classes is MEMORY, the result is MEMORY.  */
  5776 +  if (class1 == X86_64_MEMORY_CLASS || class2 == X86_64_MEMORY_CLASS)
  5777 +    return X86_64_MEMORY_CLASS;
  5778 +
  5779 +  /* Rule #4: If one of the classes is INTEGER, the result is INTEGER.  */
  5780 +  if ((class1 == X86_64_INTEGERSI_CLASS && class2 == X86_64_SSESF_CLASS)
  5781 +      || (class2 == X86_64_INTEGERSI_CLASS && class1 == X86_64_SSESF_CLASS))
  5782 +    return X86_64_INTEGERSI_CLASS;
  5783 +  if (class1 == X86_64_INTEGER_CLASS || class1 == X86_64_INTEGERSI_CLASS
  5784 +      || class2 == X86_64_INTEGER_CLASS || class2 == X86_64_INTEGERSI_CLASS)
  5785 +    return X86_64_INTEGER_CLASS;
  5786 +
  5787 +  /* Rule #5: If one of the classes is X87 or X87UP class, MEMORY is used.  */
  5788 +  if (class1 == X86_64_X87_CLASS || class1 == X86_64_X87UP_CLASS
  5789 +      || class2 == X86_64_X87_CLASS || class2 == X86_64_X87UP_CLASS)
  5790 +    return X86_64_MEMORY_CLASS;
  5791 +
  5792 +  /* Rule #6: Otherwise class SSE is used.  */
  5793 +  return X86_64_SSE_CLASS;
  5794 +}
  5795 +
  5796 +/* Classify the argument of type TYPE and mode MODE.
  5797 +   CLASSES will be filled by the register class used to pass each word
  5798 +   of the operand.  The number of words is returned.  In case the parameter
  5799 +   should be passed in memory, 0 is returned. As a special case for zero
  5800 +   sized containers, classes[0] will be NO_CLASS and 1 is returned.
  5801 +
  5802 +   See the x86-64 PS ABI for details.
  5803 +*/
  5804 +static int
  5805 +classify_argument (ffi_type *type, enum x86_64_reg_class classes[],
  5806 +		   int *byte_offset)
  5807 +{
  5808 +  /* First, align to the right place.  */
  5809 +  *byte_offset = ALIGN(*byte_offset, type->alignment);
  5810 +
  5811 +  switch (type->type)
  5812 +    {
  5813 +    case FFI_TYPE_UINT8:
  5814 +    case FFI_TYPE_SINT8:
  5815 +    case FFI_TYPE_UINT16:
  5816 +    case FFI_TYPE_SINT16:
  5817 +    case FFI_TYPE_UINT32:
  5818 +    case FFI_TYPE_SINT32:
  5819 +    case FFI_TYPE_UINT64:
  5820 +    case FFI_TYPE_SINT64:
  5821 +    case FFI_TYPE_POINTER:
  5822 +      if (((*byte_offset) % 8 + type->size) <= 4)
  5823 +	classes[0] = X86_64_INTEGERSI_CLASS;
  5824 +      else
  5825 +	classes[0] = X86_64_INTEGER_CLASS;
  5826 +      return 1;
  5827 +    case FFI_TYPE_FLOAT:
  5828 +      if (((*byte_offset) % 8) == 0)
  5829 +	classes[0] = X86_64_SSESF_CLASS;
  5830 +      else
  5831 +	classes[0] = X86_64_SSE_CLASS;
  5832 +      return 1;
  5833 +    case FFI_TYPE_DOUBLE:
  5834 +      classes[0] = X86_64_SSEDF_CLASS;
  5835 +      return 1;
  5836 +    case FFI_TYPE_LONGDOUBLE:
  5837 +      classes[0] = X86_64_X87_CLASS;
  5838 +      classes[1] = X86_64_X87UP_CLASS;
  5839 +      return 2;
  5840 +    case FFI_TYPE_STRUCT:
  5841 +      {
  5842 +	const int UNITS_PER_WORD = 8;
  5843 +	int words = (type->size + UNITS_PER_WORD - 1) / UNITS_PER_WORD;
  5844 +	ffi_type **ptr; 
  5845 +	int i;
  5846 +	enum x86_64_reg_class subclasses[MAX_CLASSES];
  5847 +
  5848 +	/* If the struct is larger than 16 bytes, pass it on the stack.  */
  5849 +	if (type->size > 16)
  5850 +	  return 0;
  5851 +
  5852 +	for (i = 0; i < words; i++)
  5853 +	  classes[i] = X86_64_NO_CLASS;
  5854 +
  5855 +	/* Merge the fields of structure.  */
  5856 +	for (ptr=type->elements; (*ptr)!=NULL; ptr++)
  5857 +	  {
  5858 +	    int num;
  5859 +
  5860 +	    num = classify_argument (*ptr, subclasses, byte_offset);
  5861 +	    if (num == 0)
  5862 +	      return 0;
  5863 +	    for (i = 0; i < num; i++)
  5864 +	      {
  5865 +		int pos = *byte_offset / 8;
  5866 +		classes[i + pos] =
  5867 +		  merge_classes (subclasses[i], classes[i + pos]);
  5868 +	      }
  5869 +
  5870 +	    if ((*ptr)->type != FFI_TYPE_STRUCT)
  5871 +	      *byte_offset += (*ptr)->size;
  5872 +	  }
  5873 +
  5874 +	/* Final merger cleanup.  */
  5875 +	for (i = 0; i < words; i++)
  5876 +	  {
  5877 +	    /* If one class is MEMORY, everything should be passed in
  5878 +	       memory.  */
  5879 +	    if (classes[i] == X86_64_MEMORY_CLASS)
  5880 +	      return 0;
  5881 +
  5882 +	    /* The X86_64_SSEUP_CLASS should be always preceded by
  5883 +	       X86_64_SSE_CLASS.  */
  5884 +	    if (classes[i] == X86_64_SSEUP_CLASS
  5885 +		&& (i == 0 || classes[i - 1] != X86_64_SSE_CLASS))
  5886 +	      classes[i] = X86_64_SSE_CLASS;
  5887 +
  5888 +	    /*  X86_64_X87UP_CLASS should be preceded by X86_64_X87_CLASS.  */
  5889 +	    if (classes[i] == X86_64_X87UP_CLASS
  5890 +		&& (i == 0 || classes[i - 1] != X86_64_X87_CLASS))
  5891 +	      classes[i] = X86_64_SSE_CLASS;
  5892 +	  }
  5893 +	return words;
  5894 +      }
  5895 +
  5896 +    default:
  5897 +      FFI_ASSERT(0);
  5898 +    }
  5899 +  return 0; /* Never reached.  */
  5900 +}
  5901 +
  5902 +/* Examine the argument and return set number of register required in each
  5903 +   class.  Return 0 iff parameter should be passed in memory.  */
  5904 +static int
  5905 +examine_argument (ffi_type *type, int in_return, int *int_nregs,int *sse_nregs)
  5906 +{
  5907 +  enum x86_64_reg_class class[MAX_CLASSES];
  5908 +  int offset = 0;
  5909 +  int n;
  5910 +
  5911 +  n = classify_argument (type, class, &offset);
  5912 +
  5913 +  if (n == 0)
  5914 +    return 0;
  5915 +
  5916 +  *int_nregs = 0;
  5917 +  *sse_nregs = 0;
  5918 +  for (n--; n>=0; n--)
  5919 +    switch (class[n])
  5920 +      {
  5921 +      case X86_64_INTEGER_CLASS:
  5922 +      case X86_64_INTEGERSI_CLASS:
  5923 +	(*int_nregs)++;
  5924 +	break;
  5925 +      case X86_64_SSE_CLASS:
  5926 +      case X86_64_SSESF_CLASS:
  5927 +      case X86_64_SSEDF_CLASS:
  5928 +	(*sse_nregs)++;
  5929 +	break;
  5930 +      case X86_64_NO_CLASS:
  5931 +      case X86_64_SSEUP_CLASS:
  5932 +	break;
  5933 +      case X86_64_X87_CLASS:
  5934 +      case X86_64_X87UP_CLASS:
  5935 +	if (!in_return)
  5936 +	  return 0;
  5937 +	break;
  5938 +      default:
  5939 +	abort ();
  5940 +      }
  5941 +  return 1;
  5942 +}
  5943 +
  5944 +/* Functions to load floats and double to an SSE register placeholder.  */
  5945 +extern void float2sse (float, __int128_t *);
  5946 +extern void double2sse (double, __int128_t *);
  5947 +extern void floatfloat2sse (void *, __int128_t *);
  5948 +
  5949 +/* Functions to put the floats and doubles back.  */
  5950 +extern float sse2float (__int128_t *);
  5951 +extern double sse2double (__int128_t *);
  5952 +extern void sse2floatfloat(__int128_t *, void *);
  5953 +
  5954 +/*@-exportheader@*/
  5955 +void
  5956 +ffi_prep_args (stackLayout *stack, extended_cif *ecif)
  5957 +/*@=exportheader@*/
  5958 +{
  5959 +  int gprcount, ssecount, i, g, s;
  5960 +  void **p_argv;
  5961 +  void *argp = &stack->argspace;
  5962 +  ffi_type **p_arg;
  5963 +
  5964 +  /* First check if the return value should be passed in memory. If so,
  5965 +     pass the pointer as the first argument.  */
  5966 +  gprcount = ssecount = 0;
  5967 +  if (ecif->cif->rtype->type != FFI_TYPE_VOID 
  5968 +      && examine_argument (ecif->cif->rtype, 1, &g, &s) == 0)
  5969 +    (void *)stack->gpr[gprcount++] = ecif->rvalue;
  5970 +
  5971 +  for (i=ecif->cif->nargs, p_arg=ecif->cif->arg_types, p_argv = ecif->avalue;
  5972 +       i!=0; i--, p_arg++, p_argv++)
  5973 +    {
  5974 +      int in_register = 0;
  5975 +
  5976 +      switch ((*p_arg)->type)
  5977 +	{
  5978 +	case FFI_TYPE_SINT8:
  5979 +	case FFI_TYPE_SINT16:
  5980 +	case FFI_TYPE_SINT32:
  5981 +	case FFI_TYPE_SINT64:
  5982 +	case FFI_TYPE_UINT8:
  5983 +	case FFI_TYPE_UINT16:
  5984 +	case FFI_TYPE_UINT32:
  5985 +	case FFI_TYPE_UINT64:
  5986 +	case FFI_TYPE_POINTER:
  5987 +	  if (gprcount < MAX_GPR_REGS)
  5988 +	    {
  5989 +	      stack->gpr[gprcount] = 0;
  5990 +	      stack->gpr[gprcount++] = *(long long *)(*p_argv);
  5991 +	      in_register = 1;
  5992 +	    }
  5993 +	  break;
  5994 +
  5995 +	case FFI_TYPE_FLOAT:
  5996 +	  if (ssecount < MAX_SSE_REGS)
  5997 +	    {
  5998 +	      float2sse (*(float *)(*p_argv), &stack->sse[ssecount++]);
  5999 +	      in_register = 1;
  6000 +	    }
  6001 +	  break;
  6002 +
  6003 +	case FFI_TYPE_DOUBLE:
  6004 +	  if (ssecount < MAX_SSE_REGS)
  6005 +	    {
  6006 +	      double2sse (*(double *)(*p_argv), &stack->sse[ssecount++]);
  6007 +	      in_register = 1;
  6008 +	    }
  6009 +	  break;
  6010 +	}
  6011 +
  6012 +      if (in_register)
  6013 +	continue;
  6014 +
  6015 +      /* Either all places in registers where filled, or this is a
  6016 +	 type that potentially goes into a memory slot.  */
  6017 +      if (examine_argument (*p_arg, 0, &g, &s) == 0
  6018 +	  || gprcount + g > MAX_GPR_REGS || ssecount + s > MAX_SSE_REGS)
  6019 +	{
  6020 +	  /* Pass this argument in memory.  */
  6021 +	  argp = (void *)ALIGN(argp, (*p_arg)->alignment);
  6022 +	  memcpy (argp, *p_argv, (*p_arg)->size);
  6023 +	  argp += (*p_arg)->size;
  6024 +	}
  6025 +      else
  6026 +	{
  6027 +	  /* All easy cases are eliminated. Now fire the big guns.  */
  6028 +
  6029 +	  enum x86_64_reg_class classes[MAX_CLASSES];
  6030 +	  int offset = 0, j, num;
  6031 +	  void *a;
  6032 +
  6033 +	  num = classify_argument (*p_arg, classes, &offset);
  6034 +	  for (j=0, a=*p_argv; j<num; j++, a+=8)
  6035 +	    {
  6036 +	      switch (classes[j])
  6037 +		{
  6038 +		case X86_64_INTEGER_CLASS:
  6039 +		case X86_64_INTEGERSI_CLASS:
  6040 +		  stack->gpr[gprcount++] = *(long long *)a;
  6041 +		  break;
  6042 +		case X86_64_SSE_CLASS:
  6043 +		  floatfloat2sse (a, &stack->sse[ssecount++]);
  6044 +		  break;
  6045 +		case X86_64_SSESF_CLASS:
  6046 +		  float2sse (*(float *)a, &stack->sse[ssecount++]);
  6047 +		  break;
  6048 +		case X86_64_SSEDF_CLASS:
  6049 +		  double2sse (*(double *)a, &stack->sse[ssecount++]);
  6050 +		  break;
  6051 +		default:
  6052 +		  abort();
  6053 +		}
  6054 +	    }
  6055 +	}
  6056 +    }
  6057 +}
  6058 +
  6059 +/* Perform machine dependent cif processing.  */
  6060 +ffi_status
  6061 +ffi_prep_cif_machdep (ffi_cif *cif)
  6062 +{
  6063 +  int gprcount, ssecount, i, g, s;
  6064 +
  6065 +  gprcount = ssecount = 0;
  6066 +
  6067 +  /* Reset the byte count. We handle this size estimation here.  */
  6068 +  cif->bytes = 0;
  6069 +
  6070 +  /* If the return value should be passed in memory, pass the pointer
  6071 +     as the first argument. The actual memory isn't allocated here.  */
  6072 +  if (cif->rtype->type != FFI_TYPE_VOID 
  6073 +      && examine_argument (cif->rtype, 1, &g, &s) == 0)
  6074 +    gprcount = 1;
  6075 +
  6076 +  /* Go over all arguments and determine the way they should be passed.
  6077 +     If it's in a register and there is space for it, let that be so. If
  6078 +     not, add it's size to the stack byte count.  */
  6079 +  for (i=0; i<cif->nargs; i++)
  6080 +    {
  6081 +      if (examine_argument (cif->arg_types[i], 0, &g, &s) == 0
  6082 +	  || gprcount + g > MAX_GPR_REGS || ssecount + s > MAX_SSE_REGS)
  6083 +	{
  6084 +	  /* This is passed in memory. First align to the basic type.  */
  6085 +	  cif->bytes = ALIGN(cif->bytes, cif->arg_types[i]->alignment);
  6086 +
  6087 +	  /* Stack arguments are *always* at least 8 byte aligned.  */
  6088 +	  cif->bytes = ALIGN(cif->bytes, 8);
  6089 +
  6090 +	  /* Now add the size of this argument.  */
  6091 +	  cif->bytes += cif->arg_types[i]->size;
  6092 +	}
  6093 +      else
  6094 +	{
  6095 +	  gprcount += g;
  6096 +	  ssecount += s;
  6097 +	}
  6098 +    }
  6099 +
  6100 +  /* Set the flag for the closures return.  */
  6101 +    switch (cif->rtype->type)
  6102 +    {
  6103 +    case FFI_TYPE_VOID:
  6104 +    case FFI_TYPE_STRUCT:
  6105 +    case FFI_TYPE_SINT64:
  6106 +    case FFI_TYPE_FLOAT:
  6107 +    case FFI_TYPE_DOUBLE:
  6108 +    case FFI_TYPE_LONGDOUBLE:
  6109 +      cif->flags = (unsigned) cif->rtype->type;
  6110 +      break;
  6111 +
  6112 +    case FFI_TYPE_UINT64:
  6113 +      cif->flags = FFI_TYPE_SINT64;
  6114 +      break;
  6115 +
  6116 +    default:
  6117 +      cif->flags = FFI_TYPE_INT;
  6118 +      break;
  6119 +    }
  6120 +
  6121 +  return FFI_OK;
  6122 +}
  6123 +
  6124 +typedef struct
  6125 +{
  6126 +  long gpr[2];
  6127 +  __int128_t sse[2];
  6128 +  long double st0;
  6129 +} return_value;
  6130 +
  6131 +void
  6132 +ffi_fill_return_value (return_value *rv, extended_cif *ecif)
  6133 +{
  6134 +  enum x86_64_reg_class classes[MAX_CLASSES];
  6135 +  int i = 0, num;
  6136 +  long *gpr = rv->gpr;
  6137 +  __int128_t *sse = rv->sse;
  6138 +  signed char sc;
  6139 +  signed short ss;
  6140 +
  6141 +  /* This is needed because of the way x86-64 handles signed short
  6142 +     integers.  */
  6143 +  switch (ecif->cif->rtype->type)
  6144 +    {
  6145 +    case FFI_TYPE_SINT8:
  6146 +      sc = *(signed char *)gpr;
  6147 +      *(long long *)ecif->rvalue = (long long)sc;
  6148 +      return;
  6149 +    case FFI_TYPE_SINT16:
  6150 +      ss = *(signed short *)gpr;
  6151 +      *(long long *)ecif->rvalue = (long long)ss;
  6152 +      return;
  6153 +    default:
  6154 +      /* Just continue.  */
  6155 +      ;
  6156 +    }
  6157 +
  6158 +  num = classify_argument (ecif->cif->rtype, classes, &i);
  6159 +
  6160 +  if (num == 0)
  6161 +    /* Return in memory.  */
  6162 +    ecif->rvalue = (void *) rv->gpr[0];
  6163 +  else if (num == 2 && classes[0] == X86_64_X87_CLASS &&
  6164 +	classes[1] == X86_64_X87UP_CLASS)
  6165 +    /* This is a long double (this is easiest to handle this way instead
  6166 +       of an eightbyte at a time as in the loop below.  */
  6167 +    *((long double *)ecif->rvalue) = rv->st0;
  6168 +  else
  6169 +    {
  6170 +      void *a;
  6171 +
  6172 +      for (i=0, a=ecif->rvalue; i<num; i++, a+=8)
  6173 +	{
  6174 +	  switch (classes[i])
  6175 +	    {
  6176 +	    case X86_64_INTEGER_CLASS:
  6177 +	    case X86_64_INTEGERSI_CLASS:
  6178 +	      *(long long *)a = *gpr;
  6179 +	      gpr++;
  6180 +	      break;
  6181 +	    case X86_64_SSE_CLASS:
  6182 +	      sse2floatfloat (sse++, a);
  6183 +	      break;
  6184 +	    case X86_64_SSESF_CLASS:
  6185 +	      *(float *)a = sse2float (sse++);
  6186 +	      break;
  6187 +	    case X86_64_SSEDF_CLASS:
  6188 +	      *(double *)a = sse2double (sse++);
  6189 +	      break;
  6190 +	    default:
  6191 +	      abort();
  6192 +	    }
  6193 +	}
  6194 +    }
  6195 +}
  6196 +
  6197 +/*@-declundef@*/
  6198 +/*@-exportheader@*/
  6199 +extern void ffi_call_UNIX64(void (*)(stackLayout *, extended_cif *),
  6200 +			    void (*) (return_value *, extended_cif *),
  6201 +			    /*@out@*/ extended_cif *, 
  6202 +			    unsigned, /*@out@*/ unsigned *, void (*fn)());
  6203 +/*@=declundef@*/
  6204 +/*@=exportheader@*/
  6205 +
  6206 +void ffi_call(/*@dependent@*/ ffi_cif *cif, 
  6207 +	      void (*fn)(), 
  6208 +	      /*@out@*/ void *rvalue, 
  6209 +	      /*@dependent@*/ void **avalue)
  6210 +{
  6211 +  extended_cif ecif;
  6212 +  int dummy;
  6213 +
  6214 +  ecif.cif = cif;
  6215 +  ecif.avalue = avalue;
  6216 +  
  6217 +  /* If the return value is a struct and we don't have a return	*/
  6218 +  /* value address then we need to make one		        */
  6219 +
  6220 +  if ((rvalue == NULL) && 
  6221 +      (examine_argument (cif->rtype, 1, &dummy, &dummy) == 0))
  6222 +    {
  6223 +      /*@-sysunrecog@*/
  6224 +      ecif.rvalue = alloca(cif->rtype->size);
  6225 +      /*@=sysunrecog@*/
  6226 +    }
  6227 +  else
  6228 +    ecif.rvalue = rvalue;
  6229 +    
  6230 +  /* Stack must always be 16byte aligned. Make it so.  */
  6231 +  cif->bytes = ALIGN(cif->bytes, 16);
  6232 +  
  6233 +  switch (cif->abi) 
  6234 +    {
  6235 +    case FFI_SYSV:
  6236 +      /* Calling 32bit code from 64bit is not possible  */
  6237 +      FFI_ASSERT(0);
  6238 +      break;
  6239 +
  6240 +    case FFI_UNIX64:
  6241 +      /*@-usedef@*/
  6242 +      ffi_call_UNIX64 (ffi_prep_args, ffi_fill_return_value, &ecif,
  6243 +		       cif->bytes, ecif.rvalue, fn);
  6244 +      /*@=usedef@*/
  6245 +      break;
  6246 +
  6247 +    default:
  6248 +      FFI_ASSERT(0);
  6249 +      break;
  6250 +    }
  6251 +}
  6252 +
  6253 +extern void ffi_closure_UNIX64(void);
  6254 +
  6255 +ffi_status
  6256 +ffi_prep_closure (ffi_closure* closure,
  6257 +		  ffi_cif* cif,
  6258 +		  void (*fun)(ffi_cif*, void*, void**, void*),
  6259 +		  void *user_data)
  6260 +{
  6261 +  volatile unsigned short *tramp;
  6262 +
  6263 +  /* FFI_ASSERT (cif->abi == FFI_OSF);  */
  6264 +
  6265 +  tramp = (volatile unsigned short *) &closure->tramp[0];
  6266 +  tramp[0] = 0xbb49;		/* mov <code>, %r11	*/
  6267 +  tramp[5] = 0xba49;		/* mov <data>, %r10	*/
  6268 +  tramp[10] = 0xff49;		/* jmp *%r11	*/
  6269 +  tramp[11] = 0x00e3;
  6270 +  *(void * volatile *) &tramp[1] = ffi_closure_UNIX64;
  6271 +  *(void * volatile *) &tramp[6] = closure;
  6272 +
  6273 +  closure->cif = cif;
  6274 +  closure->fun = fun;
  6275 +  closure->user_data = user_data;
  6276 +
  6277 +  return FFI_OK;
  6278 +}
  6279 +
  6280 +int
  6281 +ffi_closure_UNIX64_inner(ffi_closure *closure, va_list l, void *rp)
  6282 +{
  6283 +  ffi_cif *cif;
  6284 +  void **avalue;
  6285 +  ffi_type **arg_types;
  6286 +  long i, avn, argn;
  6287 +
  6288 +  cif = closure->cif;
  6289 +  avalue = alloca(cif->nargs * sizeof(void *));
  6290 +
  6291 +  argn = 0;
  6292 +
  6293 +  i = 0;
  6294 +  avn = cif->nargs;
  6295 +  arg_types = cif->arg_types;
  6296 +  
  6297 +  /* Grab the addresses of the arguments from the stack frame.  */
  6298 +  while (i < avn)
  6299 +    {
  6300 +      switch (arg_types[i]->type)
  6301 +	{
  6302 +	case FFI_TYPE_SINT8:
  6303 +	case FFI_TYPE_UINT8:
  6304 +	case FFI_TYPE_SINT16:
  6305 +	case FFI_TYPE_UINT16:
  6306 +	case FFI_TYPE_SINT32:
  6307 +	case FFI_TYPE_UINT32:
  6308 +	case FFI_TYPE_SINT64:
  6309 +	case FFI_TYPE_UINT64:
  6310 +	case FFI_TYPE_POINTER:
  6311 +	  {
  6312 +	    if (l->gp_offset > 48-8)
  6313 +	      {
  6314 +		avalue[i] = l->overflow_arg_area;
  6315 +		l->overflow_arg_area = (char *)l->overflow_arg_area + 8;
  6316 +	      }
  6317 +	    else
  6318 +	      {
  6319 +		avalue[i] = (char *)l->reg_save_area + l->gp_offset;
  6320 +		l->gp_offset += 8;
  6321 +	      }
  6322 +	  }
  6323 +	  break;
  6324 +
  6325 +	case FFI_TYPE_STRUCT:
  6326 +	  /* FIXME  */
  6327 +	  FFI_ASSERT(0);
  6328 +	  break;
  6329 +
  6330 +	case FFI_TYPE_DOUBLE:
  6331 +	  {
  6332 +	    if (l->fp_offset > 176-16)
  6333 +	      {
  6334 +		avalue[i] = l->overflow_arg_area;
  6335 +		l->overflow_arg_area = (char *)l->overflow_arg_area + 8;
  6336 +	      }
  6337 +	    else
  6338 +	      {
  6339 +		avalue[i] = (char *)l->reg_save_area + l->fp_offset;
  6340 +		l->fp_offset += 16;
  6341 +	      }
  6342 +	  }
  6343 +#if DEBUG_FFI
  6344 +	  fprintf (stderr, "double arg %d = %g\n", i, *(double *)avalue[i]);
  6345 +#endif
  6346 +	  break;
  6347 +	  
  6348 +	case FFI_TYPE_FLOAT:
  6349 +	  {
  6350 +	    if (l->fp_offset > 176-16)
  6351 +	      {
  6352 +		avalue[i] = l->overflow_arg_area;
  6353 +		l->overflow_arg_area = (char *)l->overflow_arg_area + 8;
  6354 +	      }
  6355 +	    else
  6356 +	      {
  6357 +		avalue[i] = (char *)l->reg_save_area + l->fp_offset;
  6358 +		l->fp_offset += 16;
  6359 +	      }
  6360 +	  }
  6361 +#if DEBUG_FFI
  6362 +	  fprintf (stderr, "float arg %d = %g\n", i, *(float *)avalue[i]);
  6363 +#endif
  6364 +	  break;
  6365 +	  
  6366 +	default:
  6367 +	  FFI_ASSERT(0);
  6368 +	}
  6369 +
  6370 +      argn += ALIGN(arg_types[i]->size, SIZEOF_ARG) / SIZEOF_ARG;
  6371 +      i++;
  6372 +    }
  6373 +
  6374 +  /* Invoke the closure.  */
  6375 +  (closure->fun) (cif, rp, avalue, closure->user_data);
  6376 +
  6377 +  /* FIXME: Structs not supported.  */
  6378 +  FFI_ASSERT(cif->rtype->type != FFI_TYPE_STRUCT);
  6379 +
  6380 +  /* Tell ffi_closure_UNIX64 how to perform return type promotions.  */
  6381 +
  6382 +  return cif->rtype->type;
  6383 +}
  6384 +#endif /* ifndef __x86_64__ */
  6385 diff -ruN --exclude=CVS gcc-3.2.2.orig/libffi/src/x86/sysv.S gcc/libffi/src/x86/sysv.S
  6386 --- gcc-3.2.2.orig/libffi/src/x86/sysv.S	Tue Jul 17 02:10:53 2001
  6387 +++ gcc/libffi/src/x86/sysv.S	Fri Jul 19 08:08:31 2002
  6388 @@ -1,5 +1,5 @@
  6389  /* -----------------------------------------------------------------------
  6390 -   sysv.S - Copyright (c) 1996, 1998, 2001  Cygnus Solutions
  6391 +   sysv.S - Copyright (c) 1996, 1998, 2001, 2002  Cygnus Solutions
  6392     
  6393     X86 Foreign Function Interface 
  6394  
  6395 @@ -23,6 +23,8 @@
  6396     OTHER DEALINGS IN THE SOFTWARE.
  6397     ----------------------------------------------------------------------- */
  6398  
  6399 +#ifndef __x86_64__
  6400 +
  6401  #define LIBFFI_ASM	
  6402  #include <ffi.h>
  6403  
  6404 @@ -163,3 +165,5 @@
  6405  	.align 4
  6406  .LEFDE1:
  6407  	.set	.LLFDE1,.LEFDE1-.LSFDE1
  6408 +
  6409 +#endif /* ifndef __x86_64__ */
  6410 diff -ruN --exclude=CVS gcc-3.2.2.orig/libffi/src/x86/unix64.S gcc/libffi/src/x86/unix64.S
  6411 --- gcc-3.2.2.orig/libffi/src/x86/unix64.S	Thu Jan  1 09:00:00 1970
  6412 +++ gcc/libffi/src/x86/unix64.S	Wed Jan 29 00:54:28 2003
  6413 @@ -0,0 +1,302 @@
  6414 +/* -----------------------------------------------------------------------
  6415 +   unix64.S - Copyright (c) 2002  Bo Thorsen <bo@suse.de>
  6416 +
  6417 +   x86-64 Foreign Function Interface 
  6418 +
  6419 +   Permission is hereby granted, free of charge, to any person obtaining
  6420 +   a copy of this software and associated documentation files (the
  6421 +   ``Software''), to deal in the Software without restriction, including
  6422 +   without limitation the rights to use, copy, modify, merge, publish,
  6423 +   distribute, sublicense, and/or sell copies of the Software, and to
  6424 +   permit persons to whom the Software is furnished to do so, subject to
  6425 +   the following conditions:
  6426 +
  6427 +   The above copyright notice and this permission notice shall be included
  6428 +   in all copies or substantial portions of the Software.
  6429 +
  6430 +   THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
  6431 +   OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  6432 +   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  6433 +   IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
  6434 +   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  6435 +   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  6436 +   OTHER DEALINGS IN THE SOFTWARE.
  6437 +   ----------------------------------------------------------------------- */
  6438 +
  6439 +#ifdef __x86_64__
  6440 +#define LIBFFI_ASM	
  6441 +#include <ffi.h>
  6442 +
  6443 +	.section	.rodata
  6444 +.LC0:
  6445 +	.string	"asm in progress %lld\n"
  6446 +.LC1:
  6447 +	.string	"asm in progress\n"
  6448 +.text
  6449 +	.align	2
  6450 +.globl ffi_call_UNIX64
  6451 +        .type	ffi_call_UNIX64,@function
  6452 +
  6453 +ffi_call_UNIX64:
  6454 +.LFB1:
  6455 +        pushq	%rbp
  6456 +.LCFI0:
  6457 +        movq	%rsp, %rbp
  6458 +.LCFI1:
  6459 +	/* Save all arguments */
  6460 +	subq	$48, %rsp
  6461 +.LCFI2:
  6462 +	movq	%rdi, -8(%rbp)		/* ffi_prep_args	 */
  6463 +	movq	%rsi, -16(%rbp)		/* ffi_fill_return_value */
  6464 +	movq	%rdx, -24(%rbp)		/* ecif			 */
  6465 +	movq	%rcx, -32(%rbp)		/* cif->bytes		 */
  6466 +	movq	%r8, -40(%rbp)		/* ecif.rvalue		 */
  6467 +	movq	%r9, -48(%rbp)		/* fn			 */
  6468 +
  6469 +	/* Make room for all of the new args and the register args */
  6470 +	addl	$176, %ecx
  6471 +.LCFI3:
  6472 +	subq	%rcx, %rsp
  6473 +.LCFI4:
  6474 +	/* Setup the call to ffi_prep_args.  */
  6475 +	movq	%rdi, %rax		/* &ffi_prep_args	*/
  6476 +	movq	%rsp, %rdi		/* stackLayout		*/
  6477 +	movq	%rdx, %rsi		/* ecif			*/
  6478 +	call	*%rax			/* ffi_prep_args(stackLayout, ecif);*/ 
  6479 +
  6480 +	/* ffi_prep_args have put all the register contents into the  */
  6481 +	/* stackLayout struct. Now put the register values in place.  */
  6482 +	movq	(%rsp), %rdi
  6483 +	movq	8(%rsp), %rsi
  6484 +	movq	16(%rsp), %rdx
  6485 +	movq	24(%rsp), %rcx
  6486 +	movq	32(%rsp), %r8
  6487 +	movq	40(%rsp), %r9
  6488 +	movaps	48(%rsp), %xmm0
  6489 +	movaps	64(%rsp), %xmm1
  6490 +	movaps	80(%rsp), %xmm2
  6491 +	movaps	96(%rsp), %xmm3
  6492 +	movaps	112(%rsp), %xmm4
  6493 +	movaps	128(%rsp), %xmm5
  6494 +	movaps	144(%rsp), %xmm6
  6495 +	movaps	160(%rsp), %xmm7
  6496 +
  6497 +	/* Remove space for stackLayout so stack arguments are placed
  6498 +	   correctly for the call.  */
  6499 +.LCFI5:
  6500 +	addq	$176, %rsp
  6501 +.LCFI6:
  6502 +	/* Call the user function.  */
  6503 +	call	*-48(%rbp)
  6504 +
  6505 +	/* Make stack space for the return_value struct.  */
  6506 +	subq	$64, %rsp
  6507 +
  6508 +	/* Fill in all potential return values to this struct.  */
  6509 +	movq	%rax, (%rsp)
  6510 +	movq	%rdx, 8(%rsp)
  6511 +	movaps	%xmm0, 16(%rsp)
  6512 +	movaps	%xmm1, 32(%rsp)
  6513 +	fstpt	48(%rsp)
  6514 +
  6515 +	/* Now call ffi_fill_return_value.  */
  6516 +	movq	%rsp, %rdi		/* struct return_value	  */
  6517 +	movq	-24(%rbp), %rsi		/* ecif			  */
  6518 +	movq	-16(%rbp), %rax		/* &ffi_fill_return_value */
  6519 +	call	*%rax			/* call it		  */
  6520 +
  6521 +	/* And the work is done.  */
  6522 +        leave
  6523 +        ret
  6524 +.LFE1:
  6525 +.ffi_call_UNIX64_end:
  6526 +        .size    ffi_call_UNIX64,.ffi_call_UNIX64_end-ffi_call_UNIX64
  6527 +
  6528 +.text
  6529 +	.align	2
  6530 +.globl float2sse
  6531 +        .type	float2sse,@function
  6532 +float2sse:
  6533 +	/* Save the contents of this sse-float in a pointer.  */
  6534 +	movaps	%xmm0, (%rdi)
  6535 +	ret
  6536 +
  6537 +	.align	2
  6538 +.globl floatfloat2sse
  6539 +        .type	floatfloat2sse,@function
  6540 +floatfloat2sse:
  6541 +	/* Save the contents of these two sse-floats in a pointer.  */
  6542 +	movq	(%rdi), %xmm0
  6543 +	movaps	%xmm0, (%rsi)
  6544 +	ret
  6545 +
  6546 +	.align	2
  6547 +.globl double2sse
  6548 +        .type	double2sse,@function
  6549 +double2sse:
  6550 +	/* Save the contents of this sse-double in a pointer.  */
  6551 +	movaps	%xmm0, (%rdi)
  6552 +	ret
  6553 +
  6554 +	.align	2
  6555 +.globl sse2float
  6556 +        .type	sse2float,@function
  6557 +sse2float:
  6558 +	/* Save the contents of this sse-float in a pointer.  */
  6559 +	movaps	(%rdi), %xmm0
  6560 +	ret
  6561 +
  6562 +	.align	2
  6563 +.globl sse2double
  6564 +        .type	sse2double,@function
  6565 +sse2double:
  6566 +	/* Save the contents of this pointer in a sse-double.  */
  6567 +	movaps	(%rdi), %xmm0
  6568 +	ret
  6569 +
  6570 +	.align	2
  6571 +.globl sse2floatfloat
  6572 +        .type	sse2floatfloat,@function
  6573 +sse2floatfloat:
  6574 +	/* Save the contents of this pointer in two sse-floats.  */
  6575 +	movaps	(%rdi), %xmm0
  6576 +	movq	%xmm0, (%rsi)
  6577 +	ret
  6578 +
  6579 +	.align	2
  6580 +.globl ffi_closure_UNIX64
  6581 +        .type	ffi_closure_UNIX64,@function
  6582 +
  6583 +ffi_closure_UNIX64:
  6584 +.LFB2:
  6585 +        pushq   %rbp
  6586 +.LCFI10:
  6587 +        movq    %rsp, %rbp
  6588 +.LCFI11:
  6589 +        subq    $240, %rsp
  6590 +.LCFI12:
  6591 +	movq	%rdi, -176(%rbp)
  6592 +        movq    %rsi, -168(%rbp)
  6593 +        movq    %rdx, -160(%rbp)
  6594 +        movq    %rcx, -152(%rbp)
  6595 +        movq    %r8, -144(%rbp)
  6596 +        movq    %r9, -136(%rbp)
  6597 +        /* FIXME: We can avoid all this stashing of XMM registers by
  6598 +	   (in ffi_prep_closure) computing the number of
  6599 +	   floating-point args and moving it into %rax before calling
  6600 +	   this function.  Once this is done, uncomment the next few
  6601 +	   lines and only the essential XMM registers will be written
  6602 +	   to memory.  This is a significant saving.  */
  6603 +/*         movzbl  %al, %eax  */
  6604 +/*         movq    %rax, %rdx */
  6605 +/*         leaq    0(,%rdx,4), %rax */
  6606 +/*         leaq    2f(%rip), %rdx */
  6607 +/*         subq    %rax, %rdx */
  6608 +        leaq    -1(%rbp), %rax
  6609 +/*         jmp     *%rdx */
  6610 +        movaps  %xmm7, -15(%rax)
  6611 +        movaps  %xmm6, -31(%rax)
  6612 +        movaps  %xmm5, -47(%rax)
  6613 +        movaps  %xmm4, -63(%rax)
  6614 +        movaps  %xmm3, -79(%rax)
  6615 +        movaps  %xmm2, -95(%rax)
  6616 +        movaps  %xmm1, -111(%rax)
  6617 +        movaps  %xmm0, -127(%rax)
  6618 +2:
  6619 +        movl    %edi, -180(%rbp)
  6620 +        movl    $0, -224(%rbp)
  6621 +        movl    $48, -220(%rbp)
  6622 +        leaq    16(%rbp), %rax
  6623 +        movq    %rax, -216(%rbp)
  6624 +        leaq    -176(%rbp), %rdx
  6625 +        movq    %rdx, -208(%rbp)
  6626 +        leaq    -224(%rbp), %rsi
  6627 +	movq	%r10, %rdi
  6628 +	movq	%rsp, %rdx
  6629 +        call    ffi_closure_UNIX64_inner@PLT
  6630 +
  6631 +	cmpl	$FFI_TYPE_FLOAT, %eax
  6632 +	je	1f
  6633 +	cmpl	$FFI_TYPE_DOUBLE, %eax
  6634 +	je	2f
  6635 +	cmpl	$FFI_TYPE_LONGDOUBLE, %eax
  6636 +	je	3f
  6637 +	cmpl	$FFI_TYPE_STRUCT, %eax
  6638 +	je	4f
  6639 +	popq	%rax
  6640 +        leave
  6641 +        ret
  6642 +1:
  6643 +2:
  6644 +3:	
  6645 +	movaps	-240(%rbp), %xmm0
  6646 +        leave
  6647 +        ret
  6648 +4:
  6649 +	leave
  6650 +	ret
  6651 +.LFE2:	
  6652 +		
  6653 +        .section        .eh_frame,"a",@progbits
  6654 +.Lframe0:
  6655 +        .long   .LECIE1-.LSCIE1
  6656 +.LSCIE1:
  6657 +        .long   0x0
  6658 +        .byte   0x1
  6659 +        .string "zR"
  6660 +        .uleb128 0x1
  6661 +        .sleb128 -8
  6662 +        .byte   0x10
  6663 +        .uleb128 0x1
  6664 +        .byte   0x1b
  6665 +        .byte   0xc
  6666 +        .uleb128 0x7
  6667 +        .uleb128 0x8
  6668 +        .byte   0x90
  6669 +        .uleb128 0x1
  6670 +        .align 8
  6671 +.LECIE1:
  6672 +.LSFDE1:
  6673 +	.long	.LEFDE1-.LASFDE1
  6674 +.LASFDE1:
  6675 +        .long   .LASFDE1-.Lframe0
  6676 +
  6677 +        .long   .LFB1-.
  6678 +        .long   .LFE1-.LFB1
  6679 +        .uleb128 0x0
  6680 +        .byte   0x4		# DW_CFA_advance_loc4
  6681 +        .long   .LCFI0-.LFB1
  6682 +        .byte   0xe		# DW_CFA_def_cfa_offset
  6683 +        .uleb128 0x10
  6684 +        .byte   0x86		# DW_CFA_offset: r6 at cfa-16
  6685 +        .uleb128 0x2
  6686 +        .byte   0x4		# DW_CFA_advance_loc4
  6687 +        .long   .LCFI1-.LCFI0
  6688 +        .byte   0x86		# DW_CFA_offset: r6 at cfa-16
  6689 +        .uleb128 0x2
  6690 +        .byte   0xd		# DW_CFA_def_cfa_reg: r6
  6691 +        .uleb128 0x6
  6692 +	.align 8
  6693 +.LEFDE1:
  6694 +.LSFDE3:
  6695 +        .long   .LEFDE3-.LASFDE3        # FDE Length
  6696 +.LASFDE3:
  6697 +        .long   .LASFDE3-.Lframe0       # FDE CIE offset
  6698 +
  6699 +        .long   .LFB2-. # FDE initial location
  6700 +        .long   .LFE2-.LFB2     # FDE address range
  6701 +        .uleb128 0x0    # Augmentation size
  6702 +        .byte   0x4     # DW_CFA_advance_loc4
  6703 +        .long   .LCFI10-.LFB2
  6704 +        .byte   0xe     # DW_CFA_def_cfa_offset
  6705 +        .uleb128 0x10
  6706 +        .byte   0x86    # DW_CFA_offset, column 0x6
  6707 +        .uleb128 0x2
  6708 +        .byte   0x4     # DW_CFA_advance_loc4
  6709 +        .long   .LCFI11-.LCFI10
  6710 +        .byte   0xd     # DW_CFA_def_cfa_register
  6711 +        .uleb128 0x6
  6712 +        .align 8
  6713 +.LEFDE3:
  6714 +
  6715 +#endif /* __x86_64__  */
  6716 diff -ruN --exclude=CVS gcc-3.2.2.orig/libffi/src/x86/win32.S gcc/libffi/src/x86/win32.S
  6717 --- gcc-3.2.2.orig/libffi/src/x86/win32.S	Tue Mar 27 11:39:16 2001
  6718 +++ gcc/libffi/src/x86/win32.S	Fri Dec  6 10:16:45 2002
  6719 @@ -1,5 +1,8 @@
  6720  /* -----------------------------------------------------------------------
  6721 -   win32.S - Copyright (c) 1996, 1998, 2001  Cygnus Solutions
  6722 +   win32.S - Copyright (c) 1996, 1998, 2001, 2002  Red Hat, Inc.
  6723 +	     Copyright (c) 2001  John Beniton
  6724 +	     Copyright (c) 2002  Ranjit Mathew
  6725 +			
  6726   
  6727     X86 Foreign Function Interface
  6728   
  6729 @@ -52,7 +55,10 @@
  6730          # Return stack to previous state and call the function
  6731          addl  $8,%esp
  6732   
  6733 -        call  *28(%ebp)
  6734 +        # FIXME: Align the stack to a 128-bit boundary to avoid
  6735 +        # potential performance hits.
  6736 +
  6737 +	call  *28(%ebp)
  6738   
  6739          # Remove the space we pushed for the args
  6740          movl  16(%ebp),%ecx
  6741 @@ -123,3 +129,98 @@
  6742          ret
  6743   
  6744  .ffi_call_SYSV_end:
  6745 +
  6746 +        # This assumes we are using gas.
  6747 +        .balign 16
  6748 +.globl _ffi_call_STDCALL
  6749 +
  6750 +_ffi_call_STDCALL:
  6751 +        pushl %ebp
  6752 +        movl  %esp,%ebp
  6753 +
  6754 +        # Make room for all of the new args.
  6755 +        movl  16(%ebp),%ecx 
  6756 +        subl  %ecx,%esp
  6757 +
  6758 +        movl  %esp,%eax
  6759 +
  6760 +        # Place all of the ffi_prep_args in position
  6761 +        pushl 12(%ebp)
  6762 +        pushl %eax
  6763 +        call  *8(%ebp)
  6764 +
  6765 +        # Return stack to previous state and call the function
  6766 +        addl  $8,%esp
  6767 +
  6768 +        # FIXME: Align the stack to a 128-bit boundary to avoid
  6769 +        # potential performance hits.
  6770 +
  6771 +        call  *28(%ebp)
  6772 +
  6773 +        # stdcall functions pop arguments off the stack themselves
  6774 +
  6775 +        # Load %ecx with the return type code
  6776 +        movl  20(%ebp),%ecx
  6777 +
  6778 +        # If the return value pointer is NULL, assume no return value.
  6779 +        cmpl  $0,24(%ebp)
  6780 +        jne   sc_retint
  6781 +
  6782 +        # Even if there is no space for the return value, we are
  6783 +        # obliged to handle floating-point values.
  6784 +        cmpl  $FFI_TYPE_FLOAT,%ecx
  6785 +        jne   sc_noretval
  6786 +        fstp  %st(0)
  6787 +
  6788 +        jmp   sc_epilogue
  6789 +
  6790 +sc_retint:
  6791 +        cmpl  $FFI_TYPE_INT,%ecx
  6792 +        jne   sc_retfloat
  6793 +        # Load %ecx with the pointer to storage for the return value
  6794 +        movl  24(%ebp),%ecx
  6795 +        movl  %eax,0(%ecx)
  6796 +        jmp   sc_epilogue
  6797 +
  6798 +sc_retfloat:
  6799 +        cmpl  $FFI_TYPE_FLOAT,%ecx
  6800 +        jne   sc_retdouble
  6801 +         # Load %ecx with the pointer to storage for the return value
  6802 +        movl  24(%ebp),%ecx
  6803 +        fstps (%ecx)
  6804 +        jmp   sc_epilogue
  6805 +
  6806 +sc_retdouble:
  6807 +        cmpl  $FFI_TYPE_DOUBLE,%ecx
  6808 +        jne   sc_retlongdouble
  6809 +        # Load %ecx with the pointer to storage for the return value
  6810 +        movl  24(%ebp),%ecx
  6811 +        fstpl (%ecx)
  6812 +        jmp   sc_epilogue
  6813 +
  6814 +sc_retlongdouble:
  6815 +        cmpl  $FFI_TYPE_LONGDOUBLE,%ecx
  6816 +        jne   sc_retint64
  6817 +        # Load %ecx with the pointer to storage for the return value
  6818 +        movl  24(%ebp),%ecx
  6819 +        fstpt (%ecx)
  6820 +        jmp   sc_epilogue
  6821 +
  6822 +sc_retint64:
  6823 +        cmpl  $FFI_TYPE_SINT64,%ecx
  6824 +        jne   sc_retstruct
  6825 +        # Load %ecx with the pointer to storage for the return value
  6826 +        movl  24(%ebp),%ecx
  6827 +        movl  %eax,0(%ecx)
  6828 +        movl  %edx,4(%ecx)
  6829 +
  6830 +sc_retstruct:
  6831 +        # Nothing to do!
  6832 +
  6833 +sc_noretval:
  6834 +sc_epilogue:
  6835 +        movl %ebp,%esp
  6836 +        popl %ebp
  6837 +        ret
  6838 +
  6839 +.ffi_call_STDCALL_end:
  6840 --- gcc-3.2.2.orig/libjava/configure.host	Mon Jun 10 13:15:26 2002
  6841 +++ gcc-3.2.2/libjava/configure.host	Sat Feb 15 19:57:25 2003
  6842 @@ -115,6 +115,12 @@
  6843  	enable_getenv_properties_default=no
  6844  	enable_main_args_default=no
  6845  	;;
  6846 +  sh-* | sh[34]*-*)
  6847 +	sysdeps_dir=sh
  6848 +	libgcj_flags="${libgcj_flags} -mieee"
  6849 +	libgcj_interpreter=yes
  6850 +	enable_hash_synchronization_default=yes
  6851 +	;;
  6852  esac
  6853  
  6854  # This case statement supports generic port properties and may refine
  6855 @@ -126,7 +132,8 @@
  6856    powerpc*-linux* | \
  6857    alpha*-linux* | \
  6858    sparc*-linux* | \
  6859 -  ia64-*)
  6860 +  ia64-* | \
  6861 +  sh-linux* | sh[34]*-linux*)
  6862    	can_unwind_signal=yes
  6863  	;;
  6864    *-*-darwin*)