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