This is the mail archive of the newlib@sourceware.cygnus.com 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]

Separate _link_r() from _unlink_r()


On some targets, _unlink() is implemented but _link() is not, so we
get needless failures from ld when a program calls remove() or
unlink().  This patch addresses this issue by separating these
functions into different object files.  I'm checking it in, approved
by J. Johnston.

Index: newlib/ChangeLog
from  Alexandre Oliva  <oliva@lsd.ic.unicamp.br>
	
	* libc/reent/Makefile.am (lib_a_SOURCES): Added unlinkr.c.
	(CHEWOUT_FILES): Added unlinkr.def.
	* libc/reent/Makefile.in: Rebuilt.
	* libc/sys.tex: Include unlinkr.def.
	* libc/reent/linkr.c (_unlink_r): Moved to...
	* libc/reent/unlinkr.c: ... new file.
	
Index: newlib/libc/reent/Makefile.am
===================================================================
RCS file: /cvs/cvsfiles/devo/newlib/libc/reent/Makefile.am,v
retrieving revision 1.2
diff -u -r1.2 Makefile.am
--- newlib/libc/reent/Makefile.am	1998/10/20 23:29:23	1.2
+++ newlib/libc/reent/Makefile.am	2000/03/04 09:08:52
@@ -20,6 +20,7 @@
 	sbrkr.c \
 	statr.c \
 	timer.c \
+	unlinkr.c \
 	writer.c
 
 CHEWOUT_FILES = \
@@ -35,6 +36,7 @@
 	sbrkr.def \
 	statr.def \
 	timer.def \
+	unlinkr.def \
 	writer.def
 
 SUFFIXES = .def .h
Index: newlib/libc/sys.tex
===================================================================
RCS file: /cvs/cvsfiles/devo/newlib/libc/sys.tex,v
retrieving revision 1.3
diff -u -r1.3 sys.tex
--- newlib/libc/sys.tex	1997/03/25 15:51:18	1.3
+++ newlib/libc/sys.tex	2000/03/04 09:08:53
@@ -326,6 +326,7 @@
 @include reent/statr.def
 @include reent/fstatr.def
 @include reent/linkr.def
+@include reent/unlinkr.def
 @include reent/sbrkr.def
 @up
 @end ignore
Index: newlib/libc/reent/linkr.c
===================================================================
RCS file: /cvs/cvsfiles/devo/newlib/libc/reent/linkr.c,v
retrieving revision 1.10
diff -u -r1.10 linkr.c
--- newlib/libc/reent/linkr.c	1996/08/03 01:31:47	1.10
+++ newlib/libc/reent/linkr.c	2000/03/04 09:08:53
@@ -63,40 +63,4 @@
   return ret;
 }
 
-/*
-FUNCTION
-	<<_unlink_r>>---Reentrant version of unlink
-	
-INDEX
-	_unlink_r
-
-ANSI_SYNOPSIS
-	#include <reent.h>
-	int _unlink_r(struct _reent *<[ptr]>, const char *<[file]>);
-
-TRAD_SYNOPSIS
-	#include <reent.h>
-	int _unlink_r(<[ptr]>, <[file]>)
-	struct _reent *<[ptr]>;
-	char *<[file]>;
-
-DESCRIPTION
-	This is a reentrant version of <<unlink>>.  It
-	takes a pointer to the global data block, which holds
-	<<errno>>.
-*/
-
-int
-_unlink_r (ptr, file)
-     struct _reent *ptr;
-     _CONST char *file;
-{
-  int ret;
-
-  errno = 0;
-  if ((ret = _unlink (file)) == -1 && errno != 0)
-    ptr->_errno = errno;
-  return ret;
-}
-
 #endif /* ! defined (REENTRANT_SYSCALLS_PROVIDED) */
Index: newlib/libc/reent/unlinkr.c
===================================================================
RCS file: unlinkr.c
diff -N unlinkr.c
--- newlib/libc/reent/unlinkr.c	Tue May  5 13:32:27 1998
+++ newlib/libc/reent/unlinkr.c	Sat Mar  4 01:08:53 2000
@@ -0,0 +1,59 @@
+/* Reentrant versions of file system calls.  These implementations
+   just call the usual system calls.  */
+
+#include <reent.h>
+#include <unistd.h>
+#include <_syslist.h>
+
+/* Some targets provides their own versions of these functions.  Those
+   targets should define REENTRANT_SYSCALLS_PROVIDED in TARGET_CFLAGS.  */
+
+#ifdef _REENT_ONLY
+#ifndef REENTRANT_SYSCALLS_PROVIDED
+#define REENTRANT_SYSCALLS_PROVIDED
+#endif
+#endif
+
+#ifndef REENTRANT_SYSCALLS_PROVIDED
+
+/* We use the errno variable used by the system dependent layer.  */
+#undef errno
+extern int errno;
+
+/*
+FUNCTION
+	<<_unlink_r>>---Reentrant version of unlink
+	
+INDEX
+	_unlink_r
+
+ANSI_SYNOPSIS
+	#include <reent.h>
+	int _unlink_r(struct _reent *<[ptr]>, const char *<[file]>);
+
+TRAD_SYNOPSIS
+	#include <reent.h>
+	int _unlink_r(<[ptr]>, <[file]>)
+	struct _reent *<[ptr]>;
+	char *<[file]>;
+
+DESCRIPTION
+	This is a reentrant version of <<unlink>>.  It
+	takes a pointer to the global data block, which holds
+	<<errno>>.
+*/
+
+int
+_unlink_r (ptr, file)
+     struct _reent *ptr;
+     _CONST char *file;
+{
+  int ret;
+
+  errno = 0;
+  if ((ret = _unlink (file)) == -1 && errno != 0)
+    ptr->_errno = errno;
+  return ret;
+}
+
+#endif /* ! defined (REENTRANT_SYSCALLS_PROVIDED) */
Index: newlib/libc/reent/Makefile.in
===================================================================
RCS file: /cvs/cvsfiles/devo/newlib/libc/reent/Makefile.in,v
retrieving revision 1.18
diff -u -r1.18 Makefile.in
--- newlib/libc/reent/Makefile.in	2000/01/11 00:21:00	1.18
+++ newlib/libc/reent/Makefile.in	2000/03/04 09:08:53
@@ -102,6 +102,7 @@
 	sbrkr.c \
 	statr.c \
 	timer.c \
+	unlinkr.c \
 	writer.c
 
 
@@ -118,6 +119,7 @@
 	sbrkr.def \
 	statr.def \
 	timer.def \
+	unlinkr.def \
 	writer.def
 
 
@@ -139,7 +141,7 @@
 LIBS = @LIBS@
 lib_a_LIBADD = 
 lib_a_OBJECTS =  closer.o reent.o impure.o execr.o fstatr.o linkr.o \
-lseekr.o openr.o readr.o signalr.o sbrkr.o statr.o timer.o writer.o
+lseekr.o openr.o readr.o signalr.o sbrkr.o statr.o timer.o unlinkr.o writer.o
 CFLAGS = @CFLAGS@
 COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
 CCLD = $(CC)

-- 
Alexandre Oliva     http://www.ic.unicamp.br/~oliva/     Enjoy Guaranį
Cygnus Solutions, a Red Hat company        aoliva@{redhat, cygnus}.com
Free Software Developer and Evangelist    CS PhD student at IC-Unicamp
oliva@{lsd.ic.unicamp.br, gnu.org}   Write to mailing lists, not to me

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