Sha256: cc99177798ecb57ec45b791809806454460d2a3800d516b355101b4f23e2680d

Contents?: true

Size: 1.1 KB

Versions: 5635

Compression:

Stored size: 1.1 KB

Contents

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

static _Complex T_C_TYPE f_complex(_Complex T_C_TYPE c, int x, int *py)
{
  c = -(2 * creal (c)) + (cimag (c) + 1)* I;
  *py += x;

  return c;
}

int main (void)
{
  ffi_cif cif;
  ffi_type *args[MAX_ARGS];
  void *values[MAX_ARGS];

  _Complex T_C_TYPE tc_arg;
  _Complex T_C_TYPE tc_result;
  int tc_int_arg_x;
  int tc_y;
  int *tc_ptr_arg_y = &tc_y;

  args[0] = &T_FFI_TYPE;
  args[1] = &ffi_type_sint;
  args[2] = &ffi_type_pointer;
  values[0] = &tc_arg;
  values[1] = &tc_int_arg_x;
  values[2] = &tc_ptr_arg_y;

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

  tc_arg = 1 + 7 * I;
  tc_int_arg_x = 1234;
  tc_y = 9876;
  ffi_call(&cif, FFI_FN(f_complex), &tc_result, values);

  printf ("%f,%fi %f,%fi, x %d 1234, y %d 11110\n",
	  T_CONV creal (tc_result), T_CONV cimag (tc_result),
	  T_CONV creal (2.0), T_CONV creal (8.0), tc_int_arg_x, tc_y);

  CHECK (creal (tc_result) == -2);
  CHECK (cimag (tc_result) == 8);
  CHECK (tc_int_arg_x == 1234);
  CHECK (*tc_ptr_arg_y == 11110);

  exit(0);
}

Version data entries

5,635 entries across 5,618 versions & 41 rubygems

Version Path
mux_ruby-3.20.0 vendor/bundle/ruby/3.2.0/gems/ffi-1.16.3/ext/ffi_c/libffi/testsuite/libffi.complex/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/complex.inc
direct7-0.0.18 vendor/bundle/ruby/2.7.0/gems/ffi-1.16.3/ext/ffi_c/libffi/testsuite/libffi.complex/complex.inc
direct7-0.0.17 vendor/bundle/ruby/2.7.0/gems/ffi-1.16.3/ext/ffi_c/libffi/testsuite/libffi.complex/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/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/complex.inc
direct7-0.0.16 vendor/bundle/ruby/2.7.0/gems/ffi-1.16.3/ext/ffi_c/libffi/testsuite/libffi.complex/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/complex.inc
affixapi-1.1.101 vendor/bundle/ruby/3.3.0/gems/ffi-1.16.3/ext/ffi_c/libffi/testsuite/libffi.complex/complex.inc
ory-client-1.15.6 vendor/bundle/ruby/3.1.0/gems/ffi-1.17.0/ext/ffi_c/libffi/testsuite/libffi.complex/complex.inc
affixapi-1.1.100 vendor/bundle/ruby/3.3.0/gems/ffi-1.16.3/ext/ffi_c/libffi/testsuite/libffi.complex/complex.inc
affixapi-1.1.99 vendor/bundle/ruby/3.3.0/gems/ffi-1.16.3/ext/ffi_c/libffi/testsuite/libffi.complex/complex.inc
cloudsmith-api-2.0.15 vendor/bundle/ruby/2.6.0/gems/ffi-1.17.0/ext/ffi_c/libffi/testsuite/libffi.complex/complex.inc
ory-client-1.15.5 vendor/bundle/ruby/3.1.0/gems/ffi-1.17.0/ext/ffi_c/libffi/testsuite/libffi.complex/complex.inc
cloudsmith-api-2.0.14 vendor/bundle/ruby/2.6.0/gems/ffi-1.17.0/ext/ffi_c/libffi/testsuite/libffi.complex/complex.inc
ory-client-1.15.4 vendor/bundle/ruby/3.1.0/gems/ffi-1.17.0/ext/ffi_c/libffi/testsuite/libffi.complex/complex.inc
ory-client-1.15.3 vendor/bundle/ruby/3.1.0/gems/ffi-1.17.0/ext/ffi_c/libffi/testsuite/libffi.complex/complex.inc
ory-client-1.15.0 vendor/bundle/ruby/3.1.0/gems/ffi-1.17.0/ext/ffi_c/libffi/testsuite/libffi.complex/complex.inc
affixapi-1.1.94 vendor/bundle/ruby/3.3.0/gems/ffi-1.16.3/ext/ffi_c/libffi/testsuite/libffi.complex/complex.inc
affixapi-1.1.93 vendor/bundle/ruby/3.3.0/gems/ffi-1.16.3/ext/ffi_c/libffi/testsuite/libffi.complex/complex.inc