PowerPC: *printf in non-float-tasks
Kulpinski, Jay
Jay.Kulpinski at gd-ais.com
Wed Apr 2 15:13:57 UTC 2003
On Friday 28 March 2003 03:59 am, Sergei Organov wrote:
>
> Joel,
>
> AFAIR, there was a patch for newlib's vfprintf to don't use floating point
> when no floating-point arguments are passed. Hasn't it been incorporated
> into the newlib sources? If not then the OP may wish to apply the patch to
> his newlib.
I had this problem a _long_ time ago. At the time, this patch worked.
It's a bit of an ugly hack, but it was the simplest fix at the time.
The code was pretty convoluted, so making a more local declaration
wasn't practical. I don't know how well it applies against a newer newlib.
diff -uNr
/usr1/rtems/work-tools/original/newlib-1.8.2/newlib/libc/stdio/vfprint
f.c newlib-1.8.2/newlib/libc/stdio/vfprintf.c
--- /usr1/rtems/work-tools/original/newlib-1.8.2/newlib/libc/stdio/vfprintf.c
Mon Jul 5 13:51:05 1999
+++ newlib-1.8.2/newlib/libc/stdio/vfprintf.c Mon Jan 31 13:37:02 2000
@@ -300,7 +300,21 @@
#ifdef FLOATING_POINT
char *decimal_point = localeconv()->decimal_point;
char softsign; /* temporary negative sign for floats */
+ /*
+ * Although it is natural to declare this double here, the
+ * declaration causes gcc to save FP registers even when not
+ * printing an FP number. This results in surprising use
+ * of FP registers to print integers or strings on at least the
+ * PowerPC. A more proper solution would be to move FP printing
+ * to another file, but this does seem to work.
+ */
+#if 0
double _double; /* double precision arguments %[eEfgG] */
+#else
+ /* double precision arguments %[eEfgG] */
+ union { int i; double d; } _double_ = {0};
+#define _double (_double_.d)
+#endif
int expt; /* integer value of exponent */
int expsize; /* character count for expstr */
int ndig; /* actual number of digits returned by cvt */
More information about the users
mailing list