1/*	$NetBSD: infinityl.c,v 1.2 2005/06/12 05:21:27 lukem Exp $	*/
2
3/*
4 * IEEE-compatible infinityl.c for 64-bit or 128-bit long double format.
5 * This is public domain.
6 */
7
8#include <sys/cdefs.h>
9#if defined(LIBC_SCCS) && !defined(lint)
10__RCSID("$NetBSD: infinityl.c,v 1.2 2005/06/12 05:21:27 lukem Exp $");
11#endif /* LIBC_SCCS and not lint */
12
13#include <math.h>
14#include <machine/endian.h>
15#include <machine/ieee.h>
16
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
24
25#define	EXP_INFNAN		(LDBL_EXP_INFNAN << (31 - LDBL_EXPBITS))
26
27const 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} };
40