Date: Fri, 26 Feb 2016 20:38:24 +0000 (UTC) From: Nathan Whitehorn <nwhitehorn@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r296113 - in head/lib/libc: powerpc powerpc/gen powerpc64 powerpc64/gen Message-ID: <201602262038.u1QKcOjl003893@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: nwhitehorn Date: Fri Feb 26 20:38:23 2016 New Revision: 296113 URL: https://svnweb.freebsd.org/changeset/base/296113 Log: Make unions in PowerPC libc endian-safe. Modified: head/lib/libc/powerpc/_fpmath.h head/lib/libc/powerpc/gen/infinity.c head/lib/libc/powerpc64/_fpmath.h head/lib/libc/powerpc64/gen/infinity.c Modified: head/lib/libc/powerpc/_fpmath.h ============================================================================== --- head/lib/libc/powerpc/_fpmath.h Fri Feb 26 20:33:32 2016 (r296112) +++ head/lib/libc/powerpc/_fpmath.h Fri Feb 26 20:38:23 2016 (r296113) @@ -29,10 +29,17 @@ union IEEEl2bits { long double e; struct { +#if _BYTE_ORDER == _LITTLE_ENDIAN + unsigned int manl :32; + unsigned int manh :20; + unsigned int exp :11; + unsigned int sign :1; +#else /* _BYTE_ORDER == _LITTLE_ENDIAN */ unsigned int sign :1; unsigned int exp :11; unsigned int manh :20; unsigned int manl :32; +#endif } bits; }; Modified: head/lib/libc/powerpc/gen/infinity.c ============================================================================== --- head/lib/libc/powerpc/gen/infinity.c Fri Feb 26 20:33:32 2016 (r296112) +++ head/lib/libc/powerpc/gen/infinity.c Fri Feb 26 20:38:23 2016 (r296113) @@ -11,7 +11,20 @@ __FBSDID("$FreeBSD$"); #include <math.h> /* bytes for +Infinity on powerpc */ -const union __infinity_un __infinity = { { 0x7f, 0xf0, 0, 0, 0, 0, 0, 0 } }; +const union __infinity_un __infinity = { +#if BYTE_ORDER == BIG_ENDIAN + { 0x7f, 0xf0, 0, 0, 0, 0, 0, 0 } +#else + { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f } +#endif +}; /* bytes for NaN */ -const union __nan_un __nan = { { 0xff, 0xc0, 0, 0 } }; +const union __nan_un __nan = { +#if BYTE_ORDER == BIG_ENDIAN + {0xff, 0xc0, 0, 0} +#else + { 0, 0, 0xc0, 0xff } +#endif +}; + Modified: head/lib/libc/powerpc64/_fpmath.h ============================================================================== --- head/lib/libc/powerpc64/_fpmath.h Fri Feb 26 20:33:32 2016 (r296112) +++ head/lib/libc/powerpc64/_fpmath.h Fri Feb 26 20:38:23 2016 (r296113) @@ -29,10 +29,17 @@ union IEEEl2bits { long double e; struct { +#if _BYTE_ORDER == _LITTLE_ENDIAN + unsigned int manl :32; + unsigned int manh :20; + unsigned int exp :11; + unsigned int sign :1; +#else /* _BYTE_ORDER == _LITTLE_ENDIAN */ unsigned int sign :1; unsigned int exp :11; unsigned int manh :20; unsigned int manl :32; +#endif } bits; }; Modified: head/lib/libc/powerpc64/gen/infinity.c ============================================================================== --- head/lib/libc/powerpc64/gen/infinity.c Fri Feb 26 20:33:32 2016 (r296112) +++ head/lib/libc/powerpc64/gen/infinity.c Fri Feb 26 20:38:23 2016 (r296113) @@ -11,7 +11,20 @@ __FBSDID("$FreeBSD$"); #include <math.h> /* bytes for +Infinity on powerpc */ -const union __infinity_un __infinity = { { 0x7f, 0xf0, 0, 0, 0, 0, 0, 0 } }; +const union __infinity_un __infinity = { +#if BYTE_ORDER == BIG_ENDIAN + { 0x7f, 0xf0, 0, 0, 0, 0, 0, 0 } +#else + { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f } +#endif +}; /* bytes for NaN */ -const union __nan_un __nan = { { 0xff, 0xc0, 0, 0 } }; +const union __nan_un __nan = { +#if BYTE_ORDER == BIG_ENDIAN + {0xff, 0xc0, 0, 0} +#else + { 0, 0, 0xc0, 0xff } +#endif +}; +
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201602262038.u1QKcOjl003893>