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]

[RFC 3/3] Cell SPU offloaded stdio: Other stdio functions


Attached is a patch to implement stdio functions w/o FILE operations.

2007-01-09  Kazunori Asayama <asayama@sm.sony.co.jp>

	* 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.
Index: newlib/newlib/libc/machine/spu/vsscanf.c
===================================================================
--- /dev/null
+++ newlib/newlib/libc/machine/spu/vsscanf.c
@@ -0,0 +1,45 @@
+#include <_ansi.h>
+#include <stdio.h>
+
+#include "c99ppe.h"
+
+#ifdef _HAVE_STDC
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#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 */
Index: newlib/newlib/libc/machine/spu/snprintf.c
===================================================================
--- /dev/null
+++ newlib/newlib/libc/machine/spu/snprintf.c
@@ -0,0 +1,52 @@
+#include <_ansi.h>
+#include <stdio.h>
+
+#include "c99ppe.h"
+
+#ifdef _HAVE_STDC
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#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, args.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 */
Index: newlib/newlib/libc/machine/spu/sprintf.c
===================================================================
--- /dev/null
+++ newlib/newlib/libc/machine/spu/sprintf.c
@@ -0,0 +1,48 @@
+#include <_ansi.h>
+#include <stdio.h>
+
+#include "c99ppe.h"
+
+#ifdef _HAVE_STDC
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#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, args.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 */
Index: newlib/newlib/libc/machine/spu/sscanf.c
===================================================================
--- /dev/null
+++ newlib/newlib/libc/machine/spu/sscanf.c
@@ -0,0 +1,49 @@
+#include <_ansi.h>
+#include <stdio.h>
+
+#include "c99ppe.h"
+
+#ifdef _HAVE_STDC
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#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, args.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 */
Index: newlib/newlib/libc/machine/spu/vsnprintf.c
===================================================================
--- newlib.orig/newlib/libc/machine/spu/vsnprintf.c
+++ newlib/newlib/libc/machine/spu/vsnprintf.c
@@ -1,4 +1,3 @@
-
 #include <_ansi.h>
 #include <stdio.h>
 
@@ -32,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;
Index: newlib/newlib/libc/machine/spu/vsprintf.c
===================================================================
--- newlib.orig/newlib/libc/machine/spu/vsprintf.c
+++ newlib/newlib/libc/machine/spu/vsprintf.c
@@ -1,4 +1,3 @@
-
 #include <_ansi.h>
 #include <stdio.h>
 
@@ -19,6 +18,8 @@ typedef struct
   va_list ap;
 } c99_vsprintf_t;
 
+#ifndef _REENT_ONLY
+
 int
 _DEFUN (vsprintf, (str, fmt, ap),
      char *str _AND
@@ -27,6 +28,9 @@ _DEFUN (vsprintf, (str, fmt, ap),
 {
   int* ret;
   c99_vsprintf_t args;
+
+  CHECK_STR_INIT(_REENT);
+
   ret = (int*) &args;
 
   args.str = str;
@@ -37,3 +41,5 @@ _DEFUN (vsprintf, (str, fmt, ap),
 
   return *ret;
 }
+
+#endif /* ! _REENT_ONLY */
Index: newlib/newlib/libc/machine/spu/remove.c
===================================================================
--- /dev/null
+++ newlib/newlib/libc/machine/spu/remove.c
@@ -0,0 +1,16 @@
+#include <stdio.h>
+
+#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;
+}
+
Index: newlib/newlib/libc/machine/spu/rename.c
===================================================================
--- /dev/null
+++ newlib/newlib/libc/machine/spu/rename.c
@@ -0,0 +1,29 @@
+
+#include <_ansi.h>
+#include <stdio.h>
+
+#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;
+}
Index: newlib/newlib/libc/machine/spu/tmpnam.c
===================================================================
--- /dev/null
+++ newlib/newlib/libc/machine/spu/tmpnam.c
@@ -0,0 +1,15 @@
+#include <stdio.h>
+
+#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;
+}
Index: newlib/newlib/libc/machine/spu/Makefile.am
===================================================================
--- newlib.orig/newlib/libc/machine/spu/Makefile.am
+++ newlib/newlib/libc/machine/spu/Makefile.am
@@ -16,7 +16,8 @@ lib_a_SOURCES = setjmp.S memcpy.c memmov
 	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)
Index: newlib/newlib/libc/machine/spu/Makefile.in
===================================================================
--- newlib.orig/newlib/libc/machine/spu/Makefile.in
+++ newlib/newlib/libc/machine/spu/Makefile.in
@@ -68,7 +68,10 @@ 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
 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-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 memmov
 	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)

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