return_ldl.c 704 B

1234567891011121314151617181920212223242526272829303132333435
  1. /* Area: ffi_call
  2. Purpose: Check return value long double.
  3. Limitations: none.
  4. PR: none.
  5. Originator: <andreast@gcc.gnu.org> 20071113 */
  6. /* { dg-do run } */
  7. #include "ffitest.h"
  8. static long double return_ldl(long double ldl)
  9. {
  10. return 2*ldl;
  11. }
  12. int main (void)
  13. {
  14. ffi_cif cif;
  15. ffi_type *args[MAX_ARGS];
  16. void *values[MAX_ARGS];
  17. long double ldl, rldl;
  18. args[0] = &ffi_type_longdouble;
  19. values[0] = &ldl;
  20. /* Initialize the cif */
  21. CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
  22. &ffi_type_longdouble, args) == FFI_OK);
  23. for (ldl = -127.0; ldl < 127.0; ldl++)
  24. {
  25. ffi_call(&cif, FFI_FN(return_ldl), &rldl, values);
  26. CHECK(rldl == 2 * ldl);
  27. }
  28. exit(0);
  29. }