summaryrefslogtreecommitdiffstats
path: root/lib/libc/alpha/gen
diff options
context:
space:
mode:
authordes <des@FreeBSD.org>2004-03-16 20:42:02 +0000
committerdes <des@FreeBSD.org>2004-03-16 20:42:02 +0000
commitce346529a392bdc70b527967b64de371a411c397 (patch)
tree6f573f40ecc689ac27427614841b8f02fedfd30e /lib/libc/alpha/gen
parentffa157ec1e6e53fb7cdd4737c35288e138bb357d (diff)
downloadFreeBSD-src-ce346529a392bdc70b527967b64de371a411c397.zip
FreeBSD-src-ce346529a392bdc70b527967b64de371a411c397.tar.gz
Use unions to avoid violating C99 strict aliasing rules.
Diffstat (limited to 'lib/libc/alpha/gen')
-rw-r--r--lib/libc/alpha/gen/flt_rounds.c11
-rw-r--r--lib/libc/alpha/gen/fpgetround.c11
-rw-r--r--lib/libc/alpha/gen/fpgetsticky.c11
-rw-r--r--lib/libc/alpha/gen/fpsetround.c13
-rw-r--r--lib/libc/alpha/gen/fpsetsticky.c16
5 files changed, 36 insertions, 26 deletions
diff --git a/lib/libc/alpha/gen/flt_rounds.c b/lib/libc/alpha/gen/flt_rounds.c
index a5181e3..c3219d9 100644
--- a/lib/libc/alpha/gen/flt_rounds.c
+++ b/lib/libc/alpha/gen/flt_rounds.c
@@ -47,13 +47,14 @@ static const int map[] = {
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];
}
diff --git a/lib/libc/alpha/gen/fpgetround.c b/lib/libc/alpha/gen/fpgetround.c
index 70de648..1fd96b2 100644
--- a/lib/libc/alpha/gen/fpgetround.c
+++ b/lib/libc/alpha/gen/fpgetround.c
@@ -41,11 +41,12 @@ __FBSDID("$FreeBSD$");
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);
}
diff --git a/lib/libc/alpha/gen/fpgetsticky.c b/lib/libc/alpha/gen/fpgetsticky.c
index 2cca07d..7586eb4 100644
--- a/lib/libc/alpha/gen/fpgetsticky.c
+++ b/lib/libc/alpha/gen/fpgetsticky.c
@@ -41,11 +41,12 @@ __FBSDID("$FreeBSD$");
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);
}
diff --git a/lib/libc/alpha/gen/fpsetround.c b/lib/libc/alpha/gen/fpsetround.c
index 627aca96..8e994c7 100644
--- a/lib/libc/alpha/gen/fpsetround.c
+++ b/lib/libc/alpha/gen/fpsetround.c
@@ -42,17 +42,20 @@ fp_rnd_t
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);
}
diff --git a/lib/libc/alpha/gen/fpsetsticky.c b/lib/libc/alpha/gen/fpsetsticky.c
index 02af77a..698109f 100644
--- a/lib/libc/alpha/gen/fpsetsticky.c
+++ b/lib/libc/alpha/gen/fpsetsticky.c
@@ -42,16 +42,20 @@ fp_except_t
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);
OpenPOWER on IntegriCloud