Module Name:    src
Committed By:   matt
Date:           Sun Aug 16 03:30:55 UTC 2009

Modified Files:
        src/lib/libpthread/arch/mips [matt-nb5-mips64]: SYS.h _context_u.S
            genassym.cf

Log Message:
Make ABI agonstic (first pass).


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.3.48.1 src/lib/libpthread/arch/mips/SYS.h
cvs rdiff -u -r1.3 -r1.3.14.1 src/lib/libpthread/arch/mips/_context_u.S
cvs rdiff -u -r1.7 -r1.7.14.1 src/lib/libpthread/arch/mips/genassym.cf

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libpthread/arch/mips/SYS.h
diff -u src/lib/libpthread/arch/mips/SYS.h:1.3 src/lib/libpthread/arch/mips/SYS.h:1.3.48.1
--- src/lib/libpthread/arch/mips/SYS.h:1.3	Thu Aug  7 16:44:53 2003
+++ src/lib/libpthread/arch/mips/SYS.h	Sun Aug 16 03:30:55 2009
@@ -1,127 +1,6 @@
-/*	$NetBSD: SYS.h,v 1.3 2003/08/07 16:44:53 agc Exp $ */
-
-/*-
- * Copyright (c) 1996 Jonathan Stone
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *      This product includes software developed by Jonathan Stone for
- *      the NetBSD Project.
- * 4. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*-
- * Copyright (c) 1991, 1993
- *	The Regents of the University of California.  All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Ralph Campbell.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *	from: @(#)SYS.h	8.1 (Berkeley) 6/4/93
- */
-
-#include <sys/syscall.h>
-#include <mips/asm.h>
-
+/*	$NetBSD: SYS.h,v 1.3.48.1 2009/08/16 03:30:55 matt Exp $ */
 
 /*
- * If compiling for shared libs, Emit sysV ABI PIC segment pseudo-ops.
- *
- * i)  Emit .abicalls before .LEAF entrypoint, and .cpload/.cprestore after.
- * ii) Do interprocedure jumps indirectly via t9, with the side-effect of
- *     preserving the callee's entry address in t9.
+ * We could duplicate libc's SYS.h here but it's easier just to include it.
  */
-#ifdef __ABICALLS__
-	.abicalls
-# define PIC_PROLOGUE(x,sr)	.set noreorder; .cpload sr; .set reorder
-#else
-# define PIC_PROLOGUE(x,sr)
-#endif
-#define PIC_CALL(l,sr)		  \
-	la sr, _C_LABEL(l)	; \
-	jalr sr			; \
-
-#ifdef __STDC__
-# define SYSTRAP(x)	li v0,SYS_ ## x; syscall;
-#else
-# define SYSTRAP(x)	li v0,SYS_/**/x; syscall;
-#endif
-
-
-/*
- * Do a syscall that cannot fail (sync, get{p,u,g,eu,eg)id)
- */
-#define RSYSCALL_NOERROR(x)						\
-	PSEUDO_NOERROR(x,x)
-
-/*
- * Do a normal syscall.
- */
-#define RSYSCALL(x)							\
-	PSEUDO(x,x)
-
-
-/*
- * Do a renamed or pseudo syscall (e.g., _exit()), where the entrypoint
- * and syscall name are not the same.
- */
-#define PSEUDO_NOERROR(x,y)						\
-LEAF(x);								\
-	SYSTRAP(y);							\
-	j ra;								\
-	END(x)
-
-#define PSEUDO(x,y)							\
-LEAF(x);								\
-	PIC_PROLOGUE(x,t9);						\
-	SYSTRAP(y);							\
-	bne a3,zero,err;						\
-	j ra;								\
-err:									\
-	PIC_CALL(__cerror,t9);						\
-	END(x)
+#include "../../../libc/arch/mips/SYS.h"

Index: src/lib/libpthread/arch/mips/_context_u.S
diff -u src/lib/libpthread/arch/mips/_context_u.S:1.3 src/lib/libpthread/arch/mips/_context_u.S:1.3.14.1
--- src/lib/libpthread/arch/mips/_context_u.S:1.3	Mon Apr 28 20:23:02 2008
+++ src/lib/libpthread/arch/mips/_context_u.S	Sun Aug 16 03:30:55 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: _context_u.S,v 1.3 2008/04/28 20:23:02 martin Exp $	*/
+/*	$NetBSD: _context_u.S,v 1.3.14.1 2009/08/16 03:30:55 matt Exp $	*/
 
 /*
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -49,45 +49,45 @@
 /* Macro to Save the callee-save register set */
 #define GETC(reg)					; \
 	REG_PROLOGUE					; \
-	REG_S	s0, (UC_REGS + _REG_S0 * SZREG)(reg)	; \
-	REG_S	s1, (UC_REGS + _REG_S1 * SZREG)(reg)	; \
-	REG_S	s2, (UC_REGS + _REG_S2 * SZREG)(reg)	; \
-	REG_S	s3, (UC_REGS + _REG_S3 * SZREG)(reg)	; \
-	REG_S	s4, (UC_REGS + _REG_S4 * SZREG)(reg)	; \
-	REG_S	s5, (UC_REGS + _REG_S5 * SZREG)(reg)	; \
-	REG_S	s6, (UC_REGS + _REG_S6 * SZREG)(reg)	; \
-	REG_S	s7, (UC_REGS + _REG_S7 * SZREG)(reg)	; \
-	REG_S	gp, (UC_REGS + _REG_GP * SZREG)(reg)	; \
-	REG_S	sp, (UC_REGS + _REG_SP * SZREG)(reg)	; \
-	REG_S	s8, (UC_REGS + _REG_S8 * SZREG)(reg)	; \
-	REG_S	ra, (UC_REGS + _REG_RA * SZREG)(reg)	; \
-	REG_S	ra, (UC_REGS + _REG_EPC* SZREG)(reg)	; \
+	REG_S	s0, _OFFSETOF_UC_GREGS_S0(reg)		; \
+	REG_S	s1, _OFFSETOF_UC_GREGS_S1(reg)		; \
+	REG_S	s2, _OFFSETOF_UC_GREGS_S2(reg)		; \
+	REG_S	s3, _OFFSETOF_UC_GREGS_S3(reg)		; \
+	REG_S	s4, _OFFSETOF_UC_GREGS_S4(reg)		; \
+	REG_S	s5, _OFFSETOF_UC_GREGS_S5(reg)		; \
+	REG_S	s6, _OFFSETOF_UC_GREGS_S6(reg)		; \
+	REG_S	s7, _OFFSETOF_UC_GREGS_S7(reg)		; \
+	REG_S	gp, _OFFSETOF_UC_GREGS_GP(reg)		; \
+	REG_S	sp, _OFFSETOF_UC_GREGS_SP(reg)		; \
+	REG_S	s8, _OFFSETOF_UC_GREGS_S8(reg)		; \
+	REG_S	ra, _OFFSETOF_UC_GREGS_RA(reg)		; \
+	REG_S	ra, _OFFSETOF_UC_GREGS_EPC(reg)		; \
 	REG_EPILOGUE					; \
 	li	t0, 1					; \
 	sll	t0, t0, _UC_USER_BIT			; \
 	ori	t0, t0, _UC_CPU				; \
-	sw	t0, (UC_FLAGS)(reg)
+	INT_S	t0, UC_FLAGS(reg)
 
 #define SETC(reg)					; \
-	lw	t0, (UC_FLAGS)(reg)			; \
+	INT_L	t0, UC_FLAGS(reg)			; \
 	li	t1, 1					; \
 	sll	t1, t1, _UC_USER_BIT			; \
 	and	t0, t1, t0				; \
 	beq	t0, zero, 1f				; \
 	REG_PROLOGUE					; \
-	REG_L	s0, (UC_REGS + _REG_S0 * SZREG)(reg)	; \
-	REG_L	s1, (UC_REGS + _REG_S1 * SZREG)(reg)	; \
-	REG_L	s2, (UC_REGS + _REG_S2 * SZREG)(reg)	; \
-	REG_L	s3, (UC_REGS + _REG_S3 * SZREG)(reg)	; \
-	REG_L	s4, (UC_REGS + _REG_S4 * SZREG)(reg)	; \
-	REG_L	s5, (UC_REGS + _REG_S5 * SZREG)(reg)	; \
-	REG_L	s6, (UC_REGS + _REG_S6 * SZREG)(reg)	; \
-	REG_L	s7, (UC_REGS + _REG_S7 * SZREG)(reg)	; \
-	REG_L	s8, (UC_REGS + _REG_S8 * SZREG)(reg)	; \
-	REG_L	t9, (UC_REGS + _REG_EPC * SZREG)(reg)	; \
-	REG_L	gp, (UC_REGS + _REG_GP * SZREG)(reg)	; \
-	REG_L	sp, (UC_REGS + _REG_SP * SZREG)(reg)	; \
-	REG_L	ra, (UC_REGS + _REG_RA * SZREG)(reg)	; \
+	REG_L	s0, _OFFSETOF_UC_GREGS_S0(reg)		; \
+	REG_L	s1, _OFFSETOF_UC_GREGS_S1(reg)		; \
+	REG_L	s2, _OFFSETOF_UC_GREGS_S2(reg)		; \
+	REG_L	s3, _OFFSETOF_UC_GREGS_S3(reg)		; \
+	REG_L	s4, _OFFSETOF_UC_GREGS_S4(reg)		; \
+	REG_L	s5, _OFFSETOF_UC_GREGS_S5(reg)		; \
+	REG_L	s6, _OFFSETOF_UC_GREGS_S6(reg)		; \
+	REG_L	s7, _OFFSETOF_UC_GREGS_S7(reg)		; \
+	REG_L	t9, _OFFSETOF_UC_GREGS_EPC(reg)		; \
+	REG_L	gp, _OFFSETOF_UC_GREGS_GP(reg)		; \
+	REG_L	sp, _OFFSETOF_UC_GREGS_SP(reg)		; \
+	REG_L	s8, _OFFSETOF_UC_GREGS_S8(reg)		; \
+	REG_L	ra, _OFFSETOF_UC_GREGS_RA(reg)		; \
 	REG_EPILOGUE					; \
 							; \
 	/* part procedure call, part RET */		; \
@@ -97,25 +97,23 @@
 							; \
 1:							; \
 	move	a0, reg					; \
-	la	t9, _C_LABEL(setcontext)		; \
-	jr	t9					; \
-	nop						; \
+	PIC_TAILCALL(setcontext)
 	/* NOTREACHED */
 
 LEAF(_getcontext_u)
-	PIC_PROLOGUE(_getcontext_u, t9)
+	PIC_PROLOGUE(_getcontext_u)
 	GETC(a0)
-	xor	v0, v0, v0
-	j	ra
+	move	v0, zero
+	PIC_RETURN()
 END(_getcontext_u)
 
 LEAF(_setcontext_u)
-	PIC_PROLOGUE(_setcontext_u, t9)
+	PIC_PROLOGUE(_setcontext_u)
 	SETC(a0)
 END(_setcontext_u)
 
 LEAF(_swapcontext_u)
-	PIC_PROLOGUE(_swapcontext_u, t9)
+	PIC_PROLOGUE(_swapcontext_u)
 	GETC(a0)
 	SETC(a1)
 END(_swapcontext_u)

Index: src/lib/libpthread/arch/mips/genassym.cf
diff -u src/lib/libpthread/arch/mips/genassym.cf:1.7 src/lib/libpthread/arch/mips/genassym.cf:1.7.14.1
--- src/lib/libpthread/arch/mips/genassym.cf:1.7	Mon Apr 28 20:23:02 2008
+++ src/lib/libpthread/arch/mips/genassym.cf	Sun Aug 16 03:30:55 2009
@@ -1,4 +1,4 @@
-#	$NetBSD: genassym.cf,v 1.7 2008/04/28 20:23:02 martin Exp $
+#	$NetBSD: genassym.cf,v 1.7.14.1 2009/08/16 03:30:55 matt Exp $
 
 # Copyright (c) 2001 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -28,19 +28,35 @@
 # POSSIBILITY OF SUCH DAMAGE.
 #
 
-
+include <sys/types.h>
+include <machine/reg.h>
+include <machine/regnum.h>
 include <ucontext.h>
 include <sys/queue.h>
 include "pthread.h"
 include "pthread_int.h"
 include "pthread_md.h"
 
-define PT_UC		offsetof(struct __pthread_st, pt_uc)
-define CONTEXTSIZE	sizeof(ucontext_t)
-define UC_FLAGS		offsetof(ucontext_t, uc_flags)
-define UC_REGS		offsetof(ucontext_t, uc_mcontext.__gregs)
-define UC_EPC		offsetof(ucontext_t, uc_mcontext.__gregs[_REG_EPC])
-define STACKSPACE		STACKSPACE
+define PT_UC			offsetof(struct __pthread_st, pt_uc)
+define UCONTEXT_SIZE		sizeof(ucontext_t)
+define _OFFSETOF_UC_LINK	offsetof(ucontext_t, uc_link)
+define _OFFSETOF_UC_FLAGS	offsetof(ucontext_t, uc_flags)
+define _OFFSETOF_UC_GREGS	offsetof(ucontext_t, uc_mcontext.__gregs[0])
+define _OFFSETOF_UC_GREGS_V0	offsetof(ucontext_t, uc_mcontext.__gregs[_REG_V0])
+define _OFFSETOF_UC_GREGS_S0	offsetof(ucontext_t, uc_mcontext.__gregs[_REG_S0])
+define _OFFSETOF_UC_GREGS_S1	offsetof(ucontext_t, uc_mcontext.__gregs[_REG_S1])
+define _OFFSETOF_UC_GREGS_S2	offsetof(ucontext_t, uc_mcontext.__gregs[_REG_S2])
+define _OFFSETOF_UC_GREGS_S3	offsetof(ucontext_t, uc_mcontext.__gregs[_REG_S3])
+define _OFFSETOF_UC_GREGS_S4	offsetof(ucontext_t, uc_mcontext.__gregs[_REG_S4])
+define _OFFSETOF_UC_GREGS_S5	offsetof(ucontext_t, uc_mcontext.__gregs[_REG_S5])
+define _OFFSETOF_UC_GREGS_S6	offsetof(ucontext_t, uc_mcontext.__gregs[_REG_S6])
+define _OFFSETOF_UC_GREGS_S7	offsetof(ucontext_t, uc_mcontext.__gregs[_REG_S7])
+define _OFFSETOF_UC_GREGS_S8	offsetof(ucontext_t, uc_mcontext.__gregs[_REG_S8])
+define _OFFSETOF_UC_GREGS_GP	offsetof(ucontext_t, uc_mcontext.__gregs[_REG_GP])
+define _OFFSETOF_UC_GREGS_SP	offsetof(ucontext_t, uc_mcontext.__gregs[_REG_SP])
+define _OFFSETOF_UC_GREGS_RA	offsetof(ucontext_t, uc_mcontext.__gregs[_REG_RA])
+define _OFFSETOF_UC_GREGS_EPC	offsetof(ucontext_t, uc_mcontext.__gregs[_REG_EPC])
+define _OFFSETOF_UC_GREGS_EPC	offsetof(ucontext_t, uc_mcontext.__gregs[_REG_EPC])
 
 # uc_flags
 define _UC_CPU		_UC_CPU

Reply via email to