Sha256: 9eff70a5e26f415f5e888c8cd1e52d9f9a652295210cd69bf3b4d031dc57809a

Contents?: true

Size: 1.01 KB

Versions: 4056

Compression:

Stored size: 1.01 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 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

4,056 entries across 4,040 versions & 38 rubygems

Version Path
mux_ruby-3.11.1 vendor/bundle/ruby/3.2.0/gems/ffi-1.15.5/ext/ffi_c/libffi/testsuite/libffi.call/struct10.c
mux_ruby-3.11.0 vendor/bundle/ruby/3.2.0/gems/ffi-1.15.5/ext/ffi_c/libffi/testsuite/libffi.call/struct10.c
cybrid_api_bank_ruby-0.94.31 vendor/bundle/ruby/3.2.0/gems/ffi-1.15.5/ext/ffi_c/libffi/testsuite/libffi.call/struct10.c
cybrid_api_organization_ruby-0.94.31 vendor/bundle/ruby/3.2.0/gems/ffi-1.15.5/ext/ffi_c/libffi/testsuite/libffi.call/struct10.c
cybrid_api_id_ruby-0.94.31 vendor/bundle/ruby/3.2.0/gems/ffi-1.15.5/ext/ffi_c/libffi/testsuite/libffi.call/struct10.c
cybrid_api_bank_ruby-0.94.30 vendor/bundle/ruby/3.2.0/gems/ffi-1.15.5/ext/ffi_c/libffi/testsuite/libffi.call/struct10.c
cybrid_api_organization_ruby-0.94.30 vendor/bundle/ruby/3.2.0/gems/ffi-1.15.5/ext/ffi_c/libffi/testsuite/libffi.call/struct10.c
cybrid_api_id_ruby-0.94.30 vendor/bundle/ruby/3.2.0/gems/ffi-1.15.5/ext/ffi_c/libffi/testsuite/libffi.call/struct10.c
cybrid_api_bank_ruby-0.94.29 vendor/bundle/ruby/3.2.0/gems/ffi-1.15.5/ext/ffi_c/libffi/testsuite/libffi.call/struct10.c
cybrid_api_id_ruby-0.94.29 vendor/bundle/ruby/3.2.0/gems/ffi-1.15.5/ext/ffi_c/libffi/testsuite/libffi.call/struct10.c
cybrid_api_organization_ruby-0.94.29 vendor/bundle/ruby/3.2.0/gems/ffi-1.15.5/ext/ffi_c/libffi/testsuite/libffi.call/struct10.c
ory-client-1.2.9 vendor/bundle/ruby/2.5.0/gems/ffi-1.15.5/ext/ffi_c/libffi/testsuite/libffi.call/struct10.c
cybrid_api_bank_ruby-0.94.27 vendor/bundle/ruby/3.2.0/gems/ffi-1.15.5/ext/ffi_c/libffi/testsuite/libffi.call/struct10.c
cybrid_api_organization_ruby-0.94.27 vendor/bundle/ruby/3.2.0/gems/ffi-1.15.5/ext/ffi_c/libffi/testsuite/libffi.call/struct10.c
cybrid_api_id_ruby-0.94.27 vendor/bundle/ruby/3.2.0/gems/ffi-1.15.5/ext/ffi_c/libffi/testsuite/libffi.call/struct10.c
cybrid_api_id_ruby-0.94.26 vendor/bundle/ruby/3.2.0/gems/ffi-1.15.5/ext/ffi_c/libffi/testsuite/libffi.call/struct10.c
cybrid_api_bank_ruby-0.94.26 vendor/bundle/ruby/3.2.0/gems/ffi-1.15.5/ext/ffi_c/libffi/testsuite/libffi.call/struct10.c
cybrid_api_organization_ruby-0.94.26 vendor/bundle/ruby/3.2.0/gems/ffi-1.15.5/ext/ffi_c/libffi/testsuite/libffi.call/struct10.c
cybrid_api_bank_ruby-0.94.25 vendor/bundle/ruby/3.2.0/gems/ffi-1.15.5/ext/ffi_c/libffi/testsuite/libffi.call/struct10.c
cybrid_api_organization_ruby-0.94.25 vendor/bundle/ruby/3.2.0/gems/ffi-1.15.5/ext/ffi_c/libffi/testsuite/libffi.call/struct10.c