Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'newlib/libc/posix')
-rw-r--r--newlib/libc/posix/Makefile.am40
-rw-r--r--newlib/libc/posix/Makefile.in76
-rw-r--r--newlib/libc/posix/closedir.c31
-rw-r--r--newlib/libc/posix/creat.c4
-rw-r--r--newlib/libc/posix/execl.c12
-rw-r--r--newlib/libc/posix/execle.c12
-rw-r--r--newlib/libc/posix/execlp.c12
-rw-r--r--newlib/libc/posix/execve.c5
-rw-r--r--newlib/libc/posix/isatty.c2
-rw-r--r--newlib/libc/posix/opendir.c17
-rw-r--r--newlib/libc/posix/popen.c17
-rw-r--r--newlib/libc/posix/readdir.c37
-rw-r--r--newlib/libc/posix/readdir_r.c108
-rw-r--r--newlib/libc/posix/rewinddir.c11
-rw-r--r--newlib/libc/posix/scandir.c55
-rw-r--r--newlib/libc/posix/seekdir.c14
-rw-r--r--newlib/libc/posix/telldir.c77
17 files changed, 95 insertions, 435 deletions
diff --git a/newlib/libc/posix/Makefile.am b/newlib/libc/posix/Makefile.am
index d39aed316..1274137f9 100644
--- a/newlib/libc/posix/Makefile.am
+++ b/newlib/libc/posix/Makefile.am
@@ -4,48 +4,20 @@ 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
+LIB_SOURCES = \
+ closedir.c opendir.c readdir.c rewinddir.c scandir.c seekdir.c \
+ telldir.c execl.c execle.c execlp.c execv.c execve.c execvp.c \
+ popen.c creat.c isatty.c
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)
+libposix_la_SOURCES = $(LIB_SOURCES)
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)
+lib_a_SOURCES = $(LIB_SOURCES)
noinst_DATA =
endif # USE_LIBTOOL
diff --git a/newlib/libc/posix/Makefile.in b/newlib/libc/posix/Makefile.in
index 8867573fa..32a7b5dbd 100644
--- a/newlib/libc/posix/Makefile.in
+++ b/newlib/libc/posix/Makefile.in
@@ -1,6 +1,6 @@
-# Makefile.in generated automatically by automake 1.4-p6 from Makefile.am
+# Makefile.in generated automatically by automake 1.4 from Makefile.am
-# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
+# Copyright (C) 1994, 1995-8, 1999 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.
@@ -58,32 +58,20 @@ 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@
@@ -93,13 +81,10 @@ 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@
@@ -110,34 +95,20 @@ 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
+LIB_SOURCES = \
+ closedir.c opendir.c readdir.c rewinddir.c scandir.c seekdir.c \
+ telldir.c execl.c execle.c execlp.c execv.c execve.c execvp.c \
+ popen.c creat.c isatty.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_TRUE@noinst_LTLIBRARIES = @USE_LIBTOOL_TRUE@libposix.la
+@USE_LIBTOOL_TRUE@libposix_la_SOURCES = @USE_LIBTOOL_TRUE@$(LIB_SOURCES)
+@USE_LIBTOOL_TRUE@noinst_DATA = @USE_LIBTOOL_TRUE@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)
+@USE_LIBTOOL_FALSE@noinst_LIBRARIES = @USE_LIBTOOL_FALSE@lib.a
+@USE_LIBTOOL_FALSE@lib_a_SOURCES = @USE_LIBTOOL_FALSE@$(LIB_SOURCES)
CHEWOUT_FILES =
@@ -156,15 +127,18 @@ 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)
+lib_a_LIBADD =
+@USE_LIBTOOL_FALSE@lib_a_OBJECTS = closedir.o opendir.o readdir.o \
+@USE_LIBTOOL_FALSE@rewinddir.o scandir.o seekdir.o telldir.o execl.o \
+@USE_LIBTOOL_FALSE@execle.o execlp.o execv.o execve.o execvp.o popen.o \
+@USE_LIBTOOL_FALSE@creat.o isatty.o
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
+libposix_la_LIBADD =
+@USE_LIBTOOL_TRUE@libposix_la_OBJECTS = closedir.lo opendir.lo \
+@USE_LIBTOOL_TRUE@readdir.lo rewinddir.lo scandir.lo seekdir.lo \
+@USE_LIBTOOL_TRUE@telldir.lo execl.lo execle.lo execlp.lo execv.lo \
+@USE_LIBTOOL_TRUE@execve.lo execvp.lo popen.lo creat.lo isatty.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)
@@ -184,7 +158,7 @@ OBJECTS = $(lib_a_OBJECTS) $(libposix_la_OBJECTS)
all: all-redirect
.SUFFIXES:
-.SUFFIXES: .S .c .def .lo .o .obj .s
+.SUFFIXES: .S .c .def .lo .o .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
@@ -205,11 +179,6 @@ 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 $<
@@ -218,7 +187,6 @@ maintainer-clean-noinstLIBRARIES:
mostlyclean-compile:
-rm -f *.o core *.core
- -rm -f *.$(OBJEXT)
clean-compile:
diff --git a/newlib/libc/posix/closedir.c b/newlib/libc/posix/closedir.c
index 634f5ad12..4ad6e4c97 100644
--- a/newlib/libc/posix/closedir.c
+++ b/newlib/libc/posix/closedir.c
@@ -41,37 +41,22 @@ static char sccsid[] = "@(#)closedir.c 5.9 (Berkeley) 2/23/91";
#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)
+closedir(dirp)
+ register DIR *dirp;
{
- int fd, rc;
+ int fd;
-#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;
+ dirp->dd_fd = -1;
+ dirp->dd_loc = 0;
+ (void)free((void *)dirp->dd_buf);
+ (void)free((void *)dirp);
+ return(close(fd));
}
#endif /* ! HAVE_OPENDIR */
diff --git a/newlib/libc/posix/creat.c b/newlib/libc/posix/creat.c
index b8a4f9a14..6b1116206 100644
--- a/newlib/libc/posix/creat.c
+++ b/newlib/libc/posix/creat.c
@@ -5,9 +5,7 @@
#include <fcntl.h>
int
-_DEFUN(creat, (path, mode),
- const char *path _AND
- mode_t mode)
+creat (const char *path, 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
index 6acbe52ed..098005666 100644
--- a/newlib/libc/posix/execl.c
+++ b/newlib/libc/posix/execl.c
@@ -16,19 +16,17 @@ static char ***p_environ = &environ;
#include <stdarg.h>
int
-_DEFUN(execl, (path, arg0, ...),
- _CONST char *path _AND
- _CONST char *arg0 _DOTS)
+execl (_CONST char *path, _CONST char *arg0, ...)
#else
#include <varargs.h>
int
-_DEFUN(execl, (path, arg0, va_alist),
- _CONST char *path _AND
- _CONST char *arg0 _AND
- va_dcl)
+execl (path, arg0, va_alist)
+ _CONST char *path;
+ _CONST char *arg0;
+ va_dcl
#endif
diff --git a/newlib/libc/posix/execle.c b/newlib/libc/posix/execle.c
index efe204d86..439437023 100644
--- a/newlib/libc/posix/execle.c
+++ b/newlib/libc/posix/execle.c
@@ -11,19 +11,17 @@
#include <stdarg.h>
int
-_DEFUN(execle, (path, arg0, ...),
- _CONST char *path _AND
- _CONST char *arg0 _DOTS)
+execle (_CONST char *path, _CONST char *arg0, ...)
#else
#include <varargs.h>
int
-_DEFUN(execle, (path, arg0, va_alist),
- _CONST char *path _AND
- _CONST char *arg0 _AND
- va_dcl)
+execle (path, arg0, va_alist)
+ _CONST char *path;
+ _CONST char *arg0;
+ va_dcl
#endif
diff --git a/newlib/libc/posix/execlp.c b/newlib/libc/posix/execlp.c
index 5252cd988..dd04914bc 100644
--- a/newlib/libc/posix/execlp.c
+++ b/newlib/libc/posix/execlp.c
@@ -11,19 +11,17 @@
#include <stdarg.h>
int
-_DEFUN(execlp, (path, arg0, ...),
- _CONST char *path _AND
- _CONST char *arg0 _DOTS)
+execlp (_CONST char *path, _CONST char *arg0, ...)
#else
#include <varargs.h>
int
-_DEFUN(execlp, (path, arg0, va_alist),
- _CONST char *path _AND
- _CONST char *arg0 _AND
- va_dcl)
+execlp (path, arg0, va_alist)
+ _CONST char *path;
+ _CONST char *arg0;
+ va_dcl
#endif
diff --git a/newlib/libc/posix/execve.c b/newlib/libc/posix/execve.c
index 8083c03b0..1be0ed128 100644
--- a/newlib/libc/posix/execve.c
+++ b/newlib/libc/posix/execve.c
@@ -8,10 +8,7 @@
int
-_DEFUN(execve, (path, argv, envp),
- const char *path _AND
- char * const argv[] _AND
- char * const envp[])
+execve (const char *path, char * const argv[], char * const envp[])
{
return _execve (path, argv, envp);
}
diff --git a/newlib/libc/posix/isatty.c b/newlib/libc/posix/isatty.c
index 2732ca2a0..3c64647a9 100644
--- a/newlib/libc/posix/isatty.c
+++ b/newlib/libc/posix/isatty.c
@@ -5,7 +5,7 @@
#include <sys/stat.h>
int
-_DEFUN(isatty, (fd), int fd)
+isatty (int fd)
{
struct stat buf;
diff --git a/newlib/libc/posix/opendir.c b/newlib/libc/posix/opendir.c
index c9a97dbf3..f924c0b52 100644
--- a/newlib/libc/posix/opendir.c
+++ b/newlib/libc/posix/opendir.c
@@ -41,25 +41,20 @@ static char sccsid[] = "@(#)opendir.c 5.11 (Berkeley) 2/23/91";
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>
-#include <sys/lock.h>
/*
* open a directory.
*/
DIR *
-_DEFUN(opendir, (name),
- const char *name)
+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 ||
+ if (fcntl(fd, F_SETFD, 1) == -1 ||
(dirp = (DIR *)malloc(sizeof(DIR))) == NULL) {
close (fd);
return NULL;
@@ -83,12 +78,6 @@ _DEFUN(opendir, (name),
/*
* 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;
}
diff --git a/newlib/libc/posix/popen.c b/newlib/libc/posix/popen.c
index 0f25a3ed0..d6d174d08 100644
--- a/newlib/libc/posix/popen.c
+++ b/newlib/libc/posix/popen.c
@@ -63,20 +63,15 @@ static struct pid {
} *pidlist;
FILE *
-_DEFUN(popen, (program, type),
- const char *program _AND
- const char *type)
+popen(program, type)
+ const char *program;
+ 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
- )) {
+ if ((*type != 'r' && *type != 'w') || type[1]) {
errno = EINVAL;
return (NULL);
}
@@ -144,8 +139,8 @@ _DEFUN(popen, (program, type),
* if already `pclosed', or waitpid returns an error.
*/
int
-_DEFUN(pclose, (iop),
- FILE *iop)
+pclose(iop)
+ FILE *iop;
{
register struct pid *cur, *last;
int pstat;
diff --git a/newlib/libc/posix/readdir.c b/newlib/libc/posix/readdir.c
index da07d5c00..308330cb0 100644
--- a/newlib/libc/posix/readdir.c
+++ b/newlib/libc/posix/readdir.c
@@ -39,61 +39,36 @@ static char sccsid[] = "@(#)readdir.c 5.7 (Berkeley) 6/1/90";
#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)
-{
+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
+ if (dirp->dd_size <= 0)
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
+ if ((int)dp & 03) /* bogus pointer check */
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
+ dp->d_reclen > dirp->dd_len + 1 - dirp->dd_loc)
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);
}
}
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
index bffad9612..6a3814b55 100644
--- a/newlib/libc/posix/rewinddir.c
+++ b/newlib/libc/posix/rewinddir.c
@@ -39,19 +39,12 @@ static char sccsid[] = "@(#)rewinddir.c 5.1 (Berkeley) 5/25/90";
#include <sys/types.h>
#include <dirent.h>
-#include <sys/lock.h>
void
-_DEFUN(rewinddir, (dirp),
- DIR *dirp)
+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
index 2cd586050..6acaff739 100644
--- a/newlib/libc/posix/scandir.c
+++ b/newlib/libc/posix/scandir.c
@@ -49,7 +49,6 @@ static char sccsid[] = "@(#)scandir.c 5.10 (Berkeley) 2/23/91";
#include <dirent.h>
#include <stdlib.h>
#include <string.h>
-#include <sys/lock.h>
/*
* The DIRSIZ macro gives the minimum record length which will hold
@@ -71,11 +70,11 @@ static char sccsid[] = "@(#)scandir.c 5.10 (Berkeley) 2/23/91";
#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 **)))
+scandir(dirname, namelist, select, dcomp)
+ const char *dirname;
+ struct dirent ***namelist;
+ int (*select) __P((struct dirent *));
+ int (*dcomp) __P((const void *, const void *));
{
register struct dirent *d, *p, **names;
register size_t nitems;
@@ -85,15 +84,8 @@ _DEFUN(scandir, (dirname, namelist, select, dcomp),
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
+ if (fstat(dirp->dd_fd, &stb) < 0)
return(-1);
- }
/*
* estimate the array size by taking the size of the directory file
@@ -101,12 +93,8 @@ _DEFUN(scandir, (dirname, namelist, select, dcomp),
*/
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
+ if (names == NULL)
return(-1);
- }
nitems = 0;
while ((d = readdir(dirp)) != NULL) {
@@ -116,12 +104,8 @@ _DEFUN(scandir, (dirname, namelist, select, dcomp),
* 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
+ if (p == NULL)
return(-1);
- }
p->d_ino = d->d_ino;
p->d_reclen = d->d_reclen;
#ifdef _DIRENT_HAVE_D_NAMLEN
@@ -135,31 +119,20 @@ _DEFUN(scandir, (dirname, namelist, select, dcomp),
* 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
+ if (fstat(dirp->dd_fd, &stb) < 0)
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
+ if (names == NULL)
return(-1);
- }
}
names[nitems-1] = p;
}
closedir(dirp);
if (nitems && dcomp != NULL)
- qsort(names, nitems, sizeof(struct dirent *), (void *)dcomp);
+ qsort(names, nitems, sizeof(struct dirent *), dcomp);
*namelist = names;
-#ifdef HAVE_DD_LOCK
- __lock_release_recursive(dirp->dd_lock);
-#endif
return(nitems);
}
@@ -167,9 +140,9 @@ _DEFUN(scandir, (dirname, namelist, select, dcomp),
* Alphabetic order comparison routine for those who want it.
*/
int
-_DEFUN(alphasort, (d1, d2),
- const struct dirent **d1 _AND
- const struct dirent **d2)
+alphasort(d1, d2)
+ const struct dirent **d1;
+ const struct dirent **d2;
{
return(strcmp((*d1)->d_name, (*d2)->d_name));
}
diff --git a/newlib/libc/posix/seekdir.c b/newlib/libc/posix/seekdir.c
index 3965edabf..dab3bfb24 100644
--- a/newlib/libc/posix/seekdir.c
+++ b/newlib/libc/posix/seekdir.c
@@ -39,24 +39,18 @@ static char sccsid[] = "@(#)seekdir.c 5.7 (Berkeley) 6/1/90";
#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)
+seekdir(dirp, loc)
+ DIR *dirp;
+ 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
index a8c5440d1..30c003760 100644
--- a/newlib/libc/posix/telldir.c
+++ b/newlib/libc/posix/telldir.c
@@ -41,7 +41,6 @@ static char sccsid[] = "@(#)telldir.c 5.9 (Berkeley) 2/23/91";
#include <dirent.h>
#include <stdlib.h>
#include <unistd.h>
-#include <sys/lock.h>
/*
* The option SINGLEUSE may be defined to say that a telldir
@@ -61,7 +60,6 @@ struct ddloc {
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 */
@@ -69,61 +67,42 @@ struct ddloc {
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)
+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)
+_seekdir(dirp, loc)
+ register DIR *dirp;
+ 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) {
@@ -132,12 +111,8 @@ _DEFUN(_seekdir, (dirp, loc),
prevlp = &lp->loc_next;
lp = lp->loc_next;
}
- if (lp == NULL) {
-#ifdef HAVE_DD_LOCK
- __lock_release(dd_hash_lock);
-#endif
+ if (lp == NULL)
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);
@@ -153,46 +128,6 @@ found:
*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 */