Skip to content

Commit

Permalink
Fix soft-fp build warning on sparc about strict aliasing.
Browse files Browse the repository at this point in the history
	* sysdeps/sparc/sparc32/soft-fp/q_neg.c (_Q_neg): Use a union to
	access the quad as both a long double and as a series of 4 words.
  • Loading branch information
David S. Miller committed Dec 19, 2014
1 parent 6d4188d commit 0d4ba8b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
2014-12-19 David S. Miller <davem@davemloft.net>

* sysdeps/sparc/sparc32/soft-fp/q_neg.c (_Q_neg): Use a union to
access the quad as both a long double and as a series of 4 words.

* get-dynamic-info.h (elf_get_dynamic_info): Ignore -Warray-bounds for a
link_map->l_info array access.

Expand Down
17 changes: 11 additions & 6 deletions sysdeps/sparc/sparc32/soft-fp/q_neg.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,25 @@

long double _Q_neg(const long double a)
{
long double c = a;
union {
long double ldbl;
UWtype words[4];
} c;

c.ldbl = a;

#if (__BYTE_ORDER == __BIG_ENDIAN)
((UWtype *)&c)[0] ^= (((UWtype)1) << (W_TYPE_SIZE - 1));
c.words[0] ^= (((UWtype)1) << (W_TYPE_SIZE - 1));
#elif (__BYTE_ORDER == __LITTLE_ENDIAN) && (W_TYPE_SIZE == 64)
((UWtype *)&c)[1] ^= (((UWtype)1) << (W_TYPE_SIZE - 1));
c.words[1] ^= (((UWtype)1) << (W_TYPE_SIZE - 1));
#elif (__BYTE_ORDER == __LITTLE_ENDIAN) && (W_TYPE_SIZE == 32)
((UWtype *)&c)[3] ^= (((UWtype)1) << (W_TYPE_SIZE - 1));
c.words[3] ^= (((UWtype)1) << (W_TYPE_SIZE - 1));
#else
FP_DECL_Q(A); FP_DECL_Q(C);

FP_UNPACK_RAW_Q(A, a);
FP_NEG_Q(C, A);
FP_PACK_RAW_Q(c, C);
FP_PACK_RAW_Q(c.ldbl, C);
#endif
return c;
return c.ldbl;
}

0 comments on commit 0d4ba8b

Please sign in to comment.