summaryrefslogtreecommitdiff
path: root/lib/libc/arch
diff options
context:
space:
mode:
authorDavid Leonard <d@cvs.openbsd.org>1998-11-20 11:19:02 +0000
committerDavid Leonard <d@cvs.openbsd.org>1998-11-20 11:19:02 +0000
commitf547068f88348f54941dc06da46491f99701933e (patch)
tree8548a6b78719cba1de575b7f49e5f8ac4e6f1683 /lib/libc/arch
parent394c7a9821726b84f284c0c4385b1a9198afa0b0 (diff)
Add thread-safety to libc, so that libc_r will build (on i386 at least).
All POSIX libc api now there (to P1003.1c/D10) (more md stuff is needed for other libc/arch/*) (setlogin is no longer a special syscall) Add -pthread option to gcc (that makes it use -lc_r and -D_POSIX_THREADS). Doc some re-entrant routines Add libc_r to intro(3) dig() uses some libc srcs and an extra -I was needed there. Add more md stuff to libc_r. Update includes for the pthreads api Update libc_r TODO
Diffstat (limited to 'lib/libc/arch')
-rw-r--r--lib/libc/arch/i386/SYS.h74
-rw-r--r--lib/libc/arch/i386/sys/Ovfork.S4
-rw-r--r--lib/libc/arch/i386/sys/setlogin.S55
-rw-r--r--lib/libc/arch/i386/sys/sigprocmask.S4
-rw-r--r--lib/libc/arch/i386/sys/sigsuspend.S4
-rw-r--r--lib/libc/arch/i386/sys/syscall.S4
6 files changed, 73 insertions, 72 deletions
diff --git a/lib/libc/arch/i386/SYS.h b/lib/libc/arch/i386/SYS.h
index 1cf818fd304..e02d5cf985f 100644
--- a/lib/libc/arch/i386/SYS.h
+++ b/lib/libc/arch/i386/SYS.h
@@ -33,24 +33,80 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $OpenBSD: SYS.h,v 1.3 1996/08/19 08:12:12 tholo Exp $
+ * $OpenBSD: SYS.h,v 1.4 1998/11/20 11:18:29 d Exp $
*/
#include <machine/asm.h>
#include <sys/syscall.h>
#ifdef __STDC__
+# define __ENTRY(p,x) ENTRY(p##x)
+# define __DO_SYSCALL(x) \
+ movl $(SYS_##x),%eax; \
+ int $0x80
+# define __LABEL2(p,x) _C_LABEL(p##x)
+#else
+# define __ENTRY(p,x) ENTRY(p/**/x)
+# define __DO_SYSCALL(x) \
+ movl $(SYS_/**/x),%eax; \
+ int $0x80
+# define __LABEL2(p,x) _C_LABEL(p/**/x)
+#endif
-#define SYSCALL(x) .text; .align 2; 2: jmp PIC_PLT(cerror); ENTRY(x); movl $(SYS_ ## x),%eax; int $0x80; jc 2b
-#define RSYSCALL(x) SYSCALL(x); ret
-#define PSEUDO(x,y) ENTRY(x); movl $(SYS_ ## y),%eax; int $0x80; ret
+/* perform a syscall, set errno */
+#define __SYSCALL(p,x) \
+ .text; \
+ .align 2; \
+ 2: \
+ jmp PIC_PLT(cerror); \
+ __ENTRY(p,x); \
+ __DO_SYSCALL(x); \
+ jc 2b
-#else /* !__STDC__ */
+/* perform a syscall, set errno, return */
+# define __RSYSCALL(p,x) __SYSCALL(p,x); ret
-#define SYSCALL(x) .text; .align 2; 2: jmp PIC_PLT(cerror); ENTRY(x); movl $(SYS_/**/x),%eax; int $0x80; jc 2b
-#define RSYSCALL(x) SYSCALL(x); ret
-#define PSEUDO(x,y) ENTRY(x); movl $(SYS_/**/y),%eax; int $0x80; ret
+/* perform a syscall, return */
+# define __PSEUDO(p,x,y) \
+ __ENTRY(p,x); \
+ __DO_SYSCALL(y); \
+ ret
-#endif
+/* jump to the real syscall */
+/* XXX shouldn't be here */
+# define __PASSTHRU(p,x) \
+ .globl __LABEL2(p,x); \
+ ENTRY(x); \
+ jmp PIC_PLT(__LABEL2(p,x))
+/*
+ * Design note:
+ *
+ * When the syscalls need to be renamed so they can be handled
+ * specially by the threaded library, these macros insert `_thread_sys_'
+ * in front of their name. This avoids the need to #ifdef _THREAD_SAFE
+ * everywhere that the renamed function needs to be called.
+ * The PASSTHRU macro is later used for system calls that don't need
+ * wrapping. (XXX its a shame the loader can't do this aliasing)
+ */
+#ifdef _THREAD_SAFE
+/*
+ * For the thread_safe versions, we prepend _thread_sys_ to the function
+ * name so that the 'C' wrapper can go around the real name.
+ */
+# define SYSCALL(x) __SYSCALL(_thread_sys_,x)
+# define RSYSCALL(x) __RSYSCALL(_thread_sys_,x)
+# define PSEUDO(x,y) __PSEUDO(_thread_sys_,x,y)
+# define SYSENTRY(x) __ENTRY(_thread_sys_,x)
+# define PASSTHRU(x) __PASSTHRU(_thread_sys_,x)
+#else _THREAD_SAFE
+/*
+ * The non-threaded library defaults to traditional syscalls where
+ * the function name matches the syscall name.
+ */
+# define SYSCALL(x) __SYSCALL(,x)
+# define RSYSCALL(x) __RSYSCALL(,x)
+# define PSEUDO(x,y) __PSEUDO(,x,y)
+# define SYSENTRY(x) __ENTRY(,x)
+#endif _THREAD_SAFE
.globl cerror
diff --git a/lib/libc/arch/i386/sys/Ovfork.S b/lib/libc/arch/i386/sys/Ovfork.S
index 97430e6ae5f..264e09e302f 100644
--- a/lib/libc/arch/i386/sys/Ovfork.S
+++ b/lib/libc/arch/i386/sys/Ovfork.S
@@ -38,7 +38,7 @@
#if defined(SYSLIBC_SCCS)
.text
- .asciz "$OpenBSD: Ovfork.S,v 1.2 1996/08/19 08:13:26 tholo Exp $"
+ .asciz "$OpenBSD: Ovfork.S,v 1.3 1998/11/20 11:18:29 d Exp $"
#endif /* SYSLIB_SCCS */
/*
@@ -48,7 +48,7 @@
* %eax == pid of child in parent, %eax == pid of parent in child.
*
*/
-ENTRY(vfork)
+SYSENTRY(vfork)
popl %ecx /* my rta into ecx */
movl $(SYS_vfork),%eax
int $0x80
diff --git a/lib/libc/arch/i386/sys/setlogin.S b/lib/libc/arch/i386/sys/setlogin.S
deleted file mode 100644
index acd1144725d..00000000000
--- a/lib/libc/arch/i386/sys/setlogin.S
+++ /dev/null
@@ -1,55 +0,0 @@
-/*-
- * Copyright (c) 1991 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * William Jolitz.
- *
- * 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.
- */
-
-#include "SYS.h"
-
-#if defined(SYSLIBC_SCCS)
- .text
- .asciz "$OpenBSD: setlogin.S,v 1.2 1996/08/19 08:13:39 tholo Exp $"
-#endif /* SYSLIB_SCCS */
-
- .globl ___logname_valid /* in getlogin() */
-SYSCALL(setlogin)
- xorl %eax,%eax
-#ifdef PIC
- PIC_PROLOGUE
- movl PIC_GOT(___logname_valid),%edx
- PIC_EPILOGUE
- movl %eax,(%edx)
-#else
- movl %eax,___logname_valid
-#endif
- ret /* setlogin(name) */
diff --git a/lib/libc/arch/i386/sys/sigprocmask.S b/lib/libc/arch/i386/sys/sigprocmask.S
index 17853ed793d..ee3d19b7d87 100644
--- a/lib/libc/arch/i386/sys/sigprocmask.S
+++ b/lib/libc/arch/i386/sys/sigprocmask.S
@@ -38,10 +38,10 @@
#if defined(SYSLIBC_SCCS)
.text
- .asciz "$OpenBSD: sigprocmask.S,v 1.3 1997/07/23 20:55:23 kstailey Exp $"
+ .asciz "$OpenBSD: sigprocmask.S,v 1.4 1998/11/20 11:18:30 d Exp $"
#endif /* SYSLIBC_SCCS */
-ENTRY(sigprocmask)
+SYSENTRY(sigprocmask)
movl 8(%esp),%ecx # fetch new sigset pointer
testl %ecx,%ecx # check new sigset pointer
jnz 1f # if not null, indirect
diff --git a/lib/libc/arch/i386/sys/sigsuspend.S b/lib/libc/arch/i386/sys/sigsuspend.S
index c0254cfebbf..f0c84ce734c 100644
--- a/lib/libc/arch/i386/sys/sigsuspend.S
+++ b/lib/libc/arch/i386/sys/sigsuspend.S
@@ -38,10 +38,10 @@
#if defined(SYSLIBC_SCCS)
.text
- .asciz "$OpenBSD: sigsuspend.S,v 1.2 1996/08/19 08:13:44 tholo Exp $"
+ .asciz "$OpenBSD: sigsuspend.S,v 1.3 1998/11/20 11:18:30 d Exp $"
#endif /* SYSLIBC_SCCS */
-ENTRY(sigsuspend)
+SYSENTRY(sigsuspend)
movl 4(%esp),%eax # fetch mask arg
movl (%eax),%eax # indirect to mask arg
movl %eax,4(%esp)
diff --git a/lib/libc/arch/i386/sys/syscall.S b/lib/libc/arch/i386/sys/syscall.S
index 4a6db63c799..6ecd61cd4ed 100644
--- a/lib/libc/arch/i386/sys/syscall.S
+++ b/lib/libc/arch/i386/sys/syscall.S
@@ -38,10 +38,10 @@
#if defined(SYSLIBC_SCCS)
.text
- .asciz "$OpenBSD: syscall.S,v 1.2 1996/08/19 08:13:46 tholo Exp $"
+ .asciz "$OpenBSD: syscall.S,v 1.3 1998/11/20 11:18:30 d Exp $"
#endif /* SYSLIBC_SCCS */
-ENTRY(syscall)
+SYSENTRY(syscall)
pop %ecx /* rta */
pop %eax /* syscall number */
push %ecx