Sha256: 52c8c953db75b5012591d77c5e693e89e172d3fd18eb832a8ac3de7d20eb174d

Contents?: true

Size: 1.02 KB

Versions: 1581

Compression:

Stored size: 1.02 KB

Contents

/* Area:	ffi_call
   Purpose:	Check structures.
   Limitations:	none.
   PR:		none.
   Originator:	Sergei Trofimovich <slyfox@gentoo.org>

   The test originally discovered in ruby's bindings
   for ffi in https://bugs.gentoo.org/634190  */

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

struct s {
  int s32;
  float f32;
  signed char s8;
};

struct s ABI_ATTR make_s(void) {
  struct s r;
  r.s32 = 0x1234;
  r.f32 = 7.0;
  r.s8  = 0x78;
  return r;
}

int main() {
  ffi_cif cif;
  struct s r;
  ffi_type rtype;
  ffi_type* s_fields[] = {
    &ffi_type_sint,
    &ffi_type_float,
    &ffi_type_schar,
    NULL,
  };

  rtype.size      = 0;
  rtype.alignment = 0,
  rtype.type      = FFI_TYPE_STRUCT,
  rtype.elements  = s_fields,

  r.s32 = 0xbad;
  r.f32 = 999.999;
  r.s8  = 0x51;

  // Here we emulate the following call:
  //r = make_s();

  CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 0, &rtype, NULL) == FFI_OK);
  ffi_call(&cif, FFI_FN(make_s), &r, NULL);

  CHECK(r.s32 == 0x1234);
  CHECK(r.f32 == 7.0);
  CHECK(r.s8  == 0x78);
  exit(0);
}

Version data entries

1,581 entries across 1,580 versions & 16 rubygems

Version Path
ory-client-1.14.2 vendor/bundle/ruby/3.1.0/gems/ffi-1.17.0/ext/ffi_c/libffi/testsuite/libffi.call/struct10.c
affixapi-1.1.90 vendor/bundle/ruby/3.3.0/gems/ffi-1.16.3/ext/ffi_c/libffi/testsuite/libffi.call/struct10.c
ory-kratos-client-1.2.1 vendor/bundle/ruby/3.1.0/gems/ffi-1.17.0/ext/ffi_c/libffi/testsuite/libffi.call/struct10.c
ory-client-1.14.1 vendor/bundle/ruby/3.1.0/gems/ffi-1.17.0/ext/ffi_c/libffi/testsuite/libffi.call/struct10.c
ory-client-1.14.0 vendor/bundle/ruby/3.1.0/gems/ffi-1.17.0/ext/ffi_c/libffi/testsuite/libffi.call/struct10.c
affixapi-1.1.89 vendor/bundle/ruby/3.3.0/gems/ffi-1.16.3/ext/ffi_c/libffi/testsuite/libffi.call/struct10.c
ory-hydra-client-2.2.1 vendor/bundle/ruby/3.1.0/gems/ffi-1.17.0/ext/ffi_c/libffi/testsuite/libffi.call/struct10.c
ory-oathkeeper-client-0.40.8 vendor/bundle/ruby/3.1.0/gems/ffi-1.17.0/ext/ffi_c/libffi/testsuite/libffi.call/struct10.c
ory-client-1.13.10 vendor/bundle/ruby/3.1.0/gems/ffi-1.17.0/ext/ffi_c/libffi/testsuite/libffi.call/struct10.c
ory-client-1.13.6 vendor/bundle/ruby/3.1.0/gems/ffi-1.17.0/ext/ffi_c/libffi/testsuite/libffi.call/struct10.c
ory-client-1.13.4 vendor/bundle/ruby/3.1.0/gems/ffi-1.17.0/ext/ffi_c/libffi/testsuite/libffi.call/struct10.c
ory-client-1.13.3 vendor/bundle/ruby/3.1.0/gems/ffi-1.17.0/ext/ffi_c/libffi/testsuite/libffi.call/struct10.c
ory-client-1.13.2 vendor/bundle/ruby/3.1.0/gems/ffi-1.17.0/ext/ffi_c/libffi/testsuite/libffi.call/struct10.c
ory-client-1.13.1 vendor/bundle/ruby/3.1.0/gems/ffi-1.17.0/ext/ffi_c/libffi/testsuite/libffi.call/struct10.c
ory-client-1.13.0 vendor/bundle/ruby/3.1.0/gems/ffi-1.17.0/ext/ffi_c/libffi/testsuite/libffi.call/struct10.c
mux_ruby-3.17.0 vendor/bundle/ruby/3.2.0/gems/ffi-1.16.3/ext/ffi_c/libffi/testsuite/libffi.call/struct10.c
affixapi-1.1.88 vendor/bundle/ruby/3.3.0/gems/ffi-1.16.3/ext/ffi_c/libffi/testsuite/libffi.call/struct10.c
affixapi-1.1.87 vendor/bundle/ruby/3.3.0/gems/ffi-1.16.3/ext/ffi_c/libffi/testsuite/libffi.call/struct10.c
affixapi-1.1.86 vendor/bundle/ruby/3.3.0/gems/ffi-1.16.3/ext/ffi_c/libffi/testsuite/libffi.call/struct10.c
affixapi-1.1.85 vendor/bundle/ruby/3.3.0/gems/ffi-1.16.3/ext/ffi_c/libffi/testsuite/libffi.call/struct10.c