Sha256: f124edbd32f7b253d3cbfd5362cb54d43fef45aa801525dd68d5e9ad52d27bbf

Contents?: true

Size: 1.74 KB

Versions: 1600

Compression:

Stored size: 1.74 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;

static 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);

  CHECK_FLOAT_EQ(arg.a, 4);
  CHECK_FLOAT_EQ(arg.b, 5);
  CHECK_FLOAT_EQ(arg.c, 1);
  CHECK_FLOAT_EQ(arg.d, 8);
}

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];

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

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

  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

1,600 entries across 1,599 versions & 16 rubygems

Version Path
ory-client-1.18.5 vendor/bundle/ruby/3.1.0/gems/ffi-1.17.1/ext/ffi_c/libffi/testsuite/libffi.closures/testclosure.c
ory-client-1.18.4 vendor/bundle/ruby/3.1.0/gems/ffi-1.17.1/ext/ffi_c/libffi/testsuite/libffi.closures/testclosure.c
ory-kratos-client-1.3.8 vendor/bundle/ruby/3.1.0/gems/ffi-1.17.1/ext/ffi_c/libffi/testsuite/libffi.closures/testclosure.c
ory-kratos-client-1.3.7 vendor/bundle/ruby/3.1.0/gems/ffi-1.17.1/ext/ffi_c/libffi/testsuite/libffi.closures/testclosure.c
ory-client-1.17.2 vendor/bundle/ruby/3.1.0/gems/ffi-1.17.1/ext/ffi_c/libffi/testsuite/libffi.closures/testclosure.c
ory-kratos-client-1.3.6 vendor/bundle/ruby/3.1.0/gems/ffi-1.17.1/ext/ffi_c/libffi/testsuite/libffi.closures/testclosure.c
ory-kratos-client-1.3.6.alpha2 vendor/bundle/ruby/3.1.0/gems/ffi-1.17.1/ext/ffi_c/libffi/testsuite/libffi.closures/testclosure.c
ory-kratos-client-1.3.6.alpha1 vendor/bundle/ruby/3.1.0/gems/ffi-1.17.1/ext/ffi_c/libffi/testsuite/libffi.closures/testclosure.c
ory-kratos-client-1.3.5 vendor/bundle/ruby/3.1.0/gems/ffi-1.17.1/ext/ffi_c/libffi/testsuite/libffi.closures/testclosure.c
ory-kratos-client-1.3.4 vendor/bundle/ruby/3.1.0/gems/ffi-1.17.1/ext/ffi_c/libffi/testsuite/libffi.closures/testclosure.c
ory-client-1.17.1 vendor/bundle/ruby/3.1.0/gems/ffi-1.17.1/ext/ffi_c/libffi/testsuite/libffi.closures/testclosure.c
ory-client-1.16.10 vendor/bundle/ruby/3.1.0/gems/ffi-1.17.1/ext/ffi_c/libffi/testsuite/libffi.closures/testclosure.c
mux_ruby-4.0.0 vendor/bundle/ruby/3.2.0/gems/ffi-1.16.3/ext/ffi_c/libffi/testsuite/libffi.closures/testclosure.c
ory-client-1.16.9 vendor/bundle/ruby/3.1.0/gems/ffi-1.17.1/ext/ffi_c/libffi/testsuite/libffi.closures/testclosure.c
ory-client-1.16.7 vendor/bundle/ruby/3.1.0/gems/ffi-1.17.1/ext/ffi_c/libffi/testsuite/libffi.closures/testclosure.c
ory-hydra-client-2.4.0.alpha1 vendor/bundle/ruby/3.1.0/gems/ffi-1.17.1/ext/ffi_c/libffi/testsuite/libffi.closures/testclosure.c
ory-client-1.16.6 vendor/bundle/ruby/3.1.0/gems/ffi-1.17.1/ext/ffi_c/libffi/testsuite/libffi.closures/testclosure.c
ory-client-1.16.5 vendor/bundle/ruby/3.1.0/gems/ffi-1.17.1/ext/ffi_c/libffi/testsuite/libffi.closures/testclosure.c
ory-client-1.16.4 vendor/bundle/ruby/3.1.0/gems/ffi-1.17.1/ext/ffi_c/libffi/testsuite/libffi.closures/testclosure.c
ory-client-1.16.3 vendor/bundle/ruby/3.1.0/gems/ffi-1.17.1/ext/ffi_c/libffi/testsuite/libffi.closures/testclosure.c