[RFA] v850 syscall fixes
Kevin Buettner
kevinb@redhat.com
Fri Mar 11 22:08:00 GMT 2011
This patch, in conjunction with a corresponding patch to the sim,
fixes a number of failures in GDB's gdb.base/fileio.exp test.
I'll be posting the sim patch to gdb-patches shortly.
I wrote this patch a while back, but here are a few things that I
remember about it...
- I did a survey of the number used for SYS_rename for other
architectures. 128 is used for a non-SVR4 sparc64 library. 3001
was used by ARM. SVR4 sparc64 and rs6000 both used 134. Therefore,
I chose 134 since two other architectures were also using it.
- The errno handling in libc/sys/sysnecv850/trap.S was broken from
the very start. I doubt that it was ever tested.
Is this okay to commit? (I'm willing to break it up a bit if that'll
make it easier to review, but all of the changes below are v850 specific.
The only tricky bit is probably the errno handling in trap.S.)
libgloss/ChangeLog:
* v850/sys/syscall.h (SYS_rename): Define.
newlib/ChangeLog:
* libc/sys/sysnecv850/trap.S (___trap0): Fix errno handling.
* libc/sys/sysnecv850/rename.c: New file.
* libc/sys/sysnecv850/Makefile.am (lib_a_SOURCES): Add rename.c
* libc/sys/sysnecv850/Makefile.in: Regenerate.
* libc/sys/sysnecv850/fstat.c (_fstat): Invoke trap for SYS_fstat.
* libc/sys/sysnecv850/unlink.c (_unlink): Invoke trap for SYS_unlink.
Index: libgloss/v850/sys/syscall.h
===================================================================
RCS file: /cvs/src/src/libgloss/v850/sys/syscall.h,v
retrieving revision 1.1
diff -u -p -r1.1 syscall.h
--- libgloss/v850/sys/syscall.h 17 Mar 2000 22:48:53 -0000 1.1
+++ libgloss/v850/sys/syscall.h 11 Mar 2011 21:18:08 -0000
@@ -34,6 +34,7 @@
#define SYS_execve 59
#define SYS_times 43
#define SYS_gettimeofday 116
+#define SYS_rename 134
#define SYS_utime 201 /* not really a system call */
#define SYS_wait 202 /* nor is this */
Index: newlib/libc/sys/sysnecv850/Makefile.am
===================================================================
RCS file: /cvs/src/src/newlib/libc/sys/sysnecv850/Makefile.am,v
retrieving revision 1.7
diff -u -p -r1.7 Makefile.am
--- newlib/libc/sys/sysnecv850/Makefile.am 9 Sep 2010 14:54:24 -0000 1.7
+++ newlib/libc/sys/sysnecv850/Makefile.am 11 Mar 2011 21:18:08 -0000
@@ -16,7 +16,7 @@ extra_objs = $(lpfx)_exit.o $(lpfx)acces
$(lpfx)open.o $(lpfx)pipe.o $(lpfx)read.o $(lpfx)link.o \
$(lpfx)sbrk.o $(lpfx)stat.o $(lpfx)time.o $(lpfx)trap.o \
$(lpfx)unlink.o $(lpfx)utime.o $(lpfx)wait.o $(lpfx)write.o \
- $(lpfx)times.o $(lpfx)gettime.o
+ $(lpfx)times.o $(lpfx)gettime.o $(lpfx)rename.o
else
extra_objs =
endif
@@ -27,7 +27,7 @@ EXTRA_lib_a_SOURCES = \
execv.c execve.c fork.c fstat.c getpid.c isatty.c \
kill.c lseek.c open.c pipe.c read.c link.c \
sbrk.c stat.c time.c trap.S unlink.c utime.c wait.c write.c \
- times.c gettime.c
+ times.c gettime.c rename.c
lib_a_SOURCES =
lib_a_DEPENDENCIES = $(extra_objs)
lib_a_CCASFLAGS = $(AM_CCASFLAGS)
Index: newlib/libc/sys/sysnecv850/Makefile.in
===================================================================
RCS file: /cvs/src/src/newlib/libc/sys/sysnecv850/Makefile.in,v
retrieving revision 1.19
diff -u -p -r1.19 Makefile.in
--- newlib/libc/sys/sysnecv850/Makefile.in 9 Sep 2010 14:54:24 -0000 1.19
+++ newlib/libc/sys/sysnecv850/Makefile.in 11 Mar 2011 21:18:08 -0000
@@ -65,7 +65,8 @@ lib_a_AR = $(AR) $(ARFLAGS)
@MAY_SUPPLY_SYSCALLS_TRUE@ $(lpfx)time.o $(lpfx)trap.o \
@MAY_SUPPLY_SYSCALLS_TRUE@ $(lpfx)unlink.o $(lpfx)utime.o \
@MAY_SUPPLY_SYSCALLS_TRUE@ $(lpfx)wait.o $(lpfx)write.o \
-@MAY_SUPPLY_SYSCALLS_TRUE@ $(lpfx)times.o $(lpfx)gettime.o
+@MAY_SUPPLY_SYSCALLS_TRUE@ $(lpfx)times.o $(lpfx)gettime.o \
+@MAY_SUPPLY_SYSCALLS_TRUE@ $(lpfx)rename.o
am_lib_a_OBJECTS =
lib_a_OBJECTS = $(am_lib_a_OBJECTS)
DEFAULT_INCLUDES = -I.@am__isrc@
@@ -111,6 +112,7 @@ MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
MKDIR_P = @MKDIR_P@
NEWLIB_CFLAGS = @NEWLIB_CFLAGS@
+NO_INCLUDE_LIST = @NO_INCLUDE_LIST@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
@@ -194,7 +196,7 @@ noinst_LIBRARIES = lib.a
@MAY_SUPPLY_SYSCALLS_TRUE@ $(lpfx)open.o $(lpfx)pipe.o $(lpfx)read.o $(lpfx)link.o \
@MAY_SUPPLY_SYSCALLS_TRUE@ $(lpfx)sbrk.o $(lpfx)stat.o $(lpfx)time.o $(lpfx)trap.o \
@MAY_SUPPLY_SYSCALLS_TRUE@ $(lpfx)unlink.o $(lpfx)utime.o $(lpfx)wait.o $(lpfx)write.o \
-@MAY_SUPPLY_SYSCALLS_TRUE@ $(lpfx)times.o $(lpfx)gettime.o
+@MAY_SUPPLY_SYSCALLS_TRUE@ $(lpfx)times.o $(lpfx)gettime.o $(lpfx)rename.o
lib_a_LIBADD = $(extra_objs)
EXTRA_lib_a_SOURCES = \
@@ -202,7 +204,7 @@ EXTRA_lib_a_SOURCES = \
execv.c execve.c fork.c fstat.c getpid.c isatty.c \
kill.c lseek.c open.c pipe.c read.c link.c \
sbrk.c stat.c time.c trap.S unlink.c utime.c wait.c write.c \
- times.c gettime.c
+ times.c gettime.c rename.c
lib_a_SOURCES =
lib_a_DEPENDENCIES = $(extra_objs)
@@ -448,6 +450,12 @@ lib_a-gettime.o: gettime.c
lib_a-gettime.obj: gettime.c
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-gettime.obj `if test -f 'gettime.c'; then $(CYGPATH_W) 'gettime.c'; else $(CYGPATH_W) '$(srcdir)/gettime.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`
+
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
Index: newlib/libc/sys/sysnecv850/fstat.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/sys/sysnecv850/fstat.c,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 fstat.c
--- newlib/libc/sys/sysnecv850/fstat.c 17 Feb 2000 19:39:50 -0000 1.1.1.1
+++ newlib/libc/sys/sysnecv850/fstat.c 11 Mar 2011 21:18:08 -0000
@@ -13,6 +13,5 @@ int
_fstat (int file,
struct stat *st)
{
- st->st_mode = S_IFCHR;
- return 0;
+ return TRAP0 (SYS_fstat, file, st, 0);
}
Index: newlib/libc/sys/sysnecv850/rename.c
===================================================================
RCS file: newlib/libc/sys/sysnecv850/rename.c
diff -N newlib/libc/sys/sysnecv850/rename.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ newlib/libc/sys/sysnecv850/rename.c 11 Mar 2011 21:18:08 -0000
@@ -0,0 +1,17 @@
+#include <_ansi.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include "sys/syscall.h"
+
+int errno;
+
+int __trap0 (int function, int p1, int p2, int p3);
+
+#define TRAP0(f, p1, p2, p3) __trap0(f, (int)(p1), (int)(p2), (int)(p3))
+
+int
+rename (const char *oldpath,
+ const char *newpath)
+{
+ return TRAP0 (SYS_rename, oldpath, newpath, 0);
+}
Index: newlib/libc/sys/sysnecv850/trap.S
===================================================================
RCS file: /cvs/src/src/newlib/libc/sys/sysnecv850/trap.S,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 trap.S
--- newlib/libc/sys/sysnecv850/trap.S 17 Feb 2000 19:39:50 -0000 1.1.1.1
+++ newlib/libc/sys/sysnecv850/trap.S 11 Mar 2011 21:18:08 -0000
@@ -2,9 +2,9 @@
.global ___trap0
___trap0:
trap 31
- tst r10,r10
+ tst r11,r11
bz .L0
movhi hi(_errno),r0,r6
- st.w r10,lo(_errno)[r6]
+ st.w r11,lo(_errno)[r6]
.L0:
jmp [r31]
Index: newlib/libc/sys/sysnecv850/unlink.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/sys/sysnecv850/unlink.c,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 unlink.c
--- newlib/libc/sys/sysnecv850/unlink.c 17 Feb 2000 19:39:50 -0000 1.1.1.1
+++ newlib/libc/sys/sysnecv850/unlink.c 11 Mar 2011 21:18:08 -0000
@@ -10,7 +10,7 @@ int __trap0 (int function, int p1, int p
#define TRAP0(f, p1, p2, p3) __trap0(f, (int)(p1), (int)(p2), (int)(p3))
int
-_unlink ()
+_unlink (const char *path)
{
- return -1;
+ return TRAP0 (SYS_unlink, path, 0, 0);
}
Index: newlib/libc/sys/sysnecv850/sys/syscall.h
===================================================================
RCS file: /cvs/src/src/newlib/libc/sys/sysnecv850/sys/syscall.h,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 syscall.h
--- newlib/libc/sys/sysnecv850/sys/syscall.h 17 Feb 2000 19:39:50 -0000 1.1.1.1
+++ newlib/libc/sys/sysnecv850/sys/syscall.h 11 Mar 2011 21:18:08 -0000
@@ -29,6 +29,7 @@
#define SYS_execve 59
#define SYS_times 43
#define SYS_gettimeofday 116
+#define SYS_rename 134
#define SYS_utime 201 /* not really a system call */
#define SYS_wait 202 /* nor is this */
More information about the Newlib
mailing list