diff options
author | Mikhail Borisov <borisov.mikhail@gmail.com> | 2022-02-10 16:45:39 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:39 +0300 |
commit | a6a92afe03e02795227d2641b49819b687f088f8 (patch) | |
tree | f6984a1d27d5a7ec88a6fdd6e20cd5b7693b6ece /contrib/restricted/libffi/testsuite/libffi.call/float_va.c | |
parent | c6dc8b8bd530985bc4cce0137e9a5de32f1087cb (diff) | |
download | ydb-a6a92afe03e02795227d2641b49819b687f088f8.tar.gz |
Restoring authorship annotation for Mikhail Borisov <borisov.mikhail@gmail.com>. Commit 1 of 2.
Diffstat (limited to 'contrib/restricted/libffi/testsuite/libffi.call/float_va.c')
-rw-r--r-- | contrib/restricted/libffi/testsuite/libffi.call/float_va.c | 214 |
1 files changed, 107 insertions, 107 deletions
diff --git a/contrib/restricted/libffi/testsuite/libffi.call/float_va.c b/contrib/restricted/libffi/testsuite/libffi.call/float_va.c index 5acff91f66..f91d1e2500 100644 --- a/contrib/restricted/libffi/testsuite/libffi.call/float_va.c +++ b/contrib/restricted/libffi/testsuite/libffi.call/float_va.c @@ -1,107 +1,107 @@ -/* Area: fp and variadics - Purpose: check fp inputs and returns work on variadics, even the fixed params - Limitations: None - PR: none - Originator: <david.gilbert@linaro.org> 2011-01-25 - - Intended to stress the difference in ABI on ARM vfp -*/ - -/* { dg-do run } */ - -#include <stdarg.h> - -#include "ffitest.h" - -/* prints out all the parameters, and returns the sum of them all. - * 'x' is the number of variadic parameters all of which are double in this test - */ -double float_va_fn(unsigned int x, double y,...) -{ - double total=0.0; - va_list ap; - unsigned int i; - - total+=(double)x; - total+=y; - - printf("%u: %.1f :", x, y); - - va_start(ap, y); - for(i=0;i<x;i++) - { - double arg=va_arg(ap, double); - total+=arg; - printf(" %d:%.1f ", i, arg); - } - va_end(ap); - - printf(" total: %.1f\n", total); - - return total; -} - -int main (void) -{ - ffi_cif cif; - - ffi_type *arg_types[5]; - void *values[5]; - double doubles[5]; - unsigned int firstarg; - double resfp; - - /* First test, pass float_va_fn(0,2.0) - note there are no actual - * variadic parameters, but it's declared variadic so the ABI may be - * different. */ - /* Call it statically and then via ffi */ - resfp=float_va_fn(0,2.0); - /* { dg-output "0: 2.0 : total: 2.0" } */ - printf("compiled: %.1f\n", resfp); - /* { dg-output "\ncompiled: 2.0" } */ - - arg_types[0] = &ffi_type_uint; - arg_types[1] = &ffi_type_double; - arg_types[2] = NULL; - CHECK(ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 2, 2, - &ffi_type_double, arg_types) == FFI_OK); - - firstarg = 0; - doubles[0] = 2.0; - values[0] = &firstarg; - values[1] = &doubles[0]; - ffi_call(&cif, FFI_FN(float_va_fn), &resfp, values); - /* { dg-output "\n0: 2.0 : total: 2.0" } */ - printf("ffi: %.1f\n", resfp); - /* { dg-output "\nffi: 2.0" } */ - - /* Second test, float_va_fn(2,2.0,3.0,4.0), now with variadic params */ - /* Call it statically and then via ffi */ - resfp=float_va_fn(2,2.0,3.0,4.0); - /* { dg-output "\n2: 2.0 : 0:3.0 1:4.0 total: 11.0" } */ - printf("compiled: %.1f\n", resfp); - /* { dg-output "\ncompiled: 11.0" } */ - - arg_types[0] = &ffi_type_uint; - arg_types[1] = &ffi_type_double; - arg_types[2] = &ffi_type_double; - arg_types[3] = &ffi_type_double; - arg_types[4] = NULL; - CHECK(ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 2, 4, - &ffi_type_double, arg_types) == FFI_OK); - - firstarg = 2; - doubles[0] = 2.0; - doubles[1] = 3.0; - doubles[2] = 4.0; - values[0] = &firstarg; - values[1] = &doubles[0]; - values[2] = &doubles[1]; - values[3] = &doubles[2]; - ffi_call(&cif, FFI_FN(float_va_fn), &resfp, values); - /* { dg-output "\n2: 2.0 : 0:3.0 1:4.0 total: 11.0" } */ - printf("ffi: %.1f\n", resfp); - /* { dg-output "\nffi: 11.0" } */ - - exit(0); -} +/* Area: fp and variadics + Purpose: check fp inputs and returns work on variadics, even the fixed params + Limitations: None + PR: none + Originator: <david.gilbert@linaro.org> 2011-01-25 + + Intended to stress the difference in ABI on ARM vfp +*/ + +/* { dg-do run } */ + +#include <stdarg.h> + +#include "ffitest.h" + +/* prints out all the parameters, and returns the sum of them all. + * 'x' is the number of variadic parameters all of which are double in this test + */ +double float_va_fn(unsigned int x, double y,...) +{ + double total=0.0; + va_list ap; + unsigned int i; + + total+=(double)x; + total+=y; + + printf("%u: %.1f :", x, y); + + va_start(ap, y); + for(i=0;i<x;i++) + { + double arg=va_arg(ap, double); + total+=arg; + printf(" %d:%.1f ", i, arg); + } + va_end(ap); + + printf(" total: %.1f\n", total); + + return total; +} + +int main (void) +{ + ffi_cif cif; + + ffi_type *arg_types[5]; + void *values[5]; + double doubles[5]; + unsigned int firstarg; + double resfp; + + /* First test, pass float_va_fn(0,2.0) - note there are no actual + * variadic parameters, but it's declared variadic so the ABI may be + * different. */ + /* Call it statically and then via ffi */ + resfp=float_va_fn(0,2.0); + /* { dg-output "0: 2.0 : total: 2.0" } */ + printf("compiled: %.1f\n", resfp); + /* { dg-output "\ncompiled: 2.0" } */ + + arg_types[0] = &ffi_type_uint; + arg_types[1] = &ffi_type_double; + arg_types[2] = NULL; + CHECK(ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 2, 2, + &ffi_type_double, arg_types) == FFI_OK); + + firstarg = 0; + doubles[0] = 2.0; + values[0] = &firstarg; + values[1] = &doubles[0]; + ffi_call(&cif, FFI_FN(float_va_fn), &resfp, values); + /* { dg-output "\n0: 2.0 : total: 2.0" } */ + printf("ffi: %.1f\n", resfp); + /* { dg-output "\nffi: 2.0" } */ + + /* Second test, float_va_fn(2,2.0,3.0,4.0), now with variadic params */ + /* Call it statically and then via ffi */ + resfp=float_va_fn(2,2.0,3.0,4.0); + /* { dg-output "\n2: 2.0 : 0:3.0 1:4.0 total: 11.0" } */ + printf("compiled: %.1f\n", resfp); + /* { dg-output "\ncompiled: 11.0" } */ + + arg_types[0] = &ffi_type_uint; + arg_types[1] = &ffi_type_double; + arg_types[2] = &ffi_type_double; + arg_types[3] = &ffi_type_double; + arg_types[4] = NULL; + CHECK(ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 2, 4, + &ffi_type_double, arg_types) == FFI_OK); + + firstarg = 2; + doubles[0] = 2.0; + doubles[1] = 3.0; + doubles[2] = 4.0; + values[0] = &firstarg; + values[1] = &doubles[0]; + values[2] = &doubles[1]; + values[3] = &doubles[2]; + ffi_call(&cif, FFI_FN(float_va_fn), &resfp, values); + /* { dg-output "\n2: 2.0 : 0:3.0 1:4.0 total: 11.0" } */ + printf("ffi: %.1f\n", resfp); + /* { dg-output "\nffi: 11.0" } */ + + exit(0); +} |