Update spec to require automake >= 1.13
[platform/upstream/gawk.git] / floatmagic.h
1 /*
2  * floatmagic.h -- Definitions of isnan and isinf for gawk. 
3  */
4
5 /* 
6  * Copyright (C) 2009 the Free Software Foundation, Inc.
7  * 
8  * This file is part of GAWK, the GNU implementation of the
9  * AWK Programming Language.
10  * 
11  * GAWK is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 3 of the License, or
14  * (at your option) any later version.
15  * 
16  * GAWK is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  * 
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
24  */
25
26 /*
27  * NOTE: <math.h> MUST be included before this file. Also <config.h>.
28  *
29  * These definitions are taken from the Autoconf 2.63 manual. Not pretty.
30  */
31
32 #ifndef HAVE_ISNAN
33 #ifndef isnan
34 # define isnan(x) \
35     (sizeof (x) == sizeof (long double) ? isnan_ld (x) \
36      : sizeof (x) == sizeof (double) ? isnan_d (x) \
37      : isnan_f (x))
38 static inline int isnan_f  (float       x) { return x != x; }
39 static inline int isnan_d  (double      x) { return x != x; }
40 static inline int isnan_ld (long double x) { return x != x; }
41 #endif
42 #endif
43
44 #ifndef HAVE_ISINF
45 #ifndef isinf
46 # define isinf(x) \
47     (sizeof (x) == sizeof (long double) ? isinf_ld (x) \
48      : sizeof (x) == sizeof (double) ? isinf_d (x) \
49      : isinf_f (x))
50 static inline int isinf_f  (float       x) { return isnan (x - x); }
51 static inline int isinf_d  (double      x) { return isnan (x - x); }
52 static inline int isinf_ld (long double x) { return isnan (x - x); }
53 #endif
54 #endif