From f8632815a6515a6709802ad23909585664ba1b9d Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Thu, 13 Nov 2014 12:32:35 +0100 Subject: [PATCH 1/8] powerpc: Delete patch output Clearly added by mistake. --- src/powerpc/linux64_closure.S.orig | 391 ----------------------------- 1 file changed, 391 deletions(-) delete mode 100644 src/powerpc/linux64_closure.S.orig diff --git a/src/powerpc/linux64_closure.S.orig b/src/powerpc/linux64_closure.S.orig deleted file mode 100644 index bc61b5ed..00000000 --- a/src/powerpc/linux64_closure.S.orig +++ /dev/null @@ -1,391 +0,0 @@ -/* ----------------------------------------------------------------------- - sysv.h - Copyright (c) 2003 Jakub Jelinek - Copyright (c) 2008 Red Hat, Inc. - - PowerPC64 Assembly glue. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - ``Software''), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be included - in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - DEALINGS IN THE SOFTWARE. - ----------------------------------------------------------------------- */ -#define LIBFFI_ASM -#include -#include - - .file "linux64_closure.S" - -#ifdef POWERPC64 - FFI_HIDDEN (ffi_closure_LINUX64) - .globl ffi_closure_LINUX64 -# if _CALL_ELF == 2 - .text -ffi_closure_LINUX64: - addis %r2, %r12, .TOC.-ffi_closure_LINUX64@ha - addi %r2, %r2, .TOC.-ffi_closure_LINUX64@l - .localentry ffi_closure_LINUX64, . - ffi_closure_LINUX64 -# else - .section ".opd","aw" - .align 3 -ffi_closure_LINUX64: -# ifdef _CALL_LINUX - .quad .L.ffi_closure_LINUX64,.TOC.@tocbase,0 - .type ffi_closure_LINUX64,@function - .text -.L.ffi_closure_LINUX64: -# else - FFI_HIDDEN (.ffi_closure_LINUX64) - .globl .ffi_closure_LINUX64 - .quad .ffi_closure_LINUX64,.TOC.@tocbase,0 - .size ffi_closure_LINUX64,24 - .type .ffi_closure_LINUX64,@function - .text -.ffi_closure_LINUX64: -# endif -# endif - -# if _CALL_ELF == 2 -# 32 byte special reg save area + 64 byte parm save area -# + 64 byte retval area + 13*8 fpr save area + round to 16 -# define STACKFRAME 272 -# define PARMSAVE 32 -# define RETVAL PARMSAVE+64 -# else -# 48 bytes special reg save area + 64 bytes parm save area -# + 16 bytes retval area + 13*8 bytes fpr save area + round to 16 -# define STACKFRAME 240 -# define PARMSAVE 48 -# define RETVAL PARMSAVE+64 -# endif - -.LFB1: -# if _CALL_ELF == 2 - ld %r12, FFI_TRAMPOLINE_SIZE(%r11) # closure->cif - mflr %r0 - lwz %r12, 28(%r12) # cif->flags - mtcrf 0x40, %r12 - addi %r12, %r1, PARMSAVE - bt 7, .Lparmsave - # Our caller has not allocated a parameter save area. - # We need to allocate one here and use it to pass gprs to - # ffi_closure_helper_LINUX64. - addi %r12, %r1, -STACKFRAME+PARMSAVE -.Lparmsave: - std %r0, 16(%r1) - # Save general regs into parm save area - std %r3, 0(%r12) - std %r4, 8(%r12) - std %r5, 16(%r12) - std %r6, 24(%r12) - std %r7, 32(%r12) - std %r8, 40(%r12) - std %r9, 48(%r12) - std %r10, 56(%r12) - - # load up the pointer to the parm save area - mr %r5, %r12 -# else - # copy r2 to r11 and load TOC into r2 - mr %r11, %r2 - ld %r2, 16(%r11) - - mflr %r0 - # Save general regs into parm save area - # This is the parameter save area set up by our caller. - std %r3, PARMSAVE+0(%r1) - std %r4, PARMSAVE+8(%r1) - std %r5, PARMSAVE+16(%r1) - std %r6, PARMSAVE+24(%r1) - std %r7, PARMSAVE+32(%r1) - std %r8, PARMSAVE+40(%r1) - std %r9, PARMSAVE+48(%r1) - std %r10, PARMSAVE+56(%r1) - - std %r0, 16(%r1) - - # load up the pointer to the parm save area - addi %r5, %r1, PARMSAVE -# endif - - # next save fpr 1 to fpr 13 - stfd %f1, -104+(0*8)(%r1) - stfd %f2, -104+(1*8)(%r1) - stfd %f3, -104+(2*8)(%r1) - stfd %f4, -104+(3*8)(%r1) - stfd %f5, -104+(4*8)(%r1) - stfd %f6, -104+(5*8)(%r1) - stfd %f7, -104+(6*8)(%r1) - stfd %f8, -104+(7*8)(%r1) - stfd %f9, -104+(8*8)(%r1) - stfd %f10, -104+(9*8)(%r1) - stfd %f11, -104+(10*8)(%r1) - stfd %f12, -104+(11*8)(%r1) - stfd %f13, -104+(12*8)(%r1) - - # load up the pointer to the saved fpr registers */ - addi %r6, %r1, -104 - - # load up the pointer to the result storage - addi %r4, %r1, -STACKFRAME+RETVAL - - stdu %r1, -STACKFRAME(%r1) -.LCFI0: - - # get the context pointer from the trampoline - mr %r3, %r11 - - # make the call -# if defined _CALL_LINUX || _CALL_ELF == 2 - bl ffi_closure_helper_LINUX64 -# else - bl .ffi_closure_helper_LINUX64 -# endif -.Lret: - - # now r3 contains the return type - # so use it to look up in a table - # so we know how to deal with each type - - # look up the proper starting point in table - # by using return type as offset - ld %r0, STACKFRAME+16(%r1) - cmpldi %r3, FFI_V2_TYPE_SMALL_STRUCT - bge .Lsmall - mflr %r4 # move address of .Lret to r4 - sldi %r3, %r3, 4 # now multiply return type by 16 - addi %r4, %r4, .Lret_type0 - .Lret - add %r3, %r3, %r4 # add contents of table to table address - mtctr %r3 - bctr # jump to it - -# Each of the ret_typeX code fragments has to be exactly 16 bytes long -# (4 instructions). For cache effectiveness we align to a 16 byte boundary -# first. - .align 4 - -.Lret_type0: -# case FFI_TYPE_VOID - mtlr %r0 - addi %r1, %r1, STACKFRAME - blr - nop -# case FFI_TYPE_INT -# ifdef __LITTLE_ENDIAN__ - lwa %r3, RETVAL+0(%r1) -# else - lwa %r3, RETVAL+4(%r1) -# endif - mtlr %r0 - addi %r1, %r1, STACKFRAME - blr -# case FFI_TYPE_FLOAT - lfs %f1, RETVAL+0(%r1) - mtlr %r0 - addi %r1, %r1, STACKFRAME - blr -# case FFI_TYPE_DOUBLE - lfd %f1, RETVAL+0(%r1) - mtlr %r0 - addi %r1, %r1, STACKFRAME - blr -# case FFI_TYPE_LONGDOUBLE - lfd %f1, RETVAL+0(%r1) - mtlr %r0 - lfd %f2, RETVAL+8(%r1) - b .Lfinish -# case FFI_TYPE_UINT8 -# ifdef __LITTLE_ENDIAN__ - lbz %r3, RETVAL+0(%r1) -# else - lbz %r3, RETVAL+7(%r1) -# endif - mtlr %r0 - addi %r1, %r1, STACKFRAME - blr -# case FFI_TYPE_SINT8 -# ifdef __LITTLE_ENDIAN__ - lbz %r3, RETVAL+0(%r1) -# else - lbz %r3, RETVAL+7(%r1) -# endif - extsb %r3,%r3 - mtlr %r0 - b .Lfinish -# case FFI_TYPE_UINT16 -# ifdef __LITTLE_ENDIAN__ - lhz %r3, RETVAL+0(%r1) -# else - lhz %r3, RETVAL+6(%r1) -# endif - mtlr %r0 -.Lfinish: - addi %r1, %r1, STACKFRAME - blr -# case FFI_TYPE_SINT16 -# ifdef __LITTLE_ENDIAN__ - lha %r3, RETVAL+0(%r1) -# else - lha %r3, RETVAL+6(%r1) -# endif - mtlr %r0 - addi %r1, %r1, STACKFRAME - blr -# case FFI_TYPE_UINT32 -# ifdef __LITTLE_ENDIAN__ - lwz %r3, RETVAL+0(%r1) -# else - lwz %r3, RETVAL+4(%r1) -# endif - mtlr %r0 - addi %r1, %r1, STACKFRAME - blr -# case FFI_TYPE_SINT32 -# ifdef __LITTLE_ENDIAN__ - lwa %r3, RETVAL+0(%r1) -# else - lwa %r3, RETVAL+4(%r1) -# endif - mtlr %r0 - addi %r1, %r1, STACKFRAME - blr -# case FFI_TYPE_UINT64 - ld %r3, RETVAL+0(%r1) - mtlr %r0 - addi %r1, %r1, STACKFRAME - blr -# case FFI_TYPE_SINT64 - ld %r3, RETVAL+0(%r1) - mtlr %r0 - addi %r1, %r1, STACKFRAME - blr -# case FFI_TYPE_STRUCT - mtlr %r0 - addi %r1, %r1, STACKFRAME - blr - nop -# case FFI_TYPE_POINTER - ld %r3, RETVAL+0(%r1) - mtlr %r0 - addi %r1, %r1, STACKFRAME - blr -# case FFI_V2_TYPE_FLOAT_HOMOG - lfs %f1, RETVAL+0(%r1) - lfs %f2, RETVAL+4(%r1) - lfs %f3, RETVAL+8(%r1) - b .Lmorefloat -# case FFI_V2_TYPE_DOUBLE_HOMOG - lfd %f1, RETVAL+0(%r1) - lfd %f2, RETVAL+8(%r1) - lfd %f3, RETVAL+16(%r1) - lfd %f4, RETVAL+24(%r1) - mtlr %r0 - lfd %f5, RETVAL+32(%r1) - lfd %f6, RETVAL+40(%r1) - lfd %f7, RETVAL+48(%r1) - lfd %f8, RETVAL+56(%r1) - addi %r1, %r1, STACKFRAME - blr -.Lmorefloat: - lfs %f4, RETVAL+12(%r1) - mtlr %r0 - lfs %f5, RETVAL+16(%r1) - lfs %f6, RETVAL+20(%r1) - lfs %f7, RETVAL+24(%r1) - lfs %f8, RETVAL+28(%r1) - addi %r1, %r1, STACKFRAME - blr -.Lsmall: -# ifdef __LITTLE_ENDIAN__ - ld %r3,RETVAL+0(%r1) - mtlr %r0 - ld %r4,RETVAL+8(%r1) - addi %r1, %r1, STACKFRAME - blr -# else - # A struct smaller than a dword is returned in the low bits of r3 - # ie. right justified. Larger structs are passed left justified - # in r3 and r4. The return value area on the stack will have - # the structs as they are usually stored in memory. - cmpldi %r3, FFI_V2_TYPE_SMALL_STRUCT + 7 # size 8 bytes? - neg %r5, %r3 - ld %r3,RETVAL+0(%r1) - blt .Lsmalldown - mtlr %r0 - ld %r4,RETVAL+8(%r1) - addi %r1, %r1, STACKFRAME - blr -.Lsmalldown: - addi %r5, %r5, FFI_V2_TYPE_SMALL_STRUCT + 7 - mtlr %r0 - sldi %r5, %r5, 3 - addi %r1, %r1, STACKFRAME - srd %r3, %r3, %r5 - blr -# endif - -.LFE1: - .long 0 - .byte 0,12,0,1,128,0,0,0 -# if _CALL_ELF == 2 - .size ffi_closure_LINUX64,.-ffi_closure_LINUX64 -# else -# ifdef _CALL_LINUX - .size ffi_closure_LINUX64,.-.L.ffi_closure_LINUX64 -# else - .size .ffi_closure_LINUX64,.-.ffi_closure_LINUX64 -# endif -# endif - - .section .eh_frame,EH_FRAME_FLAGS,@progbits -.Lframe1: - .4byte .LECIE1-.LSCIE1 # Length of Common Information Entry -.LSCIE1: - .4byte 0x0 # CIE Identifier Tag - .byte 0x1 # CIE Version - .ascii "zR\0" # CIE Augmentation - .uleb128 0x1 # CIE Code Alignment Factor - .sleb128 -8 # CIE Data Alignment Factor - .byte 0x41 # CIE RA Column - .uleb128 0x1 # Augmentation size - .byte 0x14 # FDE Encoding (pcrel udata8) - .byte 0xc # DW_CFA_def_cfa - .uleb128 0x1 - .uleb128 0x0 - .align 3 -.LECIE1: -.LSFDE1: - .4byte .LEFDE1-.LASFDE1 # FDE Length -.LASFDE1: - .4byte .LASFDE1-.Lframe1 # FDE CIE offset - .8byte .LFB1-. # FDE initial location - .8byte .LFE1-.LFB1 # FDE address range - .uleb128 0x0 # Augmentation size - .byte 0x2 # DW_CFA_advance_loc1 - .byte .LCFI0-.LFB1 - .byte 0xe # DW_CFA_def_cfa_offset - .uleb128 STACKFRAME - .byte 0x11 # DW_CFA_offset_extended_sf - .uleb128 0x41 - .sleb128 -2 - .align 3 -.LEFDE1: - -# if defined __ELF__ && defined __linux__ - .section .note.GNU-stack,"",@progbits -# endif -#endif From 57f52484573613e2def21171184f50bd72209cac Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Thu, 13 Nov 2014 12:42:54 +0100 Subject: [PATCH 2/8] configure: Split out configure.host Split out the host case statement to a separate file, so that we don't have to regenerate configure.in for changes therein. --- configure.ac | 217 +------------------------------------------------ configure.host | 193 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 194 insertions(+), 216 deletions(-) create mode 100644 configure.host diff --git a/configure.ac b/configure.ac index 73e5605e..66e07ae3 100644 --- a/configure.ac +++ b/configure.ac @@ -72,223 +72,8 @@ AM_CONDITIONAL(TESTSUBDIR, test -d $srcdir/testsuite) TARGETDIR="unknown" HAVE_LONG_DOUBLE_VARIANT=0 -case "$host" in - aarch64*-*-*) - TARGET=AARCH64; TARGETDIR=aarch64 - ;; - alpha*-*-*) - TARGET=ALPHA; TARGETDIR=alpha; - # Support 128-bit long double, changeable via command-line switch. - HAVE_LONG_DOUBLE='defined(__LONG_DOUBLE_128__)' - ;; - - arc*-*-*) - TARGET=ARC; TARGETDIR=arc - ;; - - arm*-*-*) - TARGET=ARM; TARGETDIR=arm - ;; - - amd64-*-freebsd* | amd64-*-openbsd*) - TARGET=X86_64; TARGETDIR=x86 - ;; - - amd64-*-freebsd*) - TARGET=X86_64; TARGETDIR=x86 - ;; - - amd64-*-freebsd*) - TARGET=X86_64; TARGETDIR=x86 - ;; - - avr32*-*-*) - TARGET=AVR32; TARGETDIR=avr32 - ;; - - bfin*) - TARGET=BFIN; TARGETDIR=bfin - ;; - - cris-*-*) - TARGET=LIBFFI_CRIS; TARGETDIR=cris - ;; - - frv-*-*) - TARGET=FRV; TARGETDIR=frv - ;; - - hppa*-*-linux* | parisc*-*-linux* | hppa*-*-openbsd*) - TARGET=PA_LINUX; TARGETDIR=pa - ;; - hppa*64-*-hpux*) - TARGET=PA64_HPUX; TARGETDIR=pa - ;; - hppa*-*-hpux*) - TARGET=PA_HPUX; TARGETDIR=pa - ;; - - i?86-*-freebsd* | i?86-*-openbsd*) - TARGET=X86_FREEBSD; TARGETDIR=x86 - ;; - i?86-win32* | i?86-*-cygwin* | i?86-*-mingw* | i?86-*-os2* | i?86-*-interix*) - TARGET=X86_WIN32; TARGETDIR=x86 - # All mingw/cygwin/win32 builds require -no-undefined for sharedlib. - # We must also check with_cross_host to decide if this is a native - # or cross-build and select where to install dlls appropriately. - if test -n "$with_cross_host" && - test x"$with_cross_host" != x"no"; then - AM_LTLDFLAGS='-no-undefined -bindir "$(toolexeclibdir)"'; - else - AM_LTLDFLAGS='-no-undefined -bindir "$(bindir)"'; - fi - ;; - i?86-*-darwin*) - TARGET=X86_DARWIN; TARGETDIR=x86 - ;; - i?86-*-solaris2.1[[0-9]]*) - TARGETDIR=x86 - if test $ac_cv_sizeof_size_t = 4; then - TARGET=X86; - else - TARGET=X86_64; - fi - ;; - - x86_64-*-darwin*) - TARGET=X86_DARWIN; TARGETDIR=x86 - ;; - - x86_64-*-cygwin* | x86_64-*-mingw*) - TARGET=X86_WIN64; TARGETDIR=x86 - # All mingw/cygwin/win32 builds require -no-undefined for sharedlib. - # We must also check with_cross_host to decide if this is a native - # or cross-build and select where to install dlls appropriately. - if test -n "$with_cross_host" && - test x"$with_cross_host" != x"no"; then - AM_LTLDFLAGS='-no-undefined -bindir "$(toolexeclibdir)"'; - else - AM_LTLDFLAGS='-no-undefined -bindir "$(bindir)"'; - fi - ;; - - i?86-*-* | x86_64-*-*) - TARGETDIR=x86 - if test $ac_cv_sizeof_size_t = 4; then - case "$host" in - *-gnux32) - TARGET=X86_64 - ;; - *) - TARGET=X86 - ;; - esac - else - TARGET=X86_64; - fi - ;; - - ia64*-*-*) - TARGET=IA64; TARGETDIR=ia64 - ;; - - m32r*-*-*) - TARGET=M32R; TARGETDIR=m32r - ;; - - m68k-*-*) - TARGET=M68K; TARGETDIR=m68k - ;; - - m88k-*-*) - TARGET=M88K; TARGETDIR=m88k - ;; - - microblaze*-*-*) - TARGET=MICROBLAZE; TARGETDIR=microblaze - ;; - - moxie-*-*) - TARGET=MOXIE; TARGETDIR=moxie - ;; - - metag-*-*) - TARGET=METAG; TARGETDIR=metag - ;; - - mips-sgi-irix5.* | mips-sgi-irix6.* | mips*-*-rtems*) - TARGET=MIPS; TARGETDIR=mips - ;; - mips*-*linux* | mips*-*-openbsd*) - # Support 128-bit long double for NewABI. - HAVE_LONG_DOUBLE='defined(__mips64)' - TARGET=MIPS; TARGETDIR=mips - ;; - - nios2*-linux*) - TARGET=NIOS2; TARGETDIR=nios2 - ;; - - or1k*-linux*) - TARGET=OR1K; TARGETDIR=or1k - ;; - - powerpc*-*-linux* | powerpc-*-sysv*) - TARGET=POWERPC; TARGETDIR=powerpc - HAVE_LONG_DOUBLE_VARIANT=1 - ;; - powerpc-*-amigaos*) - TARGET=POWERPC; TARGETDIR=powerpc - ;; - powerpc-*-beos*) - TARGET=POWERPC; TARGETDIR=powerpc - ;; - powerpc-*-darwin* | powerpc64-*-darwin*) - TARGET=POWERPC_DARWIN; TARGETDIR=powerpc - ;; - powerpc-*-aix* | rs6000-*-aix*) - TARGET=POWERPC_AIX; TARGETDIR=powerpc - ;; - powerpc-*-freebsd* | powerpc-*-openbsd*) - TARGET=POWERPC_FREEBSD; TARGETDIR=powerpc - HAVE_LONG_DOUBLE_VARIANT=1 - ;; - powerpc64-*-freebsd*) - TARGET=POWERPC; TARGETDIR=powerpc - ;; - powerpc*-*-rtems*) - TARGET=POWERPC; TARGETDIR=powerpc - ;; - - s390-*-* | s390x-*-*) - TARGET=S390; TARGETDIR=s390 - ;; - - sh-*-* | sh[[34]]*-*-*) - TARGET=SH; TARGETDIR=sh - ;; - sh64-*-* | sh5*-*-*) - TARGET=SH64; TARGETDIR=sh64 - ;; - - sparc*-*-*) - TARGET=SPARC; TARGETDIR=sparc - ;; - - tile*-*) - TARGET=TILE; TARGETDIR=tile - ;; - - vax-*-*) - TARGET=VAX; TARGETDIR=vax - ;; - - xtensa*-*) - TARGET=XTENSA; TARGETDIR=xtensa - ;; - -esac +. ${srcdir}/configure.host AC_SUBST(AM_RUNTESTFLAGS) AC_SUBST(AM_LTLDFLAGS) diff --git a/configure.host b/configure.host new file mode 100644 index 00000000..e6e35588 --- /dev/null +++ b/configure.host @@ -0,0 +1,193 @@ +# configure.host +# +# This shell script handles all host based configuration for libffi. +# + +# THIS TABLE IS SORTED. KEEP IT THAT WAY. +case "${host}" in + aarch64*-*-*) + TARGET=AARCH64; TARGETDIR=aarch64 + ;; + + alpha*-*-*) + TARGET=ALPHA; TARGETDIR=alpha; + # Support 128-bit long double, changeable via command-line switch. + HAVE_LONG_DOUBLE='defined(__LONG_DOUBLE_128__)' + ;; + + arc*-*-*) + TARGET=ARC; TARGETDIR=arc + ;; + + arm*-*-*) + TARGET=ARM; TARGETDIR=arm + ;; + + avr32*-*-*) + TARGET=AVR32; TARGETDIR=avr32 + ;; + + bfin*) + TARGET=BFIN; TARGETDIR=bfin + ;; + + cris-*-*) + TARGET=LIBFFI_CRIS; TARGETDIR=cris + ;; + + frv-*-*) + TARGET=FRV; TARGETDIR=frv + ;; + + hppa*-*-linux* | parisc*-*-linux* | hppa*-*-openbsd*) + TARGET=PA_LINUX; TARGETDIR=pa + ;; + hppa*64-*-hpux*) + TARGET=PA64_HPUX; TARGETDIR=pa + ;; + hppa*-*-hpux*) + TARGET=PA_HPUX; TARGETDIR=pa + ;; + + i?86-*-freebsd* | i?86-*-openbsd*) + TARGET=X86_FREEBSD; TARGETDIR=x86 + ;; + + i?86-win32* | i?86-*-cygwin* | i?86-*-mingw* | i?86-*-os2* | i?86-*-interix* \ + | x86_64-*-cygwin* | x86_64-*-mingw*) + TARGETDIR=x86 + if test $ac_cv_sizeof_size_t = 4; then + TARGET=X86_WIN32 + else + TARGET=X86_WIN64 + fi + # All mingw/cygwin/win32 builds require -no-undefined for sharedlib. + # We must also check with_cross_host to decide if this is a native + # or cross-build and select where to install dlls appropriately. + if test -n "$with_cross_host" && + test x"$with_cross_host" != x"no"; then + AM_LTLDFLAGS='-no-undefined -bindir "$(toolexeclibdir)"'; + else + AM_LTLDFLAGS='-no-undefined -bindir "$(bindir)"'; + fi + ;; + + i?86-*-darwin* | x86_64-*-darwin*) + TARGET=X86_DARWIN; TARGETDIR=x86 + ;; + + i?86-*-* | x86_64-*-* | amd64-*) + TARGETDIR=x86 + if test $ac_cv_sizeof_size_t = 4; then + case "$host" in + *-gnux32) + TARGET=X86_64 + ;; + *) + TARGET=X86 + ;; + esac + else + TARGET=X86_64; + fi + ;; + + ia64*-*-*) + TARGET=IA64; TARGETDIR=ia64 + ;; + + m32r*-*-*) + TARGET=M32R; TARGETDIR=m32r + ;; + + m68k-*-*) + TARGET=M68K; TARGETDIR=m68k + ;; + + m88k-*-*) + TARGET=M88K; TARGETDIR=m88k + ;; + + microblaze*-*-*) + TARGET=MICROBLAZE; TARGETDIR=microblaze + ;; + + moxie-*-*) + TARGET=MOXIE; TARGETDIR=moxie + ;; + + metag-*-*) + TARGET=METAG; TARGETDIR=metag + ;; + + mips-sgi-irix5.* | mips-sgi-irix6.* | mips*-*-rtems*) + TARGET=MIPS; TARGETDIR=mips + ;; + mips*-*linux* | mips*-*-openbsd*) + # Support 128-bit long double for NewABI. + HAVE_LONG_DOUBLE='defined(__mips64)' + TARGET=MIPS; TARGETDIR=mips + ;; + + nios2*-linux*) + TARGET=NIOS2; TARGETDIR=nios2 + ;; + + or1k*-linux*) + TARGET=OR1K; TARGETDIR=or1k + ;; + + powerpc*-*-linux* | powerpc-*-sysv*) + TARGET=POWERPC; TARGETDIR=powerpc + HAVE_LONG_DOUBLE_VARIANT=1 + ;; + powerpc-*-amigaos*) + TARGET=POWERPC; TARGETDIR=powerpc + ;; + powerpc-*-beos*) + TARGET=POWERPC; TARGETDIR=powerpc + ;; + powerpc-*-darwin* | powerpc64-*-darwin*) + TARGET=POWERPC_DARWIN; TARGETDIR=powerpc + ;; + powerpc-*-aix* | rs6000-*-aix*) + TARGET=POWERPC_AIX; TARGETDIR=powerpc + ;; + powerpc-*-freebsd* | powerpc-*-openbsd*) + TARGET=POWERPC_FREEBSD; TARGETDIR=powerpc + HAVE_LONG_DOUBLE_VARIANT=1 + ;; + powerpc64-*-freebsd*) + TARGET=POWERPC; TARGETDIR=powerpc + ;; + powerpc*-*-rtems*) + TARGET=POWERPC; TARGETDIR=powerpc + ;; + + s390-*-* | s390x-*-*) + TARGET=S390; TARGETDIR=s390 + ;; + + sh-*-* | sh[[34]]*-*-*) + TARGET=SH; TARGETDIR=sh + ;; + sh64-*-* | sh5*-*-*) + TARGET=SH64; TARGETDIR=sh64 + ;; + + sparc*-*-*) + TARGET=SPARC; TARGETDIR=sparc + ;; + + tile*-*) + TARGET=TILE; TARGETDIR=tile + ;; + + vax-*-*) + TARGET=VAX; TARGETDIR=vax + ;; + + xtensa*-*) + TARGET=XTENSA; TARGETDIR=xtensa + ;; +esac From 5d69d57a053c5049df29242def492159e1fadbae Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Thu, 13 Nov 2014 13:50:39 +0100 Subject: [PATCH 3/8] configure: Move target source selection into configure.host This eliminates the AM_CONDITIONAL ugliness, which eliminates just a bit of extra boilerplate for a new target. At the same time, properly categorize the EXTRA_DIST files into SOURCES and HEADERS, for the generation of ctags. --- Makefile.am | 243 +++++++++++++++----------------------------- configure.ac | 55 ++-------- configure.host | 64 ++++++++++++ include/Makefile.am | 3 +- 4 files changed, 160 insertions(+), 205 deletions(-) diff --git a/Makefile.am b/Makefile.am index 7766e900..dfdcea69 100644 --- a/Makefile.am +++ b/Makefile.am @@ -7,51 +7,13 @@ ACLOCAL_AMFLAGS = -I m4 SUBDIRS = include testsuite man EXTRA_DIST = LICENSE ChangeLog.v1 ChangeLog.libgcj \ - src/aarch64/ffi.c src/aarch64/ffitarget.h src/aarch64/sysv.S \ - src/alpha/ffi.c src/alpha/osf.S \ - src/alpha/ffitarget.h src/arc/ffi.c src/arc/arcompact.S \ - src/arc/ffitarget.h src/arm/ffi.c src/arm/sysv.S \ - src/arm/ffitarget.h src/avr32/ffi.c src/avr32/sysv.S \ - src/avr32/ffitarget.h src/cris/ffi.c src/cris/sysv.S \ - src/cris/ffitarget.h src/ia64/ffi.c src/ia64/ffitarget.h \ - src/ia64/ia64_flags.h src/ia64/unix.S src/mips/ffi.c \ - src/mips/n32.S src/mips/o32.S src/metag/ffi.c \ - src/metag/ffitarget.h src/metag/sysv.S src/moxie/ffi.c \ - src/moxie/ffitarget.h src/moxie/eabi.S src/mips/ffitarget.h \ - src/m32r/ffi.c src/m32r/sysv.S src/m32r/ffitarget.h \ - src/m68k/ffi.c src/m68k/sysv.S src/m68k/ffitarget.h \ - src/m88k/ffi.c src/m88k/obsd.S src/m88k/ffitarget.h \ - src/microblaze/ffi.c src/microblaze/sysv.S \ - src/microblaze/ffitarget.h \ - src/nios2/ffi.c src/nios2/ffitarget.h src/nios2/sysv.S \ - src/or1k/ffi.c src/or1k/ffitarget.h src/or1k/sysv.S \ - src/powerpc/ffi.c src/powerpc/ffi_powerpc.h \ - src/powerpc/ffi_sysv.c src/powerpc/ffi_linux64.c \ - src/powerpc/sysv.S src/powerpc/linux64.S \ - src/powerpc/linux64_closure.S src/powerpc/ppc_closure.S \ - src/powerpc/asm.h src/powerpc/aix.S src/powerpc/darwin.S \ - src/powerpc/aix_closure.S src/powerpc/darwin_closure.S \ - src/powerpc/ffi_darwin.c src/powerpc/ffitarget.h \ - src/s390/ffi.c src/s390/sysv.S src/s390/ffitarget.h \ - src/sh/ffi.c src/sh/sysv.S src/sh/ffitarget.h src/sh64/ffi.c \ - src/sh64/sysv.S src/sh64/ffitarget.h src/sparc/v8.S \ - src/sparc/v9.S src/sparc/ffitarget.h src/sparc/ffi.c \ - src/sparc/ffi64.c src/x86/darwin64.S src/x86/ffi.c src/x86/sysv.S \ - src/x86/darwin.S src/x86/ffiw64.c src/x86/win64.S \ - src/x86/ffi64.c src/x86/unix64.S \ - src/x86/ffitarget.h src/pa/ffitarget.h src/pa/ffi.c \ - src/pa/linux.S src/pa/hpux32.S src/frv/ffi.c src/bfin/ffi.c \ - src/bfin/ffitarget.h src/bfin/sysv.S src/frv/eabi.S \ - src/frv/ffitarget.h src/dlmalloc.c src/tile/ffi.c \ - src/tile/ffitarget.h src/tile/tile.S libtool-version \ - src/vax/ffi.c src/vax/ffitarget.h src/vax/elfbsd.S \ - src/xtensa/ffitarget.h src/xtensa/ffi.c src/xtensa/sysv.S \ - ChangeLog.libffi m4/libtool.m4 m4/lt~obsolete.m4 \ + ChangeLog.libffi ChangeLog.libffi-3.1 \ + m4/libtool.m4 m4/lt~obsolete.m4 \ m4/ltoptions.m4 m4/ltsugar.m4 m4/ltversion.m4 \ m4/ltversion.m4 src/debug.c msvcc.sh \ - generate-darwin-source-and-headers.py \ - libffi.xcodeproj/project.pbxproj \ - libtool-ldflags ChangeLog.libffi-3.1 + generate-darwin-source-and-headers.py \ + libffi.xcodeproj/project.pbxproj \ + libtool-ldflags info_TEXINFOS = doc/libffi.texi @@ -104,134 +66,95 @@ FLAGS_TO_PASS = $(AM_MAKEFLAGS) MAKEOVERRIDES= +pkgconfigdir = $(libdir)/pkgconfig +pkgconfig_DATA = libffi.pc + toolexeclib_LTLIBRARIES = libffi.la noinst_LTLIBRARIES = libffi_convenience.la libffi_la_SOURCES = src/prep_cif.c src/types.c \ src/raw_api.c src/java_raw_api.c src/closures.c -pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA = libffi.pc - -nodist_libffi_la_SOURCES = - if FFI_DEBUG -nodist_libffi_la_SOURCES += src/debug.c +libffi_la_SOURCES += src/debug.c endif -if MIPS -nodist_libffi_la_SOURCES += src/mips/ffi.c src/mips/o32.S src/mips/n32.S -endif -if BFIN -nodist_libffi_la_SOURCES += src/bfin/ffi.c src/bfin/sysv.S -endif -if X86 -nodist_libffi_la_SOURCES += src/x86/ffi.c src/x86/sysv.S -endif -if X86_FREEBSD -nodist_libffi_la_SOURCES += src/x86/ffi.c src/x86/sysv.S -endif -if X86_WIN32 -nodist_libffi_la_SOURCES += src/x86/ffi.c src/x86/sysv.S -endif -if X86_WIN64 -nodist_libffi_la_SOURCES += src/x86/ffiw64.c src/x86/win64.S -endif -if X86_DARWIN -nodist_libffi_la_SOURCES += src/x86/ffi.c src/x86/darwin.S src/x86/ffi64.c src/x86/darwin64.S -endif -if SPARC -nodist_libffi_la_SOURCES += src/sparc/ffi.c src/sparc/ffi64.c src/sparc/v8.S src/sparc/v9.S -endif -if ALPHA -nodist_libffi_la_SOURCES += src/alpha/ffi.c src/alpha/osf.S -endif -if IA64 -nodist_libffi_la_SOURCES += src/ia64/ffi.c src/ia64/unix.S -endif -if M32R -nodist_libffi_la_SOURCES += src/m32r/sysv.S src/m32r/ffi.c -endif -if M68K -nodist_libffi_la_SOURCES += src/m68k/ffi.c src/m68k/sysv.S -endif -if M88K -nodist_libffi_la_SOURCES += src/m88k/ffi.c src/m88k/obsd.S -endif -if MOXIE -nodist_libffi_la_SOURCES += src/moxie/ffi.c src/moxie/eabi.S -endif -if MICROBLAZE -nodist_libffi_la_SOURCES += src/microblaze/ffi.c src/microblaze/sysv.S -endif -if NIOS2 -nodist_libffi_la_SOURCES += src/nios2/sysv.S src/nios2/ffi.c -endif -if OR1K -nodist_libffi_la_SOURCES += src/or1k/sysv.S src/or1k/ffi.c -endif -if POWERPC -nodist_libffi_la_SOURCES += src/powerpc/ffi.c src/powerpc/ffi_sysv.c src/powerpc/ffi_linux64.c src/powerpc/sysv.S src/powerpc/ppc_closure.S src/powerpc/linux64.S src/powerpc/linux64_closure.S -endif -if POWERPC_AIX -nodist_libffi_la_SOURCES += src/powerpc/ffi_darwin.c src/powerpc/aix.S src/powerpc/aix_closure.S -endif -if POWERPC_DARWIN -nodist_libffi_la_SOURCES += src/powerpc/ffi_darwin.c src/powerpc/darwin.S src/powerpc/darwin_closure.S -endif -if POWERPC_FREEBSD -nodist_libffi_la_SOURCES += src/powerpc/ffi.c src/powerpc/ffi_sysv.c src/powerpc/sysv.S src/powerpc/ppc_closure.S -endif -if AARCH64 -nodist_libffi_la_SOURCES += src/aarch64/sysv.S src/aarch64/ffi.c -endif -if ARC -nodist_libffi_la_SOURCES += src/arc/arcompact.S src/arc/ffi.c -endif -if ARM -nodist_libffi_la_SOURCES += src/arm/sysv.S src/arm/ffi.c -endif -if AVR32 -nodist_libffi_la_SOURCES += src/avr32/sysv.S src/avr32/ffi.c -endif -if LIBFFI_CRIS -nodist_libffi_la_SOURCES += src/cris/sysv.S src/cris/ffi.c -endif -if FRV -nodist_libffi_la_SOURCES += src/frv/eabi.S src/frv/ffi.c -endif -if S390 -nodist_libffi_la_SOURCES += src/s390/sysv.S src/s390/ffi.c -endif -if X86_64 -nodist_libffi_la_SOURCES += src/x86/ffi64.c src/x86/unix64.S src/x86/ffi.c src/x86/sysv.S -endif -if SH -nodist_libffi_la_SOURCES += src/sh/sysv.S src/sh/ffi.c -endif -if SH64 -nodist_libffi_la_SOURCES += src/sh64/sysv.S src/sh64/ffi.c -endif -if PA_LINUX -nodist_libffi_la_SOURCES += src/pa/linux.S src/pa/ffi.c -endif -if PA_HPUX -nodist_libffi_la_SOURCES += src/pa/hpux32.S src/pa/ffi.c -endif -if TILE -nodist_libffi_la_SOURCES += src/tile/tile.S src/tile/ffi.c -endif -if XTENSA -nodist_libffi_la_SOURCES += src/xtensa/sysv.S src/xtensa/ffi.c -endif -if METAG -nodist_libffi_la_SOURCES += src/metag/sysv.S src/metag/ffi.c -endif -if VAX -nodist_libffi_la_SOURCES += src/vax/elfbsd.S src/vax/ffi.c -endif +noinst_HEADERS = \ + src/aarch64/ffitarget.h src/aarch64/internal.h \ + src/alpha/ffitarget.h src/alpha/internal.h \ + src/arc/ffitarget.h \ + src/arm/ffitarget.h src/arm/internal.h \ + src/avr32/ffitarget.h \ + src/bfin/ffitarget.h \ + src/cris/ffitarget.h \ + src/frv/ffitarget.h \ + src/ia64/ffitarget.h src/ia64/ia64_flags.h \ + src/m32r/ffitarget.h \ + src/m68k/ffitarget.h \ + src/m88k/ffitarget.h \ + src/metag/ffitarget.h \ + src/microblaze/ffitarget.h \ + src/mips/ffitarget.h \ + src/moxie/ffitarget.h \ + src/nios2/ffitarget.h \ + src/or1k/ffitarget.h \ + src/pa/ffitarget.h \ + src/powerpc/ffitarget.h src/powerpc/asm.h src/powerpc/ffi_powerpc.h \ + src/s390/ffitarget.h \ + src/sh/ffitarget.h \ + src/sh64/ffitarget.h \ + src/sparc/ffitarget.h src/sparc/internal.h \ + src/tile/ffitarget.h \ + src/vax/ffitarget.h \ + src/x86/ffitarget.h src/x86/internal.h src/x86/internal64.h \ + src/xtensa/ffitarget.h \ + src/dlmalloc.c + +EXTRA_libffi_la_SOURCES = \ + src/aarch64/ffi.c src/aarch64/sysv.S \ + src/alpha/ffi.c src/alpha/osf.S \ + src/arc/ffi.c src/arc/arcompact.S \ + src/arm/ffi.c src/arm/sysv.S \ + src/avr32/ffi.c src/avr32/sysv.S \ + src/bfin/ffi.c src/bfin/sysv.S \ + src/cris/ffi.c src/cris/sysv.S \ + src/frv/ffi.c src/frv/eabi.S \ + src/ia64/ffi.c src/ia64/unix.S \ + src/m32r/ffi.c src/m32r/sysv.S \ + src/m68k/ffi.c src/m68k/sysv.S \ + src/m88k/ffi.c src/m88k/obsd.S \ + src/metag/ffi.c src/metag/sysv.S \ + src/microblaze/ffi.c src/microblaze/sysv.S \ + src/mips/ffi.c src/mips/o32.S src/mips/n32.S \ + src/moxie/ffi.c src/moxie/eabi.S \ + src/nios2/ffi.c src/nios2/sysv.S \ + src/or1k/ffi.c src/or1k/sysv.S \ + src/pa/ffi.c src/pa/linux.S src/pa/hpux32.S \ + src/powerpc/ffi.c src/powerpc/ffi_sysv.c src/powerpc/ffi_linux64.c \ + src/powerpc/sysv.S src/powerpc/linux64.S \ + src/powerpc/linux64_closure.S src/powerpc/ppc_closure.S \ + src/powerpc/aix.S src/powerpc/darwin.S src/powerpc/aix_closure.S \ + src/powerpc/darwin_closure.S src/powerpc/ffi_darwin.c \ + src/s390/ffi.c src/s390/sysv.S \ + src/sh/ffi.c src/sh/sysv.S \ + src/sh64/ffi.c src/sh64/sysv.S \ + src/sparc/ffi.c src/sparc/ffi64.c src/sparc/v8.S src/sparc/v9.S \ + src/tile/ffi.c src/tile/tile.S \ + src/vax/ffi.c src/vax/elfbsd.S \ + src/x86/ffi.c src/x86/sysv.S \ + src/x86/ffiw64.c src/x86/win64.S \ + src/x86/ffi64.c src/x86/unix64.S \ + src/x86/darwin64.S src/x86/darwin.S \ + src/xtensa/ffi.c src/xtensa/sysv.S + +TARGET_OBJ = @TARGET_OBJ@ +libffi_la_LIBADD = $(TARGET_OBJ) +libffi_la_DEPENDENCIES = $(TARGET_OBJ) libffi_convenience_la_SOURCES = $(libffi_la_SOURCES) +EXTRA_libffi_convenience_la_SOURCES = $(EXTRA_libffi_la_SOURCES) +libffi_convenience_la_LIBADD = $(libffi_la_LIBADD) +libffi_convenience_la_DEPENDENCIES = $(libffi_la_DEPENDENCIES) nodist_libffi_convenience_la_SOURCES = $(nodist_libffi_la_SOURCES) LTLDFLAGS = $(shell $(SHELL) $(top_srcdir)/libtool-ldflags $(LDFLAGS)) diff --git a/configure.ac b/configure.ac index 66e07ae3..d5414f9d 100644 --- a/configure.ac +++ b/configure.ac @@ -75,53 +75,12 @@ HAVE_LONG_DOUBLE_VARIANT=0 . ${srcdir}/configure.host -AC_SUBST(AM_RUNTESTFLAGS) -AC_SUBST(AM_LTLDFLAGS) - -if test $TARGETDIR = unknown; then +if test -n "${UNSUPPORTED}"; then AC_MSG_ERROR(["libffi has not been ported to $host."]) fi -AM_CONDITIONAL(MIPS, test x$TARGET = xMIPS) -AM_CONDITIONAL(BFIN, test x$TARGET = xBFIN) -AM_CONDITIONAL(SPARC, test x$TARGET = xSPARC) -AM_CONDITIONAL(X86, test x$TARGET = xX86) -AM_CONDITIONAL(X86_FREEBSD, test x$TARGET = xX86_FREEBSD) -AM_CONDITIONAL(X86_WIN32, test x$TARGET = xX86_WIN32) -AM_CONDITIONAL(X86_WIN64, test x$TARGET = xX86_WIN64) -AM_CONDITIONAL(X86_DARWIN, test x$TARGET = xX86_DARWIN) -AM_CONDITIONAL(X86_DARWIN32, test x$TARGET = xX86_DARWIN && test $ac_cv_sizeof_size_t = 4) -AM_CONDITIONAL(X86_DARWIN64, test x$TARGET = xX86_DARWIN && test $ac_cv_sizeof_size_t = 8) -AM_CONDITIONAL(ALPHA, test x$TARGET = xALPHA) -AM_CONDITIONAL(IA64, test x$TARGET = xIA64) -AM_CONDITIONAL(M32R, test x$TARGET = xM32R) -AM_CONDITIONAL(M68K, test x$TARGET = xM68K) -AM_CONDITIONAL(M88K, test x$TARGET = xM88K) -AM_CONDITIONAL(MICROBLAZE, test x$TARGET = xMICROBLAZE) -AM_CONDITIONAL(METAG, test x$TARGET = xMETAG) -AM_CONDITIONAL(MOXIE, test x$TARGET = xMOXIE) -AM_CONDITIONAL(NIOS2, test x$TARGET = xNIOS2) -AM_CONDITIONAL(OR1K, test x$TARGET = xOR1K) -AM_CONDITIONAL(POWERPC, test x$TARGET = xPOWERPC) -AM_CONDITIONAL(POWERPC_AIX, test x$TARGET = xPOWERPC_AIX) -AM_CONDITIONAL(POWERPC_DARWIN, test x$TARGET = xPOWERPC_DARWIN) -AM_CONDITIONAL(POWERPC_FREEBSD, test x$TARGET = xPOWERPC_FREEBSD) -AM_CONDITIONAL(AARCH64, test x$TARGET = xAARCH64) -AM_CONDITIONAL(ARC, test x$TARGET = xARC) -AM_CONDITIONAL(ARM, test x$TARGET = xARM) -AM_CONDITIONAL(AVR32, test x$TARGET = xAVR32) -AM_CONDITIONAL(LIBFFI_CRIS, test x$TARGET = xLIBFFI_CRIS) -AM_CONDITIONAL(FRV, test x$TARGET = xFRV) -AM_CONDITIONAL(S390, test x$TARGET = xS390) -AM_CONDITIONAL(X86_64, test x$TARGET = xX86_64) -AM_CONDITIONAL(SH, test x$TARGET = xSH) -AM_CONDITIONAL(SH64, test x$TARGET = xSH64) -AM_CONDITIONAL(PA_LINUX, test x$TARGET = xPA_LINUX) -AM_CONDITIONAL(PA_HPUX, test x$TARGET = xPA_HPUX) -AM_CONDITIONAL(PA64_HPUX, test x$TARGET = xPA64_HPUX) -AM_CONDITIONAL(TILE, test x$TARGET = xTILE) -AM_CONDITIONAL(VAX, test x$TARGET = xVAX) -AM_CONDITIONAL(XTENSA, test x$TARGET = xXTENSA) +AC_SUBST(AM_RUNTESTFLAGS) +AC_SUBST(AM_LTLDFLAGS) AC_HEADER_STDC AC_CHECK_FUNCS(memcpy) @@ -347,6 +306,14 @@ AH_BOTTOM([ AC_SUBST(TARGET) AC_SUBST(TARGETDIR) +changequote(<,>) +TARGET_OBJ= +for i in $SOURCES; do + TARGET_OBJ="${TARGET_OBJ} src/${TARGETDIR}/"`echo $i | sed 's/[cS]$/lo/'` +done +changequote([,]) +AC_SUBST(TARGET_OBJ) + AC_SUBST(SHELL) AC_ARG_ENABLE(debug, diff --git a/configure.host b/configure.host index e6e35588..bc3e8386 100644 --- a/configure.host +++ b/configure.host @@ -4,49 +4,60 @@ # # THIS TABLE IS SORTED. KEEP IT THAT WAY. +# Most of the time we can define all the variables all at once... case "${host}" in aarch64*-*-*) TARGET=AARCH64; TARGETDIR=aarch64 + SOURCES="ffi.c sysv.S" ;; alpha*-*-*) TARGET=ALPHA; TARGETDIR=alpha; # Support 128-bit long double, changeable via command-line switch. HAVE_LONG_DOUBLE='defined(__LONG_DOUBLE_128__)' + SOURCES="ffi.c osf.S" ;; arc*-*-*) TARGET=ARC; TARGETDIR=arc + SOURCES="ffi.c arcompact.S" ;; arm*-*-*) TARGET=ARM; TARGETDIR=arm + SOURCES="ffi.c sysv.S" ;; avr32*-*-*) TARGET=AVR32; TARGETDIR=avr32 + SOURCES="ffi.c sysv.S" ;; bfin*) TARGET=BFIN; TARGETDIR=bfin + SOURCES="ffi.c sysv.S" ;; cris-*-*) TARGET=LIBFFI_CRIS; TARGETDIR=cris + SOURCES="ffi.c sysv.S" ;; frv-*-*) TARGET=FRV; TARGETDIR=frv + SOURCES="ffi.c eabi.S" ;; hppa*-*-linux* | parisc*-*-linux* | hppa*-*-openbsd*) TARGET=PA_LINUX; TARGETDIR=pa + SOURCES="ffi.c linux.S" ;; hppa*64-*-hpux*) TARGET=PA64_HPUX; TARGETDIR=pa ;; hppa*-*-hpux*) TARGET=PA_HPUX; TARGETDIR=pa + SOURCES="ffi.c hpux32.S" ;; i?86-*-freebsd* | i?86-*-openbsd*) @@ -94,30 +105,37 @@ case "${host}" in ia64*-*-*) TARGET=IA64; TARGETDIR=ia64 + SOURCES="ffi.c unix.S" ;; m32r*-*-*) TARGET=M32R; TARGETDIR=m32r + SOURCES="ffi.c sysv.S" ;; m68k-*-*) TARGET=M68K; TARGETDIR=m68k + SOURCES="ffi.c sysv.S" ;; m88k-*-*) TARGET=M88K; TARGETDIR=m88k + SOURCES="ffi.c obsd.S" ;; microblaze*-*-*) TARGET=MICROBLAZE; TARGETDIR=microblaze + SOURCES="ffi.c sysv.S" ;; moxie-*-*) TARGET=MOXIE; TARGETDIR=moxie + SOURCES="ffi.c eabi.S" ;; metag-*-*) TARGET=METAG; TARGETDIR=metag + SOURCES="ffi.c sysv.S" ;; mips-sgi-irix5.* | mips-sgi-irix6.* | mips*-*-rtems*) @@ -131,10 +149,12 @@ case "${host}" in nios2*-linux*) TARGET=NIOS2; TARGETDIR=nios2 + SOURCES="ffi.c sysv.S" ;; or1k*-linux*) TARGET=OR1K; TARGETDIR=or1k + SOURCES="ffi.c sysv.S" ;; powerpc*-*-linux* | powerpc-*-sysv*) @@ -166,28 +186,72 @@ case "${host}" in s390-*-* | s390x-*-*) TARGET=S390; TARGETDIR=s390 + SOURCES="ffi.c sysv.S" ;; sh-*-* | sh[[34]]*-*-*) TARGET=SH; TARGETDIR=sh + SOURCES="ffi.c sysv.S" ;; sh64-*-* | sh5*-*-*) TARGET=SH64; TARGETDIR=sh64 + SOURCES="ffi.c sysv.S" ;; sparc*-*-*) TARGET=SPARC; TARGETDIR=sparc + SOURCES="ffi.c ffi64.c v8.S v9.S" ;; tile*-*) TARGET=TILE; TARGETDIR=tile + SOURCES="ffi.c tile.S" ;; vax-*-*) TARGET=VAX; TARGETDIR=vax + SOURCES="ffi.c elfbsd.S" ;; xtensa*-*) TARGET=XTENSA; TARGETDIR=xtensa + SOURCES="ffi.c sysv.S" ;; esac + +# ... but some of the cases above share configury. +case "${TARGET}" in + MIPS) + SOURCES="ffi.c o32.S n32.S" + ;; + POWERPC) + SOURCES="ffi.c ffi_sysv.c ffi_linux64.c sysv.S ppc_closure.S" + SOURCES="${SOURCES} linux64.S linux64_closure.S" + ;; + POWERPC_AIX) + SOURCES="ffi_darwin.c aix.S aix_closure.S" + ;; + POWERPC_DARWIN) + SOURCES="ffi_darwin.c darwin.S darwin_closure.S" + ;; + POWERPC_FREEBSD) + SOURCES="ffi.c ffi_sysv.c sysv.S ppc_closure.S" + ;; + X86 | X86_FREEBSD | X86_WIN32) + SOURCES="ffi.c sysv.S" + ;; + X86_64) + SOURCES="ffi64.c unix64.S" + ;; + X86_WIN64) + SOURCES="ffiw64.c win64.S" + ;; + X86_DARWIN) + SOURCES="ffi.c darwin.S ffi64.c darwin64.S" + ;; +esac + +# If we failed to configure SOURCES, we can't do anything. +if test -z "${SOURCES}"; then + UNSUPPORTED=1 +fi diff --git a/include/Makefile.am b/include/Makefile.am index fd280249..bb241e88 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -3,7 +3,8 @@ AUTOMAKE_OPTIONS=foreign DISTCLEANFILES=ffitarget.h -EXTRA_DIST=ffi.h.in ffi_common.h +noinst_HEADERS=ffi_common.h ffi_cfi.h +EXTRA_DIST=ffi.h.in includesdir = $(libdir)/@PACKAGE_NAME@-@PACKAGE_VERSION@/include nodist_includes_HEADERS = ffi.h ffitarget.h From b5ade2fb5d9ba06519484677a5474e5dad48c2e3 Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Thu, 13 Nov 2014 09:06:10 -0800 Subject: [PATCH 4/8] testsuite: Detect clang Clang doesn't like the -Wno-psabi argument that we want to pass to GCC. Since clang is detected as GCC via __GNUC__, use ax_cv_c_compiler_vendor. --- testsuite/lib/libffi.exp | 72 ++++++++++++++++++++-------------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/testsuite/lib/libffi.exp b/testsuite/lib/libffi.exp index 5051d317..0e92bb09 100644 --- a/testsuite/lib/libffi.exp +++ b/testsuite/lib/libffi.exp @@ -100,46 +100,39 @@ proc libffi-init { args } { global libffi_link_flags global tool_root_dir global ld_library_path - - global using_gcc + global compiler_vendor set blddirffi [pwd]/.. verbose "libffi $blddirffi" - # Are we building with GCC? - set tmp [grep ../config.status "GCC='yes'"] - if { [string match $tmp "GCC='yes'"] } { + # Which compiler are we building with? + set tmp [grep ../config.log "^ax_cv_c_compiler_vendor.*$"] + regexp -- {^[^=]*=(.*)$} $tmp nil compiler_vendor - set using_gcc "yes" + if { [string match $compiler_vendor "gnu"] } { + set gccdir [lookfor_file $tool_root_dir gcc/libgcc.a] + if {$gccdir != ""} { + set gccdir [file dirname $gccdir] + } + verbose "gccdir $gccdir" - set gccdir [lookfor_file $tool_root_dir gcc/libgcc.a] - if {$gccdir != ""} { - set gccdir [file dirname $gccdir] - } - verbose "gccdir $gccdir" + set ld_library_path "." + append ld_library_path ":${gccdir}" - set ld_library_path "." - append ld_library_path ":${gccdir}" - - set compiler "${gccdir}/xgcc" - if { [is_remote host] == 0 && [which $compiler] != 0 } { - foreach i "[exec $compiler --print-multi-lib]" { - set mldir "" - regexp -- "\[a-z0-9=_/\.-\]*;" $i mldir - set mldir [string trimright $mldir "\;@"] - if { "$mldir" == "." } { - continue + set compiler "${gccdir}/xgcc" + if { [is_remote host] == 0 && [which $compiler] != 0 } { + foreach i "[exec $compiler --print-multi-lib]" { + set mldir "" + regexp -- "\[a-z0-9=_/\.-\]*;" $i mldir + set mldir [string trimright $mldir "\;@"] + if { "$mldir" == "." } { + continue + } + if { [llength [glob -nocomplain ${gccdir}/${mldir}/libgcc_s*.so.*]] >= 1 } { + append ld_library_path ":${gccdir}/${mldir}" + } } - if { [llength [glob -nocomplain ${gccdir}/${mldir}/libgcc_s*.so.*]] >= 1 } { - append ld_library_path ":${gccdir}/${mldir}" - } - } - } - - } else { - - set using_gcc "no" - + } } # add the library path for libffi. @@ -278,18 +271,25 @@ proc libffi-dg-runtest { testcases default-extra-flags } { } proc run-many-tests { testcases extra_flags } { - global using_gcc - if { [string match $using_gcc "yes"] } { + global compiler_vendor + switch $compiler_vendor { + "clang" { + set common "-W -Wall" + set optimizations { "-O0" "-O1" "-O2" "-O3" "-Os" } + } + "gnu" { set common "-W -Wall -Wno-psabi" set optimizations { "-O0" "-O2" "-O3" "-Os" "-O2 -fomit-frame-pointer" } - } else { + } + default { # Assume we are using the vendor compiler. set common "" set optimizations { "" } + } } set targetabis { "" } - if [string match $using_gcc "yes"] { + if [string match $compiler_vendor "gnu"] { if [istarget "i?86-*-*"] { set targetabis { "" From f1301a54bb80e6ae23f7687c68f36875dae69134 Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Fri, 14 Nov 2014 10:50:29 +0100 Subject: [PATCH 5/8] testsuite: Use feature test rather than enumeration for complex --- testsuite/lib/libffi.exp | 18 ++++++++++++++++++ testsuite/libffi.call/call.exp | 10 +--------- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/testsuite/lib/libffi.exp b/testsuite/lib/libffi.exp index 0e92bb09..1b8b008f 100644 --- a/testsuite/lib/libffi.exp +++ b/testsuite/lib/libffi.exp @@ -223,6 +223,24 @@ proc libffi_target_compile { source dest type options } { return [target_compile $source $dest $type $options] } +# TEST should be a preprocessor condition. Returns true if it holds. +proc libffi_feature_test { test } { + set src "ffitest.c" + + set f [open $src "w"] + puts $f "#include " + puts $f $test + puts $f "xyzzy" + puts $f "#endif" + close $f + + set lines [libffi_target_compile $src "" "preprocess" ""] + file delete $src + + set last [lindex $lines end] + return [regexp -- "xyzzy" $last] +} + # Utility routines. # diff --git a/testsuite/libffi.call/call.exp b/testsuite/libffi.call/call.exp index 982c03e8..54f2834e 100644 --- a/testsuite/libffi.call/call.exp +++ b/testsuite/libffi.call/call.exp @@ -24,15 +24,7 @@ set ctlist [lsearch -inline -all -glob [lsort [glob -nocomplain -- $srcdir/$subd run-many-tests $tlist "" -# ??? We really should preprocess ffi.h and grep -# for FFI_TARGET_HAS_COMPLEX_TYPE. -if { [istarget aarch64*] - || [istarget alpha*] - || [istarget arm*] - || [istarget i?86*] - || [istarget s390*] - || [istarget sparc*] - || [istarget x86_64*] } { +if { [libffi_feature_test "#ifdef FFI_TARGET_HAS_COMPLEX_TYPE"] } { run-many-tests $ctlist "" } else { foreach test $ctlist { From c952a92e20aa6013d8202d0b3fa1d87838c83054 Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Fri, 14 Nov 2014 11:00:14 +0100 Subject: [PATCH 6/8] testsuite: Move complex tests to their own subdirectory It seems a bit silly to isolate them by globbing vs "*complex*" when we can just as easily put them in their own subdirectory. --- testsuite/libffi.call/call.exp | 9 ----- .../cls_align_complex.inc | 0 .../cls_align_complex_double.c | 0 .../cls_align_complex_float.c | 0 .../cls_align_complex_longdouble.c | 0 .../cls_complex.inc | 0 .../cls_complex_double.c | 0 .../cls_complex_float.c | 0 .../cls_complex_longdouble.c | 0 .../cls_complex_struct.inc | 0 .../cls_complex_struct_double.c | 0 .../cls_complex_struct_float.c | 0 .../cls_complex_struct_longdouble.c | 0 .../cls_complex_va.inc | 0 .../cls_complex_va_double.c | 0 .../cls_complex_va_float.c | 0 .../cls_complex_va_longdouble.c | 0 testsuite/libffi.complex/complex.exp | 36 +++++++++++++++++++ .../complex.inc | 0 .../complex_defs_double.inc | 0 .../complex_defs_float.inc | 0 .../complex_defs_longdouble.inc | 0 .../complex_double.c | 0 .../complex_float.c | 0 .../complex_int.c | 0 .../complex_longdouble.c | 0 testsuite/libffi.complex/ffitest.h | 1 + .../many_complex.inc | 0 .../many_complex_double.c | 0 .../many_complex_float.c | 0 .../many_complex_longdouble.c | 0 .../return_complex.inc | 0 .../return_complex1.inc | 0 .../return_complex1_double.c | 0 .../return_complex1_float.c | 0 .../return_complex1_longdouble.c | 0 .../return_complex2.inc | 0 .../return_complex2_double.c | 0 .../return_complex2_float.c | 0 .../return_complex2_longdouble.c | 0 .../return_complex_double.c | 0 .../return_complex_float.c | 0 .../return_complex_longdouble.c | 0 43 files changed, 37 insertions(+), 9 deletions(-) rename testsuite/{libffi.call => libffi.complex}/cls_align_complex.inc (100%) rename testsuite/{libffi.call => libffi.complex}/cls_align_complex_double.c (100%) rename testsuite/{libffi.call => libffi.complex}/cls_align_complex_float.c (100%) rename testsuite/{libffi.call => libffi.complex}/cls_align_complex_longdouble.c (100%) rename testsuite/{libffi.call => libffi.complex}/cls_complex.inc (100%) rename testsuite/{libffi.call => libffi.complex}/cls_complex_double.c (100%) rename testsuite/{libffi.call => libffi.complex}/cls_complex_float.c (100%) rename testsuite/{libffi.call => libffi.complex}/cls_complex_longdouble.c (100%) rename testsuite/{libffi.call => libffi.complex}/cls_complex_struct.inc (100%) rename testsuite/{libffi.call => libffi.complex}/cls_complex_struct_double.c (100%) rename testsuite/{libffi.call => libffi.complex}/cls_complex_struct_float.c (100%) rename testsuite/{libffi.call => libffi.complex}/cls_complex_struct_longdouble.c (100%) rename testsuite/{libffi.call => libffi.complex}/cls_complex_va.inc (100%) rename testsuite/{libffi.call => libffi.complex}/cls_complex_va_double.c (100%) rename testsuite/{libffi.call => libffi.complex}/cls_complex_va_float.c (100%) rename testsuite/{libffi.call => libffi.complex}/cls_complex_va_longdouble.c (100%) create mode 100644 testsuite/libffi.complex/complex.exp rename testsuite/{libffi.call => libffi.complex}/complex.inc (100%) rename testsuite/{libffi.call => libffi.complex}/complex_defs_double.inc (100%) rename testsuite/{libffi.call => libffi.complex}/complex_defs_float.inc (100%) rename testsuite/{libffi.call => libffi.complex}/complex_defs_longdouble.inc (100%) rename testsuite/{libffi.call => libffi.complex}/complex_double.c (100%) rename testsuite/{libffi.call => libffi.complex}/complex_float.c (100%) rename testsuite/{libffi.call => libffi.complex}/complex_int.c (100%) rename testsuite/{libffi.call => libffi.complex}/complex_longdouble.c (100%) create mode 100644 testsuite/libffi.complex/ffitest.h rename testsuite/{libffi.call => libffi.complex}/many_complex.inc (100%) rename testsuite/{libffi.call => libffi.complex}/many_complex_double.c (100%) rename testsuite/{libffi.call => libffi.complex}/many_complex_float.c (100%) rename testsuite/{libffi.call => libffi.complex}/many_complex_longdouble.c (100%) rename testsuite/{libffi.call => libffi.complex}/return_complex.inc (100%) rename testsuite/{libffi.call => libffi.complex}/return_complex1.inc (100%) rename testsuite/{libffi.call => libffi.complex}/return_complex1_double.c (100%) rename testsuite/{libffi.call => libffi.complex}/return_complex1_float.c (100%) rename testsuite/{libffi.call => libffi.complex}/return_complex1_longdouble.c (100%) rename testsuite/{libffi.call => libffi.complex}/return_complex2.inc (100%) rename testsuite/{libffi.call => libffi.complex}/return_complex2_double.c (100%) rename testsuite/{libffi.call => libffi.complex}/return_complex2_float.c (100%) rename testsuite/{libffi.call => libffi.complex}/return_complex2_longdouble.c (100%) rename testsuite/{libffi.call => libffi.complex}/return_complex_double.c (100%) rename testsuite/{libffi.call => libffi.complex}/return_complex_float.c (100%) rename testsuite/{libffi.call => libffi.complex}/return_complex_longdouble.c (100%) diff --git a/testsuite/libffi.call/call.exp b/testsuite/libffi.call/call.exp index 54f2834e..46fb1ebb 100644 --- a/testsuite/libffi.call/call.exp +++ b/testsuite/libffi.call/call.exp @@ -20,18 +20,9 @@ libffi-init global srcdir subdir set tlist [lsearch -inline -all -not -glob [lsort [glob -nocomplain -- $srcdir/$subdir/*.{c,cc}]] *complex*] -set ctlist [lsearch -inline -all -glob [lsort [glob -nocomplain -- $srcdir/$subdir/*.{c,cc}]] *complex*] run-many-tests $tlist "" -if { [libffi_feature_test "#ifdef FFI_TARGET_HAS_COMPLEX_TYPE"] } { - run-many-tests $ctlist "" -} else { - foreach test $ctlist { - unsupported "$test" - } -} - dg-finish # Local Variables: diff --git a/testsuite/libffi.call/cls_align_complex.inc b/testsuite/libffi.complex/cls_align_complex.inc similarity index 100% rename from testsuite/libffi.call/cls_align_complex.inc rename to testsuite/libffi.complex/cls_align_complex.inc diff --git a/testsuite/libffi.call/cls_align_complex_double.c b/testsuite/libffi.complex/cls_align_complex_double.c similarity index 100% rename from testsuite/libffi.call/cls_align_complex_double.c rename to testsuite/libffi.complex/cls_align_complex_double.c diff --git a/testsuite/libffi.call/cls_align_complex_float.c b/testsuite/libffi.complex/cls_align_complex_float.c similarity index 100% rename from testsuite/libffi.call/cls_align_complex_float.c rename to testsuite/libffi.complex/cls_align_complex_float.c diff --git a/testsuite/libffi.call/cls_align_complex_longdouble.c b/testsuite/libffi.complex/cls_align_complex_longdouble.c similarity index 100% rename from testsuite/libffi.call/cls_align_complex_longdouble.c rename to testsuite/libffi.complex/cls_align_complex_longdouble.c diff --git a/testsuite/libffi.call/cls_complex.inc b/testsuite/libffi.complex/cls_complex.inc similarity index 100% rename from testsuite/libffi.call/cls_complex.inc rename to testsuite/libffi.complex/cls_complex.inc diff --git a/testsuite/libffi.call/cls_complex_double.c b/testsuite/libffi.complex/cls_complex_double.c similarity index 100% rename from testsuite/libffi.call/cls_complex_double.c rename to testsuite/libffi.complex/cls_complex_double.c diff --git a/testsuite/libffi.call/cls_complex_float.c b/testsuite/libffi.complex/cls_complex_float.c similarity index 100% rename from testsuite/libffi.call/cls_complex_float.c rename to testsuite/libffi.complex/cls_complex_float.c diff --git a/testsuite/libffi.call/cls_complex_longdouble.c b/testsuite/libffi.complex/cls_complex_longdouble.c similarity index 100% rename from testsuite/libffi.call/cls_complex_longdouble.c rename to testsuite/libffi.complex/cls_complex_longdouble.c diff --git a/testsuite/libffi.call/cls_complex_struct.inc b/testsuite/libffi.complex/cls_complex_struct.inc similarity index 100% rename from testsuite/libffi.call/cls_complex_struct.inc rename to testsuite/libffi.complex/cls_complex_struct.inc diff --git a/testsuite/libffi.call/cls_complex_struct_double.c b/testsuite/libffi.complex/cls_complex_struct_double.c similarity index 100% rename from testsuite/libffi.call/cls_complex_struct_double.c rename to testsuite/libffi.complex/cls_complex_struct_double.c diff --git a/testsuite/libffi.call/cls_complex_struct_float.c b/testsuite/libffi.complex/cls_complex_struct_float.c similarity index 100% rename from testsuite/libffi.call/cls_complex_struct_float.c rename to testsuite/libffi.complex/cls_complex_struct_float.c diff --git a/testsuite/libffi.call/cls_complex_struct_longdouble.c b/testsuite/libffi.complex/cls_complex_struct_longdouble.c similarity index 100% rename from testsuite/libffi.call/cls_complex_struct_longdouble.c rename to testsuite/libffi.complex/cls_complex_struct_longdouble.c diff --git a/testsuite/libffi.call/cls_complex_va.inc b/testsuite/libffi.complex/cls_complex_va.inc similarity index 100% rename from testsuite/libffi.call/cls_complex_va.inc rename to testsuite/libffi.complex/cls_complex_va.inc diff --git a/testsuite/libffi.call/cls_complex_va_double.c b/testsuite/libffi.complex/cls_complex_va_double.c similarity index 100% rename from testsuite/libffi.call/cls_complex_va_double.c rename to testsuite/libffi.complex/cls_complex_va_double.c diff --git a/testsuite/libffi.call/cls_complex_va_float.c b/testsuite/libffi.complex/cls_complex_va_float.c similarity index 100% rename from testsuite/libffi.call/cls_complex_va_float.c rename to testsuite/libffi.complex/cls_complex_va_float.c diff --git a/testsuite/libffi.call/cls_complex_va_longdouble.c b/testsuite/libffi.complex/cls_complex_va_longdouble.c similarity index 100% rename from testsuite/libffi.call/cls_complex_va_longdouble.c rename to testsuite/libffi.complex/cls_complex_va_longdouble.c diff --git a/testsuite/libffi.complex/complex.exp b/testsuite/libffi.complex/complex.exp new file mode 100644 index 00000000..4631db28 --- /dev/null +++ b/testsuite/libffi.complex/complex.exp @@ -0,0 +1,36 @@ +# Copyright (C) 2003, 2006, 2009, 2010, 2014 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; see the file COPYING3. If not see +# . + +dg-init +libffi-init + +global srcdir subdir + +set tlist [lsort [glob -nocomplain -- $srcdir/$subdir/*.{c,cc}]] + +if { [libffi_feature_test "#ifdef FFI_TARGET_HAS_COMPLEX_TYPE"] } { + run-many-tests $tlist "" +} else { + foreach test $tlist { + unsupported "$test" + } +} + +dg-finish + +# Local Variables: +# tcl-indent-level:4 +# End: diff --git a/testsuite/libffi.call/complex.inc b/testsuite/libffi.complex/complex.inc similarity index 100% rename from testsuite/libffi.call/complex.inc rename to testsuite/libffi.complex/complex.inc diff --git a/testsuite/libffi.call/complex_defs_double.inc b/testsuite/libffi.complex/complex_defs_double.inc similarity index 100% rename from testsuite/libffi.call/complex_defs_double.inc rename to testsuite/libffi.complex/complex_defs_double.inc diff --git a/testsuite/libffi.call/complex_defs_float.inc b/testsuite/libffi.complex/complex_defs_float.inc similarity index 100% rename from testsuite/libffi.call/complex_defs_float.inc rename to testsuite/libffi.complex/complex_defs_float.inc diff --git a/testsuite/libffi.call/complex_defs_longdouble.inc b/testsuite/libffi.complex/complex_defs_longdouble.inc similarity index 100% rename from testsuite/libffi.call/complex_defs_longdouble.inc rename to testsuite/libffi.complex/complex_defs_longdouble.inc diff --git a/testsuite/libffi.call/complex_double.c b/testsuite/libffi.complex/complex_double.c similarity index 100% rename from testsuite/libffi.call/complex_double.c rename to testsuite/libffi.complex/complex_double.c diff --git a/testsuite/libffi.call/complex_float.c b/testsuite/libffi.complex/complex_float.c similarity index 100% rename from testsuite/libffi.call/complex_float.c rename to testsuite/libffi.complex/complex_float.c diff --git a/testsuite/libffi.call/complex_int.c b/testsuite/libffi.complex/complex_int.c similarity index 100% rename from testsuite/libffi.call/complex_int.c rename to testsuite/libffi.complex/complex_int.c diff --git a/testsuite/libffi.call/complex_longdouble.c b/testsuite/libffi.complex/complex_longdouble.c similarity index 100% rename from testsuite/libffi.call/complex_longdouble.c rename to testsuite/libffi.complex/complex_longdouble.c diff --git a/testsuite/libffi.complex/ffitest.h b/testsuite/libffi.complex/ffitest.h new file mode 100644 index 00000000..d27d362d --- /dev/null +++ b/testsuite/libffi.complex/ffitest.h @@ -0,0 +1 @@ +#include "../libffi.call/ffitest.h" diff --git a/testsuite/libffi.call/many_complex.inc b/testsuite/libffi.complex/many_complex.inc similarity index 100% rename from testsuite/libffi.call/many_complex.inc rename to testsuite/libffi.complex/many_complex.inc diff --git a/testsuite/libffi.call/many_complex_double.c b/testsuite/libffi.complex/many_complex_double.c similarity index 100% rename from testsuite/libffi.call/many_complex_double.c rename to testsuite/libffi.complex/many_complex_double.c diff --git a/testsuite/libffi.call/many_complex_float.c b/testsuite/libffi.complex/many_complex_float.c similarity index 100% rename from testsuite/libffi.call/many_complex_float.c rename to testsuite/libffi.complex/many_complex_float.c diff --git a/testsuite/libffi.call/many_complex_longdouble.c b/testsuite/libffi.complex/many_complex_longdouble.c similarity index 100% rename from testsuite/libffi.call/many_complex_longdouble.c rename to testsuite/libffi.complex/many_complex_longdouble.c diff --git a/testsuite/libffi.call/return_complex.inc b/testsuite/libffi.complex/return_complex.inc similarity index 100% rename from testsuite/libffi.call/return_complex.inc rename to testsuite/libffi.complex/return_complex.inc diff --git a/testsuite/libffi.call/return_complex1.inc b/testsuite/libffi.complex/return_complex1.inc similarity index 100% rename from testsuite/libffi.call/return_complex1.inc rename to testsuite/libffi.complex/return_complex1.inc diff --git a/testsuite/libffi.call/return_complex1_double.c b/testsuite/libffi.complex/return_complex1_double.c similarity index 100% rename from testsuite/libffi.call/return_complex1_double.c rename to testsuite/libffi.complex/return_complex1_double.c diff --git a/testsuite/libffi.call/return_complex1_float.c b/testsuite/libffi.complex/return_complex1_float.c similarity index 100% rename from testsuite/libffi.call/return_complex1_float.c rename to testsuite/libffi.complex/return_complex1_float.c diff --git a/testsuite/libffi.call/return_complex1_longdouble.c b/testsuite/libffi.complex/return_complex1_longdouble.c similarity index 100% rename from testsuite/libffi.call/return_complex1_longdouble.c rename to testsuite/libffi.complex/return_complex1_longdouble.c diff --git a/testsuite/libffi.call/return_complex2.inc b/testsuite/libffi.complex/return_complex2.inc similarity index 100% rename from testsuite/libffi.call/return_complex2.inc rename to testsuite/libffi.complex/return_complex2.inc diff --git a/testsuite/libffi.call/return_complex2_double.c b/testsuite/libffi.complex/return_complex2_double.c similarity index 100% rename from testsuite/libffi.call/return_complex2_double.c rename to testsuite/libffi.complex/return_complex2_double.c diff --git a/testsuite/libffi.call/return_complex2_float.c b/testsuite/libffi.complex/return_complex2_float.c similarity index 100% rename from testsuite/libffi.call/return_complex2_float.c rename to testsuite/libffi.complex/return_complex2_float.c diff --git a/testsuite/libffi.call/return_complex2_longdouble.c b/testsuite/libffi.complex/return_complex2_longdouble.c similarity index 100% rename from testsuite/libffi.call/return_complex2_longdouble.c rename to testsuite/libffi.complex/return_complex2_longdouble.c diff --git a/testsuite/libffi.call/return_complex_double.c b/testsuite/libffi.complex/return_complex_double.c similarity index 100% rename from testsuite/libffi.call/return_complex_double.c rename to testsuite/libffi.complex/return_complex_double.c diff --git a/testsuite/libffi.call/return_complex_float.c b/testsuite/libffi.complex/return_complex_float.c similarity index 100% rename from testsuite/libffi.call/return_complex_float.c rename to testsuite/libffi.complex/return_complex_float.c diff --git a/testsuite/libffi.call/return_complex_longdouble.c b/testsuite/libffi.complex/return_complex_longdouble.c similarity index 100% rename from testsuite/libffi.call/return_complex_longdouble.c rename to testsuite/libffi.complex/return_complex_longdouble.c From c9f5b6648b0f052bbca8b50615284dd975e9ed29 Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Fri, 14 Nov 2014 13:04:33 +0100 Subject: [PATCH 7/8] testsuite: Add trivial tests for Go closures --- testsuite/libffi.go/aa-direct.c | 34 ++++++++++++++++++++++++++++ testsuite/libffi.go/closure1.c | 28 +++++++++++++++++++++++ testsuite/libffi.go/ffitest.h | 1 + testsuite/libffi.go/go.exp | 36 ++++++++++++++++++++++++++++++ testsuite/libffi.go/static-chain.h | 19 ++++++++++++++++ 5 files changed, 118 insertions(+) create mode 100644 testsuite/libffi.go/aa-direct.c create mode 100644 testsuite/libffi.go/closure1.c create mode 100644 testsuite/libffi.go/ffitest.h create mode 100644 testsuite/libffi.go/go.exp create mode 100644 testsuite/libffi.go/static-chain.h diff --git a/testsuite/libffi.go/aa-direct.c b/testsuite/libffi.go/aa-direct.c new file mode 100644 index 00000000..b00c404a --- /dev/null +++ b/testsuite/libffi.go/aa-direct.c @@ -0,0 +1,34 @@ +/* { dg-do run } */ + +#include "static-chain.h" + +#if defined(__GNUC__) && !defined(__clang__) && defined(STATIC_CHAIN_REG) + +#include "ffitest.h" + +/* Blatent assumption here that the prologue doesn't clobber the + static chain for trivial functions. If this is not true, don't + define STATIC_CHAIN_REG, and we'll test what we can via other tests. */ +void *doit(void) +{ + register void *chain __asm__(STATIC_CHAIN_REG); + return chain; +} + +int main() +{ + ffi_cif cif; + void *result; + + CHECK(ffi_prep_cif(&cif, ABI_NUM, 0, &ffi_type_pointer, NULL) == FFI_OK); + + ffi_call_go(&cif, FFI_FN(doit), &result, NULL, &result); + + CHECK(result == &result); + + return 0; +} + +#else /* UNSUPPORTED */ +int main() { return 0; } +#endif diff --git a/testsuite/libffi.go/closure1.c b/testsuite/libffi.go/closure1.c new file mode 100644 index 00000000..7b34afc8 --- /dev/null +++ b/testsuite/libffi.go/closure1.c @@ -0,0 +1,28 @@ +/* { dg-do run } */ + +#include "ffitest.h" + +void doit(ffi_cif *cif, void *rvalue, void **avalue, void *closure) +{ + (void)cif; + (void)avalue; + *(void **)rvalue = closure; +} + +typedef void * (*FN)(void); + +int main() +{ + ffi_cif cif; + ffi_go_closure cl; + void *result; + + CHECK(ffi_prep_cif(&cif, ABI_NUM, 0, &ffi_type_pointer, NULL) == FFI_OK); + CHECK(ffi_prep_go_closure(&cl, &cif, doit) == FFI_OK); + + ffi_call_go(&cif, FFI_FN(*(FN *)&cl), &result, NULL, &cl); + + CHECK(result == &cl); + + exit(0); +} diff --git a/testsuite/libffi.go/ffitest.h b/testsuite/libffi.go/ffitest.h new file mode 100644 index 00000000..d27d362d --- /dev/null +++ b/testsuite/libffi.go/ffitest.h @@ -0,0 +1 @@ +#include "../libffi.call/ffitest.h" diff --git a/testsuite/libffi.go/go.exp b/testsuite/libffi.go/go.exp new file mode 100644 index 00000000..100c5e75 --- /dev/null +++ b/testsuite/libffi.go/go.exp @@ -0,0 +1,36 @@ +# Copyright (C) 2003, 2006, 2009, 2010, 2014 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; see the file COPYING3. If not see +# . + +dg-init +libffi-init + +global srcdir subdir + +set tlist [lsort [glob -nocomplain -- $srcdir/$subdir/*.{c,cc}]] + +if { [libffi_feature_test "#ifdef FFI_GO_CLOSURES"] } { + run-many-tests $tlist "" +} else { + foreach test $tlist { + unsupported "$test" + } +} + +dg-finish + +# Local Variables: +# tcl-indent-level:4 +# End: diff --git a/testsuite/libffi.go/static-chain.h b/testsuite/libffi.go/static-chain.h new file mode 100644 index 00000000..56b7e31e --- /dev/null +++ b/testsuite/libffi.go/static-chain.h @@ -0,0 +1,19 @@ +#ifdef __aarch64__ +# define STATIC_CHAIN_REG "x18" +#elif defined(__alpha__) +# define STATIC_CHAIN_REG "r1" +#elif defined(__arm__) +# define STATIC_CHAIN_REG "ip" +#elif defined(__sparc__) +# if defined(__arch64__) || defined(__sparcv9) +# define STATIC_CHAIN_REG "g5" +# else +# define STATIC_CHAIN_REG "g2" +# endif +#elif defined(__x86_64__) +# define STATIC_CHAIN_REG "r10" +#elif defined(__i386__) +# ifndef ABI_NUM +# define STATIC_CHAIN_REG "ecx" /* FFI_DEFAULT_ABI only */ +# endif +#endif From dea49e2020b2fc97ba9293200f316f7a7b3ca73b Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Fri, 14 Nov 2014 13:05:14 +0100 Subject: [PATCH 8/8] x86: Fix typo in ffi_prep_go_closure Used the wrong register for THISCALL and FASTCALL. --- src/x86/ffi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/x86/ffi.c b/src/x86/ffi.c index 359a8649..4c96c6de 100644 --- a/src/x86/ffi.c +++ b/src/x86/ffi.c @@ -527,7 +527,7 @@ ffi_prep_go_closure (ffi_go_closure* closure, ffi_cif* cif, break; case FFI_THISCALL: case FFI_FASTCALL: - dest = ffi_go_closure_ECX; + dest = ffi_go_closure_EAX; break; case FFI_STDCALL: case FFI_PASCAL: