Date: Tue, 16 Mar 2004 10:22:51 +0100 From: des@des.no (Dag-Erling =?iso-8859-1?q?Sm=F8rgrav?=) To: alpha@freebsd.org Subject: strict aliasing patches Message-ID: <xzp4qspkuxg.fsf@dwp.des.no>
index | next in thread | raw e-mail
[-- Attachment #1 --]
The attached patches are required to build alpha world with -O2.
Please review.
DES
--
Dag-Erling Smørgrav - des@des.no
[-- Attachment #2 --]
Index: lib/libc/alpha/gen/flt_rounds.c
===================================================================
RCS file: /home/ncvs/src/lib/libc/alpha/gen/flt_rounds.c,v
retrieving revision 1.3
diff -u -r1.3 flt_rounds.c
--- lib/libc/alpha/gen/flt_rounds.c 7 Nov 2001 22:12:52 -0000 1.3
+++ lib/libc/alpha/gen/flt_rounds.c 16 Mar 2004 09:21:11 -0000
@@ -47,13 +47,14 @@
int
__flt_rounds()
{
- double fpcrval;
- u_int64_t old;
+ union {
+ double fpcrval;
+ u_int64_t intval;
+ } u;
__asm__("trapb");
- __asm__("mf_fpcr %0" : "=f" (fpcrval));
+ __asm__("mf_fpcr %0" : "=f" (u.fpcrval));
__asm__("trapb");
- old = *(u_int64_t *)&fpcrval;
- return map[(old >> 58) & 0x3];
+ return map[(u.intval >> 58) & 0x3];
}
Index: lib/libc/alpha/gen/fpgetround.c
===================================================================
RCS file: /home/ncvs/src/lib/libc/alpha/gen/fpgetround.c,v
retrieving revision 1.5
diff -u -r1.5 fpgetround.c
--- lib/libc/alpha/gen/fpgetround.c 7 Nov 2001 22:12:52 -0000 1.5
+++ lib/libc/alpha/gen/fpgetround.c 16 Mar 2004 09:21:16 -0000
@@ -41,11 +41,12 @@
fp_rnd_t
fpgetround()
{
- double fpcrval;
- u_int64_t old;
+ union {
+ double fpcrval;
+ u_int64_t intval;
+ } u;
- GET_FPCR(fpcrval);
- old = *(u_int64_t *)&fpcrval;
+ GET_FPCR(u.fpcrval);
- return ((old & FPCR_DYN_MASK) >> FPCR_DYN_SHIFT);
+ return ((u.intval & FPCR_DYN_MASK) >> FPCR_DYN_SHIFT);
}
Index: lib/libc/alpha/gen/fpgetsticky.c
===================================================================
RCS file: /home/ncvs/src/lib/libc/alpha/gen/fpgetsticky.c,v
retrieving revision 1.4
diff -u -r1.4 fpgetsticky.c
--- lib/libc/alpha/gen/fpgetsticky.c 7 Nov 2001 22:12:52 -0000 1.4
+++ lib/libc/alpha/gen/fpgetsticky.c 16 Mar 2004 09:21:22 -0000
@@ -41,11 +41,12 @@
fp_except_t
fpgetsticky()
{
- double fpcrval;
- u_int64_t old;
+ union {
+ double fpcrval;
+ u_int64_t intval;
+ } u;
- GET_FPCR(fpcrval);
- old = *(u_int64_t *)&fpcrval;
- return (((old >> IEEE_STATUS_TO_FPCR_SHIFT) & IEEE_STATUS_MASK)
+ GET_FPCR(u.fpcrval);
+ return (((u.intval >> IEEE_STATUS_TO_FPCR_SHIFT) & IEEE_STATUS_MASK)
>> IEEE_STATUS_TO_EXCSUM_SHIFT);
}
Index: lib/libc/alpha/gen/fpsetround.c
===================================================================
RCS file: /home/ncvs/src/lib/libc/alpha/gen/fpsetround.c,v
retrieving revision 1.5
diff -u -r1.5 fpsetround.c
--- lib/libc/alpha/gen/fpsetround.c 7 Nov 2001 22:12:52 -0000 1.5
+++ lib/libc/alpha/gen/fpsetround.c 16 Mar 2004 09:18:37 -0000
@@ -42,17 +42,20 @@
fpsetround(rnd_dir)
fp_rnd_t rnd_dir;
{
- double fpcrval;
+ union {
+ double fpcrval;
+ u_int64_t intval;
+ } u;
u_int64_t old, new;
- GET_FPCR(fpcrval);
- old = *(u_int64_t *)&fpcrval;
+ GET_FPCR(u.fpcrval);
+ old = u.intval;
new = old & (~FPCR_DYN_MASK);
new |= ((long) rnd_dir << FPCR_DYN_SHIFT) & FPCR_DYN_MASK;
- *(u_int64_t *)&fpcrval = new;
- SET_FPCR(fpcrval);
+ u.intval = new;
+ SET_FPCR(u.fpcrval);
return ((old & FPCR_DYN_MASK) >> FPCR_DYN_SHIFT);
}
Index: lib/libc/alpha/gen/fpsetsticky.c
===================================================================
RCS file: /home/ncvs/src/lib/libc/alpha/gen/fpsetsticky.c,v
retrieving revision 1.4
diff -u -r1.4 fpsetsticky.c
--- lib/libc/alpha/gen/fpsetsticky.c 7 Nov 2001 22:12:52 -0000 1.4
+++ lib/libc/alpha/gen/fpsetsticky.c 16 Mar 2004 09:19:10 -0000
@@ -42,16 +42,20 @@
fpsetsticky(sticky)
fp_except_t sticky;
{
- double fpcrval;
- u_int64_t old,new ;
+ union {
+ double fpcrval;
+ u_int64_t intval;
+ } u;
+ u_int64_t old, new;
- GET_FPCR(fpcrval);
- old = *(u_int64_t *)&fpcrval;
+ GET_FPCR(u.fpcrval);
+
+ old = u.intval;
new = old & ~ (IEEE_STATUS_MASK << IEEE_STATUS_TO_FPCR_SHIFT);
new |= ((sticky << IEEE_STATUS_TO_EXCSUM_SHIFT) & IEEE_STATUS_MASK)
<< IEEE_STATUS_TO_FPCR_SHIFT;
- *(u_int64_t *)&fpcrval = new;
- SET_FPCR(fpcrval);
+ u.intval = new;
+ SET_FPCR(u.fpcrval);
return (((old >> IEEE_STATUS_TO_FPCR_SHIFT) & IEEE_STATUS_MASK)
>> IEEE_STATUS_TO_EXCSUM_SHIFT);
home |
help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?xzp4qspkuxg.fsf>
