From f205ea7a0364b878d07f267286853060fa519007 Mon Sep 17 00:00:00 2001
From: Alexandre Oliva <aoliva@redhat.com>
Date: Wed, 8 Mar 2000 04:01:49 +0000
Subject: [PATCH] * 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.

---
 newlib/ChangeLog              |  9 ++++++
 newlib/libc/reent/Makefile.am |  2 ++
 newlib/libc/reent/Makefile.in |  4 ++-
 newlib/libc/reent/linkr.c     | 36 ---------------------
 newlib/libc/reent/unlinkr.c   | 59 +++++++++++++++++++++++++++++++++++
 newlib/libc/sys.tex           |  1 +
 6 files changed, 74 insertions(+), 37 deletions(-)
 create mode 100644 newlib/libc/reent/unlinkr.c

diff --git a/newlib/ChangeLog b/newlib/ChangeLog
index cf16f1d77..065694f30 100644
--- a/newlib/ChangeLog
+++ b/newlib/ChangeLog
@@ -1,3 +1,12 @@
+Wed Mar  8 00:46:41 2000  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.
+
 Wed Mar  8 00:43:07 2000  Alexandre Oliva  <oliva@lsd.ic.unicamp.br>
 
 	* libc/string/Makefile.am (lib_a_SOURCES): Added swab.c.
diff --git a/newlib/libc/reent/Makefile.am b/newlib/libc/reent/Makefile.am
index 20baf3f24..87a847e65 100644
--- a/newlib/libc/reent/Makefile.am
+++ b/newlib/libc/reent/Makefile.am
@@ -20,6 +20,7 @@ lib_a_SOURCES = \
 	sbrkr.c \
 	statr.c \
 	timer.c \
+	unlinkr.c \
 	writer.c
 
 CHEWOUT_FILES = \
@@ -35,6 +36,7 @@ CHEWOUT_FILES = \
 	sbrkr.def \
 	statr.def \
 	timer.def \
+	unlinkr.def \
 	writer.def
 
 SUFFIXES = .def .h
diff --git a/newlib/libc/reent/Makefile.in b/newlib/libc/reent/Makefile.in
index ad174b184..7c1f93134 100644
--- a/newlib/libc/reent/Makefile.in
+++ b/newlib/libc/reent/Makefile.in
@@ -102,6 +102,7 @@ lib_a_SOURCES = \
 	sbrkr.c \
 	statr.c \
 	timer.c \
+	unlinkr.c \
 	writer.c
 
 
@@ -118,6 +119,7 @@ CHEWOUT_FILES = \
 	sbrkr.def \
 	statr.def \
 	timer.def \
+	unlinkr.def \
 	writer.def
 
 
@@ -139,7 +141,7 @@ LDFLAGS = @LDFLAGS@
 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)
diff --git a/newlib/libc/reent/linkr.c b/newlib/libc/reent/linkr.c
index a15d2238c..eda8d038c 100644
--- a/newlib/libc/reent/linkr.c
+++ b/newlib/libc/reent/linkr.c
@@ -63,40 +63,4 @@ _link_r (ptr, old, new)
   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) */
diff --git a/newlib/libc/reent/unlinkr.c b/newlib/libc/reent/unlinkr.c
new file mode 100644
index 000000000..dbfc7e667
--- /dev/null
+++ b/newlib/libc/reent/unlinkr.c
@@ -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) */
diff --git a/newlib/libc/sys.tex b/newlib/libc/sys.tex
index 44b608b9c..3182b71c5 100644
--- a/newlib/libc/sys.tex
+++ b/newlib/libc/sys.tex
@@ -326,6 +326,7 @@ library, and achieve reentrancy by using a reserved global data block
 @include reent/statr.def
 @include reent/fstatr.def
 @include reent/linkr.def
+@include reent/unlinkr.def
 @include reent/sbrkr.def
 @up
 @end ignore