Sha256: 93915a0c784c3383bb8480f96871384a2ac1847b097cbe69d619ab307c5fc2d6

Contents?: true

Size: 829 Bytes

Versions: 5646

Compression:

Stored size: 829 Bytes

Contents

/* -*-c-*- */
#include "ffitest.h"
#include <complex.h>

static _Complex T_C_TYPE return_c(_Complex T_C_TYPE c)
{
  printf ("%f,%fi\n", T_CONV creal (c), T_CONV cimag (c));
  return 2 * c;
}
int main (void)
{
  ffi_cif cif;
  ffi_type *args[MAX_ARGS];
  void *values[MAX_ARGS];
  _Complex T_C_TYPE c, rc, rc2;
  T_C_TYPE cr, ci;

  args[0] = &T_FFI_TYPE;
  values[0] = &c;

  /* Initialize the cif */
  CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
		     &T_FFI_TYPE, args) == FFI_OK);

  for (cr = -127.0; cr <  127; cr++)
    {
      ci = 1000.0 - cr;
      c = cr + ci * I;
      ffi_call(&cif, FFI_FN(return_c), &rc, values);
      rc2 = return_c(c);
      printf ("%f,%fi vs %f,%fi\n",
	      T_CONV creal (rc), T_CONV cimag (rc),
	      T_CONV creal (rc2), T_CONV cimag (rc2));
      CHECK(rc == 2 * c);
    }
  exit(0);
}

Version data entries

5,646 entries across 5,629 versions & 41 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.complex/return_complex.inc
ory-client-1.16.1 vendor/bundle/ruby/3.1.0/gems/ffi-1.17.1/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex.inc
ory-client-1.16.0 vendor/bundle/ruby/3.1.0/gems/ffi-1.17.1/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex.inc
ory-client-1.15.17 vendor/bundle/ruby/3.1.0/gems/ffi-1.17.1/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex.inc
ffi-1.17.1 ext/ffi_c/libffi/testsuite/libffi.complex/return_complex.inc
ory-client-1.15.16 vendor/bundle/ruby/3.1.0/gems/ffi-1.17.0/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex.inc
ory-client-1.15.15 vendor/bundle/ruby/3.1.0/gems/ffi-1.17.0/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex.inc
ory-client-1.15.14 vendor/bundle/ruby/3.1.0/gems/ffi-1.17.0/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex.inc
ory-client-1.15.13 vendor/bundle/ruby/3.1.0/gems/ffi-1.17.0/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex.inc
cloudsmith-api-2.0.16 vendor/bundle/ruby/2.6.0/gems/ffi-1.17.0/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex.inc
affixapi-1.1.102 vendor/bundle/ruby/3.3.0/gems/ffi-1.16.3/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex.inc
mux_ruby-3.20.0 vendor/bundle/ruby/3.2.0/gems/ffi-1.16.3/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex.inc
ory-client-1.15.12 vendor/bundle/ruby/3.1.0/gems/ffi-1.17.0/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex.inc
direct7-0.0.18 vendor/bundle/ruby/2.7.0/gems/ffi-1.16.3/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex.inc
direct7-0.0.17 vendor/bundle/ruby/2.7.0/gems/ffi-1.16.3/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex.inc
ory-client-1.15.10 vendor/bundle/ruby/3.1.0/gems/ffi-1.17.0/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex.inc
mux_ruby-3.19.0 vendor/bundle/ruby/3.2.0/gems/ffi-1.16.3/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex.inc
direct7-0.0.16 vendor/bundle/ruby/2.7.0/gems/ffi-1.16.3/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex.inc
ory-client-1.15.7 vendor/bundle/ruby/3.1.0/gems/ffi-1.17.0/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex.inc
affixapi-1.1.101 vendor/bundle/ruby/3.3.0/gems/ffi-1.16.3/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex.inc