public inbox for newlib-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin] Add generic implementation of dirfd()
@ 2018-10-11  8:22 Sebastian Huber
  0 siblings, 0 replies; only message in thread
From: Sebastian Huber @ 2018-10-11  8:22 UTC (permalink / raw)
  To: newlib-cvs

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=ab4fdab5d555504a90191959546142f797913d84

commit ab4fdab5d555504a90191959546142f797913d84
Author: Sebastian Huber <sebastian.huber@embedded-brains.de>
Date:   Mon Oct 8 13:33:08 2018 +0200

    Add generic implementation of dirfd()
    
    Use existing HAVE_OPENDIR define to determine if a generic
    implementation should be provided.  Cygwin for example has its own
    implementation of opendir() and dirfd().
    
    Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>

Diff:
---
 newlib/libc/posix/Makefile.am |  2 +-
 newlib/libc/posix/Makefile.in | 28 +++++++++++++++++-----------
 newlib/libc/posix/dirfd.c     | 38 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 56 insertions(+), 12 deletions(-)

diff --git a/newlib/libc/posix/Makefile.am b/newlib/libc/posix/Makefile.am
index 481849c..6cdee1d 100644
--- a/newlib/libc/posix/Makefile.am
+++ b/newlib/libc/posix/Makefile.am
@@ -5,7 +5,7 @@ AUTOMAKE_OPTIONS = cygnus
 INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS)
 
 GENERAL_SOURCES = \
-	closedir.c collate.c collcmp.c creat.c \
+	closedir.c collate.c collcmp.c creat.c dirfd.c \
 	fnmatch.c glob.c _isatty.c isatty.c \
 	opendir.c readdir.c readdir_r.c \
 	regcomp.c regerror.c regexec.c regfree.c \
diff --git a/newlib/libc/posix/Makefile.in b/newlib/libc/posix/Makefile.in
index 147476a..6dff00b 100644
--- a/newlib/libc/posix/Makefile.in
+++ b/newlib/libc/posix/Makefile.in
@@ -74,14 +74,14 @@ lib_a_AR = $(AR) $(ARFLAGS)
 lib_a_LIBADD =
 am__objects_1 = lib_a-closedir.$(OBJEXT) lib_a-collate.$(OBJEXT) \
 	lib_a-collcmp.$(OBJEXT) lib_a-creat.$(OBJEXT) \
-	lib_a-fnmatch.$(OBJEXT) lib_a-glob.$(OBJEXT) \
-	lib_a-_isatty.$(OBJEXT) lib_a-isatty.$(OBJEXT) \
-	lib_a-opendir.$(OBJEXT) lib_a-readdir.$(OBJEXT) \
-	lib_a-readdir_r.$(OBJEXT) lib_a-regcomp.$(OBJEXT) \
-	lib_a-regerror.$(OBJEXT) lib_a-regexec.$(OBJEXT) \
-	lib_a-regfree.$(OBJEXT) lib_a-rewinddir.$(OBJEXT) \
-	lib_a-sleep.$(OBJEXT) lib_a-usleep.$(OBJEXT) \
-	lib_a-telldir.$(OBJEXT)
+	lib_a-dirfd.$(OBJEXT) lib_a-fnmatch.$(OBJEXT) \
+	lib_a-glob.$(OBJEXT) lib_a-_isatty.$(OBJEXT) \
+	lib_a-isatty.$(OBJEXT) lib_a-opendir.$(OBJEXT) \
+	lib_a-readdir.$(OBJEXT) lib_a-readdir_r.$(OBJEXT) \
+	lib_a-regcomp.$(OBJEXT) lib_a-regerror.$(OBJEXT) \
+	lib_a-regexec.$(OBJEXT) lib_a-regfree.$(OBJEXT) \
+	lib_a-rewinddir.$(OBJEXT) lib_a-sleep.$(OBJEXT) \
+	lib_a-usleep.$(OBJEXT) lib_a-telldir.$(OBJEXT)
 am__objects_2 = lib_a-scandir.$(OBJEXT) lib_a-seekdir.$(OBJEXT)
 am__objects_3 = lib_a-execl.$(OBJEXT) lib_a-execle.$(OBJEXT) \
 	lib_a-execlp.$(OBJEXT) lib_a-execv.$(OBJEXT) \
@@ -100,8 +100,8 @@ am__objects_4 = lib_a-popen.$(OBJEXT) lib_a-posix_spawn.$(OBJEXT)
 lib_a_OBJECTS = $(am_lib_a_OBJECTS)
 LTLIBRARIES = $(noinst_LTLIBRARIES)
 libposix_la_LIBADD =
-am__objects_6 = closedir.lo collate.lo collcmp.lo creat.lo fnmatch.lo \
-	glob.lo _isatty.lo isatty.lo opendir.lo readdir.lo \
+am__objects_6 = closedir.lo collate.lo collcmp.lo creat.lo dirfd.lo \
+	fnmatch.lo glob.lo _isatty.lo isatty.lo opendir.lo readdir.lo \
 	readdir_r.lo regcomp.lo regerror.lo regexec.lo regfree.lo \
 	rewinddir.lo sleep.lo usleep.lo telldir.lo
 am__objects_7 = scandir.lo seekdir.lo
@@ -290,7 +290,7 @@ top_srcdir = @top_srcdir@
 AUTOMAKE_OPTIONS = cygnus
 INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS)
 GENERAL_SOURCES = \
-	closedir.c collate.c collcmp.c creat.c \
+	closedir.c collate.c collcmp.c creat.c dirfd.c \
 	fnmatch.c glob.c _isatty.c isatty.c \
 	opendir.c readdir.c readdir_r.c \
 	regcomp.c regerror.c regexec.c regfree.c \
@@ -428,6 +428,12 @@ lib_a-creat.o: creat.c
 lib_a-creat.obj: creat.c
 	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-creat.obj `if test -f 'creat.c'; then $(CYGPATH_W) 'creat.c'; else $(CYGPATH_W) '$(srcdir)/creat.c'; fi`
 
+lib_a-dirfd.o: dirfd.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-dirfd.o `test -f 'dirfd.c' || echo '$(srcdir)/'`dirfd.c
+
+lib_a-dirfd.obj: dirfd.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-dirfd.obj `if test -f 'dirfd.c'; then $(CYGPATH_W) 'dirfd.c'; else $(CYGPATH_W) '$(srcdir)/dirfd.c'; fi`
+
 lib_a-fnmatch.o: fnmatch.c
 	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fnmatch.o `test -f 'fnmatch.c' || echo '$(srcdir)/'`fnmatch.c
 
diff --git a/newlib/libc/posix/dirfd.c b/newlib/libc/posix/dirfd.c
new file mode 100644
index 0000000..439dfa2
--- /dev/null
+++ b/newlib/libc/posix/dirfd.c
@@ -0,0 +1,38 @@
+#ifndef HAVE_OPENDIR
+
+/*-
+ * Copyright (c) 2018 embedded brains GmbH
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <dirent.h>
+
+int
+dirfd(DIR *dirp)
+{
+
+	return (__dirfd(dirp));
+}
+
+#endif /* ! HAVE_OPENDIR */


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2018-10-11  8:22 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-11  8:22 [newlib-cygwin] Add generic implementation of dirfd() Sebastian Huber

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).