This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Add missing iprintf and iscanf family for SPU


Patrick Mansfield <patmans@us.ibm.com> wrote:
> On Fri, Feb 16, 2007 at 11:27:49PM +0900, Kazunori Asayama wrote:
> > Here is a patch to add definitions of iprintf() and iscanf() family
> > for SPU.
> > 
> > They are defined as macros which are just replaced with corresponding
> > functions of printf() and scanf() family, because, for SPU with
> > offloading I/O, we have no benefit by using actually restricted
> > versions.
> > 
> > Please apply the patch.
> 
> That fixes the assert problem, but can (or should) we lose the defines for
> normal compiles?
> 
> And then lose the externs for the unsupplied functions? (Now we just end
> up with two externs for some functions.)
> 
> I mean this is confusing, and we should not (strictly) prevent a user
> defined iprintf when we aren't supplying one:

Right. I had considered about the same issue too, but on the other
hand, I wanted to avoid increase of code size by linking with both of
printf family and iprintf family.

Here is an alternative approach:

  - to eliminate internal use of iprintf family, and
  - to leave iprintf family undefined.
    (or to define iprintf family as functions if required.)

Attached is a patch to implement this.
What do you think ?

----
Index: newlib/newlib/configure.host
===================================================================
--- newlib.orig/newlib/configure.host
+++ newlib/newlib/configure.host
@@ -261,6 +261,7 @@ case "${host_cpu}" in
 	libm_machine_dir=spu
 	machine_dir=spu
 	newlib_cflags="${newlib_cflags} -ffunction-sections -fdata-sections "
+	newlib_cflags="${newlib_cflags} -DNO_INTERNAL_IPRINTF"
 	;;
   *)
 	echo '***' "Newlib does not support CPU ${host_cpu}" 1>&2
Index: newlib/newlib/libc/stdlib/assert.c
===================================================================
--- newlib.orig/newlib/libc/stdlib/assert.c
+++ newlib/newlib/libc/stdlib/assert.c
@@ -47,6 +47,7 @@ Supporting OS subroutines required (only
 #include <assert.h>
 #include <stdlib.h>
 #include <stdio.h>
+#include "local.h"
 
 void
 _DEFUN (__assert, (file, line, failedexpr),
Index: newlib/newlib/libc/stdlib/eprintf.c
===================================================================
--- newlib.orig/newlib/libc/stdlib/eprintf.c
+++ newlib/newlib/libc/stdlib/eprintf.c
@@ -12,6 +12,7 @@
 
 #include <stdlib.h>
 #include <stdio.h>
+#include "local.h"
 
 void
 __eprintf (format, file, line, expression)
Index: newlib/newlib/libc/stdlib/local.h
===================================================================
--- newlib.orig/newlib/libc/stdlib/local.h
+++ newlib/newlib/libc/stdlib/local.h
@@ -5,4 +5,8 @@
 
 char *	_EXFUN(_gcvt,(struct _reent *, double , int , char *, char, int));
 
+#ifdef NO_INTERNAL_IPRINTF
+#  define fiprintf fprintf
+#endif
+
 #endif
Index: newlib/newlib/libc/stdlib/mallocr.c
===================================================================
--- newlib.orig/newlib/libc/stdlib/mallocr.c
+++ newlib/newlib/libc/stdlib/mallocr.c
@@ -3504,7 +3504,9 @@ void malloc_stats(RONEARG) RDECL
 #ifdef INTERNAL_NEWLIB
   _REENT_SMALL_CHECK_INIT(reent_ptr);
   fp = _stderr_r(reent_ptr);
+#ifndef NO_INTERNAL_IPRINTF
 #define fprintf fiprintf
+#endif
 #else
   fp = stderr;
 #endif
Index: newlib/newlib/libc/stdlib/mstats.c
===================================================================
--- newlib.orig/newlib/libc/stdlib/mstats.c
+++ newlib/newlib/libc/stdlib/mstats.c
@@ -101,6 +101,7 @@ not portable.
 #include <stdlib.h>
 #include <malloc.h>
 #include <stdio.h>
+#include "local.h"
 
 #ifndef _REENT_ONLY
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]