summaryrefslogtreecommitdiff
path: root/lib/libc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/arch/sparc/SYS.h84
1 files changed, 38 insertions, 46 deletions
diff --git a/lib/libc/arch/sparc/SYS.h b/lib/libc/arch/sparc/SYS.h
index e9214278919..c7a67cfeb5b 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.4 2000/10/04 06:12:39 d Exp $
+ * $OpenBSD: SYS.h,v 1.5 2000/10/11 01:49:43 d Exp $
*/
#include <machine/asm.h>
@@ -42,9 +42,11 @@
#include <machine/trap.h>
#ifdef __STDC__
-#define __CONCAT(x,y) x##y
+#define _CAT(x,y) x##y
+#define __ENTRY(p,x) ENTRY(p##x)
#else
-#define __CONCAT(x,y) x/**/y
+#define _CAT(x,y) x/**/y
+#define __ENTRY(p,x) ENTRY(p/**/x)
#endif
/*
@@ -52,65 +54,55 @@
* 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 /* !PIC */
-#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
+#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(x) \
- SYSENTRY(x); \
- mov __CONCAT(SYS_,x),%g1; \
- t ST_SYSCALL; \
- bcc 1f; \
- nop; \
- ERROR(); \
- 1:
+#define __SYSCALL(p,x) \
+ __ENTRY(p,x); mov _CAT(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(x) \
- SYSENTRY(x); \
- mov (__CONCAT(SYS_,x))|SYSCALL_G2RFLAG,%g1; \
- add %o7,8,%g2; \
- t ST_SYSCALL; \
- ERROR()
+#define __RSYSCALL(p,x) \
+ __ENTRY(p,x); mov (_CAT(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(x,y) \
- SYSENTRY(x); \
- mov (__CONCAT(SYS_,y))|SYSCALL_G2RFLAG,%g1; \
- add %o7,8,%g2; \
- t ST_SYSCALL; \
- ERROR()
+#define __PSEUDO(p,x,y) \
+ __ENTRY(p,x); mov (_CAT(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