summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/arch/i386/SYS.h94
1 files changed, 49 insertions, 45 deletions
diff --git a/lib/libc/arch/i386/SYS.h b/lib/libc/arch/i386/SYS.h
index 17a43ecf593..7e117eca688 100644
--- a/lib/libc/arch/i386/SYS.h
+++ b/lib/libc/arch/i386/SYS.h
@@ -33,70 +33,74 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $OpenBSD: SYS.h,v 1.5 1999/01/06 05:36:17 d Exp $
+ * $OpenBSD: SYS.h,v 1.6 2000/01/06 08:50:35 d Exp $
*/
#include <machine/asm.h>
#include <sys/syscall.h>
+/*
+ * Design note:
+ *
+ * System calls entry points are really named _thread_sys_{syscall},
+ * and weakly aliased to the name {syscall}. This allows the thread
+ * library to replace system calls at link time.
+ */
+
+#ifdef _NO_WEAK_ALIASES
+
+#ifdef _THREAD_SAFE
+/* Use _thread_sys_{syscall} when compiled with -D_THREAD_SAFE */
+#ifdef __STDC__
+#define SYSENTRY(x) ENTRY(_thread_sys_ ## x)
+#else /* ! __STDC__ */
+#define SYSENTRY(x) ENTRY(_thread_sys_ /**/ x)
+#endif /* ! __STDC__ */
+#else /* ! _THREAD_SAFE */
+/* Use {syscall} when compiling without -D_THREAD_SAFE */
+#define SYSENTRY(x) ENTRY(x)
+#endif /* ! _THREAD_SAFE */
+
+#else /* WEAK_ALIASES */
+
+/* Use both _thread_sys_{syscall} and [weak] {syscall}. */
+
#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 SYSENTRY(x) \
+ ENTRY(_thread_sys_ ## x) \
+ .weak _C_LABEL(x); \
+ _C_LABEL(x) = _C_LABEL(_thread_sys_ ## x)
+#else /* ! __STDC__ */
+#define SYSENTRY(x) \
+ ENTRY(_thread_sys_/**/x) \
+ .weak _C_LABEL(x); \
+ _C_LABEL(x) = _C_LABEL(_thread_sys_/**/x)
+#endif /* ! __STDC__ */
+#endif /* WEAK_ALIASES */
+
+#define __DO_SYSCALL(x) \
+ movl $(__CONCAT(SYS_,x)),%eax; \
+ int $0x80
/* perform a syscall, set errno */
-#define __SYSCALL(p,x) \
+#define SYSCALL(x) \
.text; \
.align 2; \
2: \
jmp PIC_PLT(cerror); \
- __ENTRY(p,x); \
+ SYSENTRY(x); \
__DO_SYSCALL(x); \
jc 2b
/* perform a syscall, set errno, return */
-# define __RSYSCALL(p,x) __SYSCALL(p,x); ret
+#define RSYSCALL(x) \
+ SYSCALL(x); \
+ ret
/* perform a syscall, return */
-# define __PSEUDO(p,x,y) \
- __ENTRY(p,x); \
+#define PSEUDO(x,y) \
+ SYSENTRY(x); \
__DO_SYSCALL(y); \
ret
-/*
- * 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.
- */
-#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)
-#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