Sha256: e4d77d7429534df9a6e265ebac43dd25ea5fb3f5a4d5f740472245f78938830c

Contents?: true

Size: 1.65 KB

Versions: 5636

Compression:

Stored size: 1.65 KB

Contents

/* Area:	closure_call
   Purpose:	Check register allocation for closure calls with many float and double arguments
   Limitations:	none.
   PR:		none.
   Originator:	<david.schneider@picle.org> */

/* { dg-do run } */
#include "ffitest.h"
#include <float.h>
#include <math.h>

#define NARGS 16

static void cls_mixed_float_double_fn(ffi_cif* cif , void* ret, void** args,
			      void* userdata __UNUSED__)
{
    double r = 0;
    unsigned int i;
    double t;
    for(i=0; i < cif->nargs; i++)
    {
        if(cif->arg_types[i] == &ffi_type_double) {
				t = *(((double**)(args))[i]);
        } else {
				t = *(((float**)(args))[i]);
        }
        r += t;
    }
    *((double*)ret) = r;
}
typedef double (*cls_mixed)(double, float, double, double, double, double, double, float, float, double, float, float);

int main (void)
{
    ffi_cif cif;
    ffi_closure *closure;
	void* code;
    ffi_type *argtypes[12] = {&ffi_type_double, &ffi_type_float, &ffi_type_double,
                          &ffi_type_double, &ffi_type_double, &ffi_type_double,
                          &ffi_type_double, &ffi_type_float, &ffi_type_float,
                          &ffi_type_double, &ffi_type_float, &ffi_type_float};


    closure = ffi_closure_alloc(sizeof(ffi_closure), (void**)&code);
    if(closure ==NULL)
		abort();
    CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 12, &ffi_type_double, argtypes) == FFI_OK);
	CHECK(ffi_prep_closure_loc(closure, &cif, cls_mixed_float_double_fn, NULL,  code) == FFI_OK);
    double ret = ((cls_mixed)code)(0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2);
    ffi_closure_free(closure);
	if(fabs(ret - 7.8) < FLT_EPSILON)
		exit(0);
	else
		abort();
}

Version data entries

5,636 entries across 5,619 versions & 41 rubygems

Version Path
ory-client-1.13.1 vendor/bundle/ruby/3.1.0/gems/ffi-1.17.0/ext/ffi_c/libffi/testsuite/libffi.closures/cls_many_mixed_float_double.c
ory-client-1.13.0 vendor/bundle/ruby/3.1.0/gems/ffi-1.17.0/ext/ffi_c/libffi/testsuite/libffi.closures/cls_many_mixed_float_double.c
mux_ruby-3.17.0 vendor/bundle/ruby/3.2.0/gems/ffi-1.16.3/ext/ffi_c/libffi/testsuite/libffi.closures/cls_many_mixed_float_double.c
affixapi-1.1.88 vendor/bundle/ruby/3.3.0/gems/ffi-1.16.3/ext/ffi_c/libffi/testsuite/libffi.closures/cls_many_mixed_float_double.c
affixapi-1.1.87 vendor/bundle/ruby/3.3.0/gems/ffi-1.16.3/ext/ffi_c/libffi/testsuite/libffi.closures/cls_many_mixed_float_double.c
affixapi-1.1.86 vendor/bundle/ruby/3.3.0/gems/ffi-1.16.3/ext/ffi_c/libffi/testsuite/libffi.closures/cls_many_mixed_float_double.c
affixapi-1.1.85 vendor/bundle/ruby/3.3.0/gems/ffi-1.16.3/ext/ffi_c/libffi/testsuite/libffi.closures/cls_many_mixed_float_double.c
affixapi-1.1.84 vendor/bundle/ruby/3.3.0/gems/ffi-1.16.3/ext/ffi_c/libffi/testsuite/libffi.closures/cls_many_mixed_float_double.c
ffi-1.17.0 ext/ffi_c/libffi/testsuite/libffi.closures/cls_many_mixed_float_double.c
cybrid_api_id_ruby-0.117.27 vendor/bundle/ruby/3.2.0/gems/ffi-1.16.3/ext/ffi_c/libffi/testsuite/libffi.closures/cls_many_mixed_float_double.c
cybrid_api_organization_ruby-0.117.27 vendor/bundle/ruby/3.2.0/gems/ffi-1.16.3/ext/ffi_c/libffi/testsuite/libffi.closures/cls_many_mixed_float_double.c
cybrid_api_bank_ruby-0.117.27 vendor/bundle/ruby/3.2.0/gems/ffi-1.16.3/ext/ffi_c/libffi/testsuite/libffi.closures/cls_many_mixed_float_double.c
cybrid_api_id_ruby-0.117.26 vendor/bundle/ruby/3.2.0/gems/ffi-1.16.3/ext/ffi_c/libffi/testsuite/libffi.closures/cls_many_mixed_float_double.c
cybrid_api_organization_ruby-0.117.26 vendor/bundle/ruby/3.2.0/gems/ffi-1.16.3/ext/ffi_c/libffi/testsuite/libffi.closures/cls_many_mixed_float_double.c
cybrid_api_bank_ruby-0.117.26 vendor/bundle/ruby/3.2.0/gems/ffi-1.16.3/ext/ffi_c/libffi/testsuite/libffi.closures/cls_many_mixed_float_double.c
cybrid_api_bank_ruby-0.117.25 vendor/bundle/ruby/3.2.0/gems/ffi-1.16.3/ext/ffi_c/libffi/testsuite/libffi.closures/cls_many_mixed_float_double.c
cybrid_api_id_ruby-0.117.25 vendor/bundle/ruby/3.2.0/gems/ffi-1.16.3/ext/ffi_c/libffi/testsuite/libffi.closures/cls_many_mixed_float_double.c
cybrid_api_organization_ruby-0.117.25 vendor/bundle/ruby/3.2.0/gems/ffi-1.16.3/ext/ffi_c/libffi/testsuite/libffi.closures/cls_many_mixed_float_double.c
cybrid_api_organization_ruby-0.117.24 vendor/bundle/ruby/3.2.0/gems/ffi-1.16.3/ext/ffi_c/libffi/testsuite/libffi.closures/cls_many_mixed_float_double.c
cybrid_api_id_ruby-0.117.24 vendor/bundle/ruby/3.2.0/gems/ffi-1.16.3/ext/ffi_c/libffi/testsuite/libffi.closures/cls_many_mixed_float_double.c