diff options
author | Joseph Myers <joseph@codesourcery.com> | 2015-03-12 18:43:21 +0000 |
---|---|---|
committer | Joseph Myers <joseph@codesourcery.com> | 2015-03-12 18:43:21 +0000 |
commit | 7d67a196b6548562070ac11fc673c0d3d263d846 (patch) | |
tree | 34b3481a8038d6756a4a652951847cb04a2b78dd /soft-fp/soft-fp.h | |
parent | af85ebcdf7a754d3d3d3d26ba8250ab58310f535 (diff) | |
download | glibc-7d67a196b6548562070ac11fc673c0d3d263d846.tar glibc-7d67a196b6548562070ac11fc673c0d3d263d846.tar.gz glibc-7d67a196b6548562070ac11fc673c0d3d263d846.tar.bz2 glibc-7d67a196b6548562070ac11fc673c0d3d263d846.zip |
soft-fp: Define and use _FP_STATIC_ASSERT.
This patch makes soft-fp use static assertions in place of conditional
calls to abort, in places where there are checks for conditions (on
the types for which a macro is used) that the code is not prepared to
handle. The fallback definition of _FP_STATIC_ASSERT (for kernel use
only, as only relevant to compilers not supported for building glibc)
is as in misc/sys/cdefs.h.
This means that soft-fp only ever calls abort for _FP_UNREACHABLE
calls in builds with GCC versions before 4.5. Thus, there is no need
for an abort declaration or <stdlib.h> include, since the kernel code
handles defining abort as a macro itself - and so this avoids any need
for an __KERNEL__ condition on the abort declaration to avoid it
breaking with the kernel's macro definition. That is, this patch is
intended to make glibc's soft-fp code suitable for kernel use with no
kernel-local changes to the soft-fp code needed at all.
Tested for powerpc-nofpu that installed stripped shared libraries are
unchanged by the patch. One explicit <stdlib.h> include had to be
added to a file that was relying on the include from soft-fp.h.
* soft-fp/soft-fp.h (_FP_STATIC_ASSERT): New macro.
[_LIBC]: Do not include <stdlib.h>.
[!_LIBC] (abort): Remove declaration.
* soft-fp/op-2.h (_FP_MUL_MEAT_2_120_240_double): Use
_FP_STATIC_ASSERT instead of conditionally calling abort.
* soft-fp/op-common.h (_FP_FROM_INT): Likewise.
(_FP_EXTEND_CNAN): Likewise.
(FP_TRUNC): Likewise.
(__FP_CLZ): Likewise.
* sysdeps/powerpc/nofpu/flt-rounds.c: Include <stdlib.h>.
Diffstat (limited to 'soft-fp/soft-fp.h')
-rw-r--r-- | soft-fp/soft-fp.h | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/soft-fp/soft-fp.h b/soft-fp/soft-fp.h index b247125a39..3b39336b38 100644 --- a/soft-fp/soft-fp.h +++ b/soft-fp/soft-fp.h @@ -60,6 +60,17 @@ # define _FP_UNREACHABLE abort () #endif +#if ((defined __GNUC__ \ + && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))) \ + || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 201112L)) +# define _FP_STATIC_ASSERT(expr, msg) \ + _Static_assert ((expr), msg) +#else +# define _FP_STATIC_ASSERT(expr, msg) \ + extern int (*__Static_assert_function (void)) \ + [!!sizeof (struct { int __error_if_negative: (expr) ? 2 : -1; })] +#endif + /* In the Linux kernel, some architectures have a single function that uses different kinds of unpacking and packing depending on the instruction being emulated, meaning it is not readily visible to @@ -340,10 +351,4 @@ typedef USItype UHWtype; # endif #endif -#ifdef _LIBC -# include <stdlib.h> -#else -extern void abort (void); -#endif - #endif /* !SOFT_FP_H */ |