diff options
author | David Leonard <d@cvs.openbsd.org> | 2000-10-04 06:12:40 +0000 |
---|---|---|
committer | David Leonard <d@cvs.openbsd.org> | 2000-10-04 06:12:40 +0000 |
commit | c0c77480b9e0ffae543785986b90991c3def88ad (patch) | |
tree | 46c43518aa062862c0e66ab542831c143c1c9f3d /lib/libc | |
parent | ea6cf9bacbff90bcd397372ac358075e79c81996 (diff) |
use weak symbols in sparc's libc
Diffstat (limited to 'lib/libc')
-rw-r--r-- | lib/libc/arch/sparc/SYS.h | 84 |
1 files changed, 46 insertions, 38 deletions
diff --git a/lib/libc/arch/sparc/SYS.h b/lib/libc/arch/sparc/SYS.h index 0c85f6db35d..e9214278919 100644 --- a/lib/libc/arch/sparc/SYS.h +++ b/lib/libc/arch/sparc/SYS.h @@ -34,7 +34,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $OpenBSD: SYS.h,v 1.3 1999/01/06 06:12:02 d Exp $ + * $OpenBSD: SYS.h,v 1.4 2000/10/04 06:12:39 d Exp $ */ #include <machine/asm.h> @@ -42,11 +42,9 @@ #include <machine/trap.h> #ifdef __STDC__ -#define _CAT(x,y) x##y -#define __ENTRY(p,x) ENTRY(p##x) +#define __CONCAT(x,y) x##y #else -#define _CAT(x,y) x/**/y -#define __ENTRY(p,x) ENTRY(p/**/x) +#define __CONCAT(x,y) x/**/y #endif /* @@ -54,55 +52,65 @@ * change it to be position independent later, if need be. */ #ifdef PIC -#define ERROR() \ - PIC_PROLOGUE(%g1,%g2); \ - ld [%g1+cerror],%g2; jmp %g2; nop -#else -#define ERROR() \ - sethi %hi(cerror),%g1; or %lo(cerror),%g1,%g1; jmp %g1; nop +#define ERROR() \ + PIC_PROLOGUE(%g1,%g2); \ + ld [%g1+cerror],%g2; \ + jmp %g2; \ + nop +#else /* !PIC */ +#define ERROR() \ + sethi %hi(cerror),%g1; \ + or %lo(cerror),%g1,%g1; \ + jmp %g1; \ + nop #endif /* + * Syscall symbols are weakened for easy replacement by + * the user thread library. + */ +#define _THREAD_SYS(x) __CONCAT(_thread_sys_,x) +#define _THREAD_SYS_LABEL(x) __CONCAT(_C_LABEL(_thread_sys_),x) +#define SYSENTRY(x) \ + .weak _C_LABEL(x); \ + _C_LABEL(x) = _THREAD_SYS_LABEL(x); \ + .type _C_LABEL(x),@function; \ + _ENTRY(_THREAD_SYS_LABEL(x)) + +/* * SYSCALL is used when further action must be taken before returning. * Note that it adds a `nop' over what we could do, if we only knew what * came at label 1.... */ -#define __SYSCALL(p,x) \ - __ENTRY(p,x); mov _CAT(SYS_,x),%g1; t ST_SYSCALL; bcc 1f; nop; ERROR(); 1: +#define SYSCALL(x) \ + SYSENTRY(x); \ + mov __CONCAT(SYS_,x),%g1; \ + t ST_SYSCALL; \ + bcc 1f; \ + nop; \ + ERROR(); \ + 1: /* * RSYSCALL is used when the system call should just return. Here * we use the SYSCALL_G2RFLAG to put the `success' return address in %g2 * and avoid a branch. */ -#define __RSYSCALL(p,x) \ - __ENTRY(p,x); mov (_CAT(SYS_,x))|SYSCALL_G2RFLAG,%g1; add %o7,8,%g2; \ - t ST_SYSCALL; ERROR() +#define RSYSCALL(x) \ + SYSENTRY(x); \ + mov (__CONCAT(SYS_,x))|SYSCALL_G2RFLAG,%g1; \ + add %o7,8,%g2; \ + t ST_SYSCALL; \ + ERROR() /* * PSEUDO(x,y) is like RSYSCALL(y) except that the name is x. */ -#define __PSEUDO(p,x,y) \ - __ENTRY(p,x); mov (_CAT(SYS_,y))|SYSCALL_G2RFLAG,%g1; add %o7,8,%g2; \ - t ST_SYSCALL; ERROR() +#define PSEUDO(x,y) \ + SYSENTRY(x); \ + mov (__CONCAT(SYS_,y))|SYSCALL_G2RFLAG,%g1; \ + add %o7,8,%g2; \ + t ST_SYSCALL; \ + ERROR() -#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 |