diff options
author | Hans Boehm <boehm@acm.org> | 2000-02-25 19:13:44 +0000 |
---|---|---|
committer | Tom Tromey <tromey@cygnus.com> | 2000-02-25 19:13:44 +0000 |
commit | 81f299194986ab3c3a4a07e448dff2209ca8b116 (patch) | |
tree | 3d1ddd9e5907df213130f3823dd250c92c37a1c5 /libffi/src/ffitest.c | |
parent | 3461b4c72ce117e344e72c2ec5742e91d13689bd (diff) |
2000-02-25 Hans Boehm <boehm@acm.org>
* src/ia64/ffi.c, src/ia64/ia64_flags.h, src/ia64/unix.S: New
files.
* src/raw_api.c (ffi_translate_args): Fixed typo in argument
list.
(ffi_prep_raw_closure): Use ffi_translate_args, not
ffi_closure_translate.
* src/java_raw_api.c: New file.
* src/ffitest.c (closure_test_fn): New function.
(main): Define `rint' as long long on IA64. Added new test when
FFI_CLOSURES is defined.
* include/ffi.h.in (ALIGN): Use size_t, not unsigned.
(ffi_abi): Recognize IA64.
(ffi_raw): Added `flt' field.
Added "Java raw API" code.
* configure.in: Recognize ia64.
* Makefile.am (TARGET_SRC_IA64): New macro.
(libffi_la_common_SOURCES): Added java_raw_api.c.
(libffi_la_SOURCES): Define in IA64 case.
git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@32151 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libffi/src/ffitest.c')
-rw-r--r-- | libffi/src/ffitest.c | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/libffi/src/ffitest.c b/libffi/src/ffitest.c index 17d5d392c0b..3dd0989783c 100644 --- a/libffi/src/ffitest.c +++ b/libffi/src/ffitest.c @@ -196,6 +196,16 @@ static test_structure_5 struct5(test_structure_5 ts1, test_structure_5 ts2) return ts1; } +/* Take an int and a float argument, together with int userdata, and */ +/* return the sum. */ +static void closure_test_fn(ffi_cif* cif,void* resp,void** args, void* userdata) +{ + *(int*)resp = + *(int *)args[0] + (int)(*(float *)args[1]) + (int)(long)userdata; +} + +typedef int (*closure_test_type)(int, float); + int main(/*@unused@*/ int argc, /*@unused@*/ char *argv[]) { ffi_cif cif; @@ -214,7 +224,7 @@ int main(/*@unused@*/ int argc, /*@unused@*/ char *argv[]) signed int si1; signed int si2; -#if defined(ALPHA) || (defined(MIPS) && (_MIPS_SIM == _ABIN32)) +#if defined(ALPHA) || defined(IA64) || (defined(MIPS) && (_MIPS_SIM == _ABIN32)) long long rint; #else int rint; @@ -691,6 +701,27 @@ int main(/*@unused@*/ int argc, /*@unused@*/ char *argv[]) free (ts5_result); } +# if FFI_CLOSURES + /* A simple closure test */ + { + ffi_closure cl; + ffi_type * cl_arg_types[3]; + + cl_arg_types[0] = &ffi_type_sint; + cl_arg_types[1] = &ffi_type_float; + cl_arg_types[2] = NULL; + + /* Initialize the cif */ + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, + &ffi_type_sint, cl_arg_types) == FFI_OK); + + CHECK(ffi_prep_closure(&cl, &cif, closure_test_fn, + (void *) 3 /* userdata */) + == FFI_OK); + CHECK((*((closure_test_type)(&cl)))(1, 2.0) == 6); + } +# endif + /* If we arrived here, all is good */ (void) puts("\nLooks good. No surprises.\n"); |