about summary refs log tree commit diff
path: root/sysdeps/unix
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/unix')
-rw-r--r--sysdeps/unix/alpha/sysdep.S56
-rw-r--r--sysdeps/unix/i386/sysdep.S27
-rw-r--r--sysdeps/unix/opendir.c2
-rw-r--r--sysdeps/unix/sysv/linux/errnos.h32
-rw-r--r--sysdeps/unix/sysv/linux/gnu/types.h4
-rw-r--r--sysdeps/unix/sysv/linux/i386/sysdep.S32
-rw-r--r--sysdeps/unix/sysv/linux/i386/sysdep.h31
-rw-r--r--sysdeps/unix/sysv/linux/schedbits.h51
-rw-r--r--sysdeps/unix/sysv/linux/waitflags.h30
9 files changed, 246 insertions, 19 deletions
diff --git a/sysdeps/unix/alpha/sysdep.S b/sysdeps/unix/alpha/sysdep.S
index 336eb02029..8d70bda21e 100644
--- a/sysdeps/unix/alpha/sysdep.S
+++ b/sysdeps/unix/alpha/sysdep.S
@@ -17,8 +17,7 @@ not, write to the Free Software Foundation, Inc., 675 Mass Ave,
 Cambridge, MA 02139, USA.  */
 
 #include <sysdep.h>
-#define _ERRNO_H
-#include <errnos.h>
+#include <features.h>
 
 	.section .bss
 	.globl errno
@@ -30,15 +29,60 @@ errno:	.space 4
 #endif
 
 	.text
-LEAF(__syscall_error, 0)
+	.align 2
+
+#ifdef	_LIBC_REENTRANT
+
+	.globl __syscall_error
+	.ent __syscall_error
+__syscall_error:
 	ldgp	gp, 0(t12)
+	lda	sp, -16(sp)
+	.frame	sp, 16, ra, 0
+	stq	ra, 0(sp)
+	stq	v0, 8(sp)
+	.mask	0x4000001, -16
 	.prologue 1
 
-	/* Store return value in errno... */
-	stl	v0, errno
+	/* Find our pre-thread errno address  */
+	jsr	ra, __errno_location
+
+	/* Store the error value.  */
+	ldl	t0, 8(sp)
+	stl	t0, 0(v0)
 
-	/* And just kick back a -1.  */
+	/* And kick back a -1.  */
 	ldi	v0, -1
+
+	ldq	ra, 0(sp)
+	lda	sp, 16(sp)
 	ret
+	.end __syscall_error
+
+/* A default non-threaded version of __errno_location that just returns
+   the address of errno.  */
+
+	.weak	__errno_location
+	.ent	__errno_location
+__errno_location:
+	.frame	sp, 0, ra
+	ldgp	gp, 0(t12)
+	.mask	0, 0
+	.prologue 1
 
+	lda	v0, errno
+	ret
+	.end __errno_location
+
+#else
+
+ENTRY(__syscall_error)
+	ldgp	gp, 0(t12)
+	.prologue 1
+
+	stl	v0, errno
+	lda	v0, -1
+	ret
 	END(__syscall_error)
+
+#endif /* _LIBC_REENTRANT */
diff --git a/sysdeps/unix/i386/sysdep.S b/sysdeps/unix/i386/sysdep.S
index 95e2fd5c7a..7dced7cda5 100644
--- a/sysdeps/unix/i386/sysdep.S
+++ b/sysdeps/unix/i386/sysdep.S
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
+/* 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
@@ -36,17 +36,40 @@ syscall_error:
 	cmpl $EWOULDBLOCK_sys, %eax /* Is it the old EWOULDBLOCK?  */
 	jne notb		/* Branch if not.  */
 	movl $EAGAIN, %eax	/* Yes; translate it to EAGAIN.  */
-#endif
 notb:
+#endif
 #ifndef	PIC
 	movl %eax, C_SYMBOL_NAME(errno)
+#ifdef	_LIBC_REENTRANT
+	pushl %eax
+	call __errno_location
+	popl %ecx
+	movl %ecx, (%eax)
+#endif
 #else
 	/* The caller has pushed %ebx and then set it up to
 	   point to the GOT before calling us through the PLT.  */
 	movl C_SYMBOL_NAME(errno@GOT)(%ebx), %ecx
+
+#ifndef	_LIBC_REENTRANT
 	/* Pop %ebx value saved before jumping here.  */
 	popl %ebx
 	movl %eax, (%ecx)
+#else
+	movl %eax, (%ecx)
+	pushl %eax
+	call C_SYMBOL_NAME(__errno_location@PLT)
+	popl %ecx
+	/* Pop %ebx value saved before jumping here.  */
+	popl %ebx
+	movl %ecx, (%eax)
+#endif
 #endif
 	movl $-1, %eax
 	ret
+
+#ifdef	__ELF__
+#undef	__syscall_error
+.Lfe2:
+	.size	__syscall_error, .Lfe2-__syscall_error
+#endif
diff --git a/sysdeps/unix/opendir.c b/sysdeps/unix/opendir.c
index 890d428086..7161cec6e9 100644
--- a/sysdeps/unix/opendir.c
+++ b/sysdeps/unix/opendir.c
@@ -91,7 +91,7 @@ __opendir (const char *name)
 
   dirp->fd = fd;
 
-  __libc_lock_init (dirp->lock);
+  __libc_lock_init (dirp->lock)
 
   return dirp;
 }
diff --git a/sysdeps/unix/sysv/linux/errnos.h b/sysdeps/unix/sysv/linux/errnos.h
index be1e4d3feb..868819e6b3 100644
--- a/sysdeps/unix/sysv/linux/errnos.h
+++ b/sysdeps/unix/sysv/linux/errnos.h
@@ -1 +1,33 @@
+/* errnos.h - error constants.  Linux specific version.
+Copyright (C) 1996 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., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.  */
+
 #include <linux/errno.h>
+
+#ifndef __ASSEMBLER__
+#if defined __USE_REENTRANT && (!defined _LIBC || defined _LIBC_REENTRANT)
+/* Declare alias of `errno' variable so it is accessible even if macro
+   with name `errno' is defined.  */
+extern int __errno;
+
+/* When using threads, errno is a per-thread value.  */
+extern int *__errno_location __P ((void)) __attribute__ ((__const__));
+#define errno	(*__errno_location ())
+
+#endif
+#endif
diff --git a/sysdeps/unix/sysv/linux/gnu/types.h b/sysdeps/unix/sysv/linux/gnu/types.h
index abfcb6e9c9..745d2d8e2e 100644
--- a/sysdeps/unix/sysv/linux/gnu/types.h
+++ b/sysdeps/unix/sysv/linux/gnu/types.h
@@ -70,4 +70,8 @@ typedef __kernel_clock_t __clock_t;
    XPG4 seems to require `unsigned long'.  */
 typedef unsigned long __fd_mask;
 
+#ifdef	__USE_SVID
+typedef int key_t;
+#endif
+
 #endif /* gnu/types.h */
diff --git a/sysdeps/unix/sysv/linux/i386/sysdep.S b/sysdeps/unix/sysv/linux/i386/sysdep.S
index 0130ad02a9..7d5444d6a6 100644
--- a/sysdeps/unix/sysv/linux/i386/sysdep.S
+++ b/sysdeps/unix/sysv/linux/i386/sysdep.S
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995 Free Software Foundation, Inc.
+/* Copyright (C) 1995, 1996 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
@@ -27,26 +27,46 @@ Cambridge, MA 02139, USA.  */
 	.globl errno
 	.type errno,@object
 	.size errno,4
-errno:	.space 4
+errno:	.zero 4
 	.globl _errno
 	.type _errno,@object
 _errno = errno	/* This name is expected by hj libc.so.5 startup code.  */
 	.text
 
-/* The following code is not used at all in the shared library.
-   The PIC system call stubs set errno themselves.  */
+/* The following code is only used in the shared library when we
+   compile the reentrant version.  Otherwise each system call defines
+   each own version.  */
 
-#ifndef	PIC
+#ifndef PIC
 
 /* The syscall stubs jump here when they detect an error.
    The code for Linux is almost identical to the canonical Unix/i386
    code, except that the error number in %eax is negated.  */
 
-.globl __syscall_error
+	.globl	__syscall_error
+	.type	__syscall_error,@function
 __syscall_error:
 	negl %eax
 
 #define __syscall_error __syscall_error_1
 #include <sysdeps/unix/i386/sysdep.S>
 
+#endif	/* !PIC */
+
+
+#ifdef	_LIBC_REENTRANT
+	.globl	__errno_location
+	.type	__errno_location,@function
+__errno_location:
+#ifdef PIC
+	call .L2
+.L2:	popl %ecx
+	addl $_GLOBAL_OFFSET_TABLE_+[.-.L2], %ecx
+	movl errno@GOT(%ecx), %eax
+#else
+	movl $errno, %eax
+#endif
+	ret
+.Lfe1:
+	.size	__errno_location, .Lfe1-__errno_location
 #endif
diff --git a/sysdeps/unix/sysv/linux/i386/sysdep.h b/sysdeps/unix/sysv/linux/i386/sysdep.h
index c77bbbbf86..96470a19b9 100644
--- a/sysdeps/unix/sysv/linux/i386/sysdep.h
+++ b/sysdeps/unix/sysv/linux/i386/sysdep.h
@@ -45,21 +45,44 @@ Cambridge, MA 02139, USA.  */
     testl %eax, %eax;							      \
     jl syscall_error;
 
-#ifndef	PIC
+#ifndef PIC
 #define SYSCALL_ERROR_HANDLER	/* Nothing here; code in sysdep.S is used.  */
 #else
 /* Store (- %eax) into errno through the GOT.  */
+#ifdef _LIBC_REENTRANT
 #define SYSCALL_ERROR_HANDLER						      \
+  .type syscall_error,@function;					      \
+syscall_error:								      \
+  pushl %ebx;								      \
+  call 0f;								      \
+0:popl %ebx;								      \
+  xorl %edx, %edx;							      \
+  addl $_GLOBAL_OFFSET_TABLE_+[.-0b], %ebx;				      \
+  subl %eax, %edx;							      \
+  movl errno@GOT(%ebx), %ecx;						      \
+  movl %edx, (%ecx);							      \
+  pushl %edx;								      \
+  call __errno_location@PLT;						      \
+  popl %ecx;								      \
+  popl %ebx;								      \
+  movl %ecx, (%eax);							      \
+  movl $-1, %eax;							      \
+  ret;
+#else
+#define SYSCALL_ERROR_HANDLER						      \
+  .type syscall_error,@function;					      \
 syscall_error:								      \
   call 0f;								      \
 0:popl %ecx;								      \
-  negl %eax;								      \
+  xorl %edx, %edx;							      \
   addl $_GLOBAL_OFFSET_TABLE_+[.-0b], %ecx;				      \
+  subl %eax, %edx;							      \
   movl errno@GOT(%ecx), %ecx;						      \
-  movl %eax, (%ecx);							      \
+  movl %edx, (%ecx);							      \
   movl $-1, %eax;							      \
   ret;
-#endif
+#endif	/* _LIBC_REENTRANT */
+#endif	/* PIC */
 
 /* Linux takes system call arguments in registers:
 
diff --git a/sysdeps/unix/sysv/linux/schedbits.h b/sysdeps/unix/sysv/linux/schedbits.h
new file mode 100644
index 0000000000..ac27b9e2d2
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/schedbits.h
@@ -0,0 +1,51 @@
+/* Definitions of constants and data structure for POSIX 1003.1b-1993
+   scheduling interface.
+Copyright (C) 1996 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., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.  */
+
+#ifndef	_SCHEDBITS_H
+#define	_SCHEDBITS_H	1
+
+/* Scheduling algorithms.  */
+#define SCHED_OTHER	0
+#define SCHED_FIFO	1
+#define SCHED_RR	2
+
+/* Data structure to describe a process' schedulability.  */
+struct sched_params
+{
+  int sched_priority;
+};
+
+/* Cloning flags.  */
+#define	CSIGNAL	      0x000000ff  /* Signal mask to be sent at exit.  */
+#define	CLONE_VM      0x00000100  /* Set if VM shared between processes.  */
+#define	CLONE_FS      0x00000200  /* Set if fs info shared between processes.*/
+#define CLONE_FILES   0x00000400  /* Set if open files shared between processes*/
+#define CLONE_SIGHAND 0x00000800  /* Set if signal handlers shared.  */
+#define CLONE_PID     0x00001000  /* Set if pid shared.  */
+
+
+/* Clone current process.  The parameter list of FN is not for true.  Only
+   dots is not allowed by ISO C and without argument the compiler would
+   complain about a missing parameter list.  */
+extern int clone __P ((int (*__fn) (void *, ...), void *__child_stack,
+		       int __flags, int __nargs, ...));
+
+
+#endif /* schedbits.h */
diff --git a/sysdeps/unix/sysv/linux/waitflags.h b/sysdeps/unix/sysv/linux/waitflags.h
new file mode 100644
index 0000000000..0be2825159
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/waitflags.h
@@ -0,0 +1,30 @@
+/* Definitions of flag bits for `waitpid' et al.
+Copyright (C) 1992, 1996 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.  */
+
+#ifndef	_WAITFLAGS_H
+
+#define	_WAITFLAGS_H	1
+
+/* Bits in the third argument to `waitpid'.  */
+#define	WNOHANG		1	/* Don't block waiting.  */
+#define	WUNTRACED	2	/* Report status of stopped children.  */
+
+#define __WCLONE	0x80000000 /* Wait for cloned process.  */
+
+#endif	/* waitflags.h */