1193149Sdougb/*-
2135446Strhodes * Copyright (c) 2004 David Schultz <das@FreeBSD.ORG>
3135446Strhodes * All rights reserved.
4193149Sdougb *
5135446Strhodes * Redistribution and use in source and binary forms, with or without
6135446Strhodes * modification, are permitted provided that the following conditions
7135446Strhodes * are met:
8135446Strhodes * 1. Redistributions of source code must retain the above copyright
9135446Strhodes *    notice, this list of conditions and the following disclaimer.
10135446Strhodes * 2. Redistributions in binary form must reproduce the above copyright
11135446Strhodes *    notice, this list of conditions and the following disclaimer in the
12135446Strhodes *    documentation and/or other materials provided with the distribution.
13135446Strhodes *
14135446Strhodes * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15135446Strhodes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16234010Sdougb * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17135446Strhodes * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18135446Strhodes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19135446Strhodes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20135446Strhodes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21135446Strhodes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22135446Strhodes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23135446Strhodes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24135446Strhodes * SUCH DAMAGE.
25135446Strhodes *
26135446Strhodes * $FreeBSD$
27135446Strhodes */
28135446Strhodes
29135446Strhodes#include <math.h>
30135446Strhodes
31135446Strhodes#include "fpmath.h"
32135446Strhodes
33135446Strhodes/*
34135446Strhodes * XXX These routines belong in libm, but they must remain in libc for
35135446Strhodes *     binary compat until we can bump libm's major version number.
36135446Strhodes */
37135446Strhodes
38__weak_reference(__isinf, isinf);
39
40int
41__isinf(double d)
42{
43	union IEEEd2bits u;
44
45	u.d = d;
46	return (u.bits.exp == 2047 && u.bits.manl == 0 && u.bits.manh == 0);
47}
48
49int
50__isinff(float f)
51{
52	union IEEEf2bits u;
53
54	u.f = f;
55	return (u.bits.exp == 255 && u.bits.man == 0);
56}
57
58int
59__isinfl(long double e)
60{
61	union IEEEl2bits u;
62
63	u.e = e;
64	mask_nbit_l(u);
65#ifndef __alpha__
66	return (u.bits.exp == 32767 && u.bits.manl == 0 && u.bits.manh == 0);
67#else
68	return (u.bits.exp == 2047 && u.bits.manl == 0 && u.bits.manh == 0);
69#endif
70}
71