From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 113637 invoked by alias); 11 Oct 2018 08:22:45 -0000 Mailing-List: contact newlib-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: newlib-cvs-owner@sourceware.org Received: (qmail 111469 invoked by uid 10080); 11 Oct 2018 08:22:43 -0000 Date: Thu, 11 Oct 2018 08:22:00 -0000 Message-ID: <20181011082243.111464.qmail@sourceware.org> Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Sebastian Huber To: newlib-cvs@sourceware.org Subject: [newlib-cygwin] Add generic implementation of dirfd() X-Act-Checkin: newlib-cygwin X-Git-Author: Sebastian Huber X-Git-Refname: refs/heads/master X-Git-Oldrev: 738fdc6a42e15a108ef7bccfd8bc682fff2b8cd7 X-Git-Newrev: ab4fdab5d555504a90191959546142f797913d84 X-SW-Source: 2018-q4/txt/msg00014.txt.bz2 https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=ab4fdab5d555504a90191959546142f797913d84 commit ab4fdab5d555504a90191959546142f797913d84 Author: Sebastian Huber 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 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 + +int +dirfd(DIR *dirp) +{ + + return (__dirfd(dirp)); +} + +#endif /* ! HAVE_OPENDIR */