CVS commit: src/lib/libc/arch/alpha/sys

2020-10-20 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed Oct 21 01:58:30 UTC 2020

Modified Files:
src/lib/libc/arch/alpha/sys: __sigtramp2.S

Log Message:
Fix typo (thanks kamil@ for pointing it out).


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/lib/libc/arch/alpha/sys/__sigtramp2.S

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

Modified files:

Index: src/lib/libc/arch/alpha/sys/__sigtramp2.S
diff -u src/lib/libc/arch/alpha/sys/__sigtramp2.S:1.4 src/lib/libc/arch/alpha/sys/__sigtramp2.S:1.5
--- src/lib/libc/arch/alpha/sys/__sigtramp2.S:1.4	Wed Oct 21 01:55:07 2020
+++ src/lib/libc/arch/alpha/sys/__sigtramp2.S	Wed Oct 21 01:58:30 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: __sigtramp2.S,v 1.4 2020/10/21 01:55:07 thorpej Exp $	*/
+/*	$NetBSD: __sigtramp2.S,v 1.5 2020/10/21 01:58:30 thorpej Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
@@ -81,7 +81,7 @@
  * The unwind entry includes one instruction slot prior to the trampoline
  * because the unwinder will look up to (return PC - 1 insn) while unwinding.
  * Normally this would be the jump / branch, but since there isn't one in
- * this case, we place an explcit nop there instead.
+ * this case, we place an explicit nop there instead.
  */
 	nop
 



CVS commit: src/lib/libc/arch/alpha/sys

2020-10-20 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed Oct 21 01:55:07 UTC 2020

Modified Files:
src/lib/libc/arch/alpha/sys: __sigtramp2.S

Log Message:
Add call frame unwind info to the Alpha signal trampoline.  Using
kamil@'s test program:

Before:
Backtrace 2 stack frames.
0x12a74  at ./test
0x3fffdca6550 <__sigtramp_siginfo_2> at /usr/lib/libc.so.12

After:
Backtrace 4 stack frames.
0x12a74  at ./test
0x3fffdca6554 <__sigtramp_siginfo_2> at /usr/lib/libc.so.12
0x12b10  at ./test
0x129b4 <___start+0x1a4> at ./test


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/lib/libc/arch/alpha/sys/__sigtramp2.S

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

Modified files:

Index: src/lib/libc/arch/alpha/sys/__sigtramp2.S
diff -u src/lib/libc/arch/alpha/sys/__sigtramp2.S:1.3 src/lib/libc/arch/alpha/sys/__sigtramp2.S:1.4
--- src/lib/libc/arch/alpha/sys/__sigtramp2.S:1.3	Wed Oct 21 01:24:05 2020
+++ src/lib/libc/arch/alpha/sys/__sigtramp2.S	Wed Oct 21 01:55:07 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: __sigtramp2.S,v 1.3 2020/10/21 01:24:05 thorpej Exp $	*/
+/*	$NetBSD: __sigtramp2.S,v 1.4 2020/10/21 01:55:07 thorpej Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
@@ -39,10 +39,57 @@
  *		ucontext structure	[128] == sp + sizeof(siginfo_t)]
  *	sp->	siginfo structure	[0]
  */
+
+#define	CFI_OFFSET(r)	.cfi_offset r, SIZEOF_SIGINFO + UC_GREGS + r*8
+
+	.cfi_startproc simple
+	.cfi_signal_frame
+	.cfi_def_cfa _REG_SP, 0
+	CFI_OFFSET(_REG_V0)
+	CFI_OFFSET(_REG_T0)
+	CFI_OFFSET(_REG_T1)
+	CFI_OFFSET(_REG_T2)
+	CFI_OFFSET(_REG_T3)
+	CFI_OFFSET(_REG_T4)
+	CFI_OFFSET(_REG_T5)
+	CFI_OFFSET(_REG_T6)
+	CFI_OFFSET(_REG_T7)
+	CFI_OFFSET(_REG_S0)
+	CFI_OFFSET(_REG_S1)
+	CFI_OFFSET(_REG_S2)
+	CFI_OFFSET(_REG_S3)
+	CFI_OFFSET(_REG_S4)
+	CFI_OFFSET(_REG_S5)
+	CFI_OFFSET(_REG_S6)
+	CFI_OFFSET(_REG_A0)
+	CFI_OFFSET(_REG_A1)
+	CFI_OFFSET(_REG_A2)
+	CFI_OFFSET(_REG_A3)
+	CFI_OFFSET(_REG_A4)
+	CFI_OFFSET(_REG_A5)
+	CFI_OFFSET(_REG_T8)
+	CFI_OFFSET(_REG_T9)
+	CFI_OFFSET(_REG_T10)
+	CFI_OFFSET(_REG_T11)
+	CFI_OFFSET(_REG_RA)
+	CFI_OFFSET(_REG_T12)	/* a.k.a. _REG_PV */
+	CFI_OFFSET(_REG_AT)
+	CFI_OFFSET(_REG_GP)
+	CFI_OFFSET(_REG_SP)
+
+/*
+ * The unwind entry includes one instruction slot prior to the trampoline
+ * because the unwinder will look up to (return PC - 1 insn) while unwinding.
+ * Normally this would be the jump / branch, but since there isn't one in
+ * this case, we place an explcit nop there instead.
+ */
+	nop
+
 NESTED_NOPROFILE(__sigtramp_siginfo_2,0,0,ra,0,0)
 	ldgp	gp,0(ra)
 	lda	a0,(SIZEOF_SIGINFO)(sp)	/* get pointer to ucontext */
 	CALLSYS_NOERROR(setcontext)	/* and call setcontext() with it */
 	ldiq	a0,-1			/* if that failed, set an exit code */
 	CALLSYS_NOERROR(exit)		/* and call exit() */
+	.cfi_endproc
 END(__sigtramp_siginfo_2)



CVS commit: src/lib/libc/arch/alpha

2020-10-20 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed Oct 21 01:24:05 UTC 2020

Modified Files:
src/lib/libc/arch/alpha: genassym.cf
src/lib/libc/arch/alpha/gen: __setjmp14.S swapcontext.S
src/lib/libc/arch/alpha/sys: __sigtramp2.S getcontext.S

Log Message:
- Consistently use _REG_* defines from assym.h to mean register numbers,
  not offsets (i.e. *8 to get the offset).
- Define and use SIZEOF_SIGINFO and UC_GREGS constants, rather than
  hard-code magic numbers.

NFC -- same object code is generated.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/lib/libc/arch/alpha/genassym.cf
cvs rdiff -u -r1.7 -r1.8 src/lib/libc/arch/alpha/gen/__setjmp14.S
cvs rdiff -u -r1.3 -r1.4 src/lib/libc/arch/alpha/gen/swapcontext.S
cvs rdiff -u -r1.2 -r1.3 src/lib/libc/arch/alpha/sys/__sigtramp2.S
cvs rdiff -u -r1.3 -r1.4 src/lib/libc/arch/alpha/sys/getcontext.S

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

Modified files:

Index: src/lib/libc/arch/alpha/genassym.cf
diff -u src/lib/libc/arch/alpha/genassym.cf:1.2 src/lib/libc/arch/alpha/genassym.cf:1.3
--- src/lib/libc/arch/alpha/genassym.cf:1.2	Mon Apr 28 20:22:55 2008
+++ src/lib/libc/arch/alpha/genassym.cf	Wed Oct 21 01:24:04 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: genassym.cf,v 1.2 2008/04/28 20:22:55 martin Exp $
+#	$NetBSD: genassym.cf,v 1.3 2020/10/21 01:24:04 thorpej Exp $
 
 #
 # Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -34,41 +34,41 @@ include 
 include 
 include 
 
-define _REG_V0		8*_REG_V0	/* 0 */
-define _REG_T0		8*_REG_T0	/* 1 */
-define _REG_T1		8*_REG_T1	/* 2 */
-define _REG_T2		8*_REG_T2	/* 3 */
-define _REG_T3		8*_REG_T3	/* 4 */
-define _REG_T4		8*_REG_T4	/* 5 */
-define _REG_T5		8*_REG_T5	/* 6 */
-define _REG_T6		8*_REG_T6	/* 7 */
-define _REG_T7		8*_REG_T7	/* 8 */
-define _REG_S0		8*_REG_S0	/* 9 */
-define _REG_S1		8*_REG_S1	/* 10 */
-define _REG_S2		8*_REG_S2	/* 11 */
-define _REG_S3		8*_REG_S3	/* 12 */
-define _REG_S4		8*_REG_S4	/* 13 */
-define _REG_S5		8*_REG_S5	/* 14 */
-define _REG_S6		8*_REG_S6	/* 15 */
-define _REG_A0		8*_REG_A0	/* 16 */
-define _REG_A1		8*_REG_A1	/* 17 */
-define _REG_A2		8*_REG_A2	/* 18 */
-define _REG_A3		8*_REG_A3	/* 19 */
-define _REG_A4		8*_REG_A4	/* 20 */
-define _REG_A5		8*_REG_A5	/* 21 */
-define _REG_T8		8*_REG_T8	/* 22 */
-define _REG_T9		8*_REG_T9	/* 23 */
-define _REG_T10		8*_REG_T10	/* 24 */
-define _REG_T11		8*_REG_T11	/* 25 */
-define _REG_RA		8*_REG_RA	/* 26 */
-define _REG_T12		8*_REG_T12	/* 27 */
-define _REG_PV		8*_REG_PV	/* 27 */
-define _REG_AT		8*_REG_AT	/* 28 */
-define _REG_GP		8*_REG_GP	/* 29 */
-define _REG_SP		8*_REG_SP	/* 30 */
-define _REG_UNIQUE	8*_REG_UNIQUE	/* 31 */
-define _REG_PC		8*_REG_PC	/* 32 */
-define _REG_PS		8*_REG_PS	/* 33 */
+define _REG_V0		_REG_V0		/* 0 */
+define _REG_T0		_REG_T0		/* 1 */
+define _REG_T1		_REG_T1		/* 2 */
+define _REG_T2		_REG_T2		/* 3 */
+define _REG_T3		_REG_T3		/* 4 */
+define _REG_T4		_REG_T4		/* 5 */
+define _REG_T5		_REG_T5		/* 6 */
+define _REG_T6		_REG_T6		/* 7 */
+define _REG_T7		_REG_T7		/* 8 */
+define _REG_S0		_REG_S0		/* 9 */
+define _REG_S1		_REG_S1		/* 10 */
+define _REG_S2		_REG_S2		/* 11 */
+define _REG_S3		_REG_S3		/* 12 */
+define _REG_S4		_REG_S4		/* 13 */
+define _REG_S5		_REG_S5		/* 14 */
+define _REG_S6		_REG_S6		/* 15 */
+define _REG_A0		_REG_A0		/* 16 */
+define _REG_A1		_REG_A1		/* 17 */
+define _REG_A2		_REG_A2		/* 18 */
+define _REG_A3		_REG_A3		/* 19 */
+define _REG_A4		_REG_A4		/* 20 */
+define _REG_A5		_REG_A5		/* 21 */
+define _REG_T8		_REG_T8		/* 22 */
+define _REG_T9		_REG_T9		/* 23 */
+define _REG_T10		_REG_T10	/* 24 */
+define _REG_T11		_REG_T11	/* 25 */
+define _REG_RA		_REG_RA		/* 26 */
+define _REG_T12		_REG_T12	/* 27 */
+define _REG_PV		_REG_PV		/* 27 */
+define _REG_AT		_REG_AT		/* 28 */
+define _REG_GP		_REG_GP		/* 29 */
+define _REG_SP		_REG_SP		/* 30 */
+define _REG_UNIQUE	_REG_UNIQUE	/* 31 */
+define _REG_PC		_REG_PC		/* 32 */
+define _REG_PS		_REG_PS		/* 33 */
 
 define	SC_ONSTACK	offsetof(struct sigcontext, sc_onstack)
 define	SC_SP		offsetof(struct sigcontext, sc_sp)
@@ -82,3 +82,7 @@ define	SC_FP_CONTROL	offsetof(struct sig
 define	SC_MASK		offsetof(struct sigcontext, sc_mask)
 define	SC_RESERVED	offsetof(struct sigcontext, sc_reserved)
 define	SC_XXX		offsetof(struct sigcontext, sc_xxx)
+
+define	SIZEOF_SIGINFO	sizeof(siginfo_t)
+
+define	UC_GREGS	offsetof(ucontext_t, uc_mcontext.__gregs)

Index: src/lib/libc/arch/alpha/gen/__setjmp14.S
diff -u src/lib/libc/arch/alpha/gen/__setjmp14.S:1.7 src/lib/libc/arch/alpha/gen/__setjmp14.S:1.8
--- src/lib/libc/arch/alpha/gen/__setjmp14.S:1.7	Thu Jan 23 03:08:50 2014
+++ src/lib/libc/arch/alpha/gen/__setjmp14.S	Wed Oct 21 01:24:05 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: __setjmp14.S,v 1.7 2014/01/23 03:08:50 christos Exp $ */
+/* $NetBSD: __setjmp14.S,v 1.8 2020/10/21 01:24:05 thorpej Exp $ */
 
 /*
  * Copyright (c) 1994, 1995 Carnegie-Mellon University.
@@ -46,16 

CVS commit: src/lib/libc/arch/alpha/gen

2013-11-02 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Nov  2 23:54:04 UTC 2013

Modified Files:
src/lib/libc/arch/alpha/gen: fpsetmask.c fpsetsticky.c

Log Message:
fix old style decls


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/lib/libc/arch/alpha/gen/fpsetmask.c \
src/lib/libc/arch/alpha/gen/fpsetsticky.c

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

Modified files:

Index: src/lib/libc/arch/alpha/gen/fpsetmask.c
diff -u src/lib/libc/arch/alpha/gen/fpsetmask.c:1.4 src/lib/libc/arch/alpha/gen/fpsetmask.c:1.5
--- src/lib/libc/arch/alpha/gen/fpsetmask.c:1.4	Sun Jun 12 01:21:25 2005
+++ src/lib/libc/arch/alpha/gen/fpsetmask.c	Sat Nov  2 19:54:04 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: fpsetmask.c,v 1.4 2005/06/12 05:21:25 lukem Exp $	*/
+/*	$NetBSD: fpsetmask.c,v 1.5 2013/11/02 23:54:04 christos Exp $	*/
 
 /*
  * Copyright (c) 1995 Ross Harvey
@@ -33,7 +33,7 @@
 
 #include sys/cdefs.h
 #if defined(LIBC_SCCS)  !defined(lint)
-__RCSID($NetBSD: fpsetmask.c,v 1.4 2005/06/12 05:21:25 lukem Exp $);
+__RCSID($NetBSD: fpsetmask.c,v 1.5 2013/11/02 23:54:04 christos Exp $);
 #endif /* LIBC_SCCS and not lint */
 
 #include namespace.h
@@ -46,8 +46,7 @@ __weak_alias(fpsetmask,_fpsetmask)
 #endif
 
 fp_except
-fpsetmask(mask)
-	fp_except mask;
+fpsetmask(fp_except mask)
 {
 	struct alpha_fp_except_args a;
 
Index: src/lib/libc/arch/alpha/gen/fpsetsticky.c
diff -u src/lib/libc/arch/alpha/gen/fpsetsticky.c:1.4 src/lib/libc/arch/alpha/gen/fpsetsticky.c:1.5
--- src/lib/libc/arch/alpha/gen/fpsetsticky.c:1.4	Sun Jun 12 01:21:25 2005
+++ src/lib/libc/arch/alpha/gen/fpsetsticky.c	Sat Nov  2 19:54:04 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: fpsetsticky.c,v 1.4 2005/06/12 05:21:25 lukem Exp $	*/
+/*	$NetBSD: fpsetsticky.c,v 1.5 2013/11/02 23:54:04 christos Exp $	*/
 
 /*
  * Copyright (c) 1999 Ross Harvey
@@ -33,7 +33,7 @@
 
 #include sys/cdefs.h
 #if defined(LIBC_SCCS)  !defined(lint)
-__RCSID($NetBSD: fpsetsticky.c,v 1.4 2005/06/12 05:21:25 lukem Exp $);
+__RCSID($NetBSD: fpsetsticky.c,v 1.5 2013/11/02 23:54:04 christos Exp $);
 #endif /* LIBC_SCCS and not lint */
 
 #include namespace.h
@@ -46,8 +46,7 @@ __weak_alias(fpsetsticky,_fpsetsticky)
 #endif
 
 fp_except
-fpsetsticky(sticky)
-	fp_except sticky;
+fpsetsticky(fp_except sticky)
 {
 	struct alpha_fp_except_args a;
 



CVS commit: src/lib/libc/arch/alpha/gen

2013-03-13 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Mar 13 08:05:46 UTC 2013

Modified Files:
src/lib/libc/arch/alpha/gen: __longjmp14.c

Log Message:
Remove clearing of ucontext_t, the only random register values now are
argument and scratch registers (which will be reloaded after return anyway).


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/lib/libc/arch/alpha/gen/__longjmp14.c

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

Modified files:

Index: src/lib/libc/arch/alpha/gen/__longjmp14.c
diff -u src/lib/libc/arch/alpha/gen/__longjmp14.c:1.6 src/lib/libc/arch/alpha/gen/__longjmp14.c:1.7
--- src/lib/libc/arch/alpha/gen/__longjmp14.c:1.6	Tue Mar 12 19:38:20 2013
+++ src/lib/libc/arch/alpha/gen/__longjmp14.c	Wed Mar 13 08:05:46 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: __longjmp14.c,v 1.6 2013/03/12 19:38:20 martin Exp $	*/
+/*	$NetBSD: __longjmp14.c,v 1.7 2013/03/13 08:05:46 martin Exp $	*/
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -56,8 +56,6 @@ __longjmp14(jmp_buf env, int val)
 	if (val == 0)
 		val = -1;
 
-	memset(uc, 0, sizeof uc);
-
 	/* Set _UC_SIGMASK and _UC_CPU */
 	uc.uc_flags = _UC_SIGMASK | _UC_CPU;
 



CVS commit: src/lib/libc/arch/alpha/gen

2012-09-12 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Wed Sep 12 14:13:44 UTC 2012

Modified Files:
src/lib/libc/arch/alpha/gen: _lwp.c

Log Message:
Fix the build, _UC_UNIQUE has been renamed _UC_TLSBASE


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/lib/libc/arch/alpha/gen/_lwp.c

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

Modified files:

Index: src/lib/libc/arch/alpha/gen/_lwp.c
diff -u src/lib/libc/arch/alpha/gen/_lwp.c:1.6 src/lib/libc/arch/alpha/gen/_lwp.c:1.7
--- src/lib/libc/arch/alpha/gen/_lwp.c:1.6	Thu Feb 24 04:28:41 2011
+++ src/lib/libc/arch/alpha/gen/_lwp.c	Wed Sep 12 14:13:43 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: _lwp.c,v 1.6 2011/02/24 04:28:41 joerg Exp $	*/
+/*	$NetBSD: _lwp.c,v 1.7 2012/09/12 14:13:43 manu Exp $	*/
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include sys/cdefs.h
 #if defined(LIBC_SCCS)  !defined(lint)
-__RCSID($NetBSD: _lwp.c,v 1.6 2011/02/24 04:28:41 joerg Exp $);
+__RCSID($NetBSD: _lwp.c,v 1.7 2012/09/12 14:13:43 manu Exp $);
 #endif /* LIBC_SCCS and not lint */
 
 #include namespace.h
@@ -62,5 +62,5 @@ _lwp_makecontext(ucontext_t *u, void (*s
 	gr[_REG_S6] = 0;
 	gr[_REG_UNIQUE] = (unsigned long)private;
 
-	u-uc_flags |= _UC_UNIQUE;
+	u-uc_flags |= _UC_TLSBASE;
 }



CVS commit: src/lib/libc/arch/alpha/gen

2012-03-21 Thread Havard Eidnes
Module Name:src
Committed By:   he
Date:   Wed Mar 21 20:07:52 UTC 2012

Modified Files:
src/lib/libc/arch/alpha/gen: fpgetround.c fpsetround.c

Log Message:
Add some casts to get rid of bitwise op on signed value is non-portable
warning from lint.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/lib/libc/arch/alpha/gen/fpgetround.c
cvs rdiff -u -r1.11 -r1.12 src/lib/libc/arch/alpha/gen/fpsetround.c

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

Modified files:

Index: src/lib/libc/arch/alpha/gen/fpgetround.c
diff -u src/lib/libc/arch/alpha/gen/fpgetround.c:1.10 src/lib/libc/arch/alpha/gen/fpgetround.c:1.11
--- src/lib/libc/arch/alpha/gen/fpgetround.c:1.10	Sun Jun 12 05:44:36 2011
+++ src/lib/libc/arch/alpha/gen/fpgetround.c	Wed Mar 21 20:07:52 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: fpgetround.c,v 1.10 2011/06/12 05:44:36 matt Exp $ */
+/* $NetBSD: fpgetround.c,v 1.11 2012/03/21 20:07:52 he Exp $ */
 
 /*
  * Copyright (c) 1995 Christopher G. Demetriou
@@ -36,7 +36,7 @@
 
 #include sys/cdefs.h
 #if defined(LIBC_SCCS)  !defined(lint)
-__RCSID($NetBSD: fpgetround.c,v 1.10 2011/06/12 05:44:36 matt Exp $);
+__RCSID($NetBSD: fpgetround.c,v 1.11 2012/03/21 20:07:52 he Exp $);
 #endif /* LIBC_SCCS and not lint */
 
 #include namespace.h
@@ -58,5 +58,5 @@ fpgetround(void)
 
 	__asm(excb; mf_fpcr %0; excb : =f (fpcrval.d));
 
-	return ((fpcrval.u64  58)  0x3);
+	return ((fp_rnd)(fpcrval.u64  58)  0x3);
 }

Index: src/lib/libc/arch/alpha/gen/fpsetround.c
diff -u src/lib/libc/arch/alpha/gen/fpsetround.c:1.11 src/lib/libc/arch/alpha/gen/fpsetround.c:1.12
--- src/lib/libc/arch/alpha/gen/fpsetround.c:1.11	Sun Jun 12 05:44:36 2011
+++ src/lib/libc/arch/alpha/gen/fpsetround.c	Wed Mar 21 20:07:52 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: fpsetround.c,v 1.11 2011/06/12 05:44:36 matt Exp $ */
+/* $NetBSD: fpsetround.c,v 1.12 2012/03/21 20:07:52 he Exp $ */
 
 /*
  * Copyright (c) 1995 Christopher G. Demetriou
@@ -36,7 +36,7 @@
 
 #include sys/cdefs.h
 #if defined(LIBC_SCCS)  !defined(lint)
-__RCSID($NetBSD: fpsetround.c,v 1.11 2011/06/12 05:44:36 matt Exp $);
+__RCSID($NetBSD: fpsetround.c,v 1.12 2012/03/21 20:07:52 he Exp $);
 #endif /* LIBC_SCCS and not lint */
 
 #include namespace.h
@@ -58,7 +58,7 @@ fpsetround(fp_rnd rnd_dir)
 	fp_rnd old;
 
 	__asm(excb; mf_fpcr %0; excb : =f (fpcrval.d));
-	old = (fpcrval.u64  58)  0x3;
+	old = (fp_rnd)(fpcrval.u64  58)  0x3;
 
 	rnd_dir ^= old;
 



CVS commit: src/lib/libc/arch/alpha/gen

2011-06-11 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Sun Jun 12 05:44:36 UTC 2011

Modified Files:
src/lib/libc/arch/alpha/gen: __setjmp14.S flt_rounds.c fpgetround.c
fpsetround.c

Log Message:
Use excb before and after the mt_fpcr/mf_fpcr instructions as specified
in the alpha ARM 4.7.8.1 (Accessing the FPCR):

Because Alpha floating-point hardware can overlap the execution of
a number of floating-point instructions, accessing the FPCR must
be synchronized with other floating-point instructions. An EXCB
instruction must be issued both prior to and after accessing the
FPCR to ensure that the FPCR access is synchronized with the
execution of previous and subsequent floating-point instructions;
otherwise synchronization is not ensured.

Use unions to convert between double and uint64_t to avoid casting.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/lib/libc/arch/alpha/gen/__setjmp14.S
cvs rdiff -u -r1.8 -r1.9 src/lib/libc/arch/alpha/gen/flt_rounds.c
cvs rdiff -u -r1.9 -r1.10 src/lib/libc/arch/alpha/gen/fpgetround.c
cvs rdiff -u -r1.10 -r1.11 src/lib/libc/arch/alpha/gen/fpsetround.c

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

Modified files:

Index: src/lib/libc/arch/alpha/gen/__setjmp14.S
diff -u src/lib/libc/arch/alpha/gen/__setjmp14.S:1.4 src/lib/libc/arch/alpha/gen/__setjmp14.S:1.5
--- src/lib/libc/arch/alpha/gen/__setjmp14.S:1.4	Sun Mar 21 18:04:27 2004
+++ src/lib/libc/arch/alpha/gen/__setjmp14.S	Sun Jun 12 05:44:36 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: __setjmp14.S,v 1.4 2004/03/21 18:04:27 matt Exp $ */
+/* $NetBSD: __setjmp14.S,v 1.5 2011/06/12 05:44:36 matt Exp $ */
 
 /*
  * Copyright (c) 1994, 1995 Carnegie-Mellon University.
@@ -96,7 +96,9 @@
 	stt	fs5, (7*8 + SC_FPREGS)(a0)
 	stt	fs6, (8*8 + SC_FPREGS)(a0)
 	stt	fs7, (9*8 + SC_FPREGS)(a0)
+	excb	/* required 4.7.8.1 Alpha ARM */
 	mf_fpcr	ft0/* get FP control reg */
+	excb	/* required 4.7.8.1 Alpha ARM */
 	stt	ft0, SC_FPCR(a0)		/* and store it in sc_fpcr */
 	stq	zero, SC_FP_CONTROL(a0)		/* FP software control XXX */
 	stq	zero, (SC_RESERVED + 0*8)(a0)	/* sc_reserved[0] */

Index: src/lib/libc/arch/alpha/gen/flt_rounds.c
diff -u src/lib/libc/arch/alpha/gen/flt_rounds.c:1.8 src/lib/libc/arch/alpha/gen/flt_rounds.c:1.9
--- src/lib/libc/arch/alpha/gen/flt_rounds.c:1.8	Sat Dec 24 23:10:08 2005
+++ src/lib/libc/arch/alpha/gen/flt_rounds.c	Sun Jun 12 05:44:36 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: flt_rounds.c,v 1.8 2005/12/24 23:10:08 perry Exp $ */
+/* $NetBSD: flt_rounds.c,v 1.9 2011/06/12 05:44:36 matt Exp $ */
 
 /*
  * Copyright (c) 1995 Christopher G. Demetriou
@@ -36,29 +36,33 @@
 
 #include sys/cdefs.h
 #if defined(LIBC_SCCS)  !defined(lint)
-__RCSID($NetBSD: flt_rounds.c,v 1.8 2005/12/24 23:10:08 perry Exp $);
+__RCSID($NetBSD: flt_rounds.c,v 1.9 2011/06/12 05:44:36 matt Exp $);
 #endif /* LIBC_SCCS and not lint */
 
 #include sys/types.h
+#include machine/ieeefp.h
 #include machine/float.h
 
-static const int map[] = {
-	0,	/* round to zero */
-	3,	/* round to negative infinity */
-	1,	/* round to nearest */
-	2	/* round to positive infinity */
-};
+/*
+ * These come from float.h defintion
+ */
+#define	FLT_ROUND_MAP \
+	( (0  (FP_RZ*2))	/* round to zero */			\
+	| (1  (FP_RN*2))	/* round to nearest */			\
+	| (3  (FP_RM*2))	/* round to negative infinity */	\
+	| (2  (FP_RP*2)))	/* round to positive infinity */
 
 int
-__flt_rounds()
+__flt_rounds(void)
 {
-	double fpcrval;
-	u_int64_t old;
+	union {
+		double d;
+		uint64_t u64;
+	} fpcrval;
+	uint64_t old;
 
-	__asm(trapb);
-	__asm(mf_fpcr %0 : =f (fpcrval));
-	__asm(trapb);
-	old = *(u_int64_t *)(void *)fpcrval;
+	__asm(excb; mf_fpcr %0; excb : =f (fpcrval.d));
+	old = (fpcrval.u64  58)  3;
 
-	return map[(old  58)  0x3];
+	return (FLT_ROUND_MAP  (old  1))  3;
 }

Index: src/lib/libc/arch/alpha/gen/fpgetround.c
diff -u src/lib/libc/arch/alpha/gen/fpgetround.c:1.9 src/lib/libc/arch/alpha/gen/fpgetround.c:1.10
--- src/lib/libc/arch/alpha/gen/fpgetround.c:1.9	Sat Dec 24 23:10:08 2005
+++ src/lib/libc/arch/alpha/gen/fpgetround.c	Sun Jun 12 05:44:36 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: fpgetround.c,v 1.9 2005/12/24 23:10:08 perry Exp $ */
+/* $NetBSD: fpgetround.c,v 1.10 2011/06/12 05:44:36 matt Exp $ */
 
 /*
  * Copyright (c) 1995 Christopher G. Demetriou
@@ -36,7 +36,7 @@
 
 #include sys/cdefs.h
 #if defined(LIBC_SCCS)  !defined(lint)
-__RCSID($NetBSD: fpgetround.c,v 1.9 2005/12/24 23:10:08 perry Exp $);
+__RCSID($NetBSD: fpgetround.c,v 1.10 2011/06/12 05:44:36 matt Exp $);
 #endif /* LIBC_SCCS and not lint */
 
 #include namespace.h
@@ -49,13 +49,14 @@
 #endif
 
 fp_rnd
-fpgetround()
+fpgetround(void)
 {
-	double fpcrval;
-	u_int64_t old;
+	union {
+		double d;
+		uint64_t u64;
+	} fpcrval;
 
-	__asm(mf_fpcr %0 : =f (fpcrval));
-	old = *(u_int64_t *)(void *)fpcrval;
+	__asm(excb; mf_fpcr %0; excb : =f (fpcrval.d));
 
-