[PATCH] size reduction of Cell/SPU variable argument part

Jeff Johnston jjohnstn@redhat.com
Fri Aug 10 16:32:00 GMT 2007


Hidetaka,

  There is no licensing in the files you have provided so they cannot be 
accepted asis.  Newlib does not accept unlicensed third-party code, 
proprietary code, or GPL code.  LGPL is allowed in some instances but 
has to be cordoned off to a single platform.  In this case, you cannot 
use LGPL because you are replacing existing C code that already has a 
freer license.

  As you are the author and work for Toshiba, I'm assuming you will be 
able to get permission to license the code appropriately.  See the code 
you are replacing and various other examples for samples of acceptable 
licenses. 

  I also would like to hear from other SPU maintainers with regards to 
validating that the replacement code does not break things before 
checking it in.

Regards,

-- Jeff J.

Hidetaka Takano wrote:
> Hello,
>
> I'm a developper of the Cell/B.E. Linux toolchain team.
>
> I have made the more compact library only in the variable argument part of
>  the newlib-CVS-HEAD(2007.08.09), which is related to spu stdio.
>  (PPU Externally Assisted Calls)
>
> Would you accept this patch?
> The attached excel file is the result of the comparison between the original and this patch.
>
> Best regard.
> ---
> Hidetaka TAKANO (Toshiba Information Systems (JAPAN) Corp.)
> TOSHIBA CORPORATION Semiconductor Company 
> Broadband System LSI Division
> E-MAIL: hidetaka.takano@glb.toshiba.co.jp
>
>
> ========================================================
> newlib/ChangeLog:
>
> 2007-08-xx  Hidetaka Takano  <hidetaka.takano@glb.toshiba.co.jp>
>
> 	Reduce the memory consumption of variable argument functions
> 	for SPU (cell):
> 	* libc/machine/spu/Makefile.am: Replace printf/scanf family C sources
> 	  to assembler sources.
> 	* libc/machine/spu/Makefile.in: Regenerated.
> 	* libc/machine/spu/stdio.c: Add __check_init function wrapping
> 	  CHECK_INIT macro to use from assembler routines.
> 	* libc/machine/spu/c99ppe.h: Add definitions for assembler code.
> 	* libc/machine/spu/fiprintf.S: New file.
> 	* libc/machine/spu/fiscanf.S: Ditto.
> 	* libc/machine/spu/fprintf.S: Ditto.
> 	* libc/machine/spu/fscanf.S: Ditto.
> 	* libc/machine/spu/iprintf.S: Ditto.
> 	* libc/machine/spu/iscanf.S: Ditto.
> 	* libc/machine/spu/printf.S: Ditto.
> 	* libc/machine/spu/scanf.S: Ditto.
> 	* libc/machine/spu/siprintf.S: Ditto.
> 	* libc/machine/spu/siscanf.S: Ditto.
> 	* libc/machine/spu/sniprintf.S: Ditto.
> 	* libc/machine/spu/snprintf.S: Ditto.
> 	* libc/machine/spu/sprintf.S: Ditto.
> 	* libc/machine/spu/sscanf.S: Ditto.
> 	* libc/machine/spu/stack_reg_va.S: Ditto.
> 	* libc/machine/spu/fiprintf.c: Removed. (Replaced by .S)
> 	* libc/machine/spu/fiscanf.c: Ditto.
> 	* libc/machine/spu/fprintf.c: Ditto.
> 	* libc/machine/spu/fscanf.c: Ditto.
> 	* libc/machine/spu/iprintf.c: Ditto.
> 	* libc/machine/spu/iscanf.c: Ditto.
> 	* libc/machine/spu/printf.c: Ditto.
> 	* libc/machine/spu/scanf.c: Ditto.
> 	* libc/machine/spu/siprintf.c: Ditto.
> 	* libc/machine/spu/siscanf.c: Ditto.
> 	* libc/machine/spu/sniprintf.c: Ditto.
> 	* libc/machine/spu/snprintf.c: Ditto.
> 	* libc/machine/spu/sprintf.c: Ditto.
> 	* libc/machine/spu/sscanf.c: Ditto.
>
> ========================================================
> diff -uprN head/newlib/libc/machine/spu/Makefile.am mod/newlib/libc/machine/spu/Makefile.am
> --- head/newlib/libc/machine/spu/Makefile.am	2007-06-16 01:00:46.000000000 +0900
> +++ mod/newlib/libc/machine/spu/Makefile.am	2007-07-30 18:37:52.000000000 +0900
> @@ -9,18 +9,18 @@ noinst_LIBRARIES = lib.a
>  AM_CCASFLAGS = $(INCLUDES)
>  
>  lib_a_SOURCES = setjmp.S clearerr.c creat.c fclose.c feof.c ferror.c fflush.c \
> -	fgetc.c fgetpos.c fgets.c fileno.c fiprintf.c fiscanf.c fopen.c \
> -	fprintf.c fputc.c fputs.c fread.c freopen.c fscanf.c fseek.c \
> -	fsetpos.c ftell.c fwrite.c getc.c getchar.c gets.c iprintf.c \
> -	iscanf.c memcpy.c memmove.c memset.c perror.c printf.c \
> -	putc.c putchar.c puts.c remove.c rename.c rewind.c scanf.c \
> -	setbuf.c setvbuf.c siprintf.c siscanf.c sleep.c sniprintf.c \
> -	snprintf.c sprintf.c sscanf.c stdio.c strcat.c strchr.c strcmp.c \
> +	fgetc.c fgetpos.c fgets.c fileno.c fiprintf.S fiscanf.S fopen.c \
> +	fprintf.S fputc.c fputs.c fread.c freopen.c fscanf.S fseek.c \
> +	fsetpos.c ftell.c fwrite.c getc.c getchar.c gets.c iprintf.S \
> +	iscanf.S memcpy.c memmove.c memset.c perror.c printf.S \
> +	putc.c putchar.c puts.c remove.c rename.c rewind.c scanf.S \
> +	setbuf.c setvbuf.c siprintf.S siscanf.S sleep.c sniprintf.S \
> +	snprintf.S sprintf.S sscanf.S stdio.c strcat.c strchr.c strcmp.c \
>  	strcpy.c strcspn.c strlen.c strncat.c strncmp.c strncpy.c strpbrk.c \
>  	strrchr.c strspn.c strxfrm.c tmpfile.c tmpnam.c ungetc.c usleep.c \
>  	vfiprintf.c vfiscanf.c vfprintf.c vfscanf.c viprintf.c viscanf.c \
>  	vprintf.c vscanf.c vsiprintf.c vsiscanf.c vsniprintf.c vsnprintf.c \
> -	vsprintf.c vsscanf.c
> +	vsprintf.c vsscanf.c stack_reg_va.S
>  
>  lib_a_CCASFLAGS = $(AM_CCASFLAGS)
>  lib_a_CFLAGS = $(AM_CFLAGS)
> diff -uprN head/newlib/libc/machine/spu/Makefile.in mod/newlib/libc/machine/spu/Makefile.in
> --- head/newlib/libc/machine/spu/Makefile.in	2007-06-16 01:00:46.000000000 +0900
> +++ mod/newlib/libc/machine/spu/Makefile.in	2007-07-30 18:37:52.000000000 +0900
> @@ -73,13 +73,6 @@ DIST_COMMON = $(srcdir)/../../../../conf
>  	$(srcdir)/../../../../compile $(srcdir)/../../../../compile \
>  	$(srcdir)/../../../../compile $(srcdir)/../../../../compile \
>  	$(srcdir)/../../../../compile $(srcdir)/../../../../compile \
> -	$(srcdir)/../../../../compile $(srcdir)/../../../../compile \
> -	$(srcdir)/../../../../compile $(srcdir)/../../../../compile \
> -	$(srcdir)/../../../../compile $(srcdir)/../../../../compile \
> -	$(srcdir)/../../../../compile $(srcdir)/../../../../compile \
> -	$(srcdir)/../../../../compile $(srcdir)/../../../../compile \
> -	$(srcdir)/../../../../compile $(srcdir)/../../../../compile \
> -	$(srcdir)/../../../../compile $(srcdir)/../../../../compile \
>  	$(srcdir)/../../../../compile
>  subdir = .
>  ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
> @@ -135,7 +128,8 @@ am_lib_a_OBJECTS = lib_a-setjmp.$(OBJEXT
>  	lib_a-vprintf.$(OBJEXT) lib_a-vscanf.$(OBJEXT) \
>  	lib_a-vsiprintf.$(OBJEXT) lib_a-vsiscanf.$(OBJEXT) \
>  	lib_a-vsniprintf.$(OBJEXT) lib_a-vsnprintf.$(OBJEXT) \
> -	lib_a-vsprintf.$(OBJEXT) lib_a-vsscanf.$(OBJEXT)
> +	lib_a-vsprintf.$(OBJEXT) lib_a-vsscanf.$(OBJEXT) \
> +	lib_a-stack_reg_va.$(OBJEXT)
>  lib_a_OBJECTS = $(am_lib_a_OBJECTS)
>  DEFAULT_INCLUDES = -I. -I$(srcdir)
>  depcomp =
> @@ -261,18 +255,18 @@ INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLA
>  noinst_LIBRARIES = lib.a
>  AM_CCASFLAGS = $(INCLUDES)
>  lib_a_SOURCES = setjmp.S clearerr.c creat.c fclose.c feof.c ferror.c fflush.c \
> -	fgetc.c fgetpos.c fgets.c fileno.c fiprintf.c fiscanf.c fopen.c \
> -	fprintf.c fputc.c fputs.c fread.c freopen.c fscanf.c fseek.c \
> -	fsetpos.c ftell.c fwrite.c getc.c getchar.c gets.c iprintf.c \
> -	iscanf.c memcpy.c memmove.c memset.c perror.c printf.c \
> -	putc.c putchar.c puts.c remove.c rename.c rewind.c scanf.c \
> -	setbuf.c setvbuf.c siprintf.c siscanf.c sleep.c sniprintf.c \
> -	snprintf.c sprintf.c sscanf.c stdio.c strcat.c strchr.c strcmp.c \
> +	fgetc.c fgetpos.c fgets.c fileno.c fiprintf.S fiscanf.S fopen.c \
> +	fprintf.S fputc.c fputs.c fread.c freopen.c fscanf.S fseek.c \
> +	fsetpos.c ftell.c fwrite.c getc.c getchar.c gets.c iprintf.S \
> +	iscanf.S memcpy.c memmove.c memset.c perror.c printf.S \
> +	putc.c putchar.c puts.c remove.c rename.c rewind.c scanf.S \
> +	setbuf.c setvbuf.c siprintf.S siscanf.S sleep.c sniprintf.S \
> +	snprintf.S sprintf.S sscanf.S stdio.c strcat.c strchr.c strcmp.c \
>  	strcpy.c strcspn.c strlen.c strncat.c strncmp.c strncpy.c strpbrk.c \
>  	strrchr.c strspn.c strxfrm.c tmpfile.c tmpnam.c ungetc.c usleep.c \
>  	vfiprintf.c vfiscanf.c vfprintf.c vfscanf.c viprintf.c viscanf.c \
>  	vprintf.c vscanf.c vsiprintf.c vsiscanf.c vsniprintf.c vsnprintf.c \
> -	vsprintf.c vsscanf.c
> +	vsprintf.c vsscanf.c stack_reg_va.S
>  
>  lib_a_CCASFLAGS = $(AM_CCASFLAGS)
>  lib_a_CFLAGS = $(AM_CFLAGS)
> @@ -341,6 +335,96 @@ lib_a-setjmp.o: setjmp.S
>  lib_a-setjmp.obj: setjmp.S
>  	$(CCAS) $(lib_a_CCASFLAGS) $(CCASFLAGS) -c -o lib_a-setjmp.obj `if test -f 'setjmp.S'; then $(CYGPATH_W) 'setjmp.S'; else
> $(CYGPATH_W) '$(srcdir)/setjmp.S'; fi`
>  
> +lib_a-fiprintf.o: fiprintf.S
> +	$(CCAS) $(lib_a_CCASFLAGS) $(CCASFLAGS) -c -o lib_a-fiprintf.o `test -f 'fiprintf.S' || echo '$(srcdir)/'`fiprintf.S
> +
> +lib_a-fiprintf.obj: fiprintf.S
> +	$(CCAS) $(lib_a_CCASFLAGS) $(CCASFLAGS) -c -o lib_a-fiprintf.obj `if test -f 'fiprintf.S'; then $(CYGPATH_W) 'fiprintf.S';
> else $(CYGPATH_W) '$(srcdir)/fiprintf.S'; fi`
> +
> +lib_a-fiscanf.o: fiscanf.S
> +	$(CCAS) $(lib_a_CCASFLAGS) $(CCASFLAGS) -c -o lib_a-fiscanf.o `test -f 'fiscanf.S' || echo '$(srcdir)/'`fiscanf.S
> +
> +lib_a-fiscanf.obj: fiscanf.S
> +	$(CCAS) $(lib_a_CCASFLAGS) $(CCASFLAGS) -c -o lib_a-fiscanf.obj `if test -f 'fiscanf.S'; then $(CYGPATH_W) 'fiscanf.S'; else
> $(CYGPATH_W) '$(srcdir)/fiscanf.S'; fi`
> +
> +lib_a-fprintf.o: fprintf.S
> +	$(CCAS) $(lib_a_CCASFLAGS) $(CCASFLAGS) -c -o lib_a-fprintf.o `test -f 'fprintf.S' || echo '$(srcdir)/'`fprintf.S
> +
> +lib_a-fprintf.obj: fprintf.S
> +	$(CCAS) $(lib_a_CCASFLAGS) $(CCASFLAGS) -c -o lib_a-fprintf.obj `if test -f 'fprintf.S'; then $(CYGPATH_W) 'fprintf.S'; else
> $(CYGPATH_W) '$(srcdir)/fprintf.S'; fi`
> +
> +lib_a-fscanf.o: fscanf.S
> +	$(CCAS) $(lib_a_CCASFLAGS) $(CCASFLAGS) -c -o lib_a-fscanf.o `test -f 'fscanf.S' || echo '$(srcdir)/'`fscanf.S
> +
> +lib_a-fscanf.obj: fscanf.S
> +	$(CCAS) $(lib_a_CCASFLAGS) $(CCASFLAGS) -c -o lib_a-fscanf.obj `if test -f 'fscanf.S'; then $(CYGPATH_W) 'fscanf.S'; else
> $(CYGPATH_W) '$(srcdir)/fscanf.S'; fi`
> +
> +lib_a-iprintf.o: iprintf.S
> +	$(CCAS) $(lib_a_CCASFLAGS) $(CCASFLAGS) -c -o lib_a-iprintf.o `test -f 'iprintf.S' || echo '$(srcdir)/'`iprintf.S
> +
> +lib_a-iprintf.obj: iprintf.S
> +	$(CCAS) $(lib_a_CCASFLAGS) $(CCASFLAGS) -c -o lib_a-iprintf.obj `if test -f 'iprintf.S'; then $(CYGPATH_W) 'iprintf.S'; else
> $(CYGPATH_W) '$(srcdir)/iprintf.S'; fi`
> +
> +lib_a-iscanf.o: iscanf.S
> +	$(CCAS) $(lib_a_CCASFLAGS) $(CCASFLAGS) -c -o lib_a-iscanf.o `test -f 'iscanf.S' || echo '$(srcdir)/'`iscanf.S
> +
> +lib_a-iscanf.obj: iscanf.S
> +	$(CCAS) $(lib_a_CCASFLAGS) $(CCASFLAGS) -c -o lib_a-iscanf.obj `if test -f 'iscanf.S'; then $(CYGPATH_W) 'iscanf.S'; else
> $(CYGPATH_W) '$(srcdir)/iscanf.S'; fi`
> +
> +lib_a-printf.o: printf.S
> +	$(CCAS) $(lib_a_CCASFLAGS) $(CCASFLAGS) -c -o lib_a-printf.o `test -f 'printf.S' || echo '$(srcdir)/'`printf.S
> +
> +lib_a-printf.obj: printf.S
> +	$(CCAS) $(lib_a_CCASFLAGS) $(CCASFLAGS) -c -o lib_a-printf.obj `if test -f 'printf.S'; then $(CYGPATH_W) 'printf.S'; else
> $(CYGPATH_W) '$(srcdir)/printf.S'; fi`
> +
> +lib_a-scanf.o: scanf.S
> +	$(CCAS) $(lib_a_CCASFLAGS) $(CCASFLAGS) -c -o lib_a-scanf.o `test -f 'scanf.S' || echo '$(srcdir)/'`scanf.S
> +
> +lib_a-scanf.obj: scanf.S
> +	$(CCAS) $(lib_a_CCASFLAGS) $(CCASFLAGS) -c -o lib_a-scanf.obj `if test -f 'scanf.S'; then $(CYGPATH_W) 'scanf.S'; else
> $(CYGPATH_W) '$(srcdir)/scanf.S'; fi`
> +
> +lib_a-siprintf.o: siprintf.S
> +	$(CCAS) $(lib_a_CCASFLAGS) $(CCASFLAGS) -c -o lib_a-siprintf.o `test -f 'siprintf.S' || echo '$(srcdir)/'`siprintf.S
> +
> +lib_a-siprintf.obj: siprintf.S
> +	$(CCAS) $(lib_a_CCASFLAGS) $(CCASFLAGS) -c -o lib_a-siprintf.obj `if test -f 'siprintf.S'; then $(CYGPATH_W) 'siprintf.S';
> else $(CYGPATH_W) '$(srcdir)/siprintf.S'; fi`
> +
> +lib_a-siscanf.o: siscanf.S
> +	$(CCAS) $(lib_a_CCASFLAGS) $(CCASFLAGS) -c -o lib_a-siscanf.o `test -f 'siscanf.S' || echo '$(srcdir)/'`siscanf.S
> +
> +lib_a-siscanf.obj: siscanf.S
> +	$(CCAS) $(lib_a_CCASFLAGS) $(CCASFLAGS) -c -o lib_a-siscanf.obj `if test -f 'siscanf.S'; then $(CYGPATH_W) 'siscanf.S'; else
> $(CYGPATH_W) '$(srcdir)/siscanf.S'; fi`
> +
> +lib_a-sniprintf.o: sniprintf.S
> +	$(CCAS) $(lib_a_CCASFLAGS) $(CCASFLAGS) -c -o lib_a-sniprintf.o `test -f 'sniprintf.S' || echo '$(srcdir)/'`sniprintf.S
> +
> +lib_a-sniprintf.obj: sniprintf.S
> +	$(CCAS) $(lib_a_CCASFLAGS) $(CCASFLAGS) -c -o lib_a-sniprintf.obj `if test -f 'sniprintf.S'; then $(CYGPATH_W)
> 'sniprintf.S'; else $(CYGPATH_W) '$(srcdir)/sniprintf.S'; fi`
> +
> +lib_a-snprintf.o: snprintf.S
> +	$(CCAS) $(lib_a_CCASFLAGS) $(CCASFLAGS) -c -o lib_a-snprintf.o `test -f 'snprintf.S' || echo '$(srcdir)/'`snprintf.S
> +
> +lib_a-snprintf.obj: snprintf.S
> +	$(CCAS) $(lib_a_CCASFLAGS) $(CCASFLAGS) -c -o lib_a-snprintf.obj `if test -f 'snprintf.S'; then $(CYGPATH_W) 'snprintf.S';
> else $(CYGPATH_W) '$(srcdir)/snprintf.S'; fi`
> +
> +lib_a-sprintf.o: sprintf.S
> +	$(CCAS) $(lib_a_CCASFLAGS) $(CCASFLAGS) -c -o lib_a-sprintf.o `test -f 'sprintf.S' || echo '$(srcdir)/'`sprintf.S
> +
> +lib_a-sprintf.obj: sprintf.S
> +	$(CCAS) $(lib_a_CCASFLAGS) $(CCASFLAGS) -c -o lib_a-sprintf.obj `if test -f 'sprintf.S'; then $(CYGPATH_W) 'sprintf.S'; else
> $(CYGPATH_W) '$(srcdir)/sprintf.S'; fi`
> +
> +lib_a-sscanf.o: sscanf.S
> +	$(CCAS) $(lib_a_CCASFLAGS) $(CCASFLAGS) -c -o lib_a-sscanf.o `test -f 'sscanf.S' || echo '$(srcdir)/'`sscanf.S
> +
> +lib_a-sscanf.obj: sscanf.S
> +	$(CCAS) $(lib_a_CCASFLAGS) $(CCASFLAGS) -c -o lib_a-sscanf.obj `if test -f 'sscanf.S'; then $(CYGPATH_W) 'sscanf.S'; else
> $(CYGPATH_W) '$(srcdir)/sscanf.S'; fi`
> +
> +lib_a-stack_reg_va.o: stack_reg_va.S
> +	$(CCAS) $(lib_a_CCASFLAGS) $(CCASFLAGS) -c -o lib_a-stack_reg_va.o `test -f 'stack_reg_va.S' || echo
> '$(srcdir)/'`stack_reg_va.S
> +
> +lib_a-stack_reg_va.obj: stack_reg_va.S
> +	$(CCAS) $(lib_a_CCASFLAGS) $(CCASFLAGS) -c -o lib_a-stack_reg_va.obj `if test -f 'stack_reg_va.S'; then $(CYGPATH_W)
> 'stack_reg_va.S'; else $(CYGPATH_W) '$(srcdir)/stack_reg_va.S'; fi`
> +
>  .c.o:
>  	$(COMPILE) -c $<
>  
> @@ -407,30 +491,12 @@ lib_a-fileno.o: fileno.c
>  lib_a-fileno.obj: fileno.c
>  	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fileno.obj
> `if test -f 'fileno.c'; then $(CYGPATH_W) 'fileno.c'; else $(CYGPATH_W) '$(srcdir)/fileno.c'; fi`
>  
> -lib_a-fiprintf.o: fiprintf.c
> -	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fiprintf.o
> `test -f 'fiprintf.c' || echo '$(srcdir)/'`fiprintf.c
> -
> -lib_a-fiprintf.obj: fiprintf.c
> -	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fiprintf.obj
> `if test -f 'fiprintf.c'; then $(CYGPATH_W) 'fiprintf.c'; else $(CYGPATH_W) '$(srcdir)/fiprintf.c'; fi`
> -
> -lib_a-fiscanf.o: fiscanf.c
> -	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fiscanf.o
> `test -f 'fiscanf.c' || echo '$(srcdir)/'`fiscanf.c
> -
> -lib_a-fiscanf.obj: fiscanf.c
> -	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fiscanf.obj
> `if test -f 'fiscanf.c'; then $(CYGPATH_W) 'fiscanf.c'; else $(CYGPATH_W) '$(srcdir)/fiscanf.c'; fi`
> -
>  lib_a-fopen.o: fopen.c
>  	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fopen.o `test
> -f 'fopen.c' || echo '$(srcdir)/'`fopen.c
>  
>  lib_a-fopen.obj: fopen.c
>  	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fopen.obj `if
> test -f 'fopen.c'; then $(CYGPATH_W) 'fopen.c'; else $(CYGPATH_W) '$(srcdir)/fopen.c'; fi`
>  
> -lib_a-fprintf.o: fprintf.c
> -	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fprintf.o
> `test -f 'fprintf.c' || echo '$(srcdir)/'`fprintf.c
> -
> -lib_a-fprintf.obj: fprintf.c
> -	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fprintf.obj
> `if test -f 'fprintf.c'; then $(CYGPATH_W) 'fprintf.c'; else $(CYGPATH_W) '$(srcdir)/fprintf.c'; fi`
> -
>  lib_a-fputc.o: fputc.c
>  	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fputc.o `test
> -f 'fputc.c' || echo '$(srcdir)/'`fputc.c
>  
> @@ -455,12 +521,6 @@ lib_a-freopen.o: freopen.c
>  lib_a-freopen.obj: freopen.c
>  	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-freopen.obj
> `if test -f 'freopen.c'; then $(CYGPATH_W) 'freopen.c'; else $(CYGPATH_W) '$(srcdir)/freopen.c'; fi`
>  
> -lib_a-fscanf.o: fscanf.c
> -	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fscanf.o
> `test -f 'fscanf.c' || echo '$(srcdir)/'`fscanf.c
> -
> -lib_a-fscanf.obj: fscanf.c
> -	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fscanf.obj
> `if test -f 'fscanf.c'; then $(CYGPATH_W) 'fscanf.c'; else $(CYGPATH_W) '$(srcdir)/fscanf.c'; fi`
> -
>  lib_a-fseek.o: fseek.c
>  	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fseek.o `test
> -f 'fseek.c' || echo '$(srcdir)/'`fseek.c
>  
> @@ -503,18 +563,6 @@ lib_a-gets.o: gets.c
>  lib_a-gets.obj: gets.c
>  	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-gets.obj `if
> test -f 'gets.c'; then $(CYGPATH_W) 'gets.c'; else $(CYGPATH_W) '$(srcdir)/gets.c'; fi`
>  
> -lib_a-iprintf.o: iprintf.c
> -	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-iprintf.o
> `test -f 'iprintf.c' || echo '$(srcdir)/'`iprintf.c
> -
> -lib_a-iprintf.obj: iprintf.c
> -	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-iprintf.obj
> `if test -f 'iprintf.c'; then $(CYGPATH_W) 'iprintf.c'; else $(CYGPATH_W) '$(srcdir)/iprintf.c'; fi`
> -
> -lib_a-iscanf.o: iscanf.c
> -	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-iscanf.o
> `test -f 'iscanf.c' || echo '$(srcdir)/'`iscanf.c
> -
> -lib_a-iscanf.obj: iscanf.c
> -	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-iscanf.obj
> `if test -f 'iscanf.c'; then $(CYGPATH_W) 'iscanf.c'; else $(CYGPATH_W) '$(srcdir)/iscanf.c'; fi`
> -
>  lib_a-memcpy.o: memcpy.c
>  	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-memcpy.o
> `test -f 'memcpy.c' || echo '$(srcdir)/'`memcpy.c
>  
> @@ -539,12 +587,6 @@ lib_a-perror.o: perror.c
>  lib_a-perror.obj: perror.c
>  	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-perror.obj
> `if test -f 'perror.c'; then $(CYGPATH_W) 'perror.c'; else $(CYGPATH_W) '$(srcdir)/perror.c'; fi`
>  
> -lib_a-printf.o: printf.c
> -	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-printf.o
> `test -f 'printf.c' || echo '$(srcdir)/'`printf.c
> -
> -lib_a-printf.obj: printf.c
> -	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-printf.obj
> `if test -f 'printf.c'; then $(CYGPATH_W) 'printf.c'; else $(CYGPATH_W) '$(srcdir)/printf.c'; fi`
> -
>  lib_a-putc.o: putc.c
>  	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-putc.o `test
> -f 'putc.c' || echo '$(srcdir)/'`putc.c
>  
> @@ -581,12 +623,6 @@ lib_a-rewind.o: rewind.c
>  lib_a-rewind.obj: rewind.c
>  	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-rewind.obj
> `if test -f 'rewind.c'; then $(CYGPATH_W) 'rewind.c'; else $(CYGPATH_W) '$(srcdir)/rewind.c'; fi`
>  
> -lib_a-scanf.o: scanf.c
> -	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-scanf.o `test
> -f 'scanf.c' || echo '$(srcdir)/'`scanf.c
> -
> -lib_a-scanf.obj: scanf.c
> -	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-scanf.obj `if
> test -f 'scanf.c'; then $(CYGPATH_W) 'scanf.c'; else $(CYGPATH_W) '$(srcdir)/scanf.c'; fi`
> -
>  lib_a-setbuf.o: setbuf.c
>  	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-setbuf.o
> `test -f 'setbuf.c' || echo '$(srcdir)/'`setbuf.c
>  
> @@ -599,48 +635,12 @@ lib_a-setvbuf.o: setvbuf.c
>  lib_a-setvbuf.obj: setvbuf.c
>  	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-setvbuf.obj
> `if test -f 'setvbuf.c'; then $(CYGPATH_W) 'setvbuf.c'; else $(CYGPATH_W) '$(srcdir)/setvbuf.c'; fi`
>  
> -lib_a-siprintf.o: siprintf.c
> -	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-siprintf.o
> `test -f 'siprintf.c' || echo '$(srcdir)/'`siprintf.c
> -
> -lib_a-siprintf.obj: siprintf.c
> -	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-siprintf.obj
> `if test -f 'siprintf.c'; then $(CYGPATH_W) 'siprintf.c'; else $(CYGPATH_W) '$(srcdir)/siprintf.c'; fi`
> -
> -lib_a-siscanf.o: siscanf.c
> -	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-siscanf.o
> `test -f 'siscanf.c' || echo '$(srcdir)/'`siscanf.c
> -
> -lib_a-siscanf.obj: siscanf.c
> -	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-siscanf.obj
> `if test -f 'siscanf.c'; then $(CYGPATH_W) 'siscanf.c'; else $(CYGPATH_W) '$(srcdir)/siscanf.c'; fi`
> -
>  lib_a-sleep.o: sleep.c
>  	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-sleep.o `test
> -f 'sleep.c' || echo '$(srcdir)/'`sleep.c
>  
>  lib_a-sleep.obj: sleep.c
>  	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-sleep.obj `if
> test -f 'sleep.c'; then $(CYGPATH_W) 'sleep.c'; else $(CYGPATH_W) '$(srcdir)/sleep.c'; fi`
>  
> -lib_a-sniprintf.o: sniprintf.c
> -	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-sniprintf.o
> `test -f 'sniprintf.c' || echo '$(srcdir)/'`sniprintf.c
> -
> -lib_a-sniprintf.obj: sniprintf.c
> -	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-sniprintf.obj
> `if test -f 'sniprintf.c'; then $(CYGPATH_W) 'sniprintf.c'; else $(CYGPATH_W) '$(srcdir)/sniprintf.c'; fi`
> -
> -lib_a-snprintf.o: snprintf.c
> -	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-snprintf.o
> `test -f 'snprintf.c' || echo '$(srcdir)/'`snprintf.c
> -
> -lib_a-snprintf.obj: snprintf.c
> -	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-snprintf.obj
> `if test -f 'snprintf.c'; then $(CYGPATH_W) 'snprintf.c'; else $(CYGPATH_W) '$(srcdir)/snprintf.c'; fi`
> -
> -lib_a-sprintf.o: sprintf.c
> -	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-sprintf.o
> `test -f 'sprintf.c' || echo '$(srcdir)/'`sprintf.c
> -
> -lib_a-sprintf.obj: sprintf.c
> -	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-sprintf.obj
> `if test -f 'sprintf.c'; then $(CYGPATH_W) 'sprintf.c'; else $(CYGPATH_W) '$(srcdir)/sprintf.c'; fi`
> -
> -lib_a-sscanf.o: sscanf.c
> -	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-sscanf.o
> `test -f 'sscanf.c' || echo '$(srcdir)/'`sscanf.c
> -
> -lib_a-sscanf.obj: sscanf.c
> -	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-sscanf.obj
> `if test -f 'sscanf.c'; then $(CYGPATH_W) 'sscanf.c'; else $(CYGPATH_W) '$(srcdir)/sscanf.c'; fi`
> -
>  lib_a-stdio.o: stdio.c
>  	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-stdio.o `test
> -f 'stdio.c' || echo '$(srcdir)/'`stdio.c
>  
> diff -uprN head/newlib/libc/machine/spu/c99ppe.h mod/newlib/libc/machine/spu/c99ppe.h
> --- head/newlib/libc/machine/spu/c99ppe.h	2007-04-05 06:03:13.000000000 +0900
> +++ mod/newlib/libc/machine/spu/c99ppe.h	2007-08-09 15:36:48.000000000 +0900
> @@ -30,11 +30,26 @@ POSSIBILITY OF SUCH DAMAGE.
>  Author: Joel Schopp <jschopp@austin.ibm.com>
>  */
>  
> +#define SPE_C99_SIGNALCODE 0x2100
> +
> +#ifdef __ASSEMBLER__
> +
> +#define STACK_REGS	72	/* Number of registers preserved in stack
> +				  in case of variable argument API. */
> +
> +#define SPE_C99_VFPRINTF	0x23
> +#define SPE_C99_VFSCANF	 	0x24
> +#define SPE_C99_VPRINTF	 	0x25
> +#define SPE_C99_VSCANF	 	0x26
> +#define SPE_C99_VSNPRINTF	0x27
> +#define SPE_C99_VSPRINTF	0x28
> +#define SPE_C99_VSSCANF	 	0x29
> +
> +#else /* __ASSEMBLER__ */
> +
>  #include <errno.h>
>  #include <sys/syscall.h>
>  
> -#define SPE_C99_SIGNALCODE 0x2100
> -
>  #define SPE_C99_OP_SHIFT    	24
>  #define SPE_C99_OP_MASK	    	0xff
>  #define SPE_C99_DATA_MASK   	0xffffff
> @@ -102,3 +117,5 @@ FILE  *_EXFUN(__sfp,(struct _reent *));
>    do { if ((ptr) && !(ptr)->__sdidinit) __sinit (ptr); } while (0)
>  #define CHECK_STD_INIT(ptr) /* currently, do nothing */
>  #define CHECK_STR_INIT(ptr) /* currently, do nothing */
> +
> +#endif /* __ASSEMBLER__ */
> diff -uprN head/newlib/libc/machine/spu/fiprintf.S mod/newlib/libc/machine/spu/fiprintf.S
> --- head/newlib/libc/machine/spu/fiprintf.S	1970-01-01 09:00:00.000000000 +0900
> +++ mod/newlib/libc/machine/spu/fiprintf.S	2007-08-09 15:40:49.000000000 +0900
> @@ -0,0 +1,7 @@
> +/*
> + * (C) Copyright 2007 TOSHIBA CORPORATION
> + * All Rights Reserved.
> + */
> +
> +#define fprintf    fiprintf
> +#include "fprintf.S"
> diff -uprN head/newlib/libc/machine/spu/fiprintf.c mod/newlib/libc/machine/spu/fiprintf.c
> --- head/newlib/libc/machine/spu/fiprintf.c	2007-02-21 05:58:38.000000000 +0900
> +++ mod/newlib/libc/machine/spu/fiprintf.c	1970-01-01 09:00:00.000000000 +0900
> @@ -1,2 +0,0 @@
> -#define INTEGER_ONLY
> -#include "fprintf.c"
> diff -uprN head/newlib/libc/machine/spu/fiscanf.S mod/newlib/libc/machine/spu/fiscanf.S
> --- head/newlib/libc/machine/spu/fiscanf.S	1970-01-01 09:00:00.000000000 +0900
> +++ mod/newlib/libc/machine/spu/fiscanf.S	2007-08-09 15:40:39.000000000 +0900
> @@ -0,0 +1,7 @@
> +/*
> + * (C) Copyright 2007 TOSHIBA CORPORATION
> + * All Rights Reserved.
> + */
> +
> +#define fscanf    fiscanf
> +#include "fscanf.S"
> diff -uprN head/newlib/libc/machine/spu/fiscanf.c mod/newlib/libc/machine/spu/fiscanf.c
> --- head/newlib/libc/machine/spu/fiscanf.c	2007-02-21 05:58:38.000000000 +0900
> +++ mod/newlib/libc/machine/spu/fiscanf.c	1970-01-01 09:00:00.000000000 +0900
> @@ -1,2 +0,0 @@
> -#define INTEGER_ONLY
> -#include "fscanf.c"
> diff -uprN head/newlib/libc/machine/spu/fprintf.S mod/newlib/libc/machine/spu/fprintf.S
> --- head/newlib/libc/machine/spu/fprintf.S	1970-01-01 09:00:00.000000000 +0900
> +++ mod/newlib/libc/machine/spu/fprintf.S	2007-08-09 15:40:28.000000000 +0900
> @@ -0,0 +1,38 @@
> +/*
> + * (C) Copyright 2007 TOSHIBA CORPORATION
> + * All Rights Reserved.
> + */
> +
> +#include "c99ppe.h"
> +
> +#define SIGCODE SPE_C99_SIGNALCODE
> +#define NAME    fprintf
> +#define PARMS   2
> +#define OPCODE  SPE_C99_VFPRINTF
> +#define FP      3
> +
> +#define parms	$2
> +
> +	.text
> +	.align	4
> +	GLOBL	NAME
> +NAME:
> +	stqd	$0, 16($sp)		/* save caller address */
> +	il	parms, PARMS
> +	brsl	$0, __stack_reg_va	/* save register to the stack frame */
> +
> +	brsl	$0, __check_init
> +	lqd	$3, 16*(FP-1)($sp)	/* $3 <- saved FP on the stack frame */
> +	lqd	$2, 0($3)		/* FP = fp->_fp */
> +	rotqby	$2, $2, $3
> +	stqd	$2, 16*(FP-1)($sp)	/* replace FP on the stack frame */
> +
> +	il	$3, SIGCODE		/* signal code */
> +	il	$4, OPCODE		/* op code */
> +	ai	$5, $sp, 16*2		/* data ($3 save address) */
> +	brsl	$0, __send_to_ppe
> +
> +	il	$2, 16*(STACK_REGS+2+2)
> +	a	$sp, $sp, $2
> +	lqd	$0, 16($sp)		/* load caller address */
> +	bi      $0			/* return to caller */
> diff -uprN head/newlib/libc/machine/spu/fprintf.c mod/newlib/libc/machine/spu/fprintf.c
> --- head/newlib/libc/machine/spu/fprintf.c	2007-05-24 06:41:17.000000000 +0900
> +++ mod/newlib/libc/machine/spu/fprintf.c	1970-01-01 09:00:00.000000000 +0900
> @@ -1,81 +0,0 @@
> -/*
> -(C) Copyright IBM Corp. 2006
> -
> -All rights reserved.
> -
> -Redistribution and use in source and binary forms, with or without
> -modification, are permitted provided that the following conditions are met:
> -
> -    * Redistributions of source code must retain the above copyright notice,
> -this list of conditions and the following disclaimer.
> -    * Redistributions in binary form must reproduce the above copyright
> -notice, this list of conditions and the following disclaimer in the
> -documentation and/or other materials provided with the distribution.
> -    * Neither the name of IBM nor the names of its contributors may be
> -used to endorse or promote products derived from this software without
> -specific prior written permission.
> -
> -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
> -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
> -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
> -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
> -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
> -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
> -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
> -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
> -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
> -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
> -POSSIBILITY OF SUCH DAMAGE.
> -
> -Author: Joel Schopp <jschopp@austin.ibm.com>
> -*/
> -
> -#include <_ansi.h>
> -#include <stdio.h>
> -
> -#include "c99ppe.h"
> -
> -#ifdef _HAVE_STDC
> -#include <stdarg.h>
> -#else
> -#include <varargs.h>
> -#endif
> -
> -#ifdef INTEGER_ONLY
> -#  define fprintf fiprintf
> -#endif
> -
> -typedef struct
> -{
> -  int fp;
> -  unsigned int pad0[ 3 ];
> -  _CONST char* fmt;
> -  unsigned int pad1[ 3 ];
> -  va_list ap;
> -} c99_fprintf_t;
> -
> -#ifndef _REENT_ONLY
> -
> -int
> -fprintf(FILE * fp, _CONST char *fmt,...)
> -{
> -  int ret;
> -  c99_fprintf_t args;
> -
> -  CHECK_INIT(_REENT);
> -
> -  args.fp = fp->_fp;
> -  args.fmt = (char*) fmt;
> -
> -#ifdef _HAVE_STDC
> -  va_start (args.ap, fmt);
> -#else
> -  va_start (args.ap);
> -#endif
> -
> -  ret =__send_to_ppe(SPE_C99_SIGNALCODE, SPE_C99_VFPRINTF, &args);
> -
> -  va_end (args.ap);
> -  return ret;
> -}
> -#endif /* ! _REENT_ONLY */
> diff -uprN head/newlib/libc/machine/spu/fscanf.S mod/newlib/libc/machine/spu/fscanf.S
> --- head/newlib/libc/machine/spu/fscanf.S	1970-01-01 09:00:00.000000000 +0900
> +++ mod/newlib/libc/machine/spu/fscanf.S	2007-08-09 15:40:13.000000000 +0900
> @@ -0,0 +1,38 @@
> +/*
> + * (C) Copyright 2007 TOSHIBA CORPORATION
> + * All Rights Reserved.
> + */
> +
> +#include "c99ppe.h"
> +
> +#define SIGCODE SPE_C99_SIGNALCODE
> +#define NAME    fscanf
> +#define PARMS   2
> +#define OPCODE  SPE_C99_VFSCANF
> +#define FP      3
> +
> +#define parms	$2
> +
> +	.text
> +	.align	4
> +	GLOBL	NAME
> +NAME:
> +	stqd	$0, 16($sp)		/* save caller address */
> +	il	parms, PARMS
> +	brsl	$0, __stack_reg_va	/* save register to the stack frame */
> +
> +	brsl	$0, __check_init
> +	lqd	$3, 16*(FP-1)($sp)	/* $3 <- saved FP on the stack frame */
> +	lqd	$2, 0($3)		/* FP = fp->_fp */
> +	rotqby	$2, $2, $3
> +	stqd	$2, 16*(FP-1)($sp)	/* replace FP on the stack frame */
> +
> +	il	$3, SIGCODE		/* signal code */
> +	il	$4, OPCODE		/* op code */
> +	ai	$5, $sp, 16*2		/* data ($3 save address) */
> +	brsl	$0, __send_to_ppe
> +
> +	il	$2, 16*(STACK_REGS+2+2)
> +	a	$sp, $sp, $2
> +	lqd	$0, 16($sp)		/* load caller address */
> +	bi      $0			/* return to caller */
> diff -uprN head/newlib/libc/machine/spu/fscanf.c mod/newlib/libc/machine/spu/fscanf.c
> --- head/newlib/libc/machine/spu/fscanf.c	2007-05-24 06:41:17.000000000 +0900
> +++ mod/newlib/libc/machine/spu/fscanf.c	1970-01-01 09:00:00.000000000 +0900
> @@ -1,80 +0,0 @@
> -/*
> -(C) Copyright IBM Corp. 2006
> -
> -All rights reserved.
> -
> -Redistribution and use in source and binary forms, with or without
> -modification, are permitted provided that the following conditions are met:
> -
> -    * Redistributions of source code must retain the above copyright notice,
> -this list of conditions and the following disclaimer.
> -    * Redistributions in binary form must reproduce the above copyright
> -notice, this list of conditions and the following disclaimer in the
> -documentation and/or other materials provided with the distribution.
> -    * Neither the name of IBM nor the names of its contributors may be
> -used to endorse or promote products derived from this software without
> -specific prior written permission.
> -
> -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
> -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
> -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
> -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
> -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
> -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
> -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
> -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
> -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
> -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
> -POSSIBILITY OF SUCH DAMAGE.
> -
> -Author: Joel Schopp <jschopp@austin.ibm.com>
> -*/
> -
> -#include <_ansi.h>
> -#include <stdio.h>
> -
> -#include "c99ppe.h"
> -
> -#ifdef _HAVE_STDC
> -#include <stdarg.h>
> -#else
> -#include <varargs.h>
> -#endif
> -
> -#ifdef INTEGER_ONLY
> -#  define fscanf fiscanf
> -#endif
> -
> -typedef struct
> -{
> -  int fp;
> -  unsigned int pad0[ 3 ];
> -  _CONST char* fmt;
> -  unsigned int pad1[ 3 ];
> -  va_list ap;
> -} c99_vfscanf_t;
> -
> -#ifndef _REENT_ONLY
> -
> -fscanf(FILE *fp, _CONST char *fmt, ...)
> -{
> -  int ret;
> -  c99_vfscanf_t args;
> -
> -  CHECK_INIT(_REENT);
> -
> -  args.fp = fp->_fp;
> -  args.fmt = (char*) fmt;
> -#ifdef _HAVE_STDC
> -  va_start (args.ap, fmt);
> -#else
> -  va_start (args.ap);
> -#endif
> -
> -
> -  ret = __send_to_ppe(SPE_C99_SIGNALCODE, SPE_C99_VFSCANF, &args);
> -
> -  va_end (args.ap);
> -  return ret;
> -}
> -#endif /* ! _REENT_ONLY */
> diff -uprN head/newlib/libc/machine/spu/iprintf.S mod/newlib/libc/machine/spu/iprintf.S
> --- head/newlib/libc/machine/spu/iprintf.S	1970-01-01 09:00:00.000000000 +0900
> +++ mod/newlib/libc/machine/spu/iprintf.S	2007-08-09 15:40:00.000000000 +0900
> @@ -0,0 +1,7 @@
> +/*
> + * (C) Copyright 2007 TOSHIBA CORPORATION
> + * All Rights Reserved.
> + */
> +
> +#define printf    iprintf
> +#include "printf.S"
> diff -uprN head/newlib/libc/machine/spu/iprintf.c mod/newlib/libc/machine/spu/iprintf.c
> --- head/newlib/libc/machine/spu/iprintf.c	2007-02-21 05:58:38.000000000 +0900
> +++ mod/newlib/libc/machine/spu/iprintf.c	1970-01-01 09:00:00.000000000 +0900
> @@ -1,2 +0,0 @@
> -#define INTEGER_ONLY
> -#include "printf.c"
> diff -uprN head/newlib/libc/machine/spu/iscanf.S mod/newlib/libc/machine/spu/iscanf.S
> --- head/newlib/libc/machine/spu/iscanf.S	1970-01-01 09:00:00.000000000 +0900
> +++ mod/newlib/libc/machine/spu/iscanf.S	2007-08-09 15:39:50.000000000 +0900
> @@ -0,0 +1,7 @@
> +/*
> + * (C) Copyright 2007 TOSHIBA CORPORATION
> + * All Rights Reserved.
> + */
> +
> +#define scanf    iscanf
> +#include "scanf.S"
> diff -uprN head/newlib/libc/machine/spu/iscanf.c mod/newlib/libc/machine/spu/iscanf.c
> --- head/newlib/libc/machine/spu/iscanf.c	2007-02-21 05:58:38.000000000 +0900
> +++ mod/newlib/libc/machine/spu/iscanf.c	1970-01-01 09:00:00.000000000 +0900
> @@ -1,2 +0,0 @@
> -#define INTEGER_ONLY
> -#include "scanf.c"
> diff -uprN head/newlib/libc/machine/spu/printf.S mod/newlib/libc/machine/spu/printf.S
> --- head/newlib/libc/machine/spu/printf.S	1970-01-01 09:00:00.000000000 +0900
> +++ mod/newlib/libc/machine/spu/printf.S	2007-08-09 15:39:34.000000000 +0900
> @@ -0,0 +1,31 @@
> +/*
> + * (C) Copyright 2007 TOSHIBA CORPORATION
> + * All Rights Reserved.
> + */
> +
> +#include "c99ppe.h"
> +
> +#define SIGCODE SPE_C99_SIGNALCODE
> +#define NAME    printf
> +#define PARMS   1
> +#define OPCODE  SPE_C99_VPRINTF
> +
> +#define parms	$2
> +
> +	.text
> +	.align	4
> +	GLOBL	NAME
> +NAME:
> +	stqd	$0, 16($sp)		/* save caller address */
> +	il	parms, PARMS
> +	brsl	$0, __stack_reg_va	/* save register to the stack frame */
> +
> +	il	$3, SIGCODE		/* signal code */
> +	il	$4, OPCODE		/* op code */
> +	ai	$5, $sp, 16*2		/* data ($3 save address) */
> +	brsl	$0, __send_to_ppe
> +
> +	il	$2, 16*(STACK_REGS+2+2)
> +	a	$sp, $sp, $2
> +	lqd	$0, 16($sp)		/* load caller address */
> +	bi      $0			/* return to caller */
> diff -uprN head/newlib/libc/machine/spu/printf.c mod/newlib/libc/machine/spu/printf.c
> --- head/newlib/libc/machine/spu/printf.c	2007-05-24 06:41:17.000000000 +0900
> +++ mod/newlib/libc/machine/spu/printf.c	1970-01-01 09:00:00.000000000 +0900
> @@ -1,56 +0,0 @@
> -#include <_ansi.h>
> -#include <stdio.h>
> -
> -#include "c99ppe.h"
> -
> -#ifdef _HAVE_STDC
> -#include <stdarg.h>
> -#else
> -#include <varargs.h>
> -#endif
> -
> -#ifdef INTEGER_ONLY
> -#  define printf iprintf
> -#endif
> -
> -typedef struct
> -{
> -  _CONST char* fmt;
> -  unsigned int pad0[ 3 ];
> -  va_list ap;
> -} c99_printf_t;
> -
> -#ifndef _REENT_ONLY
> -
> -#ifdef _HAVE_STDC
> -int
> -_DEFUN (printf, (fmt,ap),
> -	_CONST char *fmt _AND
> -	...)
> -#else
> -int
> -#error
> -printf (fmt, va_alist)
> -     _CONST char *fmt;
> -     va_dcl
> -#endif
> -{
> -  int ret;
> -  c99_printf_t args;
> -
> -  CHECK_STD_INIT(_REENT);
> -
> -  args.fmt = fmt;
> -#ifdef _HAVE_STDC
> -  va_start (args.ap, fmt);
> -#else
> -  va_start (args.ap);
> -#endif
> -
> -  ret = __send_to_ppe(SPE_C99_SIGNALCODE, SPE_C99_VPRINTF, &args);
> -
> -  va_end (args.ap);
> -  return ret;
> -}
> -
> -#endif /* ! _REENT_ONLY */
> diff -uprN head/newlib/libc/machine/spu/scanf.S mod/newlib/libc/machine/spu/scanf.S
> --- head/newlib/libc/machine/spu/scanf.S	1970-01-01 09:00:00.000000000 +0900
> +++ mod/newlib/libc/machine/spu/scanf.S	2007-08-09 16:50:27.000000000 +0900
> @@ -0,0 +1,31 @@
> +/*
> + * (C) Copyright 2007 TOSHIBA CORPORATION
> + * All Rights Reserved.
> + */
> +
> +#include "c99ppe.h"
> +
> +#define SIGCODE SPE_C99_SIGNALCODE
> +#define NAME    scanf
> +#define PARMS   1
> +#define OPCODE  SPE_C99_VSCANF
> +
> +#define parms	$2
> +
> +	.text
> +	.align	4
> +	GLOBL	NAME
> +NAME:
> +	stqd	$0, 16($sp)		/* save caller address */
> +	il	parms, PARMS
> +	brsl	$0, __stack_reg_va	/* save register to the stack frame */
> +
> +	il	$3, SIGCODE		/* signal code */
> +	il	$4, OPCODE		/* op code */
> +	ai	$5, $sp, 16*2		/* data ($3 save address) */
> +	brsl	$0, __send_to_ppe
> +
> +	il	$2, 16*(STACK_REGS+2+2)
> +	a	$sp, $sp, $2
> +	lqd	$0, 16($sp)		/* load caller address */
> +	bi      $0			/* return to caller */
> diff -uprN head/newlib/libc/machine/spu/scanf.c mod/newlib/libc/machine/spu/scanf.c
> --- head/newlib/libc/machine/spu/scanf.c	2007-05-24 06:41:17.000000000 +0900
> +++ mod/newlib/libc/machine/spu/scanf.c	1970-01-01 09:00:00.000000000 +0900
> @@ -1,78 +0,0 @@
> -/*
> -(C) Copyright IBM Corp. 2006
> -
> -All rights reserved.
> -
> -Redistribution and use in source and binary forms, with or without
> -modification, are permitted provided that the following conditions are met:
> -
> -    * Redistributions of source code must retain the above copyright notice,
> -this list of conditions and the following disclaimer.
> -    * Redistributions in binary form must reproduce the above copyright
> -notice, this list of conditions and the following disclaimer in the
> -documentation and/or other materials provided with the distribution.
> -    * Neither the name of IBM nor the names of its contributors may be
> -used to endorse or promote products derived from this software without
> -specific prior written permission.
> -
> -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
> -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
> -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
> -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
> -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
> -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
> -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
> -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
> -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
> -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
> -POSSIBILITY OF SUCH DAMAGE.
> -
> -Author: Joel Schopp <jschopp@austin.ibm.com>
> -*/
> -
> -#include <_ansi.h>
> -#include <stdio.h>
> -
> -#include "c99ppe.h"
> -
> -#ifdef _HAVE_STDC
> -#include <stdarg.h>
> -#else
> -#include <varargs.h>
> -#endif
> -
> -#ifdef INTEGER_ONLY
> -#  define scanf iscanf
> -#endif
> -
> -typedef struct
> -{
> -  _CONST char* fmt;
> -  unsigned int pad0[ 3 ];
> -  va_list ap;
> -} c99_vscanf_t;
> -
> -#ifndef _REENT_ONLY
> -
> -scanf(_CONST char *fmt, ...)
> -{
> -  int ret;
> -  c99_vscanf_t args;
> -
> -  CHECK_STD_INIT(_REENT);
> -
> -  args.fmt = (char*) fmt;
> -#ifdef _HAVE_STDC
> -  va_start (args.ap, fmt);
> -#else
> -  va_start (args.ap);
> -#endif
> -
> -
> -  ret = __send_to_ppe(SPE_C99_SIGNALCODE, SPE_C99_VSCANF, &args);
> -
> -  va_end (args.ap);
> -  return ret;
> -}
> -
> -#endif /* ! _REENT_ONLY */
> diff -uprN head/newlib/libc/machine/spu/siprintf.S mod/newlib/libc/machine/spu/siprintf.S
> --- head/newlib/libc/machine/spu/siprintf.S	1970-01-01 09:00:00.000000000 +0900
> +++ mod/newlib/libc/machine/spu/siprintf.S	2007-08-09 16:50:38.000000000 +0900
> @@ -0,0 +1,7 @@
> +/*
> + * (C) Copyright 2007 TOSHIBA CORPORATION
> + * All Rights Reserved.
> + */
> +
> +#define sprintf    siprintf
> +#include "sprintf.S"
> diff -uprN head/newlib/libc/machine/spu/siprintf.c mod/newlib/libc/machine/spu/siprintf.c
> --- head/newlib/libc/machine/spu/siprintf.c	2007-02-21 05:58:38.000000000 +0900
> +++ mod/newlib/libc/machine/spu/siprintf.c	1970-01-01 09:00:00.000000000 +0900
> @@ -1,2 +0,0 @@
> -#define INTEGER_ONLY
> -#include "sprintf.c"
> diff -uprN head/newlib/libc/machine/spu/siscanf.S mod/newlib/libc/machine/spu/siscanf.S
> --- head/newlib/libc/machine/spu/siscanf.S	1970-01-01 09:00:00.000000000 +0900
> +++ mod/newlib/libc/machine/spu/siscanf.S	2007-08-09 16:50:50.000000000 +0900
> @@ -0,0 +1,7 @@
> +/*
> + * (C) Copyright 2007 TOSHIBA CORPORATION
> + * All Rights Reserved.
> + */
> +
> +#define sscanf    siscanf
> +#include "sscanf.S"
> diff -uprN head/newlib/libc/machine/spu/siscanf.c mod/newlib/libc/machine/spu/siscanf.c
> --- head/newlib/libc/machine/spu/siscanf.c	2007-02-21 05:58:38.000000000 +0900
> +++ mod/newlib/libc/machine/spu/siscanf.c	1970-01-01 09:00:00.000000000 +0900
> @@ -1,2 +0,0 @@
> -#define INTEGER_ONLY
> -#include "sscanf.c"
> diff -uprN head/newlib/libc/machine/spu/sniprintf.S mod/newlib/libc/machine/spu/sniprintf.S
> --- head/newlib/libc/machine/spu/sniprintf.S	1970-01-01 09:00:00.000000000 +0900
> +++ mod/newlib/libc/machine/spu/sniprintf.S	2007-08-09 16:50:59.000000000 +0900
> @@ -0,0 +1,7 @@
> +/*
> + * (C) Copyright 2007 TOSHIBA CORPORATION
> + * All Rights Reserved.
> + */
> +
> +#define snprintf    sniprintf
> +#include "snprintf.S"
> diff -uprN head/newlib/libc/machine/spu/sniprintf.c mod/newlib/libc/machine/spu/sniprintf.c
> --- head/newlib/libc/machine/spu/sniprintf.c	2007-02-21 05:58:38.000000000 +0900
> +++ mod/newlib/libc/machine/spu/sniprintf.c	1970-01-01 09:00:00.000000000 +0900
> @@ -1,2 +0,0 @@
> -#define INTEGER_ONLY
> -#include "snprintf.c"
> diff -uprN head/newlib/libc/machine/spu/snprintf.S mod/newlib/libc/machine/spu/snprintf.S
> --- head/newlib/libc/machine/spu/snprintf.S	1970-01-01 09:00:00.000000000 +0900
> +++ mod/newlib/libc/machine/spu/snprintf.S	2007-08-09 16:51:08.000000000 +0900
> @@ -0,0 +1,31 @@
> +/*
> + * (C) Copyright 2007 TOSHIBA CORPORATION
> + * All Rights Reserved.
> + */
> +
> +#include "c99ppe.h"
> +
> +#define SIGCODE SPE_C99_SIGNALCODE
> +#define NAME    snprintf
> +#define PARMS   3
> +#define OPCODE  SPE_C99_VSNPRINTF
> +
> +#define parms	$2
> +
> +	.text
> +	.align	4
> +	GLOBL	NAME
> +NAME:
> +	stqd	$0, 16($sp)		/* save caller address */
> +	il	parms, PARMS
> +	brsl	$0, __stack_reg_va	/* save register to the stack frame */
> +
> +	il	$3, SIGCODE		/* signal code */
> +	il	$4, OPCODE		/* op code */
> +	ai	$5, $sp, 16*2		/* data ($3 save address) */
> +	brsl	$0, __send_to_ppe
> +
> +	il	$2, 16*(STACK_REGS+2+2)
> +	a	$sp, $sp, $2
> +	lqd	$0, 16($sp)		/* load caller address */
> +	bi      $0			/* return to caller */
> diff -uprN head/newlib/libc/machine/spu/snprintf.c mod/newlib/libc/machine/spu/snprintf.c
> --- head/newlib/libc/machine/spu/snprintf.c	2007-05-24 06:41:17.000000000 +0900
> +++ mod/newlib/libc/machine/spu/snprintf.c	1970-01-01 09:00:00.000000000 +0900
> @@ -1,86 +0,0 @@
> -/*
> -(C) Copyright IBM Corp. 2006
> -
> -All rights reserved.
> -
> -Redistribution and use in source and binary forms, with or without
> -modification, are permitted provided that the following conditions are met:
> -
> -    * Redistributions of source code must retain the above copyright notice,
> -this list of conditions and the following disclaimer.
> -    * Redistributions in binary form must reproduce the above copyright
> -notice, this list of conditions and the following disclaimer in the
> -documentation and/or other materials provided with the distribution.
> -    * Neither the name of IBM nor the names of its contributors may be
> -used to endorse or promote products derived from this software without
> -specific prior written permission.
> -
> -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
> -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
> -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
> -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
> -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
> -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
> -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
> -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
> -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
> -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
> -POSSIBILITY OF SUCH DAMAGE.
> -
> -Author: Joel Schopp <jschopp@austin.ibm.com>
> -*/
> -
> -#include <_ansi.h>
> -#include <stdio.h>
> -
> -#include "c99ppe.h"
> -
> -#ifdef _HAVE_STDC
> -#include <stdarg.h>
> -#else
> -#include <varargs.h>
> -#endif
> -
> -#ifdef INTEGER_ONLY
> -#  define snprintf sniprintf
> -#endif
> -
> -typedef struct
> -{
> -  char* str;
> -  unsigned int pad0[ 3 ];
> -  size_t size;
> -  unsigned int pad1[ 3 ];
> -  _CONST char* fmt;
> -  unsigned int pad2[ 3 ];
> -  va_list ap;
> -} c99_snprintf_t;
> -
> -#ifndef _REENT_ONLY
> -
> -_DEFUN(snprintf, (str, size, fmt),
> -       char *str   _AND
> -       size_t size _AND
> -       _CONST char *fmt _DOTS)
> -{
> -  int ret;
> -  c99_snprintf_t args;
> -
> -  CHECK_STR_INIT(_REENT);
> -
> -  args.str = str;
> -  args.size = size;
> -  args.fmt = fmt;
> -#ifdef _HAVE_STDC
> -  va_start (args.ap, fmt);
> -#else
> -  va_start (args.ap);
> -#endif
> -
> -  ret = __send_to_ppe(SPE_C99_SIGNALCODE, SPE_C99_VSNPRINTF, &args);
> -
> -  va_end (args.ap);
> -  return ret;
> -}
> -
> -#endif /* ! _REENT_ONLY */
> diff -uprN head/newlib/libc/machine/spu/sprintf.S mod/newlib/libc/machine/spu/sprintf.S
> --- head/newlib/libc/machine/spu/sprintf.S	1970-01-01 09:00:00.000000000 +0900
> +++ mod/newlib/libc/machine/spu/sprintf.S	2007-08-09 16:49:14.000000000 +0900
> @@ -0,0 +1,31 @@
> +/*
> + * (C) Copyright 2007 TOSHIBA CORPORATION
> + * All Rights Reserved.
> + */
> +
> +#include "c99ppe.h"
> +
> +#define SIGCODE SPE_C99_SIGNALCODE
> +#define NAME    sprintf
> +#define PARMS   2
> +#define OPCODE  SPE_C99_VSPRINTF
> +
> +#define parms	$2
> +
> +	.text
> +	.align	4
> +	GLOBL	NAME
> +NAME:
> +	stqd	$0, 16($sp)		/* save caller address */
> +	il	parms, PARMS
> +	brsl	$0, __stack_reg_va	/* save register to the stack frame */
> +
> +	il	$3, SIGCODE		/* signal code */
> +	il	$4, OPCODE		/* op code */
> +	ai	$5, $sp, 16*2		/* data ($3 save address) */
> +	brsl	$0, __send_to_ppe
> +
> +	il	$2, 16*(STACK_REGS+2+2)
> +	a	$sp, $sp, $2
> +	lqd	$0, 16($sp)		/* load caller address */
> +	bi      $0			/* return to caller */
> diff -uprN head/newlib/libc/machine/spu/sprintf.c mod/newlib/libc/machine/spu/sprintf.c
> --- head/newlib/libc/machine/spu/sprintf.c	2007-05-24 06:41:17.000000000 +0900
> +++ mod/newlib/libc/machine/spu/sprintf.c	1970-01-01 09:00:00.000000000 +0900
> @@ -1,82 +0,0 @@
> -/*
> -(C) Copyright IBM Corp. 2006
> -
> -All rights reserved.
> -
> -Redistribution and use in source and binary forms, with or without
> -modification, are permitted provided that the following conditions are met:
> -
> -    * Redistributions of source code must retain the above copyright notice,
> -this list of conditions and the following disclaimer.
> -    * Redistributions in binary form must reproduce the above copyright
> -notice, this list of conditions and the following disclaimer in the
> -documentation and/or other materials provided with the distribution.
> -    * Neither the name of IBM nor the names of its contributors may be
> -used to endorse or promote products derived from this software without
> -specific prior written permission.
> -
> -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
> -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
> -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
> -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
> -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
> -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
> -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
> -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
> -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
> -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
> -POSSIBILITY OF SUCH DAMAGE.
> -
> -Author: Joel Schopp <jschopp@austin.ibm.com>
> -*/
> -
> -#include <_ansi.h>
> -#include <stdio.h>
> -
> -#include "c99ppe.h"
> -
> -#ifdef _HAVE_STDC
> -#include <stdarg.h>
> -#else
> -#include <varargs.h>
> -#endif
> -
> -#ifdef INTEGER_ONLY
> -#  define sprintf siprintf
> -#endif
> -
> -typedef struct
> -{
> -  char* str;
> -  unsigned int pad0[ 3 ];
> -  _CONST char* fmt;
> -  unsigned int pad1[ 3 ];
> -  va_list ap;
> -} c99_sprintf_t;
> -
> -#ifndef _REENT_ONLY
> -
> -_DEFUN(sprintf, (str, fmt),
> -       char *str _AND
> -       _CONST char *fmt _DOTS)
> -{
> -  int ret;
> -  c99_sprintf_t args;
> -
> -  CHECK_STR_INIT(_REENT);
> -
> -  args.str = str;
> -  args.fmt = fmt;
> -#ifdef _HAVE_STDC
> -  va_start (args.ap, fmt);
> -#else
> -  va_start (args.ap);
> -#endif
> -
> -  ret = __send_to_ppe(SPE_C99_SIGNALCODE, SPE_C99_VSPRINTF, &args);
> -
> -  va_end (args.ap);
> -  return ret;
> -}
> -
> -#endif /* ! _REENT_ONLY */
> diff -uprN head/newlib/libc/machine/spu/sscanf.S mod/newlib/libc/machine/spu/sscanf.S
> --- head/newlib/libc/machine/spu/sscanf.S	1970-01-01 09:00:00.000000000 +0900
> +++ mod/newlib/libc/machine/spu/sscanf.S	2007-08-09 15:36:17.000000000 +0900
> @@ -0,0 +1,31 @@
> +/*
> + * (C) Copyright 2007 TOSHIBA CORPORATION
> + * All Rights Reserved.
> + */
> +
> +#include "c99ppe.h"
> +
> +#define SIGCODE SPE_C99_SIGNALCODE
> +#define NAME    sscanf
> +#define PARMS   2
> +#define OPCODE  SPE_C99_VSSCANF
> +
> +#define parms	$2
> +
> +	.text
> +	.align	4
> +	GLOBL	NAME
> +NAME:
> +	stqd	$0, 16($sp)		/* save caller address */
> +	il	parms, PARMS
> +	brsl	$0, __stack_reg_va	/* save register to the stack frame */
> +
> +	il	$3, SIGCODE		/* signal code */
> +	il	$4, OPCODE		/* op code */
> +	ai	$5, $sp, 16*2		/* data ($3 save address) */
> +	brsl	$0, __send_to_ppe
> +
> +	il	$2, 16*(STACK_REGS+2+2)
> +	a	$sp, $sp, $2
> +	lqd	$0, 16($sp)		/* load caller address */
> +	bi      $0			/* return to caller */
> diff -uprN head/newlib/libc/machine/spu/sscanf.c mod/newlib/libc/machine/spu/sscanf.c
> --- head/newlib/libc/machine/spu/sscanf.c	2007-05-24 06:41:17.000000000 +0900
> +++ mod/newlib/libc/machine/spu/sscanf.c	1970-01-01 09:00:00.000000000 +0900
> @@ -1,83 +0,0 @@
> -/*
> -(C) Copyright IBM Corp. 2006
> -
> -All rights reserved.
> -
> -Redistribution and use in source and binary forms, with or without
> -modification, are permitted provided that the following conditions are met:
> -
> -    * Redistributions of source code must retain the above copyright notice,
> -this list of conditions and the following disclaimer.
> -    * Redistributions in binary form must reproduce the above copyright
> -notice, this list of conditions and the following disclaimer in the
> -documentation and/or other materials provided with the distribution.
> -    * Neither the name of IBM nor the names of its contributors may be
> -used to endorse or promote products derived from this software without
> -specific prior written permission.
> -
> -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
> -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
> -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
> -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
> -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
> -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
> -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
> -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
> -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
> -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
> -POSSIBILITY OF SUCH DAMAGE.
> -
> -Author: Joel Schopp <jschopp@austin.ibm.com>
> -*/
> -
> -#include <_ansi.h>
> -#include <stdio.h>
> -
> -#include "c99ppe.h"
> -
> -#ifdef _HAVE_STDC
> -#include <stdarg.h>
> -#else
> -#include <varargs.h>
> -#endif
> -
> -#ifdef INTEGER_ONLY
> -#  define sscanf siscanf
> -#endif
> -
> -typedef struct
> -{
> -  _CONST char* str;
> -  unsigned int pad0[ 3 ];
> -  _CONST char* fmt;
> -  unsigned int pad1[ 3 ];
> -  va_list ap;
> -} c99_sscanf_t;
> -
> -#ifndef _REENT_ONLY
> -
> -int
> -_DEFUN(sscanf, (str, fmt),
> -       _CONST char *str _AND
> -       _CONST char *fmt _DOTS)
> -{
> -  int ret;
> -  c99_sscanf_t args;
> -
> -  CHECK_STR_INIT(_REENT);
> -
> -  args.str = str;
> -  args.fmt = fmt;
> -#ifdef _HAVE_STDC
> -  va_start (args.ap, fmt);
> -#else
> -  va_start (args.ap);
> -#endif
> -
> -  ret = __send_to_ppe(SPE_C99_SIGNALCODE, SPE_C99_VSSCANF, &args);
> -
> -  va_end (args.ap);
> -  return ret;
> -}
> -
> -#endif /* ! _REENT_ONLY */
> diff -uprN head/newlib/libc/machine/spu/stack_reg_va.S mod/newlib/libc/machine/spu/stack_reg_va.S
> --- head/newlib/libc/machine/spu/stack_reg_va.S	1970-01-01 09:00:00.000000000 +0900
> +++ mod/newlib/libc/machine/spu/stack_reg_va.S	2007-08-09 15:36:02.000000000 +0900
> @@ -0,0 +1,141 @@
> +/*
> + * (C) Copyright 2007 TOSHIBA CORPORATION
> + * All Rights Reserved.
> + *
> + *
> + * This file contains code use to construct a PIC, spu side, syscall 
> + * function with variable parameters in accordance with the CBE ABI.
> + *
> + * This function is equivalent to constructing a va_list structure and 
> + * calling the va_list form of the function. Therefore, for example,
> + * a printf function stack frame will look like this:
> + *
> + *             |   Stack    | high memory
> + *             |   Parms    |
> + *             |            |
> + *             |------------|
> + *             |  Link Reg  |
> + *             |------------|
> + *             | Back Chain |<-----. <---- input SP
> + *             |------------|      |
> + *             |  Reg 74    |      |
> + *             |------------|      |
> + *             |  Reg 73    |      |
> + *             |------------|      |
> + *             //   ...    //      |
> + *             |------------|      |
> + *             |  Reg  5    |      |
> + *             |------------|      |
> + *             |  Reg  4    |<--.  |
> + *             |------------|   |  |
> + *     va_list.| call_stack |------'
> + *             |------------|   |   
> + *     va_list.|  next_arg  |---'
> + *             |------------| 
> + *             | format (r3)| <---- start of parameters
> + *             |------------|                   |------------|
> + *             |    stack   |                   |            |
> + *             |    code    |                   |(Back Chain)| <---- output SP
> + *             | 1-3 qwords | <---- code_ptr    `------------'
> + *             `------------'
> + *                            low memory
> + *
> + * This was written in assembly so that it is smaller than what would
> + * be produced by using va_start.
> + */
> +
> +#include "c99ppe.h"
> +
> +#define parms		$2
> +
> +#define offset		$67
> +#define flag		$68
> +#define regdec		$69
> +#define link		$70
> +
> +#define code_ptr	$71
> +#define ptr		$72
> +#define inst		$73
> +#define tmp		$74
> +
> +	.text
> +	.global __stack_reg_va
> +
> +__stack_reg_va:
> +
> +	/* Save registers 69-74 explicitly so that we have some
> +	 * working registers. 
> +	 */
> +	stqd	$74, 16*(-1)($sp)
> +	stqd	$73, 16*(-2)($sp)
> +	stqd	$72, 16*(-3)($sp)
> +	stqd	$71, 16*(-4)($sp)
> +	stqd	$70, 16*(-5)($sp)
> +	stqd	$69, 16*(-6)($sp)
> +
> +	/* Construct self-modifying stack code that saves the remaining
> +	 * volatile registers onto the stack.
> +	 */
> +	il	regdec, -1		/* for decrement register value in save instruction */
> +	shlqbyi	regdec, regdec, 12
> +	il	tmp, -(STACK_REGS+2+3)*16
> +	a	code_ptr, $sp, tmp
> +	lqr	tmp, save_regs_1	/* store stack code */
> +	stqd	tmp,  0(code_ptr)
> +	lqr	inst, save_regs_2
> +	ai	ptr, $sp, 16*(-6)
> +	sync
> +	bisl	link, code_ptr		/* branch to the constructed stack code */
> +
> +	/* Adjust pointer so that it points to the first variable
> +	 * argument on the stack.
> +	 */
> +	ai	offset, parms, -1	/* offset = parms - 1 */
> +	mpyi	offset, offset, 16	/* offset = offset * 16 */
> +	a	ptr, ptr, offset	/* ptr = ptr + offset */
> +
> +	/* Store the va_list to the parameter list.
> +	 */
> +	stqd	$sp, 16*(-1)(ptr)
> +	stqd	ptr, 16*(-2)(ptr)
> +
> +	/* Make $3 store address.
> +	*/
> +	ai	offset, parms, 2	/* offset = parms + 2 */
> +	mpyi	offset, offset, -16	/* offset = offset * -16 */
> +	a	ptr, ptr, offset	/* ptr = ptr + offset */
> +
> +	/* Save all the fixed (non-variable arguments on the stack)
> +	 */
> +	ceqi	flag, parms, 0x01	/* if(parms==1) flag=0xFFFFFFFF */
> +	brnz	flag, reg_3		/* if(flag!=0) jump */
> +	ceqi	flag, parms, 0x02	/* if(parms==2) flag=0xFFFFFFFF */
> +	brnz	flag, reg_4		/* if(flag!=0) jump */
> +	stqd	$5, 16*2(ptr)
> +reg_4:
> +	stqd	$4, 16*1(ptr)
> +reg_3:
> +	stqd	$3, 0(ptr)
> +
> +	il	$3, -16*(STACK_REGS+2+2)
> +	stqx	$sp, $3, $sp		/* save back chain */
> +	a	$sp, $sp, $3
> +	bi      $0			/* return to caller */
> +
> +/***************************** stack code *********************************************/
> +	
> +	/* The following code is copied into the stack for re-entract,
> +	 * self-modified, code execution. This code copies the volatile
> +	 * registers into a va_list parameter array.
> +	 */
> +	.balignl	16, 0
> +save_regs_1:
> +	stqd	inst, 16(code_ptr)	/* store instruction */
> +	sync
> +	a	inst, inst, regdec	/* decrement register number in the instruction */
> +	ceqbi	tmp, inst, 3		/* if (reg-num == 3) tmp = 0x000000FF 000..0 */
> +save_regs_2:	
> +	stqd	$68, -16(ptr)
> +	ai	ptr, ptr, -16
> +	brz	tmp, save_regs_1	/* if (tmp == 0) jump */
> +	bi	link			/* finish to make va_list */
> diff -uprN head/newlib/libc/machine/spu/stdio.c mod/newlib/libc/machine/spu/stdio.c
> --- head/newlib/libc/machine/spu/stdio.c	2007-02-02 01:33:05.000000000 +0900
> +++ mod/newlib/libc/machine/spu/stdio.c	2007-08-06 18:02:37.000000000 +0900
> @@ -80,3 +80,9 @@ _DEFUN (__sinit, (s),
>    s->_stderr = &s->__sf[2];
>    s->_stderr->_fp = SPE_STDERR;
>  }
> +
> +_VOID
> +_DEFUN_VOID (__check_init)
> +{
> +    CHECK_INIT(_REENT);
> +}



More information about the Newlib mailing list