Sha256: 0d0bda3ced70cc32cabdb0e470438c5666dbbbc6900c8e4f2d5f77f06a55917a

Contents?: true

Size: 1.77 KB

Versions: 1568

Compression:

Stored size: 1.77 KB

Contents

/* Area:	ffi_call, closure_call
   Purpose:	Check passing of multiple unsigned short values.
   Limitations:	none.
   PR:		PR13221.
   Originator:	<andreast@gcc.gnu.org> 20031129  */

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

static unsigned short test_func_fn(unsigned short a1, unsigned short a2)
{
  unsigned short result;

  result = a1 + a2;

  printf("%d %d: %d\n", a1, a2, result);

  CHECK(a1 == 2);
  CHECK(a2 == 32765);
  CHECK(result == 32767);

  return result;
}

static void test_func_gn(ffi_cif *cif __UNUSED__, void *rval, void **avals,
			 void *data __UNUSED__)
{
  unsigned short a1, a2;

  a1 = *(unsigned short *)avals[0];
  a2 = *(unsigned short *)avals[1];

  *(ffi_arg *)rval = test_func_fn(a1, a2);

}

typedef unsigned short (*test_type)(unsigned short, unsigned short);

int main (void)
{
  ffi_cif cif;
  void *code;
  ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
  void * args_dbl[3];
  ffi_type * cl_arg_types[3];
  ffi_arg res_call;
  unsigned short a, b, res_closure;

  a = 2;
  b = 32765;

  args_dbl[0] = &a;
  args_dbl[1] = &b;
  args_dbl[2] = NULL;

  cl_arg_types[0] = &ffi_type_ushort;
  cl_arg_types[1] = &ffi_type_ushort;
  cl_arg_types[2] = NULL;

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

  ffi_call(&cif, FFI_FN(test_func_fn), &res_call, args_dbl);
  /* { dg-output "2 32765: 32767" } */
  printf("res: %d\n", (unsigned short)res_call);
  /* { dg-output "\nres: 32767" } */

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

  res_closure = (*((test_type)code))(2, 32765);
  /* { dg-output "\n2 32765: 32767" } */
  printf("res: %d\n", res_closure);
  /* { dg-output "\nres: 32767" } */
  CHECK(res_closure == 32767);

  exit(0);
}

Version data entries

1,568 entries across 1,568 versions & 15 rubygems

Version Path
affixapi-1.1.102 vendor/bundle/ruby/3.3.0/gems/ffi-1.16.3/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_ushort.c
mux_ruby-3.20.0 vendor/bundle/ruby/3.2.0/gems/ffi-1.16.3/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_ushort.c
ory-client-1.15.12 vendor/bundle/ruby/3.1.0/gems/ffi-1.17.0/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_ushort.c
direct7-0.0.18 vendor/bundle/ruby/2.7.0/gems/ffi-1.16.3/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_ushort.c
direct7-0.0.17 vendor/bundle/ruby/2.7.0/gems/ffi-1.16.3/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_ushort.c
ory-client-1.15.10 vendor/bundle/ruby/3.1.0/gems/ffi-1.17.0/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_ushort.c
mux_ruby-3.19.0 vendor/bundle/ruby/3.2.0/gems/ffi-1.16.3/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_ushort.c
direct7-0.0.16 vendor/bundle/ruby/2.7.0/gems/ffi-1.16.3/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_ushort.c
ory-client-1.15.7 vendor/bundle/ruby/3.1.0/gems/ffi-1.17.0/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_ushort.c
affixapi-1.1.101 vendor/bundle/ruby/3.3.0/gems/ffi-1.16.3/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_ushort.c
ory-client-1.15.6 vendor/bundle/ruby/3.1.0/gems/ffi-1.17.0/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_ushort.c
affixapi-1.1.100 vendor/bundle/ruby/3.3.0/gems/ffi-1.16.3/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_ushort.c
affixapi-1.1.99 vendor/bundle/ruby/3.3.0/gems/ffi-1.16.3/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_ushort.c
cloudsmith-api-2.0.15 vendor/bundle/ruby/2.6.0/gems/ffi-1.17.0/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_ushort.c
ory-client-1.15.5 vendor/bundle/ruby/3.1.0/gems/ffi-1.17.0/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_ushort.c
cloudsmith-api-2.0.14 vendor/bundle/ruby/2.6.0/gems/ffi-1.17.0/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_ushort.c
ory-client-1.15.4 vendor/bundle/ruby/3.1.0/gems/ffi-1.17.0/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_ushort.c
ory-client-1.15.3 vendor/bundle/ruby/3.1.0/gems/ffi-1.17.0/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_ushort.c
ory-client-1.15.0 vendor/bundle/ruby/3.1.0/gems/ffi-1.17.0/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_ushort.c
affixapi-1.1.94 vendor/bundle/ruby/3.3.0/gems/ffi-1.16.3/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_ushort.c