summaryrefslogtreecommitdiffstats
path: root/lib/libc/sparc64
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/sparc64
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/sparc64')
-rw-r--r--lib/libc/sparc64/fpu/fpu_qp.c31
1 files changed, 14 insertions, 17 deletions
diff --git a/lib/libc/sparc64/fpu/fpu_qp.c b/lib/libc/sparc64/fpu/fpu_qp.c
index 88df045..9e3bedc 100644
--- a/lib/libc/sparc64/fpu/fpu_qp.c
+++ b/lib/libc/sparc64/fpu/fpu_qp.c
@@ -57,10 +57,9 @@ void \
_Qp_ ## qname ## toq(u_int *c, ntype n) \
{ \
struct fpemu fe; \
- atype *a; \
+ union { atype a[2]; ntype n; } u = { .n = n }; \
__asm __volatile("stx %%fsr, %0" : "=m" (fe.fe_fsr) :); \
- a = (atype *)&n; \
- fe.fe_f1.fp_sign = a[0] >> 31; \
+ fe.fe_f1.fp_sign = u.a[0] >> 31; \
fe.fe_f1.fp_sticky = 0; \
fe.fe_f1.fp_class = __fpu_ ## fname ## tof(&fe.fe_f1, __VA_ARGS__); \
c[0] = __fpu_ftoq(&fe, &fe.fe_f1, c); \
@@ -72,15 +71,13 @@ type \
_Qp_qto ## qname(u_int *c) \
{ \
struct fpemu fe; \
- u_int *a; \
- type n; \
+ union { u_int a; type n; } u; \
__asm __volatile("stx %%fsr, %0" : "=m" (fe.fe_fsr) :); \
- a = (u_int *)&n; \
fe.fe_f1.fp_sign = c[0] >> 31; \
fe.fe_f1.fp_sticky = 0; \
fe.fe_f1.fp_class = __fpu_qtof(&fe.fe_f1, c[0], c[1], c[2], c[3]); \
- a[0] = __fpu_fto ## fname(&fe, &fe.fe_f1, ## __VA_ARGS__); \
- return (n); \
+ u.a = __fpu_fto ## fname(&fe, &fe.fe_f1, ## __VA_ARGS__); \
+ return (u.n); \
}
#define FCC_EQ(fcc) ((fcc) == FSR_CC_EQ)
@@ -126,19 +123,19 @@ _QP_OP(div)
_QP_OP(mul)
_QP_OP(sub)
-_QP_TTOQ(d, d, double, u_int, a[0], a[1])
-_QP_TTOQ(i, i, int, u_int, a[0])
-_QP_TTOQ(s, s, float, u_int, a[0])
-_QP_TTOQ(x, x, long, u_long, a[0])
-_QP_TTOQ(ui, i, u_int, u_int, a[0])
-_QP_TTOQ(ux, x, u_long, u_long, a[0])
+_QP_TTOQ(d, d, double, u_int, u.a[0], u.a[1])
+_QP_TTOQ(i, i, int, u_int, u.a[0])
+_QP_TTOQ(s, s, float, u_int, u.a[0])
+_QP_TTOQ(x, x, long, u_long, u.a[0])
+_QP_TTOQ(ui, i, u_int, u_int, u.a[0])
+_QP_TTOQ(ux, x, u_long, u_long, u.a[0])
-_QP_QTOT(d, d, double, a)
+_QP_QTOT(d, d, double, &u.a)
_QP_QTOT(i, i, int)
_QP_QTOT(s, s, float)
-_QP_QTOT(x, x, long, a)
+_QP_QTOT(x, x, long, &u.a)
_QP_QTOT(ui, i, u_int)
-_QP_QTOT(ux, x, u_long, a)
+_QP_QTOT(ux, x, u_long, &u.a)
_QP_CMP(eq, 0, FCC_EQ)
_QP_CMP(ge, 0, FCC_GE)
OpenPOWER on IntegriCloud