Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libc/arch/sparc Prettify. Avoid code duplication.
details: https://anonhg.NetBSD.org/src/rev/5851fc4e6b14
branches: trunk
changeset: 581032:5851fc4e6b14
user: uwe <uwe%NetBSD.org@localhost>
date: Fri May 20 23:56:15 2005 +0000
description:
Prettify. Avoid code duplication.
Same object code is generated.
diffstat:
lib/libc/arch/sparc/SYS.h | 101 +++++++++++++++++++++++++--------------------
1 files changed, 57 insertions(+), 44 deletions(-)
diffs (152 lines):
diff -r e887e4ab4cb5 -r 5851fc4e6b14 lib/libc/arch/sparc/SYS.h
--- a/lib/libc/arch/sparc/SYS.h Fri May 20 20:06:34 2005 +0000
+++ b/lib/libc/arch/sparc/SYS.h Fri May 20 23:56:15 2005 +0000
@@ -33,7 +33,7 @@
* @(#)SYS.h 8.1 (Berkeley) 6/4/93
*
* from: Header: SYS.h,v 1.2 92/07/03 18:57:00 torek Exp
- * $NetBSD: SYS.h,v 1.15 2003/08/07 16:42:23 agc Exp $
+ * $NetBSD: SYS.h,v 1.16 2005/05/20 23:56:15 uwe Exp $
*/
#include <machine/asm.h>
@@ -55,83 +55,96 @@
#endif
/*
- * ERROR branches to cerror. This is done with a macro so that I can
- * change it to be position independent later, if need be.
+ * ERROR branches to cerror.
*/
#ifdef PIC
-#define CALL(name) \
- PIC_PROLOGUE(%g1,%g2); \
- ld [%g1+name],%g2; jmp %g2; nop
+#define CALL(name) \
+ PIC_PROLOGUE(%g1, %g2); \
+ ld [%g1 + name], %g2; \
+ jmp %g2; \
+ nop
#else
-#define CALL(name) \
- sethi %hi(name),%g1; or %lo(name),%g1,%g1; jmp %g1; nop
+#define CALL(name) \
+ set name, %g1; \
+ jmp %g1; \
+ nop
#endif
#define ERROR() CALL(CERROR)
/*
* 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....
+ * Note that it adds a `nop' over what we could do, if we only knew
+ * what came at label 1....
*/
-#define _SYSCALL(x,y) \
- ENTRY(x); mov _CAT(SYS_,y),%g1; t ST_SYSCALL; bcc 1f; nop; ERROR(); 1:
+#define _SYSCALL(x,y) \
+ENTRY(x); \
+ mov _CAT(SYS_,y), %g1; \
+ t ST_SYSCALL; \
+ bcc 1f; \
+ nop; \
+ ERROR(); \
+1: /* next insn */
-#define SYSCALL(x) \
+#define SYSCALL(x) \
_SYSCALL(x,x)
/*
- * RSYSCALL is used when the system call should just return. Here
- * we use the SYSCALL_G2RFLAG to put the `success' return address in %g2
+ * 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.
+ *
+ * PSEUDO(x,y) is like RSYSCALL(y), except that the name is x.
*/
-#define RSYSCALL(x) \
- ENTRY(x); mov (_CAT(SYS_,x))|SYSCALL_G2RFLAG,%g1; add %o7,8,%g2; \
- t ST_SYSCALL; ERROR()
+#define _RSYSCALL(x,y) \
+ENTRY(x); \
+ mov (_CAT(SYS_,y)) | SYSCALL_G2RFLAG, %g1; \
+ add %o7, 8, %g2; \
+ t ST_SYSCALL; \
+ ERROR()
+
+#define RSYSCALL(x) _RSYSCALL(x,x)
+#define PSEUDO(x,y) _RSYSCALL(x,y)
/*
- * PSEUDO(x,y) is like RSYSCALL(y) except that the name is x.
- */
-#define PSEUDO(x,y) \
- ENTRY(x); mov (_CAT(SYS_,y))|SYSCALL_G2RFLAG,%g1; add %o7,8,%g2; \
- t ST_SYSCALL; ERROR()
-
-/*
- * WSYSCALL(weak,strong) is like RSYSCALL(weak), except that weak is
- * a weak internal alias for the strong symbol.
+ * WSYSCALL(weak,strong) is like RSYSCALL(weak),
+ * except that weak is a weak internal alias for the strong symbol.
*/
#ifdef WEAK_ALIAS
-#define WSYSCALL(weak,strong) \
- WEAK_ALIAS(weak,strong); \
+#define WSYSCALL(weak,strong) \
+ WEAK_ALIAS(weak,strong); \
PSEUDO(strong,weak)
#else
-#define WSYSCALL(weak,strong) \
+#define WSYSCALL(weak,strong) \
RSYSCALL(weak)
#endif
/*
- * SYSCALL_NOERROR is like SYSCALL, except it's used for syscalls
- * that never fail.
+ * SYSCALL_NOERROR is like SYSCALL, except it's used for syscalls that
+ * never fail.
*
* XXX - This should be optimized.
*/
-#define SYSCALL_NOERROR(x) \
- ENTRY(x); mov _CAT(SYS_,x),%g1; t ST_SYSCALL
+#define SYSCALL_NOERROR(x) \
+ENTRY(x); \
+ mov _CAT(SYS_,x), %g1; \
+ t ST_SYSCALL
/*
- * RSYSCALL_NOERROR is like RSYSCALL, except it's used for syscalls
+ * RSYSCALL_NOERROR is like RSYSCALL, except it's used for syscalls
* that never fail.
*
+ * PSEUDO_NOERROR(x,y) is like RSYSCALL_NOERROR(y), except that the
+ * name is x.
+ *
* XXX - This should be optimized.
*/
-#define RSYSCALL_NOERROR(x) \
- ENTRY(x); mov (_CAT(SYS_,x))|SYSCALL_G2RFLAG,%g1; add %o7,8,%g2; \
- t ST_SYSCALL
+#define _RSYSCALL_NOERROR(x,y) \
+ENTRY(x); \
+ mov (_CAT(SYS_,y)) | SYSCALL_G2RFLAG, %g1; \
+ add %o7, 8, %g2; \
+ t ST_SYSCALL
-/*
- * PSEUDO_NOERROR(x,y) is like RSYSCALL_NOERROR(y) except that the name is x.
- */
-#define PSEUDO_NOERROR(x,y) \
- ENTRY(x); mov (_CAT(SYS_,y))|SYSCALL_G2RFLAG,%g1; add %o7,8,%g2; \
- t ST_SYSCALL
+#define RSYSCALL_NOERROR(x) _RSYSCALL_NOERROR(x,x)
+#define PSEUDO_NOERROR(x,y) _RSYSCALL_NOERROR(x,y)
.globl CERROR
Home |
Main Index |
Thread Index |
Old Index