diff --git a/newlib/ChangeLog b/newlib/ChangeLog index 0b42c05d3..740f7a118 100644 --- a/newlib/ChangeLog +++ b/newlib/ChangeLog @@ -1,3 +1,20 @@ +2007-02-01 Joel Schopp + Kazunori Asayama + + * libc/machine/spu/Makefile.am: Add objects. + * libc/machine/spu/Makefile.in: Regenerated. + * libc/machine/spu/vsscanf.c: New file. Add a stdio function + implementation. + * libc/machine/spu/snprintf.c: Ditto. + * libc/machine/spu/sprintf.c: Ditto. + * libc/machine/spu/sscanf.c: Ditto. + * libc/machine/spu/remove.c: Ditto. + * libc/machine/spu/rename.c: Ditto. + * libc/machine/spu/tmpnam.c: Ditto. + * libc/machine/spu/vsnprintf.c: Add initialization routine of + stdio stuffs. + * libc/machine/spu/vsprintf.c: Ditto. + 2007-02-01 Joel Schopp Kazunori Asayama diff --git a/newlib/libc/machine/spu/Makefile.am b/newlib/libc/machine/spu/Makefile.am index b2f837d97..fc6451c65 100644 --- a/newlib/libc/machine/spu/Makefile.am +++ b/newlib/libc/machine/spu/Makefile.am @@ -16,7 +16,8 @@ lib_a_SOURCES = setjmp.S memcpy.c memmove.c memset.c strcat.c strchr.c strcmp.c perror.c gets.c getchar.c putchar.c puts.c \ printf.c scanf.c vprintf.c vscanf.c \ setbuf.c setvbuf.c tmpfile.c \ - vsnprintf.c vsprintf.c + sprintf.c sscanf.c snprintf.c vsscanf.c vsnprintf.c vsprintf.c \ + remove.c rename.c tmpnam.c lib_a_CCASFLAGS = $(AM_CCASFLAGS) lib_a_CFLAGS = $(AM_CFLAGS) diff --git a/newlib/libc/machine/spu/Makefile.in b/newlib/libc/machine/spu/Makefile.in index 8577814ec..37187334a 100644 --- a/newlib/libc/machine/spu/Makefile.in +++ b/newlib/libc/machine/spu/Makefile.in @@ -68,7 +68,10 @@ DIST_COMMON = $(srcdir)/../../../../config.guess \ $(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 am__aclocal_m4_deps = $(top_srcdir)/../../../acinclude.m4 \ @@ -111,7 +114,11 @@ am_lib_a_OBJECTS = lib_a-setjmp.$(OBJEXT) lib_a-memcpy.$(OBJEXT) \ lib_a-scanf.$(OBJEXT) lib_a-vprintf.$(OBJEXT) \ lib_a-vscanf.$(OBJEXT) lib_a-setbuf.$(OBJEXT) \ lib_a-setvbuf.$(OBJEXT) lib_a-tmpfile.$(OBJEXT) \ - lib_a-vsnprintf.$(OBJEXT) lib_a-vsprintf.$(OBJEXT) + lib_a-sprintf.$(OBJEXT) lib_a-sscanf.$(OBJEXT) \ + lib_a-snprintf.$(OBJEXT) lib_a-vsscanf.$(OBJEXT) \ + lib_a-vsnprintf.$(OBJEXT) lib_a-vsprintf.$(OBJEXT) \ + lib_a-remove.$(OBJEXT) lib_a-rename.$(OBJEXT) \ + lib_a-tmpnam.$(OBJEXT) lib_a_OBJECTS = $(am_lib_a_OBJECTS) DEFAULT_INCLUDES = -I. -I$(srcdir) depcomp = @@ -244,7 +251,8 @@ lib_a_SOURCES = setjmp.S memcpy.c memmove.c memset.c strcat.c strchr.c strcmp.c perror.c gets.c getchar.c putchar.c puts.c \ printf.c scanf.c vprintf.c vscanf.c \ setbuf.c setvbuf.c tmpfile.c \ - vsnprintf.c vsprintf.c + sprintf.c sscanf.c snprintf.c vsscanf.c vsnprintf.c vsprintf.c \ + remove.c rename.c tmpnam.c lib_a_CCASFLAGS = $(AM_CCASFLAGS) lib_a_CFLAGS = $(AM_CFLAGS) @@ -649,6 +657,30 @@ lib_a-tmpfile.o: tmpfile.c lib_a-tmpfile.obj: tmpfile.c $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-tmpfile.obj `if test -f 'tmpfile.c'; then $(CYGPATH_W) 'tmpfile.c'; else $(CYGPATH_W) '$(srcdir)/tmpfile.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-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-vsscanf.o: vsscanf.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-vsscanf.o `test -f 'vsscanf.c' || echo '$(srcdir)/'`vsscanf.c + +lib_a-vsscanf.obj: vsscanf.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-vsscanf.obj `if test -f 'vsscanf.c'; then $(CYGPATH_W) 'vsscanf.c'; else $(CYGPATH_W) '$(srcdir)/vsscanf.c'; fi` + lib_a-vsnprintf.o: vsnprintf.c $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-vsnprintf.o `test -f 'vsnprintf.c' || echo '$(srcdir)/'`vsnprintf.c @@ -660,6 +692,24 @@ lib_a-vsprintf.o: vsprintf.c lib_a-vsprintf.obj: vsprintf.c $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-vsprintf.obj `if test -f 'vsprintf.c'; then $(CYGPATH_W) 'vsprintf.c'; else $(CYGPATH_W) '$(srcdir)/vsprintf.c'; fi` + +lib_a-remove.o: remove.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-remove.o `test -f 'remove.c' || echo '$(srcdir)/'`remove.c + +lib_a-remove.obj: remove.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-remove.obj `if test -f 'remove.c'; then $(CYGPATH_W) 'remove.c'; else $(CYGPATH_W) '$(srcdir)/remove.c'; fi` + +lib_a-rename.o: rename.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-rename.o `test -f 'rename.c' || echo '$(srcdir)/'`rename.c + +lib_a-rename.obj: rename.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-rename.obj `if test -f 'rename.c'; then $(CYGPATH_W) 'rename.c'; else $(CYGPATH_W) '$(srcdir)/rename.c'; fi` + +lib_a-tmpnam.o: tmpnam.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-tmpnam.o `test -f 'tmpnam.c' || echo '$(srcdir)/'`tmpnam.c + +lib_a-tmpnam.obj: tmpnam.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-tmpnam.obj `if test -f 'tmpnam.c'; then $(CYGPATH_W) 'tmpnam.c'; else $(CYGPATH_W) '$(srcdir)/tmpnam.c'; fi` uninstall-info-am: ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) diff --git a/newlib/libc/machine/spu/remove.c b/newlib/libc/machine/spu/remove.c new file mode 100644 index 000000000..b7027ca7d --- /dev/null +++ b/newlib/libc/machine/spu/remove.c @@ -0,0 +1,48 @@ +/* +(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 +*/ + +#include + +#include "c99ppe.h" + +int +remove (filename) + _CONST char *filename; +{ + + /* The return value gets written over buf + */ + send_to_ppe(SPE_C99_SIGNALCODE, SPE_C99_REMOVE, &filename); + + return (int)filename; +} + diff --git a/newlib/libc/machine/spu/rename.c b/newlib/libc/machine/spu/rename.c new file mode 100644 index 000000000..7b9806cfb --- /dev/null +++ b/newlib/libc/machine/spu/rename.c @@ -0,0 +1,60 @@ +/* +(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 +*/ + +#include <_ansi.h> +#include + +#include "c99ppe.h" + +typedef struct +{ + _CONST char *old; + unsigned int pad0[ 3 ]; + _CONST char *new; + unsigned int pad1[ 3 ]; +} c99_rename_t; + +int +rename (old, new) + _CONST char *old; + _CONST char *new; +{ + int *ret; + c99_rename_t args; + args.old = old; + args.new = new; + ret = (int*) &args; + + send_to_ppe(SPE_C99_SIGNALCODE, SPE_C99_RENAME, &args); + + return *ret; +} diff --git a/newlib/libc/machine/spu/snprintf.c b/newlib/libc/machine/spu/snprintf.c new file mode 100644 index 000000000..56e68c51e --- /dev/null +++ b/newlib/libc/machine/spu/snprintf.c @@ -0,0 +1,84 @@ +/* +(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 +*/ + +#include <_ansi.h> +#include + +#include "c99ppe.h" + +#ifdef _HAVE_STDC +#include +#else +#include +#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); + + ret = (int*) &args; + + args.str = str; + args.size = size; + args.fmt = fmt; +#ifdef _HAVE_STDC + va_start (args.ap, fmt); +#else + va_start (args.ap); +#endif + + send_to_ppe(SPE_C99_SIGNALCODE, SPE_C99_VSNPRINTF, &args); + + va_end (args.ap); + return *ret; +} + +#endif /* ! _REENT_ONLY */ diff --git a/newlib/libc/machine/spu/sprintf.c b/newlib/libc/machine/spu/sprintf.c new file mode 100644 index 000000000..32840b34d --- /dev/null +++ b/newlib/libc/machine/spu/sprintf.c @@ -0,0 +1,80 @@ +/* +(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 +*/ + +#include <_ansi.h> +#include + +#include "c99ppe.h" + +#ifdef _HAVE_STDC +#include +#else +#include +#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); + + ret = (int*) &args; + + args.str = str; + args.fmt = fmt; +#ifdef _HAVE_STDC + va_start (args.ap, fmt); +#else + va_start (args.ap); +#endif + + send_to_ppe(SPE_C99_SIGNALCODE, SPE_C99_VSPRINTF, &args); + + va_end (args.ap); + return *ret; +} + +#endif /* ! _REENT_ONLY */ diff --git a/newlib/libc/machine/spu/sscanf.c b/newlib/libc/machine/spu/sscanf.c new file mode 100644 index 000000000..ebe607de0 --- /dev/null +++ b/newlib/libc/machine/spu/sscanf.c @@ -0,0 +1,81 @@ +/* +(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 +*/ + +#include <_ansi.h> +#include + +#include "c99ppe.h" + +#ifdef _HAVE_STDC +#include +#else +#include +#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); + + ret = (int*) &args; + + args.str = str; + args.fmt = fmt; +#ifdef _HAVE_STDC + va_start (args.ap, fmt); +#else + va_start (args.ap); +#endif + + send_to_ppe(SPE_C99_SIGNALCODE, SPE_C99_VSSCANF, &args); + + va_end (args.ap); + return *ret; +} + +#endif /* ! _REENT_ONLY */ diff --git a/newlib/libc/machine/spu/tmpnam.c b/newlib/libc/machine/spu/tmpnam.c new file mode 100644 index 000000000..cd2856bc1 --- /dev/null +++ b/newlib/libc/machine/spu/tmpnam.c @@ -0,0 +1,47 @@ +/* +(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 +*/ + +#include + +#include "c99ppe.h" + +char * +_DEFUN (tmpnam, (s), + char *s) +{ + char **ret = &s; + /* The return value gets written over buf + */ + send_to_ppe(SPE_C99_SIGNALCODE, SPE_C99_TMPNAM, &s); + + return *ret; +} diff --git a/newlib/libc/machine/spu/vsnprintf.c b/newlib/libc/machine/spu/vsnprintf.c index fb04b4dae..f46beb2fc 100644 --- a/newlib/libc/machine/spu/vsnprintf.c +++ b/newlib/libc/machine/spu/vsnprintf.c @@ -31,6 +31,9 @@ _DEFUN (vsnprintf, (str, size, fmt, ap), { int* ret; c99_vsnprintf_t args; + + CHECK_STR_INIT(_REENT); + ret = (int*) &args; args.str = str; diff --git a/newlib/libc/machine/spu/vsprintf.c b/newlib/libc/machine/spu/vsprintf.c index 3a45c2b92..154201100 100644 --- a/newlib/libc/machine/spu/vsprintf.c +++ b/newlib/libc/machine/spu/vsprintf.c @@ -19,6 +19,8 @@ typedef struct va_list ap; } c99_vsprintf_t; +#ifndef _REENT_ONLY + int _DEFUN (vsprintf, (str, fmt, ap), char *str _AND @@ -27,6 +29,9 @@ _DEFUN (vsprintf, (str, fmt, ap), { int* ret; c99_vsprintf_t args; + + CHECK_STR_INIT(_REENT); + ret = (int*) &args; args.str = str; @@ -37,3 +42,5 @@ _DEFUN (vsprintf, (str, fmt, ap), return *ret; } + +#endif /* ! _REENT_ONLY */ diff --git a/newlib/libc/machine/spu/vsscanf.c b/newlib/libc/machine/spu/vsscanf.c new file mode 100644 index 000000000..4eba1697d --- /dev/null +++ b/newlib/libc/machine/spu/vsscanf.c @@ -0,0 +1,77 @@ +/* +(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 +*/ + +#include <_ansi.h> +#include + +#include "c99ppe.h" + +#ifdef _HAVE_STDC +#include +#else +#include +#endif + +typedef struct +{ + _CONST char *str; + unsigned int pad0[ 3 ]; + _CONST char *fmt; + unsigned int pad1[ 3 ]; + va_list ap; +} c99_vsscanf_t; + +#ifndef _REENT_ONLY + +int +_DEFUN (vsscanf, (str, fmt, ap), + _CONST char *str _AND + _CONST char *fmt _AND + va_list ap) +{ + int* ret; + c99_vsscanf_t args; + + CHECK_STR_INIT(_REENT); + + ret = (int*) &args; + + args.str = str; + args.fmt = (char*) fmt; + va_copy(args.ap,ap); + + send_to_ppe(SPE_C99_SIGNALCODE, SPE_C99_VSSCANF, &args); + + return *ret; +} + +#endif /* ! _REENT_ONLY */