about summary refs log tree commit diff
path: root/sysdeps/unix
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1996-10-02 01:40:17 +0000
committerUlrich Drepper <drepper@redhat.com>1996-10-02 01:40:17 +0000
commita68b0d31a37a86785b3dbeeee3fad96ee71fadcd (patch)
tree61537b1f028002a9e6e0f5354fced6128bda8b9c /sysdeps/unix
parent2d07133b507b13d4a5ed6dc250f4345c8a26942a (diff)
downloadglibc-a68b0d31a37a86785b3dbeeee3fad96ee71fadcd.tar.gz
glibc-a68b0d31a37a86785b3dbeeee3fad96ee71fadcd.tar.xz
glibc-a68b0d31a37a86785b3dbeeee3fad96ee71fadcd.zip
update from main archive 961001
Diffstat (limited to 'sysdeps/unix')
-rw-r--r--sysdeps/unix/Makefile3
-rw-r--r--sysdeps/unix/alpha/sysdep.S7
-rw-r--r--sysdeps/unix/readdir.c6
-rw-r--r--sysdeps/unix/readdir_r.c108
-rw-r--r--sysdeps/unix/sysv/linux/gnu/types.h2
-rw-r--r--sysdeps/unix/sysv/linux/init-first.c4
-rw-r--r--sysdeps/unix/sysv/linux/syscalls.list2
7 files changed, 120 insertions, 12 deletions
diff --git a/sysdeps/unix/Makefile b/sysdeps/unix/Makefile
index d3cc46ab31..78eecd5296 100644
--- a/sysdeps/unix/Makefile
+++ b/sysdeps/unix/Makefile
@@ -302,7 +302,8 @@ ifndef no_deps
 endif
 endif
 
-$(common-objpfx)s-proto.d: $(..)sysdeps/unix/s-proto.S $(before-compile)
+$(common-objpfx)s-proto.d: $(common-objpfx)%.d: $(..)sysdeps/unix/%.S \
+			   $(before-compile)
 	$(+make-deps)
 
 endif
diff --git a/sysdeps/unix/alpha/sysdep.S b/sysdeps/unix/alpha/sysdep.S
index 8d70bda21e..08dc3b4851 100644
--- a/sysdeps/unix/alpha/sysdep.S
+++ b/sysdeps/unix/alpha/sysdep.S
@@ -27,6 +27,8 @@ errno:	.space 4
 	.type errno, @object
 	.size errno, 4
 #endif
+	.globl __errno
+__errno = errno
 
 	.text
 	.align 2
@@ -44,7 +46,10 @@ __syscall_error:
 	.mask	0x4000001, -16
 	.prologue 1
 
-	/* Find our pre-thread errno address  */
+	/* Store into the "real" variable.  */
+	stl	v0, errno
+
+	/* Find our per-thread errno address  */
 	jsr	ra, __errno_location
 
 	/* Store the error value.  */
diff --git a/sysdeps/unix/readdir.c b/sysdeps/unix/readdir.c
index 491469bcd1..97956ecd06 100644
--- a/sysdeps/unix/readdir.c
+++ b/sysdeps/unix/readdir.c
@@ -34,12 +34,6 @@ __readdir (DIR *dirp)
 {
   struct dirent *dp;
 
-  if (dirp == NULL || dirp->data == NULL)
-    {
-      __set_errno (EINVAL);
-      return NULL;
-    }
-
   __libc_lock_lock (dirp->lock);
 
   do
diff --git a/sysdeps/unix/readdir_r.c b/sysdeps/unix/readdir_r.c
new file mode 100644
index 0000000000..ef75c36234
--- /dev/null
+++ b/sysdeps/unix/readdir_r.c
@@ -0,0 +1,108 @@
+/* Copyright (C) 1991, 92, 93, 94, 95, 96 Free Software Foundation, Inc.
+This file is part of the GNU C Library.
+
+The GNU C Library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public License as
+published by the Free Software Foundation; either version 2 of the
+License, or (at your option) any later version.
+
+The GNU C Library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with the GNU C Library; see the file COPYING.LIB.  If
+not, write to the Free Software Foundation, Inc., 675 Mass Ave,
+Cambridge, MA 02139, USA.  */
+
+#include <errno.h>
+#include <limits.h>
+#include <stddef.h>
+#include <string.h>
+#include <dirent.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <assert.h>
+
+#include <dirstream.h>
+
+
+/* Read a directory entry from DIRP.  */
+int
+__readdir_r (DIR *dirp, struct dirent *entry, struct dirent **result)
+{
+  struct dirent *dp;
+
+  __libc_lock_lock (dirp->lock);
+
+  do
+    {
+      size_t reclen;
+
+      if (dirp->offset >= dirp->size)
+	{
+	  /* We've emptied out our buffer.  Refill it.  */
+
+	  size_t maxread;
+	  off_t base;
+	  ssize_t bytes;
+
+#ifndef _DIRENT_HAVE_D_RECLEN
+	  /* Fixed-size struct; must read one at a time (see below).  */
+	  maxread = sizeof *dp;
+#else
+	  maxread = dirp->allocation;
+#endif
+
+	  base = dirp->filepos;
+	  bytes = __getdirentries (dirp->fd, dirp->data, maxread, &base);
+	  if (bytes <= 0)
+	    {
+	      dp = NULL;
+	      break;
+	    }
+	  dirp->size = (size_t) bytes;
+
+	  /* Reset the offset into the buffer.  */
+	  dirp->offset = 0;
+	}
+
+      dp = (struct dirent *) &dirp->data[dirp->offset];
+
+#ifdef _DIRENT_HAVE_D_RECLEN
+      reclen = dp->d_reclen;
+#else
+      /* The only version of `struct dirent' that lacks `d_reclen'
+	 is fixed-size.  */
+      assert (sizeof dp->d_name > 1);
+      reclen = sizeof *dp;
+      /* The name is not terminated if it is the largest possible size.
+	 Clobber the following byte to ensure proper null termination.  We
+	 read just one entry at a time above so we know that byte will not
+	 be used later.  */
+      dp->d_name[sizeof dp->d_name] = '\0';
+#endif
+
+      dirp->offset += reclen;
+
+#ifdef _DIRENT_HAVE_D_OFF
+      dirp->filepos = dp->d_off;
+#else
+      dirp->filepos += reclen;
+#endif
+
+      /* Skip deleted files.  */
+    } while (dp->d_ino == 0);
+
+  if (dp != NULL)
+    {
+      *entry = *dp;
+      *result = entry;
+    }
+
+  __libc_lock_unlock (dirp->lock);
+
+  return dp != NULL ? 0 : -1;
+}
+weak_alias (__readdir_r, readdir_r)
diff --git a/sysdeps/unix/sysv/linux/gnu/types.h b/sysdeps/unix/sysv/linux/gnu/types.h
index 745d2d8e2e..5495b61aa4 100644
--- a/sysdeps/unix/sysv/linux/gnu/types.h
+++ b/sysdeps/unix/sysv/linux/gnu/types.h
@@ -71,7 +71,7 @@ typedef __kernel_clock_t __clock_t;
 typedef unsigned long __fd_mask;
 
 #ifdef	__USE_SVID
-typedef int key_t;
+typedef int __key_t;
 #endif
 
 #endif /* gnu/types.h */
diff --git a/sysdeps/unix/sysv/linux/init-first.c b/sysdeps/unix/sysv/linux/init-first.c
index 75ada19610..6e1d71204c 100644
--- a/sysdeps/unix/sysv/linux/init-first.c
+++ b/sysdeps/unix/sysv/linux/init-first.c
@@ -21,7 +21,7 @@ Cambridge, MA 02139, USA.  */
 #include <sysdep.h>
 #include <fpu_control.h>
 #include <linux/personality.h>
-#include "init-first.h"
+#include <init-first.h>
 
 extern void __libc_init (int, char **, char **);
 extern void __libc_global_ctors (void);
@@ -95,7 +95,7 @@ SYSDEP_CALL_INIT(__libc_init_first, init);
    cause ld.so to gain an init function, which is not a cool thing. */
 
 void
-_dl_start ()
+_dl_start (void)
 {
   abort ();
 }
diff --git a/sysdeps/unix/sysv/linux/syscalls.list b/sysdeps/unix/sysv/linux/syscalls.list
index f831b41072..1dd2f4d7e7 100644
--- a/sysdeps/unix/sysv/linux/syscalls.list
+++ b/sysdeps/unix/sysv/linux/syscalls.list
@@ -19,7 +19,7 @@ ioperm		-	ioperm		3	ioperm
 iopl		-	iopl		1	iopl
 ipc		msgget	ipc		5	__ipc
 klogctl		EXTRA	syslog		3	klogctl
-llseek		EXTRA	_llseek		5	llseek
+llseek		EXTRA	_llseek		5	_llseek
 mlock		EXTRA	mlock		2	__mlock	mlock
 mlockall	EXTRA	mlockall	1	__mlockall	mlockall
 mount		EXTRA	mount		5	__mount	mount