diff options
author | andreast <andreast@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-11-02 21:18:17 +0000 |
---|---|---|
committer | andreast <andreast@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-11-02 21:18:17 +0000 |
commit | 2f9618b6872af8b00abafe59354025f2847a4fd0 (patch) | |
tree | 95f0b6571234cb212d5311ca22bf669adf744064 /libffi | |
parent | f018965cc0bdfda6a7d8484744ca0a028e05bf50 (diff) | |
download | gcc-2f9618b6872af8b00abafe59354025f2847a4fd0.tar.gz |
2009-11-02 Andreas Tobler <a.tobler@schweiz.org>
PR libffi/41908
* testsuite/libffi.call/testclosure.c: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@153824 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libffi')
-rw-r--r-- | libffi/ChangeLog | 5 | ||||
-rw-r--r-- | libffi/testsuite/libffi.call/testclosure.c | 70 |
2 files changed, 75 insertions, 0 deletions
diff --git a/libffi/ChangeLog b/libffi/ChangeLog index 8484f0c1a3e..651a01e0b6e 100644 --- a/libffi/ChangeLog +++ b/libffi/ChangeLog @@ -1,3 +1,8 @@ +2009-11-02 Andreas Tobler <a.tobler@schweiz.org> + + PR libffi/41908 + * testsuite/libffi.call/testclosure.c: New test. + 2009-09-28 Kai Tietz <kai.tietz@onevision.com> * src/x86/win64.S (_ffi_call_win64 stack): Remove for gnu diff --git a/libffi/testsuite/libffi.call/testclosure.c b/libffi/testsuite/libffi.call/testclosure.c new file mode 100644 index 00000000000..161cc891798 --- /dev/null +++ b/libffi/testsuite/libffi.call/testclosure.c @@ -0,0 +1,70 @@ +/* Area: closure_call + Purpose: Check return value float. + Limitations: none. + PR: 41908. + Originator: <rfm@gnu.org> 20091102 */ + +/* { dg-do run } */ +#include "ffitest.h" + +typedef struct cls_struct_combined { + float a; + float b; + float c; + float d; +} cls_struct_combined; + +void cls_struct_combined_fn(struct cls_struct_combined arg) +{ + printf("%g %g %g %g\n", + arg.a, arg.b, + arg.c, arg.d); + fflush(stdout); +} + +static void +cls_struct_combined_gn(ffi_cif* cif __UNUSED__, void* resp __UNUSED__, + void** args, void* userdata __UNUSED__) +{ + struct cls_struct_combined a0; + + a0 = *(struct cls_struct_combined*)(args[0]); + + cls_struct_combined_fn(a0); +} + + +int main (void) +{ + ffi_cif cif; + void *code; + ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); + ffi_type* cls_struct_fields0[5]; + ffi_type cls_struct_type0; + ffi_type* dbl_arg_types[5]; + + cls_struct_type0.size = 0; + cls_struct_type0.alignment = 0; + cls_struct_type0.type = FFI_TYPE_STRUCT; + cls_struct_type0.elements = cls_struct_fields0; + + struct cls_struct_combined g_dbl = {4.0, 5.0, 1.0, 8.0}; + + cls_struct_fields0[0] = &ffi_type_float; + cls_struct_fields0[1] = &ffi_type_float; + cls_struct_fields0[2] = &ffi_type_float; + cls_struct_fields0[3] = &ffi_type_float; + cls_struct_fields0[4] = NULL; + + dbl_arg_types[0] = &cls_struct_type0; + dbl_arg_types[1] = NULL; + + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, &ffi_type_void, + dbl_arg_types) == FFI_OK); + + CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_combined_gn, NULL, code) == FFI_OK); + + ((void(*)(cls_struct_combined)) (code))(g_dbl); + /* { dg-output "4 5 1 8" } */ + exit(0); +} |