]> git.proxmox.com Git - mirror_edk2.git/blame - StdLib/LibC/Main/X64/isnanl.c
EmbeddedPkg: Extend NvVarStoreFormattedLib LIBRARY_CLASS
[mirror_edk2.git] / StdLib / LibC / Main / X64 / isnanl.c
CommitLineData
2aa62f2b 1/* $NetBSD: isnanl.c,v 1.5.16.1 2007/05/07 19:49:07 pavel Exp $ */\r
2\r
3/*\r
4 * Copyright (c) 1992, 1993\r
5 * The Regents of the University of California. All rights reserved.\r
6 *\r
7 * This software was developed by the Computer Systems Engineering group\r
8 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and\r
9 * contributed to Berkeley.\r
10 *\r
11 * Redistribution and use in source and binary forms, with or without\r
12 * modification, are permitted provided that the following conditions\r
13 * are met:\r
14 * 1. Redistributions of source code must retain the above copyright\r
15 * notice, this list of conditions and the following disclaimer.\r
16 * 2. Redistributions in binary form must reproduce the above copyright\r
17 * notice, this list of conditions and the following disclaimer in the\r
18 * documentation and/or other materials provided with the distribution.\r
19 * 3. Neither the name of the University nor the names of its contributors\r
20 * may be used to endorse or promote products derived from this software\r
21 * without specific prior written permission.\r
22 *\r
23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND\r
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE\r
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\r
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\r
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\r
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\r
33 * SUCH DAMAGE.\r
34 *\r
35 * from: Header: isinf.c,v 1.1 91/07/08 19:03:34 torek Exp\r
36 */\r
37\r
38#include <sys/EfiCdefs.h>\r
39#if defined(LIBC_SCCS) && !defined(lint)\r
40#if 0\r
41static char sccsid[] = "@(#)isinf.c 8.1 (Berkeley) 6/4/93";\r
42#else\r
43__RCSID("$NetBSD: isnanl.c,v 1.5.16.1 2007/05/07 19:49:07 pavel Exp $");\r
44#endif\r
45#endif /* LIBC_SCCS and not lint */\r
46\r
47#include <machine/ieee.h>\r
48#include <math.h>\r
49\r
50/*\r
51 * 7.12.3.4 isnan - test for a NaN\r
52 * IEEE 754 compatible 80-bit extended-precision Intel 386 version\r
53 */\r
54int\r
55__isnanl(long double x)\r
56{\r
57 union ieee_ext_u u = { 0 };\r
58\r
59 u.extu_ld = x;\r
60\r
61 return (u.extu_ext.ext_exp == EXT_EXP_INFNAN &&\r
62 (u.extu_ext.ext_frach & 0x80000000) != 0 &&\r
63 (u.extu_ext.ext_frach != 0x80000000 || u.extu_ext.ext_fracl != 0));\r
64}\r