Commit f2c58706 authored by Alvaro Herrera's avatar Alvaro Herrera

Rethink how to get float.h in old Windows API for isnan/isinf

We include <float.h> in every place that needs isnan(), because MSVC
used to require it.  However, since MSVC 2013 that's no longer necessary
(cf. commit cec8394b), so we can retire the inclusion to a
version-specific stanza in win32_port.h, where it doesn't need to
pollute random .c files.  The header is of course still needed in a few
places for other reasons.

I (Álvaro) removed float.h from a few more files than in Emre's original
patch.  This doesn't break the build in my system, but we'll see what
the buildfarm has to say about it all.

Author: Emre Hasegeli
Discussion: https://postgr.es/m/CAE2gYzyc0+5uG+Cd9-BSL7NKC8LSHLNg1Aq2=8ubjnUwut4_iw@mail.gmail.com
parent a01d0fa1
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#include "postgres.h" #include "postgres.h"
#include <float.h>
#include <math.h> #include <math.h>
#include "access/gist.h" #include "access/gist.h"
......
#include "postgres.h" #include "postgres.h"
#include <float.h>
#include <math.h> #include <math.h>
/* Defined by Perl */ /* Defined by Perl */
......
...@@ -24,9 +24,6 @@ ...@@ -24,9 +24,6 @@
#include "postgres.h" #include "postgres.h"
#ifdef _MSC_VER
#include <float.h> /* for _isnan */
#endif
#include <math.h> #include <math.h>
#include "access/relscan.h" #include "access/relscan.h"
......
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
*/ */
#include "postgres.h" #include "postgres.h"
#include <float.h>
#include <math.h> #include <math.h>
#include "access/gist.h" #include "access/gist.h"
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
*/ */
#include "postgres.h" #include "postgres.h"
#include <float.h>
#include <math.h> #include <math.h>
#include "access/gist_private.h" #include "access/gist_private.h"
......
...@@ -24,9 +24,6 @@ ...@@ -24,9 +24,6 @@
#include "postgres.h" #include "postgres.h"
#ifdef _MSC_VER
#include <float.h> /* for _isnan */
#endif
#include <math.h> #include <math.h>
#include "access/hash.h" #include "access/hash.h"
......
...@@ -24,9 +24,6 @@ ...@@ -24,9 +24,6 @@
#include "postgres.h" #include "postgres.h"
#ifdef _MSC_VER
#include <float.h> /* for _isnan */
#endif
#include <math.h> #include <math.h>
#include "access/hash.h" #include "access/hash.h"
......
...@@ -71,9 +71,6 @@ ...@@ -71,9 +71,6 @@
#include "postgres.h" #include "postgres.h"
#ifdef _MSC_VER
#include <float.h> /* for _isnan */
#endif
#include <math.h> #include <math.h>
#include "access/amapi.h" #include "access/amapi.h"
......
...@@ -15,9 +15,6 @@ ...@@ -15,9 +15,6 @@
#include "postgres.h" #include "postgres.h"
#include <ctype.h> #include <ctype.h>
#ifdef _MSC_VER
#include <float.h> /* for _isnan */
#endif
#include <math.h> #include <math.h>
#include "access/hash.h" #include "access/hash.h"
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
#include "postgres.h" #include "postgres.h"
#include <ctype.h> #include <ctype.h>
#include <float.h>
#include <limits.h> #include <limits.h>
#include <math.h> #include <math.h>
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
#include "postgres.h" #include "postgres.h"
#include <ctype.h> #include <ctype.h>
#include <float.h> /* for _isnan */
#include <limits.h> #include <limits.h>
#include <math.h> #include <math.h>
......
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
#include "postgres.h" #include "postgres.h"
#include <ctype.h> #include <ctype.h>
#include <float.h>
#include <limits.h> #include <limits.h>
#include <math.h> #include <math.h>
#include <time.h> #include <time.h>
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
*/ */
#include "postgres.h" #include "postgres.h"
#include <float.h>
#include <math.h> #include <math.h>
#include "catalog/pg_aggregate.h" #include "catalog/pg_aggregate.h"
......
...@@ -98,7 +98,6 @@ ...@@ -98,7 +98,6 @@
#include "postgres.h" #include "postgres.h"
#include <ctype.h> #include <ctype.h>
#include <float.h>
#include <math.h> #include <math.h>
#include "access/brin.h" #include "access/brin.h"
......
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
#include <ctype.h> #include <ctype.h>
#include <math.h> #include <math.h>
#include <float.h>
#include <limits.h> #include <limits.h>
#include <sys/time.h> #include <sys/time.h>
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
*/ */
#include "postgres.h" #include "postgres.h"
#include <float.h>
#include <limits.h> #include <limits.h>
#include <unistd.h> #include <unistd.h>
......
...@@ -502,7 +502,14 @@ typedef unsigned short mode_t; ...@@ -502,7 +502,14 @@ typedef unsigned short mode_t;
#define W_OK 2 #define W_OK 2
#define R_OK 4 #define R_OK 4
/*
* isinf() and isnan() should per spec be in <math.h>, but MSVC older than
* 2013 does not have them there. It does have _fpclass() and _isnan(), but
* they're in <float.h>, so include that here even though it means float.h
* percolates to our whole tree. Recent versions don't require any of this.
*/
#if (_MSC_VER < 1800) #if (_MSC_VER < 1800)
#include <float.h>
#define isinf(x) ((_fpclass(x) == _FPCLASS_PINF) || (_fpclass(x) == _FPCLASS_NINF)) #define isinf(x) ((_fpclass(x) == _FPCLASS_PINF) || (_fpclass(x) == _FPCLASS_NINF))
#define isnan(x) _isnan(x) #define isnan(x) _isnan(x)
#endif #endif
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
#define POSTGRES_ECPG_INTERNAL #define POSTGRES_ECPG_INTERNAL
#include "postgres_fe.h" #include "postgres_fe.h"
#include <float.h>
#include <math.h> #include <math.h>
#include "ecpgtype.h" #include "ecpgtype.h"
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
#define POSTGRES_ECPG_INTERNAL #define POSTGRES_ECPG_INTERNAL
#include "postgres_fe.h" #include "postgres_fe.h"
#include <float.h>
#include <math.h> #include <math.h>
#include "catalog/pg_type_d.h" #include "catalog/pg_type_d.h"
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
#include <time.h> #include <time.h>
#include <ctype.h> #include <ctype.h>
#include <float.h>
#include <limits.h> #include <limits.h>
#include "extern.h" #include "extern.h"
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
#include "postgres_fe.h" #include "postgres_fe.h"
#include <time.h> #include <time.h>
#include <float.h>
#include <limits.h> #include <limits.h>
#include <math.h> #include <math.h>
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
*/ */
#include "c.h" #include "c.h"
#include <float.h>
#include <math.h> #include <math.h>
/* /*
......
...@@ -33,9 +33,6 @@ ...@@ -33,9 +33,6 @@
#include "c.h" #include "c.h"
#include <ctype.h> #include <ctype.h>
#ifdef _MSC_VER
#include <float.h> /* for _isnan */
#endif
#include <limits.h> #include <limits.h>
#include <math.h> #include <math.h>
#ifndef WIN32 #ifndef WIN32
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
#include "postgres.h" #include "postgres.h"
#include <float.h>
#include <math.h> #include <math.h>
#include <signal.h> #include <signal.h>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment