coverity appeasement
[minix.git] / lib / libc / gen / infinityl_ieee754.c
blob7506faac07e02c01ade1f553a806a75ee6d71b5e
1 /* $NetBSD: infinityl_ieee754.c,v 1.1 2011/01/17 23:53:03 matt Exp $ */
3 /*
4 * IEEE-compatible infinityl.c for 64-bit or 128-bit long double format.
5 * This is public domain.
6 */
8 #include <sys/cdefs.h>
9 #if defined(LIBC_SCCS) && !defined(lint)
10 __RCSID("$NetBSD: infinityl_ieee754.c,v 1.1 2011/01/17 23:53:03 matt Exp $");
11 #endif /* LIBC_SCCS and not lint */
13 #include <math.h>
14 #include <machine/endian.h>
15 #include <machine/ieee.h>
17 #ifdef __HAVE_LONG_DOUBLE
18 #define LDBL_EXPBITS EXT_EXPBITS
19 #define LDBL_EXP_INFNAN EXT_EXP_INFNAN
20 #else
21 #define LDBL_EXPBITS DBL_EXPBITS
22 #define LDBL_EXP_INFNAN DBL_EXP_INFNAN
23 #endif
25 #define EXP_INFNAN (LDBL_EXP_INFNAN << (31 - LDBL_EXPBITS))
27 const union __long_double_u __infinityl = { {
28 #if BYTE_ORDER == BIG_ENDIAN
29 [0] = (EXP_INFNAN >> 24) & 0x7f,
30 [1] = (EXP_INFNAN >> 16) & 0xff,
31 [2] = (EXP_INFNAN >> 8) & 0xff,
32 [3] = (EXP_INFNAN >> 0) & 0xff,
33 #else
34 [sizeof(long double)-4] = (EXP_INFNAN >> 0) & 0xff,
35 [sizeof(long double)-3] = (EXP_INFNAN >> 8) & 0xff,
36 [sizeof(long double)-2] = (EXP_INFNAN >> 16) & 0xff,
37 [sizeof(long double)-1] = (EXP_INFNAN >> 24) & 0x7f,
38 #endif
39 } };