| 1 |
#include "ffi_platypus.h" |
| 2 |
|
| 3 |
long double |
| 4 |
my_long_double(long double a, long double b) |
| 5 |
{ |
| 6 |
if(a != 1.0L || b != 3.0L) |
| 7 |
exit(2); |
| 8 |
return a+b; |
| 9 |
} |
| 10 |
|
| 11 |
int |
| 12 |
dlmain(int argc, char *argv[]) |
| 13 |
{ |
| 14 |
ffi_cif cif; |
| 15 |
ffi_type *args[2]; |
| 16 |
void *values[2]; |
| 17 |
|
| 18 |
if(&ffi_type_longdouble == &ffi_type_double) |
| 19 |
return 2; |
| 20 |
|
| 21 |
args[0] = &ffi_type_longdouble; |
| 22 |
args[1] = &ffi_type_longdouble; |
| 23 |
|
| 24 |
if(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &ffi_type_longdouble, args) == FFI_OK) |
| 25 |
{ |
| 26 |
long double answer; |
| 27 |
long double a = 1.0L; |
| 28 |
long double b = 3.0L; |
| 29 |
values[0] = &a; |
| 30 |
values[1] = &b; |
| 31 |
ffi_call(&cif, (void*) my_long_double, &answer, values); |
| 32 |
if(answer == 4.0L) |
| 33 |
return 0; |
| 34 |
} |
| 35 |
|
| 36 |
return 2; |
| 37 |
} |