Working towards having the gcc fortran compiler operational we need
support for stat(). This is pretty straightforward, it uses the stop and
signal method to execute the standard stat() on the PowerPC part of the
cell.
------------------------------------------------------------------------
This patch adds stat function implementation to newlib.
diff -uNpr newlib-1.14.0.orig/libgloss/spu/jsre.h
newlib-1.14.0/libgloss/spu/jsre.h
--- newlib-1.14.0.orig/libgloss/spu/jsre.h 2006-07-25
18:18:32.792724008 +0200
+++ newlib-1.14.0/libgloss/spu/jsre.h 2006-07-25 14:03:37.345704400
+0200
@@ -57,6 +57,7 @@ Author: Andreas Neukoetter (ti95neuk@de.
#define JSRE_LSEEK 9
#define JSRE_OPEN 15
#define JSRE_READ 16
+#define JSRE_STAT 23
#define JSRE_UNLINK 24
#define JSRE_WRITE 27
@@ -120,6 +121,13 @@ typedef struct
unsigned int pad1[ 3 ];
} syscall_fstat_t;
+typedef struct
+{
+ unsigned int pathname;
+ unsigned int pad0[ 3 ];
+ unsigned int ptr;
+ unsigned int pad1[ 3 ];
+} syscall_stat_t;
typedef struct
{
diff -uNpr newlib-1.14.0.orig/libgloss/spu/syscalls.c
newlib-1.14.0/libgloss/spu/syscalls.c
--- newlib-1.14.0.orig/libgloss/spu/syscalls.c 2006-07-25
18:18:32.798723096 +0200
+++ newlib-1.14.0/libgloss/spu/syscalls.c 2006-07-25
14:03:37.360702120 +0200
@@ -243,6 +243,37 @@ fstat (int file, struct stat *pstat)
}
int
+stat (const char *pathname, struct stat *pstat)
+{
+ syscall_stat_t sys;
+ syscall_out_t *psys_out = ( syscall_out_t* )&sys;
+ jsre_stat_t pjstat;
+
+ sys.pathname = pathname;
+ sys.ptr = ( unsigned int )&pjstat;
+
+ send_to_ppe_0x2101 (JSRE_STAT, &sys);
+
+ pstat->st_dev = pjstat.dev;
+ pstat->st_ino = pjstat.ino;
+ pstat->st_mode = pjstat.mode;
+ pstat->st_nlink = pjstat.nlink;
+ pstat->st_uid = pjstat.uid;
+ pstat->st_gid = pjstat.gid;
+ pstat->st_rdev = pjstat.rdev;
+ pstat->st_size = pjstat.size;
+ pstat->st_blksize = pjstat.blksize;
+ pstat->st_blocks = pjstat.blocks;
+ pstat->st_atime = pjstat.atime;
+ pstat->st_mtime = pjstat.mtime;
+ pstat->st_ctime = pjstat.ctime;
+
+ errno = psys_out->err;
+ return( psys_out->rc );
+}
+
+
+int
unlink (const char *pathname)
{
int rc;