mirror of
https://github.com/partic2/libffi
synced 2026-11-10 01:57:19 +00:00
Merge pull request #145 from rth7680/master
Configure and testsuite cleanups, v2
This commit is contained in:
+54
-36
@@ -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.
|
||||
@@ -230,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 <ffi.h>"
|
||||
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.
|
||||
|
||||
#
|
||||
@@ -278,18 +289,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 {
|
||||
""
|
||||
|
||||
@@ -20,26 +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 ""
|
||||
|
||||
# ??? 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*] } {
|
||||
run-many-tests $ctlist ""
|
||||
} else {
|
||||
foreach test $ctlist {
|
||||
unsupported "$test"
|
||||
}
|
||||
}
|
||||
|
||||
dg-finish
|
||||
|
||||
# Local Variables:
|
||||
|
||||
@@ -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
|
||||
# <http://www.gnu.org/licenses/>.
|
||||
|
||||
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:
|
||||
@@ -0,0 +1 @@
|
||||
#include "../libffi.call/ffitest.h"
|
||||
@@ -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
|
||||
@@ -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);
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
#include "../libffi.call/ffitest.h"
|
||||
@@ -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
|
||||
# <http://www.gnu.org/licenses/>.
|
||||
|
||||
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:
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user