diff options
author | David Leonard <d@cvs.openbsd.org> | 2000-01-06 08:50:36 +0000 |
---|---|---|
committer | David Leonard <d@cvs.openbsd.org> | 2000-01-06 08:50:36 +0000 |
commit | 7de3fd6d6616429f19f0a3d79537f100ba4439a3 (patch) | |
tree | f1df12fbdb970420a01ecab411b885815e0d55fe /lib/libc/arch/i386 | |
parent | 407801c8a4b2c59bea54ff5d9acb04153b8ac17a (diff) |
use weak symbols
Diffstat (limited to 'lib/libc/arch/i386')
-rw-r--r-- | lib/libc/arch/i386/SYS.h | 94 |
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 |