cls_float.c
上传用户:fbh598
上传日期:2007-07-05
资源大小:5960k
文件大小:1k
源码类别:

Java编程

开发平台:

Unix_Linux

  1. /* Area: closure_call
  2.    Purpose: Check return value float.
  3.    Limitations: none.
  4.    PR: none.
  5.    Originator: <andreast@gcc.gnu.org> 20030828  */
  6. /* { dg-do run { xfail mips*-*-* arm*-*-* strongarm*-*-* xscale*-*-* } } */
  7. #include "ffitest.h"
  8. static void cls_ret_float_fn(ffi_cif* cif,void* resp,void** args,
  9.      void* userdata)
  10.  {
  11.    *(float *)resp = *(float *)args[0];
  12.    printf("%g: %gn",*(float *)args[0],
  13.   *(float *)resp);
  14.  }
  15. typedef float (*cls_ret_float)(float);
  16. int main (void)
  17. {
  18.   ffi_cif cif;
  19. #ifndef USING_MMAP
  20.   static ffi_closure cl;
  21. #endif
  22.   ffi_closure *pcl;
  23.   ffi_type * cl_arg_types[2];
  24.   float res;
  25. #ifdef USING_MMAP
  26.   pcl = allocate_mmap (sizeof(ffi_closure));
  27. #else
  28.   pcl = &cl;
  29. #endif
  30.   cl_arg_types[0] = &ffi_type_float;
  31.   cl_arg_types[1] = NULL;
  32.   /* Initialize the cif */
  33.   CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
  34.      &ffi_type_float, cl_arg_types) == FFI_OK);
  35.   CHECK(ffi_prep_closure(pcl, &cif, cls_ret_float_fn, NULL)  == FFI_OK);
  36.   res = ((((cls_ret_float)pcl)(-2122.12)));
  37.   /* { dg-output "\-2122.12: \-2122.12" } */
  38.   printf("res: %.6fn", res);
  39.   /* { dg-output "nres: -2122.120117" } */
  40.   exit(0);
  41. }