diff options
Diffstat (limited to 'newlib/libc/posix')
-rw-r--r-- | newlib/libc/posix/Makefile.am | 69 | ||||
-rw-r--r-- | newlib/libc/posix/Makefile.in | 408 | ||||
-rw-r--r-- | newlib/libc/posix/closedir.c | 77 | ||||
-rw-r--r-- | newlib/libc/posix/creat.c | 13 | ||||
-rw-r--r-- | newlib/libc/posix/execl.c | 49 | ||||
-rw-r--r-- | newlib/libc/posix/execle.c | 46 | ||||
-rw-r--r-- | newlib/libc/posix/execlp.c | 44 | ||||
-rw-r--r-- | newlib/libc/posix/execv.c | 20 | ||||
-rw-r--r-- | newlib/libc/posix/execve.c | 17 | ||||
-rw-r--r-- | newlib/libc/posix/execvp.c | 69 | ||||
-rw-r--r-- | newlib/libc/posix/isatty.c | 17 | ||||
-rw-r--r-- | newlib/libc/posix/opendir.c | 95 | ||||
-rw-r--r-- | newlib/libc/posix/popen.c | 175 | ||||
-rw-r--r-- | newlib/libc/posix/readdir.c | 101 | ||||
-rw-r--r-- | newlib/libc/posix/readdir_r.c | 108 | ||||
-rw-r--r-- | newlib/libc/posix/rewinddir.c | 57 | ||||
-rw-r--r-- | newlib/libc/posix/scandir.c | 177 | ||||
-rw-r--r-- | newlib/libc/posix/seekdir.c | 62 | ||||
-rw-r--r-- | newlib/libc/posix/telldir.c | 198 |
19 files changed, 0 insertions, 1802 deletions
diff --git a/newlib/libc/posix/Makefile.am b/newlib/libc/posix/Makefile.am deleted file mode 100644 index d39aed316..000000000 --- a/newlib/libc/posix/Makefile.am +++ /dev/null @@ -1,69 +0,0 @@ -## Process this file with automake to generate Makefile.in - -AUTOMAKE_OPTIONS = cygnus - -INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS) - -GENERAL_SOURCES = \ - closedir.c creat.c isatty.c \ - opendir.c readdir.c \ - readdir_r.c rewinddir.c telldir.c - -ELIX_2_OBJS = \ - scandir.$(oext) seekdir.$(oext) - -ELIX_3_OBJS = \ - execl.$(oext) execle.$(oext) execlp.$(oext) execv.$(oext) \ - execve.$(oext) execvp.$(oext) - -ELIX_4_OBJS = \ - popen.$(oext) - -if ELIX_LEVEL_1 -LIB_OBJS = -else -if ELIX_LEVEL_2 -LIB_OBJS = $(ELIX_2_OBJS) -else -if ELIX_LEVEL_3 -LIB_OBJS = $(ELIX_2_OBJS) $(ELIX_3_OBJS) -else -LIB_OBJS = $(ELIX_2_OBJS) $(ELIX_3_OBJS) $(ELIX_4_OBJS) -endif -endif -endif - -libposix_la_LDFLAGS = -Xcompiler -nostdlib - -if USE_LIBTOOL -noinst_LTLIBRARIES = libposix.la -libposix_la_SOURCES = $(GENERAL_SOURCES) -libposix_la_LIBADD = $(LIB_OBJS) -libposix_la_DEPENDENCIES = $(LIB_OBJS) -noinst_DATA = objectlist.awk.in -else -noinst_LIBRARIES = lib.a -lib_a_SOURCES = $(GENERAL_SOURCES) -lib_a_LIBADD = $(LIB_OBJS) -lib_a_DEPENDENCIES = $(LIB_OBJS) -noinst_DATA = -endif # USE_LIBTOOL - -include $(srcdir)/../../Makefile.shared - -CHEWOUT_FILES = - -SUFFIXES = .def - -CHEW = ../../doc/makedoc -f $(srcdir)/../../doc/doc.str - -.c.def: - $(CHEW) < $< > $*.def 2> $*.ref - touch stmp-def - -TARGETDOC = ../tmp.texi - -# No doc for posix. -doc: - -CLEANFILES = $(CHEWOUT_FILES) *.ref diff --git a/newlib/libc/posix/Makefile.in b/newlib/libc/posix/Makefile.in deleted file mode 100644 index 8867573fa..000000000 --- a/newlib/libc/posix/Makefile.in +++ /dev/null @@ -1,408 +0,0 @@ -# Makefile.in generated automatically by automake 1.4-p6 from Makefile.am - -# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc. -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - - - -SHELL = @SHELL@ - -srcdir = @srcdir@ -top_srcdir = @top_srcdir@ -VPATH = @srcdir@ -prefix = @prefix@ -exec_prefix = @exec_prefix@ - -bindir = @bindir@ -sbindir = @sbindir@ -libexecdir = @libexecdir@ -datadir = @datadir@ -sysconfdir = @sysconfdir@ -sharedstatedir = @sharedstatedir@ -localstatedir = @localstatedir@ -libdir = @libdir@ -infodir = @infodir@ -mandir = @mandir@ -includedir = @includedir@ -oldincludedir = /usr/include - -DESTDIR = - -pkgdatadir = $(datadir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ - -top_builddir = .. - -ACLOCAL = @ACLOCAL@ -AUTOCONF = @AUTOCONF@ -AUTOMAKE = @AUTOMAKE@ -AUTOHEADER = @AUTOHEADER@ - -INSTALL = @INSTALL@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS) -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -transform = @program_transform_name@ - -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_alias = @build_alias@ -build_triplet = @build@ -host_alias = @host_alias@ -host_triplet = @host@ -target_alias = @target_alias@ -target_triplet = @target@ -AR = @AR@ -AS = @AS@ -CC = @CC@ -CPP = @CPP@ -CRT0 = @CRT0@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -DLLTOOL = @DLLTOOL@ -EXEEXT = @EXEEXT@ -GCJ = @GCJ@ -GCJFLAGS = @GCJFLAGS@ -LDFLAGS = @LDFLAGS@ -LIBC_EXTRA_DEF = @LIBC_EXTRA_DEF@ -LIBC_EXTRA_LIB = @LIBC_EXTRA_LIB@ -LIBC_MACHINE_LIB = @LIBC_MACHINE_LIB@ -LIBC_POSIX_LIB = @LIBC_POSIX_LIB@ -LIBC_SIGNAL_DEF = @LIBC_SIGNAL_DEF@ -LIBC_SIGNAL_LIB = @LIBC_SIGNAL_LIB@ -LIBC_STDIO64_DEF = @LIBC_STDIO64_DEF@ -LIBC_STDIO64_LIB = @LIBC_STDIO64_LIB@ -LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@ -LIBC_SYS_LIB = @LIBC_SYS_LIB@ -LIBC_UNIX_LIB = @LIBC_UNIX_LIB@ -LIBTOOL = @LIBTOOL@ -LN_S = @LN_S@ -MAINT = @MAINT@ -MAKEINFO = @MAKEINFO@ -NEWLIB_CFLAGS = @NEWLIB_CFLAGS@ -OBJDUMP = @OBJDUMP@ -OBJEXT = @OBJEXT@ -PACKAGE = @PACKAGE@ -RANLIB = @RANLIB@ -STRIP = @STRIP@ -VERSION = @VERSION@ -aext = @aext@ -extra_dir = @extra_dir@ -libm_machine_dir = @libm_machine_dir@ -machine_dir = @machine_dir@ -newlib_basedir = @newlib_basedir@ -oext = @oext@ -sys_dir = @sys_dir@ - -AUTOMAKE_OPTIONS = cygnus - -INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS) - -GENERAL_SOURCES = closedir.c creat.c isatty.c opendir.c readdir.c readdir_r.c rewinddir.c telldir.c - - -ELIX_2_OBJS = scandir.$(oext) seekdir.$(oext) - - -ELIX_3_OBJS = execl.$(oext) execle.$(oext) execlp.$(oext) execv.$(oext) execve.$(oext) execvp.$(oext) - - -ELIX_4_OBJS = popen.$(oext) - -@ELIX_LEVEL_1_TRUE@LIB_OBJS = -@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_TRUE@LIB_OBJS = $(ELIX_2_OBJS) -@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_TRUE@LIB_OBJS = $(ELIX_2_OBJS) $(ELIX_3_OBJS) -@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@LIB_OBJS = $(ELIX_2_OBJS) $(ELIX_3_OBJS) $(ELIX_4_OBJS) - -libposix_la_LDFLAGS = -Xcompiler -nostdlib - -@USE_LIBTOOL_TRUE@noinst_LTLIBRARIES = libposix.la -@USE_LIBTOOL_TRUE@libposix_la_SOURCES = $(GENERAL_SOURCES) -@USE_LIBTOOL_TRUE@libposix_la_LIBADD = $(LIB_OBJS) -@USE_LIBTOOL_TRUE@libposix_la_DEPENDENCIES = $(LIB_OBJS) -@USE_LIBTOOL_TRUE@noinst_DATA = objectlist.awk.in -@USE_LIBTOOL_FALSE@noinst_DATA = -@USE_LIBTOOL_FALSE@noinst_LIBRARIES = lib.a -@USE_LIBTOOL_FALSE@lib_a_SOURCES = $(GENERAL_SOURCES) -@USE_LIBTOOL_FALSE@lib_a_LIBADD = $(LIB_OBJS) -@USE_LIBTOOL_FALSE@lib_a_DEPENDENCIES = $(LIB_OBJS) - -CHEWOUT_FILES = - -SUFFIXES = .def - -CHEW = ../../doc/makedoc -f $(srcdir)/../../doc/doc.str - -TARGETDOC = ../tmp.texi - -CLEANFILES = $(CHEWOUT_FILES) *.ref -mkinstalldirs = $(SHELL) $(top_srcdir)/../../mkinstalldirs -CONFIG_CLEAN_FILES = -LIBRARIES = $(noinst_LIBRARIES) - - -DEFS = @DEFS@ -I. -I$(srcdir) -CPPFLAGS = @CPPFLAGS@ -LIBS = @LIBS@ -@USE_LIBTOOL_FALSE@lib_a_OBJECTS = closedir.$(OBJEXT) creat.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@isatty.$(OBJEXT) opendir.$(OBJEXT) readdir.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@readdir_r.$(OBJEXT) rewinddir.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@telldir.$(OBJEXT) -LTLIBRARIES = $(noinst_LTLIBRARIES) - -@USE_LIBTOOL_TRUE@libposix_la_OBJECTS = closedir.lo creat.lo isatty.lo \ -@USE_LIBTOOL_TRUE@opendir.lo readdir.lo readdir_r.lo rewinddir.lo \ -@USE_LIBTOOL_TRUE@telldir.lo -CFLAGS = @CFLAGS@ -COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -CCLD = $(CC) -LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ -DATA = $(noinst_DATA) - -DIST_COMMON = Makefile.am Makefile.in - - -DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) - -TAR = gtar -GZIP_ENV = --best -SOURCES = $(lib_a_SOURCES) $(libposix_la_SOURCES) -OBJECTS = $(lib_a_OBJECTS) $(libposix_la_OBJECTS) - -all: all-redirect -.SUFFIXES: -.SUFFIXES: .S .c .def .lo .o .obj .s -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) $(srcdir)/../../Makefile.shared - cd $(top_srcdir) && $(AUTOMAKE) --cygnus posix/Makefile - -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - cd $(top_builddir) \ - && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status - - -mostlyclean-noinstLIBRARIES: - -clean-noinstLIBRARIES: - -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) - -distclean-noinstLIBRARIES: - -maintainer-clean-noinstLIBRARIES: - -.c.o: - $(COMPILE) -c $< - -# FIXME: We should only use cygpath when building on Windows, -# and only if it is available. -.c.obj: - $(COMPILE) -c `cygpath -w $<` - -.s.o: - $(COMPILE) -c $< - -.S.o: - $(COMPILE) -c $< - -mostlyclean-compile: - -rm -f *.o core *.core - -rm -f *.$(OBJEXT) - -clean-compile: - -distclean-compile: - -rm -f *.tab.c - -maintainer-clean-compile: - -.c.lo: - $(LIBTOOL) --mode=compile $(COMPILE) -c $< - -.s.lo: - $(LIBTOOL) --mode=compile $(COMPILE) -c $< - -.S.lo: - $(LIBTOOL) --mode=compile $(COMPILE) -c $< - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs - -distclean-libtool: - -maintainer-clean-libtool: - -lib.a: $(lib_a_OBJECTS) $(lib_a_DEPENDENCIES) - -rm -f lib.a - $(AR) cru lib.a $(lib_a_OBJECTS) $(lib_a_LIBADD) - $(RANLIB) lib.a - -mostlyclean-noinstLTLIBRARIES: - -clean-noinstLTLIBRARIES: - -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) - -distclean-noinstLTLIBRARIES: - -maintainer-clean-noinstLTLIBRARIES: - -libposix.la: $(libposix_la_OBJECTS) $(libposix_la_DEPENDENCIES) - $(LINK) $(libposix_la_LDFLAGS) $(libposix_la_OBJECTS) $(libposix_la_LIBADD) $(LIBS) - -tags: TAGS - -ID: $(HEADERS) $(SOURCES) $(LISP) - list='$(SOURCES) $(HEADERS)'; \ - unique=`for i in $$list; do echo $$i; done | \ - awk ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ - here=`pwd` && cd $(srcdir) \ - && mkid -f$$here/ID $$unique $(LISP) - -TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP) - tags=; \ - here=`pwd`; \ - list='$(SOURCES) $(HEADERS)'; \ - unique=`for i in $$list; do echo $$i; done | \ - awk ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ - test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ - || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS) - -mostlyclean-tags: - -clean-tags: - -distclean-tags: - -rm -f TAGS ID - -maintainer-clean-tags: - -distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) - -subdir = posix - -distdir: $(DISTFILES) - @for file in $(DISTFILES); do \ - if test -f $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - cp -pr $$d/$$file $(distdir)/$$file; \ - else \ - test -f $(distdir)/$$file \ - || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ - || cp -p $$d/$$file $(distdir)/$$file || :; \ - fi; \ - done -info-am: -info: info-am -dvi-am: -dvi: dvi-am -check-am: -check: check-am -installcheck-am: -installcheck: installcheck-am -install-info-am: -install-info: install-info-am -install-exec-am: -install-exec: install-exec-am - -install-data-am: -install-data: install-data-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am -install: install-am -uninstall-am: -uninstall: uninstall-am -all-am: Makefile $(LIBRARIES) $(LTLIBRARIES) $(DATA) -all-redirect: all-am -install-strip: - $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install -installdirs: - - -mostlyclean-generic: - -clean-generic: - -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) - -distclean-generic: - -rm -f Makefile $(CONFIG_CLEAN_FILES) - -rm -f config.cache config.log stamp-h stamp-h[0-9]* - -maintainer-clean-generic: -mostlyclean-am: mostlyclean-noinstLIBRARIES mostlyclean-compile \ - mostlyclean-libtool mostlyclean-noinstLTLIBRARIES \ - mostlyclean-tags mostlyclean-generic - -mostlyclean: mostlyclean-am - -clean-am: clean-noinstLIBRARIES clean-compile clean-libtool \ - clean-noinstLTLIBRARIES clean-tags clean-generic \ - mostlyclean-am - -clean: clean-am - -distclean-am: distclean-noinstLIBRARIES distclean-compile \ - distclean-libtool distclean-noinstLTLIBRARIES \ - distclean-tags distclean-generic clean-am - -rm -f libtool - -distclean: distclean-am - -maintainer-clean-am: maintainer-clean-noinstLIBRARIES \ - maintainer-clean-compile maintainer-clean-libtool \ - maintainer-clean-noinstLTLIBRARIES \ - maintainer-clean-tags maintainer-clean-generic \ - distclean-am - @echo "This command is intended for maintainers to use;" - @echo "it deletes files that may require special tools to rebuild." - -maintainer-clean: maintainer-clean-am - -.PHONY: mostlyclean-noinstLIBRARIES distclean-noinstLIBRARIES \ -clean-noinstLIBRARIES maintainer-clean-noinstLIBRARIES \ -mostlyclean-compile distclean-compile clean-compile \ -maintainer-clean-compile mostlyclean-libtool distclean-libtool \ -clean-libtool maintainer-clean-libtool mostlyclean-noinstLTLIBRARIES \ -distclean-noinstLTLIBRARIES clean-noinstLTLIBRARIES \ -maintainer-clean-noinstLTLIBRARIES tags mostlyclean-tags distclean-tags \ -clean-tags maintainer-clean-tags distdir info-am info dvi-am dvi check \ -check-am installcheck-am installcheck install-info-am install-info \ -install-exec-am install-exec install-data-am install-data install-am \ -install uninstall-am uninstall all-redirect all-am all installdirs \ -mostlyclean-generic distclean-generic clean-generic \ -maintainer-clean-generic clean mostlyclean distclean maintainer-clean - - -objectlist.awk.in: $(noinst_LTLIBRARIES) - -rm -f objectlist.awk.in - for i in `ls *.lo` ; \ - do \ - echo $$i `pwd`/$$i >> objectlist.awk.in ; \ - done - -.c.def: - $(CHEW) < $< > $*.def 2> $*.ref - touch stmp-def - -# No doc for posix. -doc: - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/newlib/libc/posix/closedir.c b/newlib/libc/posix/closedir.c deleted file mode 100644 index 634f5ad12..000000000 --- a/newlib/libc/posix/closedir.c +++ /dev/null @@ -1,77 +0,0 @@ -#ifndef HAVE_OPENDIR - -/* - * Copyright (c) 1983 Regents of the University of California. - * 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. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)closedir.c 5.9 (Berkeley) 2/23/91"; -#endif /* LIBC_SCCS and not lint */ - -#include <sys/types.h> -#include <dirent.h> -#include <stdlib.h> -#include <unistd.h> -#include <sys/lock.h> - -extern void _cleanupdir (DIR *dirp); - -/* - * close a directory. - */ -int -_DEFUN(closedir, (dirp), - register DIR *dirp) -{ - int fd, rc; - -#ifdef HAVE_DD_LOCK - __lock_acquire_recursive(dirp->dd_lock); -#endif - rc = 0; - fd = dirp->dd_fd; - if (fd != -1) { - dirp->dd_fd = -1; - dirp->dd_loc = 0; - (void)free((void *)dirp->dd_buf); - (void)free((void *)dirp); - rc = close(fd); - _cleanupdir(dirp); - } -#ifdef HAVE_DD_LOCK - __lock_release_recursive(dirp->dd_lock); - __lock_close_recursive(dirp->dd_lock); -#endif - return rc; -} - -#endif /* ! HAVE_OPENDIR */ diff --git a/newlib/libc/posix/creat.c b/newlib/libc/posix/creat.c deleted file mode 100644 index b8a4f9a14..000000000 --- a/newlib/libc/posix/creat.c +++ /dev/null @@ -1,13 +0,0 @@ -/* creat() "system call" */ - -/* This is needed by f2c and therefore the SPEC benchmarks. */ - -#include <fcntl.h> - -int -_DEFUN(creat, (path, mode), - const char *path _AND - mode_t mode) -{ - return open (path, O_WRONLY | O_CREAT | O_TRUNC, mode); -} diff --git a/newlib/libc/posix/execl.c b/newlib/libc/posix/execl.c deleted file mode 100644 index 6acbe52ed..000000000 --- a/newlib/libc/posix/execl.c +++ /dev/null @@ -1,49 +0,0 @@ -/* execl.c */ - -/* This and the other exec*.c files in this directory require - the target to provide the _execve syscall. */ - -#include <_ansi.h> -#include <unistd.h> - -/* Only deal with a pointer to environ, to work around subtle bugs with shared - libraries and/or small data systems where the user declares his own - 'environ'. */ -static char ***p_environ = &environ; - -#ifdef _HAVE_STDC - -#include <stdarg.h> - -int -_DEFUN(execl, (path, arg0, ...), - _CONST char *path _AND - _CONST char *arg0 _DOTS) - -#else - -#include <varargs.h> - -int -_DEFUN(execl, (path, arg0, va_alist), - _CONST char *path _AND - _CONST char *arg0 _AND - va_dcl) - -#endif - -{ - int i; - va_list args; - _CONST char *argv[256]; - - va_start (args, arg0); - argv[0] = arg0; - i = 1; - do - argv[i] = va_arg (args, _CONST char *); - while (argv[i++] != NULL); - va_end (args); - - return _execve (path, (char * _CONST *) argv, *p_environ); -} diff --git a/newlib/libc/posix/execle.c b/newlib/libc/posix/execle.c deleted file mode 100644 index efe204d86..000000000 --- a/newlib/libc/posix/execle.c +++ /dev/null @@ -1,46 +0,0 @@ -/* execle.c */ - -/* This and the other exec*.c files in this directory require - the target to provide the _execve syscall. */ - -#include <_ansi.h> -#include <unistd.h> - -#ifdef _HAVE_STDC - -#include <stdarg.h> - -int -_DEFUN(execle, (path, arg0, ...), - _CONST char *path _AND - _CONST char *arg0 _DOTS) - -#else - -#include <varargs.h> - -int -_DEFUN(execle, (path, arg0, va_alist), - _CONST char *path _AND - _CONST char *arg0 _AND - va_dcl) - -#endif - -{ - int i; - va_list args; - _CONST char * _CONST *envp; - _CONST char *argv[256]; - - va_start (args, arg0); - argv[0] = arg0; - i = 1; - do - argv[i] = va_arg (args, _CONST char *); - while (argv[i++] != NULL); - envp = va_arg (args, _CONST char * _CONST *); - va_end (args); - - return _execve (path, (char * _CONST *) argv, (char * _CONST *) envp); -} diff --git a/newlib/libc/posix/execlp.c b/newlib/libc/posix/execlp.c deleted file mode 100644 index 5252cd988..000000000 --- a/newlib/libc/posix/execlp.c +++ /dev/null @@ -1,44 +0,0 @@ -/* execlp.c */ - -/* This and the other exec*.c files in this directory require - the target to provide the _execve syscall. */ - -#include <_ansi.h> -#include <unistd.h> - -#ifdef _HAVE_STDC - -#include <stdarg.h> - -int -_DEFUN(execlp, (path, arg0, ...), - _CONST char *path _AND - _CONST char *arg0 _DOTS) - -#else - -#include <varargs.h> - -int -_DEFUN(execlp, (path, arg0, va_alist), - _CONST char *path _AND - _CONST char *arg0 _AND - va_dcl) - -#endif - -{ - int i; - va_list args; - _CONST char *argv[256]; - - va_start (args, arg0); - argv[0] = arg0; - i = 1; - do - argv[i] = va_arg (args, _CONST char *); - while (argv[i++] != NULL); - va_end (args); - - return execvp (path, (char * _CONST *) argv); -} diff --git a/newlib/libc/posix/execv.c b/newlib/libc/posix/execv.c deleted file mode 100644 index 5effb9c57..000000000 --- a/newlib/libc/posix/execv.c +++ /dev/null @@ -1,20 +0,0 @@ -/* execv.c */ - -/* This and the other exec*.c files in this directory require - the target to provide the _execve syscall. */ - -#include <_ansi.h> -#include <unistd.h> - -/* Only deal with a pointer to environ, to work around subtle bugs with shared - libraries and/or small data systems where the user declares his own - 'environ'. */ -static char ***p_environ = &environ; - -int -_DEFUN (execv, (path, argv), - const char *path _AND - char * const argv[]) -{ - return _execve (path, (char * _CONST *) argv, *p_environ); -} diff --git a/newlib/libc/posix/execve.c b/newlib/libc/posix/execve.c deleted file mode 100644 index 8083c03b0..000000000 --- a/newlib/libc/posix/execve.c +++ /dev/null @@ -1,17 +0,0 @@ -/* execve.c */ - -/* This and the other exec*.c files in this directory require - the target to provide the _execve syscall. */ - - -#include <unistd.h> - - -int -_DEFUN(execve, (path, argv, envp), - const char *path _AND - char * const argv[] _AND - char * const envp[]) -{ - return _execve (path, argv, envp); -} diff --git a/newlib/libc/posix/execvp.c b/newlib/libc/posix/execvp.c deleted file mode 100644 index 70743163d..000000000 --- a/newlib/libc/posix/execvp.c +++ /dev/null @@ -1,69 +0,0 @@ -/* execvp.c */ - -/* This and the other exec*.c files in this directory require - the target to provide the _execve syscall. */ - -#include <_ansi.h> -#include <stdlib.h> -#include <unistd.h> -#include <dirent.h> -#include <string.h> -#include <errno.h> -#include <ctype.h> - -#define PATH_DELIM ':' - -/* - * Copy string, until c or <nul> is encountered. - * NUL-terminate the destination string (s1). - */ - -static char * -_DEFUN (strccpy, (s1, s2, c), - char *s1 _AND - char *s2 _AND - char c) -{ - char *dest = s1; - - while (*s2 && *s2 != c) - *s1++ = *s2++; - *s1 = 0; - - return dest; -} - -int -_DEFUN (execvp, (file, argv), - _CONST char *file _AND - char * _CONST argv[]) -{ - char *path = getenv ("PATH"); - char buf[MAXNAMLEN]; - - /* If $PATH doesn't exist, just pass FILE on unchanged. */ - if (!path) - return execv (file, argv); - - /* If FILE contains a directory, don't search $PATH. */ - if (strchr (file, '/') - ) - return execv (file, argv); - - while (*path) - { - strccpy (buf, path, PATH_DELIM); - /* An empty entry means the current directory. */ - if (*buf != 0 && buf[strlen(buf) - 1] != '/') - strcat (buf, "/"); - strcat (buf, file); - if (execv (buf, argv) == -1 && errno != ENOENT) - return -1; - while (*path && *path != PATH_DELIM) - path++; - if (*path == PATH_DELIM) - path++; /* skip over delim */ - } - - return -1; -} diff --git a/newlib/libc/posix/isatty.c b/newlib/libc/posix/isatty.c deleted file mode 100644 index 2732ca2a0..000000000 --- a/newlib/libc/posix/isatty.c +++ /dev/null @@ -1,17 +0,0 @@ -/* isatty.c */ - -/* Dumb implementation so programs will at least run. */ - -#include <sys/stat.h> - -int -_DEFUN(isatty, (fd), int fd) -{ - struct stat buf; - - if (fstat (fd, &buf) < 0) - return 0; - if (S_ISCHR (buf.st_mode)) - return 1; - return 0; -} diff --git a/newlib/libc/posix/opendir.c b/newlib/libc/posix/opendir.c deleted file mode 100644 index c9a97dbf3..000000000 --- a/newlib/libc/posix/opendir.c +++ /dev/null @@ -1,95 +0,0 @@ -#ifndef HAVE_OPENDIR - -/* - * Copyright (c) 1983 Regents of the University of California. - * 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. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)opendir.c 5.11 (Berkeley) 2/23/91"; -#endif /* LIBC_SCCS and not lint */ - -#include <dirent.h> -#include <fcntl.h> -#include <stdlib.h> -#include <unistd.h> -#include <sys/lock.h> - -/* - * open a directory. - */ -DIR * -_DEFUN(opendir, (name), - const char *name) -{ - register DIR *dirp; - register int fd; - int rc = 0; - - if ((fd = open(name, 0)) == -1) - return NULL; -#ifdef HAVE_FCNTL - rc = fcntl(fd, F_SETFD, 1); -#endif - if (rc == -1 || - (dirp = (DIR *)malloc(sizeof(DIR))) == NULL) { - close (fd); - return NULL; - } - /* - * If CLSIZE is an exact multiple of DIRBLKSIZ, use a CLSIZE - * buffer that it cluster boundary aligned. - * Hopefully this can be a big win someday by allowing page trades - * to user space to be done by getdirentries() - */ - dirp->dd_buf = malloc (512); - dirp->dd_len = 512; - - if (dirp->dd_buf == NULL) { - close (fd); - return NULL; - } - dirp->dd_fd = fd; - dirp->dd_loc = 0; - dirp->dd_seek = 0; - /* - * Set up seek point for rewinddir. - */ - -#ifdef HAVE_DD_LOCK - /* if we have a locking mechanism, initialize it */ - __lock_init_recursive(dirp->dd_lock); -#endif - - return dirp; -} - -#endif /* ! HAVE_OPENDIR */ diff --git a/newlib/libc/posix/popen.c b/newlib/libc/posix/popen.c deleted file mode 100644 index 0f25a3ed0..000000000 --- a/newlib/libc/posix/popen.c +++ /dev/null @@ -1,175 +0,0 @@ -/* $NetBSD: popen.c,v 1.11 1995/06/16 07:05:33 jtc Exp $ */ - -/* - * Copyright (c) 1988, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software written by Ken Arnold and - * published in UNIX Review, Vol. 6, No. 8. - * - * 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. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)popen.c 8.1 (Berkeley) 6/4/93"; -#else -static char rcsid[] = "$NetBSD: popen.c,v 1.11 1995/06/16 07:05:33 jtc Exp $"; -#endif -#endif /* LIBC_SCCS and not lint */ - -#include <sys/param.h> -#include <sys/types.h> -#include <sys/wait.h> - -#include <signal.h> -#include <errno.h> -#include <unistd.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <paths.h> - -static struct pid { - struct pid *next; - FILE *fp; - pid_t pid; -} *pidlist; - -FILE * -_DEFUN(popen, (program, type), - const char *program _AND - const char *type) -{ - struct pid *cur; - FILE *iop; - int pdes[2], pid; - - if ((*type != 'r' && *type != 'w') - || (type[1] -#ifdef __CYGWIN__ - && (type[2] || (type[1] != 'b' && type[1] != 't')) -#endif - )) { - errno = EINVAL; - return (NULL); - } - - if ((cur = malloc(sizeof(struct pid))) == NULL) - return (NULL); - - if (pipe(pdes) < 0) { - free(cur); - return (NULL); - } - - switch (pid = vfork()) { - case -1: /* Error. */ - (void)close(pdes[0]); - (void)close(pdes[1]); - free(cur); - return (NULL); - /* NOTREACHED */ - case 0: /* Child. */ - if (*type == 'r') { - if (pdes[1] != STDOUT_FILENO) { - (void)dup2(pdes[1], STDOUT_FILENO); - (void)close(pdes[1]); - } - (void) close(pdes[0]); - } else { - if (pdes[0] != STDIN_FILENO) { - (void)dup2(pdes[0], STDIN_FILENO); - (void)close(pdes[0]); - } - (void)close(pdes[1]); - } - execl(_PATH_BSHELL, "sh", "-c", program, NULL); -#ifdef __CYGWIN__ - /* On cygwin32, we may not have /bin/sh. In that - case, try to find sh on PATH. */ - execlp("sh", "sh", "-c", program, NULL); -#endif - _exit(127); - /* NOTREACHED */ - } - - /* Parent; assume fdopen can't fail. */ - if (*type == 'r') { - iop = fdopen(pdes[0], type); - (void)close(pdes[1]); - } else { - iop = fdopen(pdes[1], type); - (void)close(pdes[0]); - } - - /* Link into list of file descriptors. */ - cur->fp = iop; - cur->pid = pid; - cur->next = pidlist; - pidlist = cur; - - return (iop); -} - -/* - * pclose -- - * Pclose returns -1 if stream is not associated with a `popened' command, - * if already `pclosed', or waitpid returns an error. - */ -int -_DEFUN(pclose, (iop), - FILE *iop) -{ - register struct pid *cur, *last; - int pstat; - pid_t pid; - - (void)fclose(iop); - - /* Find the appropriate file pointer. */ - for (last = NULL, cur = pidlist; cur; last = cur, cur = cur->next) - if (cur->fp == iop) - break; - if (cur == NULL) - return (-1); - - do { - pid = waitpid(cur->pid, &pstat, 0); - } while (pid == -1 && errno == EINTR); - - /* Remove the entry from the linked list. */ - if (last == NULL) - pidlist = cur->next; - else - last->next = cur->next; - free(cur); - - return (pid == -1 ? -1 : pstat); -} diff --git a/newlib/libc/posix/readdir.c b/newlib/libc/posix/readdir.c deleted file mode 100644 index da07d5c00..000000000 --- a/newlib/libc/posix/readdir.c +++ /dev/null @@ -1,101 +0,0 @@ -#ifndef HAVE_OPENDIR - -/* - * Copyright (c) 1983 Regents of the University of California. - * 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. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)readdir.c 5.7 (Berkeley) 6/1/90"; -#endif /* LIBC_SCCS and not lint */ - -#include <dirent.h> - -extern int getdents (int fd, void *dp, int count); - -/* - * get next entry in a directory. - */ -struct dirent * -_DEFUN(readdir, (dirp), - register DIR *dirp) -{ - register struct dirent *dp; - -#ifdef HAVE_DD_LOCK - __lock_acquire_recursive(dirp->dd_lock); -#endif - - if (dirp->dd_fd == -1) - return NULL; - - for (;;) { - if (dirp->dd_loc == 0) { - dirp->dd_size = getdents (dirp->dd_fd, - dirp->dd_buf, - dirp->dd_len); - - if (dirp->dd_size <= 0) { -#ifdef HAVE_DD_LOCK - __lock_release_recursive(dirp->dd_lock); -#endif - return NULL; - } - } - if (dirp->dd_loc >= dirp->dd_size) { - dirp->dd_loc = 0; - continue; - } - dp = (struct dirent *)(dirp->dd_buf + dirp->dd_loc); - if ((int)dp & 03) { /* bogus pointer check */ -#ifdef HAVE_DD_LOCK - __lock_release_recursive(dirp->dd_lock); -#endif - return NULL; - } - if (dp->d_reclen <= 0 || - dp->d_reclen > dirp->dd_len + 1 - dirp->dd_loc) { -#ifdef HAVE_DD_LOCK - __lock_release_recursive(dirp->dd_lock); -#endif - return NULL; - } - dirp->dd_loc += dp->d_reclen; - if (dp->d_ino == 0) - continue; -#ifdef HAVE_DD_LOCK - __lock_release_recursive(dirp->dd_lock); -#endif - return (dp); - } -} - -#endif /* ! HAVE_OPENDIR */ diff --git a/newlib/libc/posix/readdir_r.c b/newlib/libc/posix/readdir_r.c deleted file mode 100644 index 9bc013c64..000000000 --- a/newlib/libc/posix/readdir_r.c +++ /dev/null @@ -1,108 +0,0 @@ -#ifndef HAVE_OPENDIR - -/* - * Copyright (c) 1983 Regents of the University of California. - * 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. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - */ - -/* this code is modified from readdir.c by Jeff Johnston, June 5, 2002 */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)readdir.c 5.7 (Berkeley) 6/1/90"; -#endif /* LIBC_SCCS and not lint */ - -#include <dirent.h> -#include <errno.h> -#include <string.h> - -extern int getdents (int fd, void *dp, int count); - -/* - * get next entry in a directory using supplied dirent structure. - */ -int -_DEFUN(readdir_r, (dirp, dp, dpp), - register DIR *dirp _AND - struct dirent *dp _AND - struct dirent **dpp) { - -struct dirent *tmpdp; - -#ifdef HAVE_DD_LOCK - __lock_acquire_recursive(dirp->dd_lock); -#endif - - if (dirp->dd_fd == -1) { - *dpp = NULL; - return errno = EBADF; - } - - for (;;) { - if (dirp->dd_loc == 0) { - dirp->dd_size = getdents (dirp->dd_fd, - dirp->dd_buf, - dirp->dd_len); - - if (dirp->dd_size <= 0) { -#ifdef HAVE_DD_LOCK - __lock_release_recursive(dirp->dd_lock); -#endif - *dpp = NULL; - return errno; - } - } - if (dirp->dd_loc >= dirp->dd_size) { - dirp->dd_loc = 0; - continue; - } - tmpdp = (struct dirent *)(dirp->dd_buf + dirp->dd_loc); - memcpy (dp, tmpdp, sizeof(struct dirent)); - - if (dp->d_reclen <= 0 || - dp->d_reclen > dirp->dd_len + 1 - dirp->dd_loc) { -#ifdef HAVE_DD_LOCK - __lock_release_recursive(dirp->dd_lock); -#endif - *dpp = NULL; - return -1; - } - dirp->dd_loc += dp->d_reclen; - if (dp->d_ino == 0) - continue; -#ifdef HAVE_DD_LOCK - __lock_release_recursive(dirp->dd_lock); -#endif - *dpp = dp; - return 0; - } -} - -#endif /* ! HAVE_OPENDIR */ diff --git a/newlib/libc/posix/rewinddir.c b/newlib/libc/posix/rewinddir.c deleted file mode 100644 index bffad9612..000000000 --- a/newlib/libc/posix/rewinddir.c +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef HAVE_OPENDIR - -/* - * Copyright (c) 1990 The Regents of the University of California. - * 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. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)rewinddir.c 5.1 (Berkeley) 5/25/90"; -#endif /* LIBC_SCCS and not lint */ - -#include <sys/types.h> -#include <dirent.h> -#include <sys/lock.h> - -void -_DEFUN(rewinddir, (dirp), - DIR *dirp) -{ -#ifdef HAVE_DD_LOCK - __lock_acquire_recursive(dirp->dd_lock); -#endif - _seekdir((dirp), (off_t)0); -#ifdef HAVE_DD_LOCK - __lock_release_recursive(dirp->dd_lock); -#endif -} - -#endif /* ! HAVE_OPENDIR */ diff --git a/newlib/libc/posix/scandir.c b/newlib/libc/posix/scandir.c deleted file mode 100644 index 2cd586050..000000000 --- a/newlib/libc/posix/scandir.c +++ /dev/null @@ -1,177 +0,0 @@ -#ifndef HAVE_OPENDIR - -/* - * Copyright (c) 1983 Regents of the University of California. - * 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. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)scandir.c 5.10 (Berkeley) 2/23/91"; -#endif /* LIBC_SCCS and not lint */ - -/* - * Scan the directory dirname calling select to make a list of selected - * directory entries then sort using qsort and compare routine dcomp. - * Returns the number of entries and a pointer to a list of pointers to - * struct dirent (through namelist). Returns -1 if there were any errors. - */ - -#include <sys/types.h> -#include <sys/stat.h> -#include <dirent.h> -#include <stdlib.h> -#include <string.h> -#include <sys/lock.h> - -/* - * The DIRSIZ macro gives the minimum record length which will hold - * the directory entry. This requires the amount of space in struct dirent - * without the d_name field, plus enough space for the name with a terminating - * null byte (dp->d_namlen+1), rounded up to a 4 byte boundary. - */ -#undef DIRSIZ -#ifdef _DIRENT_HAVE_D_NAMLEN -#define DIRSIZ(dp) \ - ((sizeof (struct dirent) - (MAXNAMLEN+1)) + (((dp)->d_namlen+1 + 3) &~ 3)) -#else -#define DIRSIZ(dp) \ - ((sizeof (struct dirent) - (MAXNAMLEN+1)) + ((strlen((dp)->d_name)+1 + 3) &~ 3)) -#endif - -#ifndef __P -#define __P(args) () -#endif - -int -_DEFUN(scandir, (dirname, namelist, select, dcomp), - const char *dirname _AND - struct dirent ***namelist _AND - int (*select) __P((const struct dirent *)) _AND - int (*dcomp) __P((const struct dirent **, const struct dirent **))) -{ - register struct dirent *d, *p, **names; - register size_t nitems; - struct stat stb; - long arraysz; - DIR *dirp; - - if ((dirp = opendir(dirname)) == NULL) - return(-1); -#ifdef HAVE_DD_LOCK - __lock_acquire_recursive(dirp->dd_lock); -#endif - if (fstat(dirp->dd_fd, &stb) < 0) { -#ifdef HAVE_DD_LOCK - __lock_release_recursive(dirp->dd_lock); -#endif - return(-1); - } - - /* - * estimate the array size by taking the size of the directory file - * and dividing it by a multiple of the minimum size entry. - */ - arraysz = (stb.st_size / 24); - names = (struct dirent **)malloc(arraysz * sizeof(struct dirent *)); - if (names == NULL) { -#ifdef HAVE_DD_LOCK - __lock_release_recursive(dirp->dd_lock); -#endif - return(-1); - } - - nitems = 0; - while ((d = readdir(dirp)) != NULL) { - if (select != NULL && !(*select)(d)) - continue; /* just selected names */ - /* - * Make a minimum size copy of the data - */ - p = (struct dirent *)malloc(DIRSIZ(d)); - if (p == NULL) { -#ifdef HAVE_DD_LOCK - __lock_release_recursive(dirp->dd_lock); -#endif - return(-1); - } - p->d_ino = d->d_ino; - p->d_reclen = d->d_reclen; -#ifdef _DIRENT_HAVE_D_NAMLEN - p->d_namlen = d->d_namlen; - bcopy(d->d_name, p->d_name, p->d_namlen + 1); -#else - strcpy(p->d_name, d->d_name); -#endif - /* - * Check to make sure the array has space left and - * realloc the maximum size. - */ - if (++nitems >= arraysz) { - if (fstat(dirp->dd_fd, &stb) < 0) { -#ifdef HAVE_DD_LOCK - __lock_release_recursive(dirp->dd_lock); -#endif - return(-1); /* just might have grown */ - } - arraysz = stb.st_size / 12; - names = (struct dirent **)realloc((char *)names, - arraysz * sizeof(struct dirent *)); - if (names == NULL) { -#ifdef HAVE_DD_LOCK - __lock_release_recursive(dirp->dd_lock); -#endif - return(-1); - } - } - names[nitems-1] = p; - } - closedir(dirp); - if (nitems && dcomp != NULL) - qsort(names, nitems, sizeof(struct dirent *), (void *)dcomp); - *namelist = names; -#ifdef HAVE_DD_LOCK - __lock_release_recursive(dirp->dd_lock); -#endif - return(nitems); -} - -/* - * Alphabetic order comparison routine for those who want it. - */ -int -_DEFUN(alphasort, (d1, d2), - const struct dirent **d1 _AND - const struct dirent **d2) -{ - return(strcmp((*d1)->d_name, (*d2)->d_name)); -} - -#endif /* ! HAVE_OPENDIR */ diff --git a/newlib/libc/posix/seekdir.c b/newlib/libc/posix/seekdir.c deleted file mode 100644 index 3965edabf..000000000 --- a/newlib/libc/posix/seekdir.c +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef HAVE_OPENDIR - -/* - * Copyright (c) 1983 Regents of the University of California. - * 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. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)seekdir.c 5.7 (Berkeley) 6/1/90"; -#endif /* LIBC_SCCS and not lint */ - -#include <sys/param.h> -#include <dirent.h> -#include <sys/lock.h> - -/* - * Seek to an entry in a directory. - * _seekdir is in telldir.c so that it can share opaque data structures. - */ -void -_DEFUN(seekdir, (dirp, loc), - DIR *dirp _AND - long loc) -{ -#ifdef HAVE_DD_LOCK - __lock_acquire_recursive(dirp->dd_lock); -#endif - _seekdir(dirp, loc); -#ifdef HAVE_DD_LOCK - __lock_release_recursive(dirp->dd_lock); -#endif -} - -#endif /* ! HAVE_OPENDIR */ diff --git a/newlib/libc/posix/telldir.c b/newlib/libc/posix/telldir.c deleted file mode 100644 index a8c5440d1..000000000 --- a/newlib/libc/posix/telldir.c +++ /dev/null @@ -1,198 +0,0 @@ -#ifndef HAVE_OPENDIR - -/* - * Copyright (c) 1983 Regents of the University of California. - * 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. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)telldir.c 5.9 (Berkeley) 2/23/91"; -#endif /* LIBC_SCCS and not lint */ - -#include <sys/param.h> -#include <dirent.h> -#include <stdlib.h> -#include <unistd.h> -#include <sys/lock.h> - -/* - * The option SINGLEUSE may be defined to say that a telldir - * cookie may be used only once before it is freed. This option - * is used to avoid having memory usage grow without bound. - */ -#define SINGLEUSE - -/* - * One of these structures is malloced to describe the current directory - * position each time telldir is called. It records the current magic - * cookie returned by getdirentries and the offset within the buffer - * associated with that return value. - */ -struct ddloc { - struct ddloc *loc_next;/* next structure in list */ - long loc_index; /* key associated with structure */ - long loc_seek; /* magic cookie returned by getdirentries */ - long loc_loc; /* offset of entry in buffer */ - DIR *loc_dirp; /* DIR pointer */ -}; - -#define NDIRHASH 32 /* Num of hash lists, must be a power of 2 */ -#define LOCHASH(i) ((i)&(NDIRHASH-1)) - -static long dd_loccnt; /* Index of entry for sequential readdir's */ -static struct ddloc *dd_hash[NDIRHASH]; /* Hash list heads for ddlocs */ -__LOCK_INIT(static, dd_hash_lock); - -/* - * return a pointer into a directory - */ - -#ifndef _ELIX_LEVEL || _ELIX_LEVEL >= 2 - -long -_DEFUN(telldir, (dirp), - DIR *dirp) -{ - register int index; - register struct ddloc *lp; - - if ((lp = (struct ddloc *)malloc(sizeof(struct ddloc))) == NULL) - return (-1); - -#ifdef HAVE_DD_LOCK - __lock_acquire_recursive(dirp->dd_lock); - __lock_acquire(dd_hash_lock); -#endif - index = dd_loccnt++; - lp->loc_index = index; - lp->loc_seek = dirp->dd_seek; - lp->loc_loc = dirp->dd_loc; - lp->loc_dirp = dirp; - lp->loc_next = dd_hash[LOCHASH(index)]; - dd_hash[LOCHASH(index)] = lp; -#ifdef HAVE_DD_LOCK - __lock_release(dd_hash_lock); - __lock_release_recursive(dirp->dd_lock); -#endif - return (index); -} - -#endif /* !_ELIX_LEVEL || _ELIX_LEVEL >= 2 */ - -/* - * seek to an entry in a directory. - * Only values returned by "telldir" should be passed to seekdir. - */ -void -_DEFUN(_seekdir, (dirp, loc), - register DIR *dirp _AND - long loc) -{ - register struct ddloc *lp; - register struct ddloc **prevlp; - struct dirent *dp; - extern long lseek(); - -#ifdef HAVE_DD_LOCK - __lock_acquire(dd_hash_lock); -#endif - prevlp = &dd_hash[LOCHASH(loc)]; - lp = *prevlp; - while (lp != NULL) { - if (lp->loc_index == loc) - break; - prevlp = &lp->loc_next; - lp = lp->loc_next; - } - if (lp == NULL) { -#ifdef HAVE_DD_LOCK - __lock_release(dd_hash_lock); -#endif - return; - } - if (lp->loc_loc == dirp->dd_loc && lp->loc_seek == dirp->dd_seek) - goto found; - (void) lseek(dirp->dd_fd, lp->loc_seek, 0); - dirp->dd_seek = lp->loc_seek; - dirp->dd_loc = 0; - while (dirp->dd_loc < lp->loc_loc) { - dp = readdir(dirp); - if (dp == NULL) - break; - } -found: -#ifdef SINGLEUSE - *prevlp = lp->loc_next; - free((caddr_t)lp); -#endif -#ifdef HAVE_DD_LOCK - __lock_release(dd_hash_lock); -#endif -} - -/* clean out any hash entries from a closed directory */ -void -_DEFUN(_cleanupdir, (dirp), - register DIR *dirp) -{ - int i; - -#ifdef HAVE_DD_LOCK - __lock_acquire(dd_hash_lock); -#endif - for (i = 0; i < NDIRHASH; ++i) { - register struct ddloc *lp; - register struct ddloc *prevlp; - lp = dd_hash[i]; - while (lp != NULL && lp->loc_dirp == dirp) { - dd_hash[i] = lp->loc_next; - prevlp = lp; - free((caddr_t)lp); - lp = prevlp->loc_next; - } - prevlp = lp; - while (lp != NULL) { - lp = lp->loc_next; - if (lp != NULL && lp->loc_dirp == dirp) { - prevlp->loc_next = lp->loc_next; - free((caddr_t)lp); - lp = prevlp; - } - else - prevlp = lp; - } - } -#ifdef HAVE_DD_LOCK - __lock_release(dd_hash_lock); -#endif - -} -#endif /* ! HAVE_OPENDIR */ |