diff options
author | des <des@FreeBSD.org> | 2004-03-16 20:42:02 +0000 |
---|---|---|
committer | des <des@FreeBSD.org> | 2004-03-16 20:42:02 +0000 |
commit | ce346529a392bdc70b527967b64de371a411c397 (patch) | |
tree | 6f573f40ecc689ac27427614841b8f02fedfd30e /lib/libc/alpha/gen/fpsetround.c | |
parent | ffa157ec1e6e53fb7cdd4737c35288e138bb357d (diff) | |
download | FreeBSD-src-ce346529a392bdc70b527967b64de371a411c397.zip FreeBSD-src-ce346529a392bdc70b527967b64de371a411c397.tar.gz |
Use unions to avoid violating C99 strict aliasing rules.
Diffstat (limited to 'lib/libc/alpha/gen/fpsetround.c')
-rw-r--r-- | lib/libc/alpha/gen/fpsetround.c | 13 |
1 files changed, 8 insertions, 5 deletions
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); } |