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]

[PATCH 4/5] stdio offloading


Because the SPEs have 256K of memory and using something like printf() takes >100K, there is an interface for the SPE to stop and signal in order to execute certain standard calls on the PowerPC part of the cell. This patch offloads a large number of these stdio calls so that an SPE application developer will have enough memory space left to do something useful.

This patch is completely isolated to the machine/spe directory.
Offload some c99 stdio functions to the PPE
Index: newlib-1.12.0/newlib/libc/machine/spu/printf.c
===================================================================
--- /dev/null
+++ newlib-1.12.0/newlib/libc/machine/spu/printf.c
@@ -0,0 +1,54 @@
+
+#include <_ansi.h>
+#include <stdio.h>
+
+#include "c99ppe.h"
+
+#ifdef _HAVE_STDC
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+
+typedef struct
+{
+  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)
+     char *fmt;
+     va_dcl
+#endif
+{
+  int* ret;
+  c99_printf_t args;
+  ret = (int*) &args;
+
+  args.fmt = fmt;
+#ifdef _HAVE_STDC
+  va_start (args.ap, args.fmt);
+#else
+  va_start (args.ap);
+#endif
+
+
+  /*  ret = vfprintf (_stdout_r (_REENT), fmt, ap);*/
+  send_to_ppe(SPE_C99_SIGNALCODE, SPE_C99_VPRINTF, &args);
+
+  va_end (args.ap);
+  return *ret;
+}
+
+#endif /* ! _REENT_ONLY */
Index: newlib-1.12.0/newlib/libc/machine/spu/c99ppe.h
===================================================================
--- /dev/null
+++ newlib-1.12.0/newlib/libc/machine/spu/c99ppe.h
@@ -0,0 +1,107 @@
+/*
+(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>
+*/
+
+#define SPE_C99_SIGNALCODE 0x2100
+
+#define SPE_C99_OP_SHIFT    	24
+#define SPE_C99_OP_MASK	    	0xff
+#define SPE_C99_DATA_MASK   	0xffffff
+
+enum {
+	SPE_C99_CLEARERR=0x01,
+	SPE_C99_FCLOSE,
+	SPE_C99_FEOF,
+	SPE_C99_FERROR,
+	SPE_C99_FFLUSH,
+	SPE_C99_FGETC,
+	SPE_C99_FGETPOS,
+	SPE_C99_FGETS,
+	SPE_C99_FILENO,
+	SPE_C99_FOPEN, //implemented
+	SPE_C99_FPUTC,
+	SPE_C99_FPUTS,
+	SPE_C99_FREAD,
+	SPE_C99_FREOPEN,
+	SPE_C99_FSEEK,
+	SPE_C99_FSETPOS,
+	SPE_C99_FTELL,
+	SPE_C99_FWRITE,
+	SPE_C99_GETC,
+	SPE_C99_GETCHAR,
+	SPE_C99_GETS,
+	SPE_C99_PERROR,
+	SPE_C99_PUTC,
+	SPE_C99_PUTCHAR,
+	SPE_C99_PUTS,
+	SPE_C99_REMOVE,
+	SPE_C99_RENAME,
+	SPE_C99_REWIND,
+	SPE_C99_SETBUF,
+	SPE_C99_SETVBUF,
+	SPE_C99_SYSTEM, //not yet implemented in newlib
+	SPE_C99_TMPFILE,
+	SPE_C99_TMPNAM,
+	SPE_C99_UNGETC,
+	SPE_C99_VFPRINTF,
+	SPE_C99_VFSCANF,
+	SPE_C99_VPRINTF,
+	SPE_C99_VSCANF,
+	SPE_C99_VSNPRINTF,
+	SPE_C99_VSPRINTF,
+	SPE_C99_VSSCANF,
+	SPE_C99_LAST_OPCODE,
+};
+#define SPE_C99_NR_OPCODES 	((SPE_C99_LAST_OPCODE - SPE_C99_CLEARERR) + 1)
+
+#define SPE_STDIN                   1
+#define SPE_STDOUT                  2
+#define SPE_STDERR                  3
+#define SPE_FOPEN_MAX               (FOPEN_MAX+1)
+#define SPE_FOPEN_MIN               4
+static void
+
+send_to_ppe(int signalcode, int opcode, void *data)
+{
+
+	unsigned int	combined = ( ( opcode<<24 )&0xff000000 ) | ( ( unsigned int )data & 0x00ffffff );
+
+        vector unsigned int stopfunc = {
+                signalcode,     /* stop 0x210x*/
+                (unsigned int) combined,
+                0x4020007f,     /* nop */
+                0x35000000      /* bi $0 */
+        };
+
+        void (*f) (void) = (void *) &stopfunc;
+        asm ("sync");
+        return (f ());
+}
Index: newlib-1.12.0/newlib/libc/machine/spu/configure
===================================================================
--- newlib-1.12.0.orig/newlib/libc/machine/spu/configure
+++ newlib-1.12.0/newlib/libc/machine/spu/configure
@@ -1588,12 +1588,9 @@ OBJEXT=${oext}
 
 
 
+extra_objs="printf.o vfprintf.o clearerr.o fclose.o feof.o ferror.o fflush.o fgetc.o fgetpos.o fgets.o fileno.o fopen.o fputc.o fputs.o fread.o freopen.o fseek.o fsetpos.o ftell.o fwrite.o getc.o getchar.o gets.o perror.o putc.o putchar.o puts.o remove.o rename.o rewind.o setbuf.o setvbuf.o tmpfile.o ungetc.o vfprintf.o vfscanf.o vprintf.o vscanf.o vsnprintf.o vsprintf.o vsscanf.o"
 
-
-
-extra_objs=
-extra_sources=
-
+extra_sources="printf.c vfprintf.c clearerr.c fclose.c feof.c ferror.c fflush.c fgetc.c fgetpos.c fgets.c fileno.c fopen.c fputc.c fputs.c fread.c freopen.c fseek.c fsetpos.c ftell.c fwrite.c getc.c getchar.c gets.c perror.c putc.c putchar.c puts.c remove.c rename.c rewind.c setbuf.c setvbuf.c tmpfile.c ungetc.c vfprintf.c vfscanf.c vprintf.c vscanf.c vsnprintf.c vsprintf.c vsscanf.c"
 
 
 trap '' 1 2 15
Index: newlib-1.12.0/newlib/libc/machine/spu/configure.in
===================================================================
--- newlib-1.12.0.orig/newlib/libc/machine/spu/configure.in
+++ newlib-1.12.0/newlib/libc/machine/spu/configure.in
@@ -9,8 +9,9 @@ AC_CONFIG_AUX_DIR(../../../..)
 
 NEWLIB_CONFIGURE(../../..)
 
-extra_objs=
-extra_sources=
+extra_objs="printf.o vfprintf.o clearerr.o fclose.o feof.o ferror.o fflush.o fgetc.o fgetpos.o fgets.o fileno.o fopen.o fputc.o fputs.o fread.o freopen.o fseek.o fsetpos.o ftell.o fwrite.o getc.o getchar.o gets.o perror.o putc.o putchar.o puts.o remove.o rename.o rewind.o setbuf.o setvbuf.o tmpfile.o ungetc.o vfprintf.o vfscanf.o vprintf.o vscanf.o vsnprintf.o vsprintf.o vsscanf.o"
+
+extra_sources="printf.c vfprintf.c clearerr.c fclose.c feof.c ferror.c fflush.c fgetc.c fgetpos.c fgets.c fileno.c fopen.c fputc.c fputs.c fread.c freopen.c fseek.c fsetpos.c ftell.c fwrite.c getc.c getchar.c gets.c perror.c putc.c putchar.c puts.c remove.c rename.c rewind.c setbuf.c setvbuf.c tmpfile.c ungetc.c vfprintf.c vfscanf.c vprintf.c vscanf.c vsnprintf.c vsprintf.c vsscanf.c"
 AC_SUBST(extra_objs)
 AC_SUBST(extra_sources)
 
Index: newlib-1.12.0/newlib/libc/machine/spu/fopen.c
===================================================================
--- /dev/null
+++ newlib-1.12.0/newlib/libc/machine/spu/fopen.c
@@ -0,0 +1,39 @@
+
+#include <_ansi.h>
+#include <stdio.h>
+
+#include "c99ppe.h"
+
+#ifdef _HAVE_STDC
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+
+typedef struct
+{
+  char* fp;
+  unsigned int pad0[ 3 ];
+  char* mode;
+  unsigned int pad1[ 3 ];
+} c99_fopen_t;
+
+#ifndef _REENT_ONLY
+FILE *
+_DEFUN (fopen, (file, mode),
+	_CONST char *file _AND
+	_CONST char *mode)
+{
+  FILE** ret;
+  c99_fopen_t args;
+  args.fp = file;
+  args.mode = mode;
+  ret = (FILE**) &args;
+
+  /*  ret = vfprintf (_stdout_r (_REENT), fmt, ap);*/
+  send_to_ppe(SPE_C99_SIGNALCODE, SPE_C99_FOPEN, &args);
+
+  return *ret;
+}
+
+#endif /* ! _REENT_ONLY */
Index: newlib-1.12.0/newlib/libc/machine/spu/vfprintf.c
===================================================================
--- /dev/null
+++ newlib-1.12.0/newlib/libc/machine/spu/vfprintf.c
@@ -0,0 +1,43 @@
+
+#include <_ansi.h>
+#include <stdio.h>
+
+#include "c99ppe.h"
+
+#ifdef _HAVE_STDC
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+
+typedef struct
+{
+  FILE * fp;
+  unsigned int pad0[ 3 ];
+  char* fmt;
+  unsigned int pad1[ 3 ];
+  va_list ap;
+} c99_vfprintf_t;
+
+#ifndef _REENT_ONLY
+
+int
+_DEFUN (vfprintf, (fp, fmt0, ap),
+	FILE * fp _AND
+	_CONST char *fmt0 _AND
+	va_list ap)
+{
+  int* ret;
+  c99_vfprintf_t args;
+  ret = (int*) &args;
+
+  args.fp = fp;
+  args.fmt = (char*) fmt0;
+  va_copy(args.ap,ap);
+
+  send_to_ppe(SPE_C99_SIGNALCODE, SPE_C99_VFPRINTF, &args);
+
+  return *ret;
+}
+
+#endif /* ! _REENT_ONLY */
Index: newlib-1.12.0/newlib/libc/machine/spu/clearerr.c
===================================================================
--- /dev/null
+++ newlib-1.12.0/newlib/libc/machine/spu/clearerr.c
@@ -0,0 +1,15 @@
+#include <stdio.h>
+
+#include "c99ppe.h"
+#undef clearerr
+
+_VOID
+_DEFUN (clearerr, (fp),
+	FILE * fp)
+
+{
+  send_to_ppe(SPE_C99_SIGNALCODE, SPE_C99_CLEARERR, &fp);
+
+  return;
+}
+
Index: newlib-1.12.0/newlib/libc/machine/spu/fclose.c
===================================================================
--- /dev/null
+++ newlib-1.12.0/newlib/libc/machine/spu/fclose.c
@@ -0,0 +1,25 @@
+
+#include <_ansi.h>
+#include <stdio.h>
+
+#include "c99ppe.h"
+
+#ifdef _HAVE_STDC
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+
+#ifndef _REENT_ONLY
+int
+_DEFUN (fclose, (fp),
+	FILE * fp)
+{
+  int* ret = (int*) &fp;
+
+  send_to_ppe(SPE_C99_SIGNALCODE, SPE_C99_FCLOSE, &fp);
+
+  return *ret;
+}
+
+#endif /* ! _REENT_ONLY */
Index: newlib-1.12.0/newlib/libc/machine/spu/feof.c
===================================================================
--- /dev/null
+++ newlib-1.12.0/newlib/libc/machine/spu/feof.c
@@ -0,0 +1,18 @@
+#include <stdio.h>
+
+#include "c99ppe.h"
+
+#undef feof
+
+int
+_DEFUN (feof, (fp),
+	FILE * fp)
+{
+  int* result;
+  result = (int*)&fp;
+
+  send_to_ppe(SPE_C99_SIGNALCODE, SPE_C99_FEOF, &fp);
+
+
+  return *result;
+}
Index: newlib-1.12.0/newlib/libc/machine/spu/ferror.c
===================================================================
--- /dev/null
+++ newlib-1.12.0/newlib/libc/machine/spu/ferror.c
@@ -0,0 +1,20 @@
+#include <stdio.h>
+
+#include "c99ppe.h"
+
+#undef feof
+
+#undef ferror
+
+int
+_DEFUN (ferror, (fp),
+	FILE * fp)
+{
+  int* result;
+  result = (int*)&fp;
+
+  send_to_ppe(SPE_C99_SIGNALCODE, SPE_C99_FERROR, &fp);
+
+
+  return *result;
+}
Index: newlib-1.12.0/newlib/libc/machine/spu/fflush.c
===================================================================
--- /dev/null
+++ newlib-1.12.0/newlib/libc/machine/spu/fflush.c
@@ -0,0 +1,16 @@
+#include <stdio.h>
+
+#include "c99ppe.h"
+
+int
+_DEFUN (fflush, (fp),
+	FILE * fp)
+{
+  int* result;
+  result = (int*)&fp;
+
+  send_to_ppe(SPE_C99_SIGNALCODE, SPE_C99_FFLUSH, &fp);
+
+
+  return *result;
+}
Index: newlib-1.12.0/newlib/libc/machine/spu/fgetc.c
===================================================================
--- /dev/null
+++ newlib-1.12.0/newlib/libc/machine/spu/fgetc.c
@@ -0,0 +1,16 @@
+#include <stdio.h>
+
+#include "c99ppe.h"
+
+int
+_DEFUN (fgetc, (fp),
+	FILE * fp)
+{
+  int* result;
+  result = (int*)&fp;
+
+  send_to_ppe(SPE_C99_SIGNALCODE, SPE_C99_FGETC, &fp);
+
+
+  return *result;
+}
Index: newlib-1.12.0/newlib/libc/machine/spu/fgetpos.c
===================================================================
--- /dev/null
+++ newlib-1.12.0/newlib/libc/machine/spu/fgetpos.c
@@ -0,0 +1,28 @@
+#include <stdio.h>
+
+#include "c99ppe.h"
+
+typedef struct
+{
+  FILE * fp;
+  unsigned int pad0[ 3 ];
+  _fpos_t * pos;
+} c99_fgetpos_t;
+
+int
+_DEFUN (fgetpos, (fp, pos),
+	FILE * fp _AND
+	_fpos_t * pos)
+{
+  c99_fgetpos_t arg;
+  int* result;
+  result = (int*)&fp;
+
+  arg.fp = fp;
+  arg.pos = pos;
+
+  send_to_ppe(SPE_C99_SIGNALCODE, SPE_C99_FGETPOS, &arg);
+
+
+  return *result;
+}
Index: newlib-1.12.0/newlib/libc/machine/spu/fgets.c
===================================================================
--- /dev/null
+++ newlib-1.12.0/newlib/libc/machine/spu/fgets.c
@@ -0,0 +1,31 @@
+#include <stdio.h>
+
+#include "c99ppe.h"
+
+typedef struct
+{
+  char *buf;
+  unsigned int pad0[3];
+  int n;
+  unsigned int pad1[3];
+  FILE *fp;
+} c99_fgets_t;
+
+char *
+_DEFUN (fgets, (buf, n, fp),
+	char *buf _AND
+	int n _AND
+	FILE * fp)
+{
+  char** ret;
+  c99_fgets_t args;
+  args.buf = buf;
+  args.n = n;
+  args.fp = fp;
+  ret = (char**) &args;
+
+  send_to_ppe(SPE_C99_SIGNALCODE, SPE_C99_FGETS, &args);
+
+  return *ret;
+}
+
Index: newlib-1.12.0/newlib/libc/machine/spu/fileno.c
===================================================================
--- /dev/null
+++ newlib-1.12.0/newlib/libc/machine/spu/fileno.c
@@ -0,0 +1,16 @@
+#include <stdio.h>
+
+#include "c99ppe.h"
+
+
+int
+_DEFUN (fileno, (fp),
+	FILE *fp)
+
+{
+  int *ret = (int*)&fp;
+  send_to_ppe(SPE_C99_SIGNALCODE, SPE_C99_FILENO, &fp);
+
+  return *ret;
+}
+
Index: newlib-1.12.0/newlib/libc/machine/spu/fputc.c
===================================================================
--- /dev/null
+++ newlib-1.12.0/newlib/libc/machine/spu/fputc.c
@@ -0,0 +1,30 @@
+
+#include <_ansi.h>
+#include <stdio.h>
+
+#include "c99ppe.h"
+
+typedef struct
+{
+  int ch;
+  unsigned int pad0[ 3 ];
+  FILE* fp;
+  unsigned int pad1[ 3 ];
+} c99_fputc_t;
+
+int
+fputc (c, fp)
+     int c;
+     register FILE *fp;
+{
+  int* ret;
+  c99_fputc_t args;
+  args.ch = c;
+  args.fp = fp;
+  ret = (int*)&args;
+
+  send_to_ppe(SPE_C99_SIGNALCODE, SPE_C99_FPUTC, &args);
+
+  return *ret;
+}
+
Index: newlib-1.12.0/newlib/libc/machine/spu/fputs.c
===================================================================
--- /dev/null
+++ newlib-1.12.0/newlib/libc/machine/spu/fputs.c
@@ -0,0 +1,30 @@
+
+#include <_ansi.h>
+#include <stdio.h>
+
+#include "c99ppe.h"
+
+typedef struct
+{
+  char* s;
+  unsigned int pad0[ 3 ];
+  FILE* fp;
+  unsigned int pad1[ 3 ];
+} c99_fputs_t;
+
+int
+_DEFUN (fputs, (s, fp),
+	char _CONST * s _AND
+	FILE * fp)
+{
+  int* ret;
+  c99_fputs_t args;
+  args.s = s;
+  args.fp = fp;
+  ret = (int*)&args;
+
+  send_to_ppe(SPE_C99_SIGNALCODE, SPE_C99_FPUTS, &args);
+
+  return *ret;
+}
+
Index: newlib-1.12.0/newlib/libc/machine/spu/fread.c
===================================================================
--- /dev/null
+++ newlib-1.12.0/newlib/libc/machine/spu/fread.c
@@ -0,0 +1,36 @@
+
+#include <_ansi.h>
+#include <stdio.h>
+
+#include "c99ppe.h"
+
+typedef struct
+{
+  char* buf;
+  unsigned int pad0[ 3 ];
+  size_t size;
+  unsigned int pad1[ 3 ];
+  size_t count;
+  unsigned int pad2[ 3 ];
+  FILE *fp;
+} c99_fread_t;
+
+size_t
+_DEFUN (fread, (buf, size, count, fp),
+	_PTR buf _AND
+	size_t size _AND
+	size_t count _AND
+	FILE * fp)
+{
+  size_t* ret;
+  c99_fread_t args;
+  args.buf = buf;
+  args.size = size;
+  args.count = count;
+  args.fp = fp;
+  ret = (size_t*) &args;
+
+  send_to_ppe(SPE_C99_SIGNALCODE, SPE_C99_FREAD, &args);
+
+  return *ret;
+}
Index: newlib-1.12.0/newlib/libc/machine/spu/freopen.c
===================================================================
--- /dev/null
+++ newlib-1.12.0/newlib/libc/machine/spu/freopen.c
@@ -0,0 +1,32 @@
+
+#include <_ansi.h>
+#include <stdio.h>
+
+#include "c99ppe.h"
+
+typedef struct
+{
+  char *file;
+  unsigned int pad0[ 3 ];
+  char *mode;
+  unsigned int pad1[ 3 ];
+  FILE *fp;
+} c99_freopen_t;
+
+FILE *
+_DEFUN (freopen, (file, mode, fp),
+	const char *file _AND
+	const char *mode _AND
+	FILE *fp)
+{
+  FILE **ret;
+  c99_freopen_t args;
+  args.file = file;
+  args.mode = mode;
+  args.fp = fp;
+  ret = (FILE**) &args;
+
+  send_to_ppe(SPE_C99_SIGNALCODE, SPE_C99_FREOPEN, &args);
+
+  return *ret;
+}
Index: newlib-1.12.0/newlib/libc/machine/spu/fseek.c
===================================================================
--- /dev/null
+++ newlib-1.12.0/newlib/libc/machine/spu/fseek.c
@@ -0,0 +1,33 @@
+
+#include <_ansi.h>
+#include <stdio.h>
+
+#include "c99ppe.h"
+
+typedef struct
+{
+  FILE* fp;
+  unsigned int pad0[ 3 ];
+  long offset;
+  unsigned int pad1[ 3 ];
+  int whence;
+} c99_fseek_t;
+
+int
+_DEFUN (fseek, (fp, offset, whence),
+     register FILE *fp _AND
+     long offset _AND
+     int whence)
+{
+  int* ret;
+  c99_fseek_t args;
+  args.fp = fp;
+  args.offset = offset;
+  args.whence = whence;
+  ret = (int*)&args;
+
+  send_to_ppe(SPE_C99_SIGNALCODE, SPE_C99_FSEEK, &args);
+
+  return *ret;
+}
+
Index: newlib-1.12.0/newlib/libc/machine/spu/fsetpos.c
===================================================================
--- /dev/null
+++ newlib-1.12.0/newlib/libc/machine/spu/fsetpos.c
@@ -0,0 +1,29 @@
+
+#include <_ansi.h>
+#include <stdio.h>
+
+#include "c99ppe.h"
+
+typedef struct
+{
+  FILE* fp;
+  unsigned int pad0[ 3 ];
+  _fpos_t *pos;
+} c99_fsetpos_t;
+
+int
+_DEFUN (fsetpos, (iop, pos),
+	FILE * iop _AND
+	_CONST _fpos_t * pos)
+{
+  int* ret;
+  c99_fsetpos_t args;
+  args.fp = iop;
+  args.pos = pos;
+  ret = (int*)&args;
+
+  send_to_ppe(SPE_C99_SIGNALCODE, SPE_C99_FSETPOS, &args);
+
+  return *ret;
+}
+
Index: newlib-1.12.0/newlib/libc/machine/spu/ftell.c
===================================================================
--- /dev/null
+++ newlib-1.12.0/newlib/libc/machine/spu/ftell.c
@@ -0,0 +1,16 @@
+#include <stdio.h>
+
+#include "c99ppe.h"
+
+
+long
+_DEFUN (ftell, (fp),
+	FILE * fp)
+{
+  long *ret = (long*)&fp;
+
+  send_to_ppe(SPE_C99_SIGNALCODE, SPE_C99_CLEARERR, &fp);
+
+  return *ret;
+}
+
Index: newlib-1.12.0/newlib/libc/machine/spu/fwrite.c
===================================================================
--- /dev/null
+++ newlib-1.12.0/newlib/libc/machine/spu/fwrite.c
@@ -0,0 +1,36 @@
+
+#include <_ansi.h>
+#include <stdio.h>
+
+#include "c99ppe.h"
+
+typedef struct
+{
+  char* buf;
+  unsigned int pad0[ 3 ];
+  size_t size;
+  unsigned int pad1[ 3 ];
+  size_t count;
+  unsigned int pad2[ 3 ];
+  FILE *fp;
+} c99_fwrite_t;
+
+size_t
+_DEFUN (fread, (buf, size, count, fp),
+	_PTR buf _AND
+	size_t size _AND
+	size_t count _AND
+	FILE * fp)
+{
+  size_t* ret;
+  c99_fwrite_t args;
+  args.buf = buf;
+  args.size = size;
+  args.count = count;
+  args.fp = fp;
+  ret = (size_t*) &args;
+
+  send_to_ppe(SPE_C99_SIGNALCODE, SPE_C99_FWRITE, &args);
+
+  return *ret;
+}
Index: newlib-1.12.0/newlib/libc/machine/spu/getc.c
===================================================================
--- /dev/null
+++ newlib-1.12.0/newlib/libc/machine/spu/getc.c
@@ -0,0 +1,21 @@
+#include <stdio.h>
+
+#include "c99ppe.h"
+/*
+ * A subroutine version of the macro getc.
+ */
+
+#undef getc
+
+int
+getc (fp)
+     FILE *fp;
+{
+  int* ret;
+  ret = (int*)&fp;
+
+  send_to_ppe(SPE_C99_SIGNALCODE, SPE_C99_GETC, &fp);
+
+  return *ret;
+}
+
Index: newlib-1.12.0/newlib/libc/machine/spu/getchar.c
===================================================================
--- /dev/null
+++ newlib-1.12.0/newlib/libc/machine/spu/getchar.c
@@ -0,0 +1,16 @@
+#include <stdio.h>
+
+#include "c99ppe.h"
+
+#undef getchar
+
+int
+getchar ()
+{
+  int ret;
+
+  send_to_ppe(SPE_C99_SIGNALCODE, SPE_C99_GETCHAR, &ret);
+
+  return ret;
+}
+
Index: newlib-1.12.0/newlib/libc/machine/spu/gets.c
===================================================================
--- /dev/null
+++ newlib-1.12.0/newlib/libc/machine/spu/gets.c
@@ -0,0 +1,16 @@
+#include <stdio.h>
+
+#include "c99ppe.h"
+
+char *
+gets (buf)
+     char *buf;
+{
+
+  /* The return value gets written over buf
+   */
+  send_to_ppe(SPE_C99_SIGNALCODE, SPE_C99_GETS, &buf);
+
+  return buf;
+}
+
Index: newlib-1.12.0/newlib/libc/machine/spu/perror.c
===================================================================
--- /dev/null
+++ newlib-1.12.0/newlib/libc/machine/spu/perror.c
@@ -0,0 +1,14 @@
+#include <stdio.h>
+
+#include "c99ppe.h"
+
+void
+_DEFUN (perror, (s),
+	_CONST char *s)
+
+{
+  send_to_ppe(SPE_C99_SIGNALCODE, SPE_C99_PERROR, &s);
+
+  return;
+}
+
Index: newlib-1.12.0/newlib/libc/machine/spu/putchar.c
===================================================================
--- /dev/null
+++ newlib-1.12.0/newlib/libc/machine/spu/putchar.c
@@ -0,0 +1,17 @@
+#include <stdio.h>
+
+#include "c99ppe.h"
+
+#undef putchar
+
+int
+putchar (c)
+     int c;
+{
+  /* c gets overwritten before return */
+
+  send_to_ppe(SPE_C99_SIGNALCODE, SPE_C99_GETCHAR, &c);
+
+  return c;
+}
+
Index: newlib-1.12.0/newlib/libc/machine/spu/puts.c
===================================================================
--- /dev/null
+++ newlib-1.12.0/newlib/libc/machine/spu/puts.c
@@ -0,0 +1,16 @@
+#include <stdio.h>
+
+#include "c99ppe.h"
+
+int
+_DEFUN (puts, (s),
+	char _CONST * s)
+{
+
+  /* The return value gets written over s
+   */
+  send_to_ppe(SPE_C99_SIGNALCODE, SPE_C99_PUTS, &s);
+
+  return (int)s;
+}
+
Index: newlib-1.12.0/newlib/libc/machine/spu/remove.c
===================================================================
--- /dev/null
+++ newlib-1.12.0/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_GETS, &filename);
+
+  return (int)filename;
+}
+
Index: newlib-1.12.0/newlib/libc/machine/spu/rename.c
===================================================================
--- /dev/null
+++ newlib-1.12.0/newlib/libc/machine/spu/rename.c
@@ -0,0 +1,29 @@
+
+#include <_ansi.h>
+#include <stdio.h>
+
+#include "c99ppe.h"
+
+typedef struct
+{
+  char *old;
+  unsigned int pad0[ 3 ];
+  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-1.12.0/newlib/libc/machine/spu/rewind.c
===================================================================
--- /dev/null
+++ newlib-1.12.0/newlib/libc/machine/spu/rewind.c
@@ -0,0 +1,13 @@
+#include <stdio.h>
+
+#include "c99ppe.h"
+
+void
+_DEFUN (rewind, (fp),
+	FILE * fp)
+{
+  send_to_ppe(SPE_C99_SIGNALCODE, SPE_C99_REWIND, &fp);
+
+  return;
+}
+
Index: newlib-1.12.0/newlib/libc/machine/spu/setbuf.c
===================================================================
--- /dev/null
+++ newlib-1.12.0/newlib/libc/machine/spu/setbuf.c
@@ -0,0 +1,28 @@
+
+#include <_ansi.h>
+#include <stdio.h>
+
+#include "c99ppe.h"
+
+typedef struct
+{
+  FILE* fp;
+  unsigned int pad0[ 3 ];
+  char *buf;
+  unsigned int pad1[ 3 ];
+} c99_setbuf_t;
+
+void
+_DEFUN (setbuf, (fp, buf),
+	FILE * fp _AND
+	char *buf)
+{
+  c99_setbuf_t args;
+  args.fp = fp;
+  args.buf = buf;
+
+  send_to_ppe(SPE_C99_SIGNALCODE, SPE_C99_SETBUF, &args);
+
+  return;
+}
+
Index: newlib-1.12.0/newlib/libc/machine/spu/setvbuf.c
===================================================================
--- /dev/null
+++ newlib-1.12.0/newlib/libc/machine/spu/setvbuf.c
@@ -0,0 +1,38 @@
+
+#include <_ansi.h>
+#include <stdio.h>
+
+#include "c99ppe.h"
+
+typedef struct
+{
+  FILE* fp;
+  unsigned int pad0[ 3 ];
+  char *buf;
+  unsigned int pad1[ 3 ];
+  int mode;
+  unsigned int pad2[ 3 ];
+  size_t size;
+  unsigned int pad3[ 3 ];
+} c99_setvbuf_t;
+
+int
+_DEFUN (setvbuf, (fp, buf, mode, size),
+	FILE * fp _AND
+	char *buf _AND
+	int mode _AND
+	size_t size)
+{
+  int* ret;
+  c99_setvbuf_t args;
+  args.fp = fp;
+  args.buf = buf;
+  args.mode = mode;
+  args.size = size;
+  ret = (int*)&args;
+
+  send_to_ppe(SPE_C99_SIGNALCODE, SPE_C99_SETVBUF, &args);
+
+  return *ret;
+}
+
Index: newlib-1.12.0/newlib/libc/machine/spu/tmpfile.c
===================================================================
--- /dev/null
+++ newlib-1.12.0/newlib/libc/machine/spu/tmpfile.c
@@ -0,0 +1,14 @@
+#include <stdio.h>
+
+#include "c99ppe.h"
+
+FILE *
+_DEFUN_VOID (tmpfile)
+{
+  FILE* ret;
+
+  send_to_ppe(SPE_C99_SIGNALCODE, SPE_C99_TMPFILE, &ret);
+
+  return ret;
+}
+
Index: newlib-1.12.0/newlib/libc/machine/spu/tmpnam.c
===================================================================
--- /dev/null
+++ newlib-1.12.0/newlib/libc/machine/spu/tmpnam.c
@@ -0,0 +1,16 @@
+#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-1.12.0/newlib/libc/machine/spu/ungetc.c
===================================================================
--- /dev/null
+++ newlib-1.12.0/newlib/libc/machine/spu/ungetc.c
@@ -0,0 +1,30 @@
+
+#include <_ansi.h>
+#include <stdio.h>
+
+#include "c99ppe.h"
+
+typedef struct
+{
+  int c;
+  unsigned int pad0[ 3 ];
+  FILE* fp;
+  unsigned int pad1[ 3 ];
+} c99_ungetc_t;
+
+int
+ungetc (c, fp)
+     int c;
+     register FILE *fp;
+{
+  int* ret;
+  c99_ungetc_t args;
+  args.c = c;
+  args.fp = fp;
+  ret = (int*)&args;
+
+  send_to_ppe(SPE_C99_SIGNALCODE, SPE_C99_UNGETC, &args);
+
+  return *ret;
+}
+
Index: newlib-1.12.0/newlib/libc/machine/spu/vfscanf.c
===================================================================
--- /dev/null
+++ newlib-1.12.0/newlib/libc/machine/spu/vfscanf.c
@@ -0,0 +1,43 @@
+
+#include <_ansi.h>
+#include <stdio.h>
+
+#include "c99ppe.h"
+
+#ifdef _HAVE_STDC
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+
+typedef struct
+{
+  FILE * fp;
+  unsigned int pad0[ 3 ];
+  char* fmt;
+  unsigned int pad1[ 3 ];
+  va_list ap;
+} c99_vfscanf_t;
+
+#ifndef _REENT_ONLY
+
+int
+_DEFUN (vfscanf, (fp, fmt, ap),
+    FILE *fp _AND
+    _CONST char *fmt _AND
+    va_list ap)
+{
+  int* ret;
+  c99_vfscanf_t args;
+  ret = (int*) &args;
+
+  args.fp = fp;
+  args.fmt = (char*) fmt;
+  va_copy(args.ap,ap);
+
+  send_to_ppe(SPE_C99_SIGNALCODE, SPE_C99_VFSCANF, &args);
+
+  return *ret;
+}
+
+#endif /* ! _REENT_ONLY */
Index: newlib-1.12.0/newlib/libc/machine/spu/vsnprintf.c
===================================================================
--- /dev/null
+++ newlib-1.12.0/newlib/libc/machine/spu/vsnprintf.c
@@ -0,0 +1,47 @@
+
+#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 ];
+  char* fmt;
+  unsigned int pad2[ 3 ];
+  va_list ap;
+} c99_vsnprintf_t;
+
+#ifndef _REENT_ONLY
+
+int
+_DEFUN (vsnprintf, (str, size, fmt, ap),
+     char *str _AND
+     size_t size _AND
+     _CONST char *fmt _AND
+     va_list ap)
+{
+  int* ret;
+  c99_vsnprintf_t args;
+  ret = (int*) &args;
+
+  args.str = str;
+  args.size = size;
+  args.fmt = fmt;
+  va_copy(args.ap,ap);
+
+  send_to_ppe(SPE_C99_SIGNALCODE, SPE_C99_VSNPRINTF, &args);
+
+  return *ret;
+}
+
+#endif /* ! _REENT_ONLY */
Index: newlib-1.12.0/newlib/libc/machine/spu/vsscanf.c
===================================================================
--- /dev/null
+++ newlib-1.12.0/newlib/libc/machine/spu/vsscanf.c
@@ -0,0 +1,39 @@
+
+#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 ];
+  char *fmt;
+  unsigned int pad1[ 3 ];
+  va_list ap;
+} c99_vsscanf_t;
+
+int
+_DEFUN (vsscanf, (str, fmt, ap),
+    _CONST char *str _AND
+    _CONST char *fmt _AND
+    va_list ap)
+{
+  int* ret;
+  c99_vsscanf_t args;
+  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;
+}
Index: newlib-1.12.0/newlib/libc/machine/spu/putc.c
===================================================================
--- /dev/null
+++ newlib-1.12.0/newlib/libc/machine/spu/putc.c
@@ -0,0 +1,32 @@
+
+#include <_ansi.h>
+#include <stdio.h>
+
+#include "c99ppe.h"
+
+typedef struct
+{
+  int ch;
+  unsigned int pad0[ 3 ];
+  FILE* fp;
+  unsigned int pad1[ 3 ];
+} c99_putc_t;
+
+#undef putc
+
+int
+putc (c, fp)
+     int c;
+     register FILE *fp;
+{
+  int* ret;
+  c99_putc_t args;
+  args.ch = c;
+  args.fp = fp;
+  ret = (int*)&args;
+
+  send_to_ppe(SPE_C99_SIGNALCODE, SPE_C99_PUTC, &args);
+
+  return *ret;
+}
+
Index: newlib-1.12.0/newlib/libc/machine/spu/vscanf.c
===================================================================
--- /dev/null
+++ newlib-1.12.0/newlib/libc/machine/spu/vscanf.c
@@ -0,0 +1,39 @@
+
+#include <_ansi.h>
+#include <stdio.h>
+
+#include "c99ppe.h"
+
+#ifdef _HAVE_STDC
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+
+typedef struct
+{
+  char* fmt;
+  unsigned int pad0[ 3 ];
+  va_list ap;
+} c99_vscanf_t;
+
+#ifndef _REENT_ONLY
+
+int
+_DEFUN (vscanf, (fmt, ap),
+     _CONST char *fmt _AND
+     va_list ap)
+{
+  int* ret;
+  c99_vscanf_t args;
+  ret = (int*) &args;
+
+  args.fmt = (char*) fmt;
+  va_copy(args.ap,ap);
+
+  send_to_ppe(SPE_C99_SIGNALCODE, SPE_C99_VSCANF, &args);
+
+  return *ret;
+}
+
+#endif /* ! _REENT_ONLY */
Index: newlib-1.12.0/newlib/libc/machine/spu/vprintf.c
===================================================================
--- /dev/null
+++ newlib-1.12.0/newlib/libc/machine/spu/vprintf.c
@@ -0,0 +1,39 @@
+
+#include <_ansi.h>
+#include <stdio.h>
+
+#include "c99ppe.h"
+
+#ifdef _HAVE_STDC
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+
+typedef struct
+{
+  char* fmt;
+  unsigned int pad0[ 3 ];
+  va_list ap;
+} c99_vprintf_t;
+
+#ifndef _REENT_ONLY
+
+int
+_DEFUN (vprintf, (fmt, ap),
+     _CONST char *fmt _AND
+     va_list ap)
+{
+  int* ret;
+  c99_vprintf_t args;
+  ret = (int*) &args;
+
+  args.fmt = (char*) fmt;
+  va_copy(args.ap,ap);
+
+  send_to_ppe(SPE_C99_SIGNALCODE, SPE_C99_VPRINTF, &args);
+
+  return *ret;
+}
+
+#endif /* ! _REENT_ONLY */
Index: newlib-1.12.0/newlib/libc/machine/spu/vsprintf.c
===================================================================
--- /dev/null
+++ newlib-1.12.0/newlib/libc/machine/spu/vsprintf.c
@@ -0,0 +1,39 @@
+
+#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 ];
+  char *fmt;
+  unsigned int pad1[ 3 ];
+  va_list ap;
+} c99_vsprintf_t;
+
+int
+_DEFUN (vsprintf, (str, fmt, ap),
+     char *str _AND
+     _CONST char *fmt _AND
+     va_list ap)
+{
+  int* ret;
+  c99_vsprintf_t args;
+  ret = (int*) &args;
+
+  args.str = str;
+  args.fmt = (char*) fmt;
+  va_copy(args.ap,ap);
+
+  send_to_ppe(SPE_C99_SIGNALCODE, SPE_C99_VSPRINTF, &args);
+
+  return *ret;
+}

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