Sha256: 5a5656a481d8b68b6364882069170179c46bdee442a2c4009d4ca0ae1ba6a285

Contents?: true

Size: 1.62 KB

Versions: 260

Compression:

Stored size: 1.62 KB

Contents

/* Area:	closure_call
   Purpose:	Check return value float.
   Limitations:	none.
   PR:		41908.
   Originator:	<rfm@gnu.org> 20091102	 */

/* { dg-do run } */
#include "ffitest.h"

typedef struct cls_struct_combined {
  float a;
  float b;
  float c;
  float d;
} cls_struct_combined;

void cls_struct_combined_fn(struct cls_struct_combined arg)
{
  printf("%g %g %g %g\n",
	 arg.a, arg.b,
	 arg.c, arg.d);
  fflush(stdout);
}

static void
cls_struct_combined_gn(ffi_cif* cif __UNUSED__, void* resp __UNUSED__,
        void** args, void* userdata __UNUSED__)
{
  struct cls_struct_combined a0;

  a0 = *(struct cls_struct_combined*)(args[0]);

  cls_struct_combined_fn(a0);
}


int main (void)
{
  ffi_cif cif;
  void *code;
  ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
  ffi_type* cls_struct_fields0[5];
  ffi_type cls_struct_type0;
  ffi_type* dbl_arg_types[5];

  cls_struct_type0.size = 0;
  cls_struct_type0.alignment = 0;
  cls_struct_type0.type = FFI_TYPE_STRUCT;
  cls_struct_type0.elements = cls_struct_fields0;

  struct cls_struct_combined g_dbl = {4.0, 5.0, 1.0, 8.0};

  cls_struct_fields0[0] = &ffi_type_float;
  cls_struct_fields0[1] = &ffi_type_float;
  cls_struct_fields0[2] = &ffi_type_float;
  cls_struct_fields0[3] = &ffi_type_float;
  cls_struct_fields0[4] = NULL;

  dbl_arg_types[0] = &cls_struct_type0;
  dbl_arg_types[1] = NULL;

  CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, &ffi_type_void,
		     dbl_arg_types) == FFI_OK);

  CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_combined_gn, NULL, code) == FFI_OK);

  ((void(*)(cls_struct_combined)) (code))(g_dbl);
  /* { dg-output "4 5 1 8" } */
  exit(0);
}

Version data entries

260 entries across 256 versions & 28 rubygems

Version Path
ffi-1.9.18 ext/ffi_c/libffi/testsuite/libffi.call/testclosure.c
ffi-1.9.17-x64-mingw32 ext/ffi_c/libffi/testsuite/libffi.call/testclosure.c
ffi-1.9.17-x86-mingw32 ext/ffi_c/libffi/testsuite/libffi.call/testclosure.c
ffi-1.9.17 ext/ffi_c/libffi/testsuite/libffi.call/testclosure.c
ffi-1.9.16-x64-mingw32 ext/ffi_c/libffi/testsuite/libffi.call/testclosure.c
ffi-1.9.16-x86-mingw32 ext/ffi_c/libffi/testsuite/libffi.call/testclosure.c
ffi-1.9.16 ext/ffi_c/libffi/testsuite/libffi.call/testclosure.c
ffi-1.9.15 ext/ffi_c/libffi/testsuite/libffi.call/testclosure.c
vagrant-unbundled-1.9.1.1 vendor/bundle/ruby/2.4.0/gems/ffi-1.9.10/ext/ffi_c/libffi/testsuite/libffi.call/testclosure.c
arcabouco-0.2.13 vendor/bundle/gems/ffi-1.9.14/ext/ffi_c/libffi/testsuite/libffi.call/testclosure.c
gameboard-3.1.0 vendor/bundle/ruby/2.3.0/gems/ffi-1.9.14/ext/ffi_c/libffi/testsuite/libffi.call/testclosure.c
gameboard-3.0.0 vendor/bundle/ruby/2.3.0/gems/ffi-1.9.14/ext/ffi_c/libffi/testsuite/libffi.call/testclosure.c
tdiary-5.0.2 vendor/bundle/gems/ffi-1.9.14/ext/ffi_c/libffi/testsuite/libffi.call/testclosure.c
vagrant-compose-yaml-0.1.3 vendor/bundle/ruby/2.2.0/gems/ffi-1.9.10/ext/ffi_c/libffi/testsuite/libffi.call/testclosure.c
vagrant-compose-yaml-0.1.2 vendor/bundle/ruby/2.2.0/gems/ffi-1.9.10/ext/ffi_c/libffi/testsuite/libffi.call/testclosure.c
vagrant-compose-yaml-0.1.1 vendor/bundle/ruby/2.2.0/gems/ffi-1.9.10/ext/ffi_c/libffi/testsuite/libffi.call/testclosure.c
vagrant-compose-yaml-0.1.0 vendor/bundle/ruby/2.2.0/gems/ffi-1.9.10/ext/ffi_c/libffi/testsuite/libffi.call/testclosure.c
vagrant-unbundled-1.8.5.2 vendor/bundle/ruby/2.3.0/gems/ffi-1.9.12/ext/ffi_c/libffi/testsuite/libffi.call/testclosure.c
vagrant-unbundled-1.8.5.1 vendor/bundle/ruby/2.3.0/gems/ffi-1.9.12/ext/ffi_c/libffi/testsuite/libffi.call/testclosure.c
ffi-1.9.14-x86-mingw32 ext/ffi_c/libffi/testsuite/libffi.call/testclosure.c