Sha256: d4fde2abab766080818f3950967c1d1c4e9cf09506687d609dfe1d24d23879bf

Contents?: true

Size: 1.15 KB

Versions: 1578

Compression:

Stored size: 1.15 KB

Contents

/* Area:	ffi_call
   Purpose:	Check structures.
   Limitations:	none.
   PR:		none.
   Originator:	From the original ffitest.c  */

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

typedef struct
{
  float f;
} s55;

static s55 ABI_ATTR f55(s55 ts, float f)
{
  s55 r;
  r.f = ts.f + f;
  printf ("f55>> %g + %g = %g\n", ts.f, f, r.f);
  return r;
}

int main (void)
{
  ffi_cif cif;
  s55 F, Fr;
  float f;
  void *values[] = { &F, &f };
  ffi_type s55_type;
  ffi_type *args[] = { &s55_type, &ffi_type_float };
  ffi_type *s55_type_elements[] = { &ffi_type_float, NULL };

  /* This is a hack to get a properly aligned result buffer */
  s55 *s55_result =
    (s55 *) malloc (sizeof(s55));

  s55_type.size = 0;
  s55_type.alignment = 0;
  s55_type.type = FFI_TYPE_STRUCT;
  s55_type.elements = s55_type_elements;

  /* Initialize the cif */
  CHECK(ffi_prep_cif(&cif, ABI_NUM, 2, &s55_type, args) == FFI_OK);

  F.f = 1;
  Fr = f55(F, 2.14);
  printf ("%g\n", Fr.f);

  F.f = 1;
  f = 2.14;
  ffi_call(&cif, FFI_FN(f55), s55_result, values);
  printf ("%g\n", s55_result->f);

  fflush(0);

  CHECK(fabs(Fr.f - s55_result->f) < FLT_EPSILON);

  free (s55_result);
  exit(0);
}

Version data entries

1,578 entries across 1,578 versions & 15 rubygems

Version Path
ory-client-1.16.2 vendor/bundle/ruby/3.1.0/gems/ffi-1.17.1/ext/ffi_c/libffi/testsuite/libffi.call/s55.c
ory-client-1.16.1 vendor/bundle/ruby/3.1.0/gems/ffi-1.17.1/ext/ffi_c/libffi/testsuite/libffi.call/s55.c
ory-client-1.16.0 vendor/bundle/ruby/3.1.0/gems/ffi-1.17.1/ext/ffi_c/libffi/testsuite/libffi.call/s55.c
ory-client-1.15.17 vendor/bundle/ruby/3.1.0/gems/ffi-1.17.1/ext/ffi_c/libffi/testsuite/libffi.call/s55.c
ffi-1.17.1 ext/ffi_c/libffi/testsuite/libffi.call/s55.c
ory-client-1.15.16 vendor/bundle/ruby/3.1.0/gems/ffi-1.17.0/ext/ffi_c/libffi/testsuite/libffi.call/s55.c
ory-client-1.15.15 vendor/bundle/ruby/3.1.0/gems/ffi-1.17.0/ext/ffi_c/libffi/testsuite/libffi.call/s55.c
ory-client-1.15.14 vendor/bundle/ruby/3.1.0/gems/ffi-1.17.0/ext/ffi_c/libffi/testsuite/libffi.call/s55.c
ory-client-1.15.13 vendor/bundle/ruby/3.1.0/gems/ffi-1.17.0/ext/ffi_c/libffi/testsuite/libffi.call/s55.c
cloudsmith-api-2.0.16 vendor/bundle/ruby/2.6.0/gems/ffi-1.17.0/ext/ffi_c/libffi/testsuite/libffi.call/s55.c
affixapi-1.1.102 vendor/bundle/ruby/3.3.0/gems/ffi-1.16.3/ext/ffi_c/libffi/testsuite/libffi.call/s55.c
mux_ruby-3.20.0 vendor/bundle/ruby/3.2.0/gems/ffi-1.16.3/ext/ffi_c/libffi/testsuite/libffi.call/s55.c
ory-client-1.15.12 vendor/bundle/ruby/3.1.0/gems/ffi-1.17.0/ext/ffi_c/libffi/testsuite/libffi.call/s55.c
direct7-0.0.18 vendor/bundle/ruby/2.7.0/gems/ffi-1.16.3/ext/ffi_c/libffi/testsuite/libffi.call/s55.c
direct7-0.0.17 vendor/bundle/ruby/2.7.0/gems/ffi-1.16.3/ext/ffi_c/libffi/testsuite/libffi.call/s55.c
ory-client-1.15.10 vendor/bundle/ruby/3.1.0/gems/ffi-1.17.0/ext/ffi_c/libffi/testsuite/libffi.call/s55.c
mux_ruby-3.19.0 vendor/bundle/ruby/3.2.0/gems/ffi-1.16.3/ext/ffi_c/libffi/testsuite/libffi.call/s55.c
direct7-0.0.16 vendor/bundle/ruby/2.7.0/gems/ffi-1.16.3/ext/ffi_c/libffi/testsuite/libffi.call/s55.c
ory-client-1.15.7 vendor/bundle/ruby/3.1.0/gems/ffi-1.17.0/ext/ffi_c/libffi/testsuite/libffi.call/s55.c
affixapi-1.1.101 vendor/bundle/ruby/3.3.0/gems/ffi-1.16.3/ext/ffi_c/libffi/testsuite/libffi.call/s55.c