summaryrefslogtreecommitdiff
path: root/lib/libc/arch/i386/SYS.h
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/i386/SYS.h
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/i386/SYS.h')
-rw-r--r--lib/libc/arch/i386/SYS.h74
1 files changed, 65 insertions, 9 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