From 3b60b701b1e3ee239cacb1aafa71bb721c812ccd Mon Sep 17 00:00:00 2001 From: Kevin Buettner Date: Mon, 21 Mar 2011 22:11:14 +0000 Subject: [PATCH] * 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. --- newlib/ChangeLog | 9 +++++++++ newlib/libc/sys/sysnecv850/Makefile.am | 4 ++-- newlib/libc/sys/sysnecv850/Makefile.in | 14 +++++++++++--- newlib/libc/sys/sysnecv850/fstat.c | 3 +-- newlib/libc/sys/sysnecv850/rename.c | 17 +++++++++++++++++ newlib/libc/sys/sysnecv850/sys/syscall.h | 1 + newlib/libc/sys/sysnecv850/trap.S | 4 ++-- newlib/libc/sys/sysnecv850/unlink.c | 4 ++-- 8 files changed, 45 insertions(+), 11 deletions(-) create mode 100644 newlib/libc/sys/sysnecv850/rename.c diff --git a/newlib/ChangeLog b/newlib/ChangeLog index aed574eca..308a04020 100644 --- a/newlib/ChangeLog +++ b/newlib/ChangeLog @@ -1,3 +1,12 @@ +2011-03-21 Kevin Buettner + + * 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. + 2011-03-03 Corinna Vinschen * libc/include/string.h: Include sys/cdefs.h. diff --git a/newlib/libc/sys/sysnecv850/Makefile.am b/newlib/libc/sys/sysnecv850/Makefile.am index 544438810..df150168c 100644 --- a/newlib/libc/sys/sysnecv850/Makefile.am +++ b/newlib/libc/sys/sysnecv850/Makefile.am @@ -16,7 +16,7 @@ extra_objs = $(lpfx)_exit.o $(lpfx)access.o $(lpfx)chmod.o \ $(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) diff --git a/newlib/libc/sys/sysnecv850/Makefile.in b/newlib/libc/sys/sysnecv850/Makefile.in index 9a95df704..e57f4d99d 100644 --- a/newlib/libc/sys/sysnecv850/Makefile.in +++ b/newlib/libc/sys/sysnecv850/Makefile.in @@ -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 \ diff --git a/newlib/libc/sys/sysnecv850/fstat.c b/newlib/libc/sys/sysnecv850/fstat.c index e8783b376..b7eed0afe 100644 --- a/newlib/libc/sys/sysnecv850/fstat.c +++ b/newlib/libc/sys/sysnecv850/fstat.c @@ -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); } diff --git a/newlib/libc/sys/sysnecv850/rename.c b/newlib/libc/sys/sysnecv850/rename.c new file mode 100644 index 000000000..9d9f7dbf9 --- /dev/null +++ b/newlib/libc/sys/sysnecv850/rename.c @@ -0,0 +1,17 @@ +#include <_ansi.h> +#include +#include +#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); +} diff --git a/newlib/libc/sys/sysnecv850/sys/syscall.h b/newlib/libc/sys/sysnecv850/sys/syscall.h index f301ea0ee..0866f0276 100644 --- a/newlib/libc/sys/sysnecv850/sys/syscall.h +++ b/newlib/libc/sys/sysnecv850/sys/syscall.h @@ -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 */ diff --git a/newlib/libc/sys/sysnecv850/trap.S b/newlib/libc/sys/sysnecv850/trap.S index 9955572a3..dc470d72b 100644 --- a/newlib/libc/sys/sysnecv850/trap.S +++ b/newlib/libc/sys/sysnecv850/trap.S @@ -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] diff --git a/newlib/libc/sys/sysnecv850/unlink.c b/newlib/libc/sys/sysnecv850/unlink.c index c6261d3eb..34b712f02 100644 --- a/newlib/libc/sys/sysnecv850/unlink.c +++ b/newlib/libc/sys/sysnecv850/unlink.c @@ -10,7 +10,7 @@ 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 -_unlink () +_unlink (const char *path) { - return -1; + return TRAP0 (SYS_unlink, path, 0, 0); }