Sha256: 7d39f073da37e5dc888af4eab0903225a8406ac2ca2dfed426c10b2b76ca9d82

Contents?: true

Size: 1.1 KB

Versions: 5646

Compression:

Stored size: 1.1 KB

Contents

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

static void cls_ret_complex_fn(ffi_cif* cif __UNUSED__, void* resp, void** args,
			      void* userdata __UNUSED__)
 {
   _Complex T_C_TYPE *pa;
   _Complex T_C_TYPE *pr;
   pa = (_Complex T_C_TYPE *)args[0];
   pr = (_Complex T_C_TYPE *)resp;
   *pr = *pa;

   printf("%.6f,%.6fi: %.6f,%.6fi\n",
	  T_CONV creal (*pa), T_CONV cimag (*pa),
	  T_CONV creal (*pr), T_CONV cimag (*pr));
 }
typedef _Complex T_C_TYPE (*cls_ret_complex)(_Complex T_C_TYPE);

int main (void)
{
  ffi_cif cif;
  void *code;
  ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
  ffi_type * cl_arg_types[2];
  _Complex T_C_TYPE res;

  cl_arg_types[0] = &T_FFI_TYPE;
  cl_arg_types[1] = NULL;

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

  CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_complex_fn, NULL, code)  == FFI_OK);

  res = (*((cls_ret_complex)code))(0.125 + 128.0 * I);
  printf("res: %.6f,%.6fi\n", T_CONV creal (res), T_CONV cimag (res));
  CHECK (res == (0.125 + 128.0 * I));

  exit(0);
}

Version data entries

5,646 entries across 5,629 versions & 41 rubygems

Version Path
ffi-1.12.1 ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex.inc
ffi-1.12.0 ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex.inc
zuora_connect_ui-0.10.0 vendor/ruby/2.6.0/gems/ffi-1.11.1/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex.inc
zuora_connect_ui-0.10.0 vendor/ruby/2.6.0/gems/ffi-1.11.3/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex.inc
ffi-1.11.3 ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex.inc
vagrant-unbundled-2.2.6.2 vendor/bundle/ruby/2.6.0/gems/ffi-1.11.1/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex.inc
ffi-1.11.2 ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex.inc
zuora_connect_ui-0.9.2 vendor/ruby/2.6.0/gems/ffi-1.11.1/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex.inc
chatops-rpc-0.0.2 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/ffi-1.11.1/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex.inc
chatops-rpc-0.0.1 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/ffi-1.11.1/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex.inc
zuora_connect_ui-0.9.1 vendor/ruby/2.6.0/gems/ffi-1.11.1/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex.inc
vagrant-unbundled-2.2.6.1 vendor/bundle/ruby/2.6.0/gems/ffi-1.11.1/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex.inc
vagrant-unbundled-2.2.6.0 vendor/bundle/ruby/2.6.0/gems/ffi-1.11.1/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex.inc
zuora_connect_ui-0.9.0 vendor/ruby/2.6.0/gems/ffi-1.11.1/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex.inc
cloudsmith-api-0.44.4 vendor/bundle/ruby/2.3.0/gems/ffi-1.11.1/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex.inc
zuora_connect_ui-0.8.3 vendor/ruby/2.6.0/gems/ffi-1.11.1/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex.inc
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.5.0/gems/ffi-1.9.25/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex.inc
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.5.0/gems/ffi-1.10.0/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex.inc
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex.inc
zuora_connect_ui-0.8.2 vendor/ruby/2.6.0/gems/ffi-1.11.1/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex.inc