This is the mail archive of the
libffi-discuss@sourceware.org
mailing list for the libffi project.
[PATCH] Use plain old %f format specifier for doubles
- From: Peter Rosin <peda at lysator dot liu dot se>
- To: libffi-discuss at sourceware dot org
- Cc: Peter Rosin <peda at lysator dot liu dot se>
- Date: Wed, 21 Mar 2012 09:59:07 +0100
- Subject: [PATCH] Use plain old %f format specifier for doubles
---
ChangeLog | 6 ++++++
testsuite/libffi.call/float_va.c | 14 +++++++-------
2 files changed, 13 insertions(+), 7 deletions(-)
Hi!
Another trivial patch, fixes testsuite failures on MinGW, which
has different sizes for double and long double.
Cheers,
Peter
diff --git a/ChangeLog b/ChangeLog
index bb5bc16..04c286f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2012-03-21 Peter Rosin <peda@lysator.liu.se>
+
+ * testsuite/libffi.call/float_va.c (float_va_fn): Use %f when
+ printing doubles (%lf is for long doubles).
+ (main): Likewise.
+
2012-03-03 H.J. Lu <hongjiu.lu@intel.com>
* src/x86/ffi64.c (ffi_call): Cast the return value to unsigned
diff --git a/testsuite/libffi.call/float_va.c b/testsuite/libffi.call/float_va.c
index 2039ae5..aae158e 100644
--- a/testsuite/libffi.call/float_va.c
+++ b/testsuite/libffi.call/float_va.c
@@ -25,18 +25,18 @@ double float_va_fn(unsigned int x, double y,...)
total+=(double)x;
total+=y;
- printf("%u: %.1lf :", x, 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:%.1lf ", i, arg);
+ printf(" %d:%.1f ", i, arg);
}
va_end(ap);
- printf(" total: %.1lf\n", total);
+ printf(" total: %.1f\n", total);
return total;
}
@@ -57,7 +57,7 @@ int main (void)
/* Call it statically and then via ffi */
resfp=float_va_fn(0,2.0);
// { dg-output "0: 2.0 : total: 2.0" }
- printf("compiled: %.1lf\n", resfp);
+ printf("compiled: %.1f\n", resfp);
// { dg-output "\ncompiled: 2.0" }
arg_types[0] = &ffi_type_uint;
@@ -72,14 +72,14 @@ int main (void)
values[1] = &doubles[0];
ffi_call(&cif, FFI_FN(float_va_fn), &resfp, values);
// { dg-output "\n0: 2.0 : total: 2.0" }
- printf("ffi: %.1lf\n", resfp);
+ 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: %.1lf\n", resfp);
+ printf("compiled: %.1f\n", resfp);
// { dg-output "\ncompiled: 11.0" }
arg_types[0] = &ffi_type_uint;
@@ -100,7 +100,7 @@ int main (void)
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: %.1lf\n", resfp);
+ printf("ffi: %.1f\n", resfp);
// { dg-output "\nffi: 11.0" }
exit(0);
--
1.7.9