diff options
author | Thomas Koenig <tkoenig@gcc.gnu.org> | 2021-09-13 19:49:49 +0200 |
---|---|---|
committer | Thomas Koenig <tkoenig@gcc.gnu.org> | 2021-09-13 19:49:49 +0200 |
commit | b18a97e5dd0935e1c4a626c230f21457d0aad3d5 (patch) | |
tree | c1818f41af6fe780deafb6cd6a183f32085fe654 /libffi | |
parent | e76a53644c9d70e998c0d050e9a456af388c6b61 (diff) | |
download | gcc-b18a97e5dd0935e1c4a626c230f21457d0aad3d5.zip gcc-b18a97e5dd0935e1c4a626c230f21457d0aad3d5.tar.gz gcc-b18a97e5dd0935e1c4a626c230f21457d0aad3d5.tar.bz2 |
Merged current trunk to branch.
Diffstat (limited to 'libffi')
-rw-r--r-- | libffi/ChangeLog | 23 | ||||
-rwxr-xr-x | libffi/configure | 12 | ||||
-rw-r--r-- | libffi/configure.host | 21 | ||||
-rw-r--r-- | libffi/src/mips/ffi.c | 8 | ||||
-rw-r--r-- | libffi/src/mips/n32.S | 2 | ||||
-rw-r--r-- | libffi/src/x86/ffi64.c | 9 | ||||
-rw-r--r-- | libffi/testsuite/libffi.call/nested_struct12.c | 107 |
7 files changed, 153 insertions, 29 deletions
diff --git a/libffi/ChangeLog b/libffi/ChangeLog index fc59bd8..1048153 100644 --- a/libffi/ChangeLog +++ b/libffi/ChangeLog @@ -1,3 +1,26 @@ +2021-08-30 YunQiang Su <yunqiang.su@cipunited.com> + + PR libffi/83636 + * src/mips/n32.S: disable .set mips4 + * src/mips/ffi.c: use different JR encoding for r6. + +2021-07-09 H.J. Lu <hjl.tools@gmail.com> + + PR libffi/101336 + * configure.host: Always check __x86_64__ for x86 hosts. + +2021-06-16 Jakub Jelinek <jakub@redhat.com> + + * src/x86/ffi64.c (classify_argument): For FFI_TYPE_STRUCT set words + to number of words needed for type->size + byte_offset bytes rather + than just type->size bytes. Compute pos before the loop and check + total size of the structure. + * testsuite/libffi.call/nested_struct12.c: New test. + +2021-01-05 Samuel Thibault <samuel.thibault@ens-lyon.org> + + * configure: Re-generate. + 2020-12-05 Iain Sandoe <iain@sandoe.co.uk> PR target/97865 diff --git a/libffi/configure b/libffi/configure index 2c0ba17..8d52ec4 100755 --- a/libffi/configure +++ b/libffi/configure @@ -10743,16 +10743,6 @@ freebsd* | dragonfly*) esac ;; -gnu*) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - hardcode_into_libs=yes - ;; - haiku*) version_type=linux need_lib_prefix=no @@ -10874,7 +10864,7 @@ linux*oldld* | linux*aout* | linux*coff*) # project, but have not yet been accepted: they are GCC-local changes # for the time being. (See # https://lists.gnu.org/archive/html/libtool-patches/2018-05/msg00000.html) -linux* | k*bsd*-gnu | kopensolaris*-gnu | uclinuxfdpiceabi) +linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu* | uclinuxfdpiceabi) version_type=linux need_lib_prefix=no need_version=no diff --git a/libffi/configure.host b/libffi/configure.host index 786b32c..7248acb 100644 --- a/libffi/configure.host +++ b/libffi/configure.host @@ -95,20 +95,13 @@ case "${host}" in i?86-*-* | x86_64-*-* | amd64-*) TARGETDIR=x86 if test $ac_cv_sizeof_size_t = 4; then - case "$host" in - *-gnux32) - TARGET=X86_64 - ;; - *) - echo 'int foo (void) { return __x86_64__; }' > conftest.c - if $CC $CFLAGS -Werror -S conftest.c -o conftest.s > /dev/null 2>&1; then - TARGET=X86_64; - else - TARGET=X86; - fi - rm -f conftest.* - ;; - esac + echo 'int foo (void) { return __x86_64__; }' > conftest.c + if $CC $CFLAGS -Werror -S conftest.c -o conftest.s > /dev/null 2>&1; then + TARGET=X86_64; + else + TARGET=X86; + fi + rm -f conftest.* else TARGET=X86_64; fi diff --git a/libffi/src/mips/ffi.c b/libffi/src/mips/ffi.c index 5d0dd70..ecd783a 100644 --- a/libffi/src/mips/ffi.c +++ b/libffi/src/mips/ffi.c @@ -698,7 +698,11 @@ ffi_prep_closure_loc (ffi_closure *closure, /* lui $12,high(codeloc) */ tramp[2] = 0x3c0c0000 | ((unsigned)codeloc >> 16); /* jr $25 */ +#if !defined(__mips_isa_rev) || (__mips_isa_rev<6) tramp[3] = 0x03200008; +#else + tramp[3] = 0x03200009; +#endif /* ori $12,low(codeloc) */ tramp[4] = 0x358c0000 | ((unsigned)codeloc & 0xffff); #else @@ -726,7 +730,11 @@ ffi_prep_closure_loc (ffi_closure *closure, /* ori $25,low(fn) */ tramp[10] = 0x37390000 | ((unsigned long)fn & 0xffff); /* jr $25 */ +#if !defined(__mips_isa_rev) || (__mips_isa_rev<6) tramp[11] = 0x03200008; +#else + tramp[11] = 0x03200009; +#endif /* ori $12,low(codeloc) */ tramp[12] = 0x358c0000 | ((unsigned long)codeloc & 0xffff); diff --git a/libffi/src/mips/n32.S b/libffi/src/mips/n32.S index c6985d3..06e6c46 100644 --- a/libffi/src/mips/n32.S +++ b/libffi/src/mips/n32.S @@ -43,7 +43,9 @@ #ifdef __GNUC__ .abicalls #endif +#if !defined(__mips_isa_rev) || (__mips_isa_rev<6) .set mips4 +#endif .text .align 2 .globl ffi_call_N32 diff --git a/libffi/src/x86/ffi64.c b/libffi/src/x86/ffi64.c index 131b5e3..243cbc7 100644 --- a/libffi/src/x86/ffi64.c +++ b/libffi/src/x86/ffi64.c @@ -217,7 +217,8 @@ classify_argument (ffi_type *type, enum x86_64_reg_class classes[], case FFI_TYPE_STRUCT: { const size_t UNITS_PER_WORD = 8; - size_t words = (type->size + UNITS_PER_WORD - 1) / UNITS_PER_WORD; + size_t words = (type->size + byte_offset + UNITS_PER_WORD - 1) + / UNITS_PER_WORD; ffi_type **ptr; int i; enum x86_64_reg_class subclasses[MAX_CLASSES]; @@ -241,16 +242,16 @@ classify_argument (ffi_type *type, enum x86_64_reg_class classes[], /* Merge the fields of structure. */ for (ptr = type->elements; *ptr != NULL; ptr++) { - size_t num; + size_t num, pos; byte_offset = ALIGN (byte_offset, (*ptr)->alignment); num = classify_argument (*ptr, subclasses, byte_offset % 8); if (num == 0) return 0; - for (i = 0; i < num; i++) + pos = byte_offset / 8; + for (i = 0; i < num && (i + pos) < words; i++) { - size_t pos = byte_offset / 8; classes[i + pos] = merge_classes (subclasses[i], classes[i + pos]); } diff --git a/libffi/testsuite/libffi.call/nested_struct12.c b/libffi/testsuite/libffi.call/nested_struct12.c new file mode 100644 index 0000000..6f3d736 --- /dev/null +++ b/libffi/testsuite/libffi.call/nested_struct12.c @@ -0,0 +1,107 @@ +/* Area: ffi_call, closure_call + Purpose: Check structure passing. + Limitations: none. + PR: none. + Originator: <jincheng@ca.ibm.com> and <jakub@redhat.com> 20210609 */ + +/* { dg-do run } */ +#include "ffitest.h" + +typedef struct A { + float a, b; +} A; + +typedef struct B { + float x; + struct A y; +} B; + +B B_fn(float b0, struct B b1) +{ + struct B result; + + result.x = b0 + b1.x; + result.y.a = b0 + b1.y.a; + result.y.b = b0 + b1.y.b; + + printf("%g %g %g %g: %g %g %g\n", b0, b1.x, b1.y.a, b1.y.b, + result.x, result.y.a, result.y.b); + + return result; +} + +static void +B_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, + void* userdata __UNUSED__) +{ + float b0; + struct B b1; + + b0 = *(float*)(args[0]); + b1 = *(struct B*)(args[1]); + + *(B*)resp = B_fn(b0, b1); +} + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + void* args_dbl[3]; + ffi_type* cls_struct_fields[3]; + ffi_type* cls_struct_fields1[3]; + ffi_type cls_struct_type, cls_struct_type1; + ffi_type* dbl_arg_types[3]; + + float e_dbl = 12.125f; + struct B f_dbl = { 24.75f, { 31.625f, 32.25f } }; + + struct B res_dbl; + + cls_struct_type.size = 0; + cls_struct_type.alignment = 0; + cls_struct_type.type = FFI_TYPE_STRUCT; + cls_struct_type.elements = cls_struct_fields; + + cls_struct_type1.size = 0; + cls_struct_type1.alignment = 0; + cls_struct_type1.type = FFI_TYPE_STRUCT; + cls_struct_type1.elements = cls_struct_fields1; + + cls_struct_fields[0] = &ffi_type_float; + cls_struct_fields[1] = &ffi_type_float; + cls_struct_fields[2] = NULL; + + cls_struct_fields1[0] = &ffi_type_float; + cls_struct_fields1[1] = &cls_struct_type; + cls_struct_fields1[2] = NULL; + + + dbl_arg_types[0] = &ffi_type_float; + dbl_arg_types[1] = &cls_struct_type1; + dbl_arg_types[2] = NULL; + + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type1, + dbl_arg_types) == FFI_OK); + + args_dbl[0] = &e_dbl; + args_dbl[1] = &f_dbl; + args_dbl[2] = NULL; + + ffi_call(&cif, FFI_FN(B_fn), &res_dbl, args_dbl); + /* { dg-output "12.125 24.75 31.625 32.25: 36.875 43.75 44.375" } */ + CHECK( res_dbl.x == (e_dbl + f_dbl.x)); + CHECK( res_dbl.y.a == (e_dbl + f_dbl.y.a)); + CHECK( res_dbl.y.b == (e_dbl + f_dbl.y.b)); + + CHECK(ffi_prep_closure_loc(pcl, &cif, B_gn, NULL, code) == FFI_OK); + + res_dbl = ((B(*)(float, B))(code))(e_dbl, f_dbl); + /* { dg-output "\n12.125 24.75 31.625 32.25: 36.875 43.75 44.375" } */ + CHECK( res_dbl.x == (e_dbl + f_dbl.x)); + CHECK( res_dbl.y.a == (e_dbl + f_dbl.y.a)); + CHECK( res_dbl.y.b == (e_dbl + f_dbl.y.b)); + + exit(0); +} |