55 lines
1.8 KiB
C
55 lines
1.8 KiB
C
|
/*
|
||
|
* floatmagic.h -- Definitions of isnan and isinf for gawk.
|
||
|
*/
|
||
|
|
||
|
/*
|
||
|
* Copyright (C) 2009 the Free Software Foundation, Inc.
|
||
|
*
|
||
|
* This file is part of GAWK, the GNU implementation of the
|
||
|
* AWK Programming Language.
|
||
|
*
|
||
|
* GAWK is free software; you can redistribute it and/or modify
|
||
|
* it under the terms of the GNU General Public License as published by
|
||
|
* the Free Software Foundation; either version 3 of the License, or
|
||
|
* (at your option) any later version.
|
||
|
*
|
||
|
* GAWK is distributed in the hope that it will be useful,
|
||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
* GNU General Public License for more details.
|
||
|
*
|
||
|
* You should have received a copy of the GNU General Public License
|
||
|
* along with this program; if not, write to the Free Software
|
||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||
|
*/
|
||
|
|
||
|
/*
|
||
|
* NOTE: <math.h> MUST be included before this file. Also <config.h>.
|
||
|
*
|
||
|
* These definitions are taken from the Autoconf 2.63 manual. Not pretty.
|
||
|
*/
|
||
|
|
||
|
#ifndef HAVE_ISNAN
|
||
|
#ifndef isnan
|
||
|
# define isnan(x) \
|
||
|
(sizeof (x) == sizeof (long double) ? isnan_ld (x) \
|
||
|
: sizeof (x) == sizeof (double) ? isnan_d (x) \
|
||
|
: isnan_f (x))
|
||
|
static inline int isnan_f (float x) { return x != x; }
|
||
|
static inline int isnan_d (double x) { return x != x; }
|
||
|
static inline int isnan_ld (long double x) { return x != x; }
|
||
|
#endif
|
||
|
#endif
|
||
|
|
||
|
#ifndef HAVE_ISINF
|
||
|
#ifndef isinf
|
||
|
# define isinf(x) \
|
||
|
(sizeof (x) == sizeof (long double) ? isinf_ld (x) \
|
||
|
: sizeof (x) == sizeof (double) ? isinf_d (x) \
|
||
|
: isinf_f (x))
|
||
|
static inline int isinf_f (float x) { return isnan (x - x); }
|
||
|
static inline int isinf_d (double x) { return isnan (x - x); }
|
||
|
static inline int isinf_ld (long double x) { return isnan (x - x); }
|
||
|
#endif
|
||
|
#endif
|