summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlvaro Herrera2018-07-11 13:09:59 +0000
committerAlvaro Herrera2018-07-11 13:11:48 +0000
commitf2c587067a8eb9cf1c8f009262381a6576ba3dd0 (patch)
tree187b568af528038ae94f9606b3c0c8d0778cfdee
parenta01d0fa1d889cc2003e1941e8b98707c4d701ba9 (diff)
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 cec8394b5ccd), 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
-rw-r--r--contrib/cube/cube.c1
-rw-r--r--contrib/jsonb_plperl/jsonb_plperl.c1
-rw-r--r--contrib/tsm_system_time/tsm_system_time.c3
-rw-r--r--src/backend/access/gist/gistproc.c1
-rw-r--r--src/backend/access/gist/gistutil.c1
-rw-r--r--src/backend/access/tablesample/bernoulli.c3
-rw-r--r--src/backend/access/tablesample/system.c3
-rw-r--r--src/backend/optimizer/path/costsize.c3
-rw-r--r--src/backend/utils/adt/arrayfuncs.c3
-rw-r--r--src/backend/utils/adt/datetime.c1
-rw-r--r--src/backend/utils/adt/int8.c1
-rw-r--r--src/backend/utils/adt/nabstime.c1
-rw-r--r--src/backend/utils/adt/orderedsetaggs.c1
-rw-r--r--src/backend/utils/adt/selfuncs.c1
-rw-r--r--src/backend/utils/adt/timestamp.c1
-rw-r--r--src/backend/utils/misc/help_config.c1
-rw-r--r--src/include/port/win32_port.h7
-rw-r--r--src/interfaces/ecpg/ecpglib/data.c1
-rw-r--r--src/interfaces/ecpg/ecpglib/execute.c1
-rw-r--r--src/interfaces/ecpg/pgtypeslib/datetime.c1
-rw-r--r--src/interfaces/ecpg/pgtypeslib/timestamp.c1
-rw-r--r--src/port/rint.c1
-rw-r--r--src/port/snprintf.c3
-rw-r--r--src/test/regress/regress.c1
24 files changed, 7 insertions, 35 deletions
diff --git a/contrib/cube/cube.c b/contrib/cube/cube.c
index 092ef149cfa..f02ac24ea18 100644
--- a/contrib/cube/cube.c
+++ b/contrib/cube/cube.c
@@ -8,7 +8,6 @@
#include "postgres.h"
-#include <float.h>
#include <math.h>
#include "access/gist.h"
diff --git a/contrib/jsonb_plperl/jsonb_plperl.c b/contrib/jsonb_plperl/jsonb_plperl.c
index e847ae53699..79c5f57d8fd 100644
--- a/contrib/jsonb_plperl/jsonb_plperl.c
+++ b/contrib/jsonb_plperl/jsonb_plperl.c
@@ -1,6 +1,5 @@
#include "postgres.h"
-#include <float.h>
#include <math.h>
/* Defined by Perl */
diff --git a/contrib/tsm_system_time/tsm_system_time.c b/contrib/tsm_system_time/tsm_system_time.c
index f0c220aa4ac..249d6f4d463 100644
--- a/contrib/tsm_system_time/tsm_system_time.c
+++ b/contrib/tsm_system_time/tsm_system_time.c
@@ -24,9 +24,6 @@
#include "postgres.h"
-#ifdef _MSC_VER
-#include <float.h> /* for _isnan */
-#endif
#include <math.h>
#include "access/relscan.h"
diff --git a/src/backend/access/gist/gistproc.c b/src/backend/access/gist/gistproc.c
index 97e6dc99100..0536b318ccb 100644
--- a/src/backend/access/gist/gistproc.c
+++ b/src/backend/access/gist/gistproc.c
@@ -17,7 +17,6 @@
*/
#include "postgres.h"
-#include <float.h>
#include <math.h>
#include "access/gist.h"
diff --git a/src/backend/access/gist/gistutil.c b/src/backend/access/gist/gistutil.c
index 55cccd247a0..12804c321c2 100644
--- a/src/backend/access/gist/gistutil.c
+++ b/src/backend/access/gist/gistutil.c
@@ -13,7 +13,6 @@
*/
#include "postgres.h"
-#include <float.h>
#include <math.h>
#include "access/gist_private.h"
diff --git a/src/backend/access/tablesample/bernoulli.c b/src/backend/access/tablesample/bernoulli.c
index 1f2a9339351..fba62e7b167 100644
--- a/src/backend/access/tablesample/bernoulli.c
+++ b/src/backend/access/tablesample/bernoulli.c
@@ -24,9 +24,6 @@
#include "postgres.h"
-#ifdef _MSC_VER
-#include <float.h> /* for _isnan */
-#endif
#include <math.h>
#include "access/hash.h"
diff --git a/src/backend/access/tablesample/system.c b/src/backend/access/tablesample/system.c
index f888e04f40c..4d937b4258a 100644
--- a/src/backend/access/tablesample/system.c
+++ b/src/backend/access/tablesample/system.c
@@ -24,9 +24,6 @@
#include "postgres.h"
-#ifdef _MSC_VER
-#include <float.h> /* for _isnan */
-#endif
#include <math.h>
#include "access/hash.h"
diff --git a/src/backend/optimizer/path/costsize.c b/src/backend/optimizer/path/costsize.c
index a2a7e0c5202..a6811e03384 100644
--- a/src/backend/optimizer/path/costsize.c
+++ b/src/backend/optimizer/path/costsize.c
@@ -71,9 +71,6 @@
#include "postgres.h"
-#ifdef _MSC_VER
-#include <float.h> /* for _isnan */
-#endif
#include <math.h>
#include "access/amapi.h"
diff --git a/src/backend/utils/adt/arrayfuncs.c b/src/backend/utils/adt/arrayfuncs.c
index 0cbdbe5587e..0c6c9da253e 100644
--- a/src/backend/utils/adt/arrayfuncs.c
+++ b/src/backend/utils/adt/arrayfuncs.c
@@ -15,9 +15,6 @@
#include "postgres.h"
#include <ctype.h>
-#ifdef _MSC_VER
-#include <float.h> /* for _isnan */
-#endif
#include <math.h>
#include "access/hash.h"
diff --git a/src/backend/utils/adt/datetime.c b/src/backend/utils/adt/datetime.c
index 979f6fd7b22..017cc1a7b15 100644
--- a/src/backend/utils/adt/datetime.c
+++ b/src/backend/utils/adt/datetime.c
@@ -15,7 +15,6 @@
#include "postgres.h"
#include <ctype.h>
-#include <float.h>
#include <limits.h>
#include <math.h>
diff --git a/src/backend/utils/adt/int8.c b/src/backend/utils/adt/int8.c
index 96686ccb2c9..73798e7796b 100644
--- a/src/backend/utils/adt/int8.c
+++ b/src/backend/utils/adt/int8.c
@@ -14,7 +14,6 @@
#include "postgres.h"
#include <ctype.h>
-#include <float.h> /* for _isnan */
#include <limits.h>
#include <math.h>
diff --git a/src/backend/utils/adt/nabstime.c b/src/backend/utils/adt/nabstime.c
index fae97135dbb..6ecb41b98f5 100644
--- a/src/backend/utils/adt/nabstime.c
+++ b/src/backend/utils/adt/nabstime.c
@@ -17,7 +17,6 @@
#include "postgres.h"
#include <ctype.h>
-#include <float.h>
#include <limits.h>
#include <math.h>
#include <time.h>
diff --git a/src/backend/utils/adt/orderedsetaggs.c b/src/backend/utils/adt/orderedsetaggs.c
index 5867f3df070..be9422dcfb6 100644
--- a/src/backend/utils/adt/orderedsetaggs.c
+++ b/src/backend/utils/adt/orderedsetaggs.c
@@ -14,7 +14,6 @@
*/
#include "postgres.h"
-#include <float.h>
#include <math.h>
#include "catalog/pg_aggregate.h"
diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c
index 4b08cdb721a..f1c78ffb656 100644
--- a/src/backend/utils/adt/selfuncs.c
+++ b/src/backend/utils/adt/selfuncs.c
@@ -98,7 +98,6 @@
#include "postgres.h"
#include <ctype.h>
-#include <float.h>
#include <math.h>
#include "access/brin.h"
diff --git a/src/backend/utils/adt/timestamp.c b/src/backend/utils/adt/timestamp.c
index 1d75caebe17..b98036f200b 100644
--- a/src/backend/utils/adt/timestamp.c
+++ b/src/backend/utils/adt/timestamp.c
@@ -17,7 +17,6 @@
#include <ctype.h>
#include <math.h>
-#include <float.h>
#include <limits.h>
#include <sys/time.h>
diff --git a/src/backend/utils/misc/help_config.c b/src/backend/utils/misc/help_config.c
index 25f5c828046..871c5357568 100644
--- a/src/backend/utils/misc/help_config.c
+++ b/src/backend/utils/misc/help_config.c
@@ -16,7 +16,6 @@
*/
#include "postgres.h"
-#include <float.h>
#include <limits.h>
#include <unistd.h>
diff --git a/src/include/port/win32_port.h b/src/include/port/win32_port.h
index d31c28f7d44..b398cd3b975 100644
--- a/src/include/port/win32_port.h
+++ b/src/include/port/win32_port.h
@@ -502,7 +502,14 @@ typedef unsigned short mode_t;
#define W_OK 2
#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)
+#include <float.h>
#define isinf(x) ((_fpclass(x) == _FPCLASS_PINF) || (_fpclass(x) == _FPCLASS_NINF))
#define isnan(x) _isnan(x)
#endif
diff --git a/src/interfaces/ecpg/ecpglib/data.c b/src/interfaces/ecpg/ecpglib/data.c
index bd8553f1f53..f3d326a50b1 100644
--- a/src/interfaces/ecpg/ecpglib/data.c
+++ b/src/interfaces/ecpg/ecpglib/data.c
@@ -3,7 +3,6 @@
#define POSTGRES_ECPG_INTERNAL
#include "postgres_fe.h"
-#include <float.h>
#include <math.h>
#include "ecpgtype.h"
diff --git a/src/interfaces/ecpg/ecpglib/execute.c b/src/interfaces/ecpg/ecpglib/execute.c
index c1b44d36f2b..6f6819a8f48 100644
--- a/src/interfaces/ecpg/ecpglib/execute.c
+++ b/src/interfaces/ecpg/ecpglib/execute.c
@@ -16,7 +16,6 @@
#define POSTGRES_ECPG_INTERNAL
#include "postgres_fe.h"
-#include <float.h>
#include <math.h>
#include "catalog/pg_type_d.h"
diff --git a/src/interfaces/ecpg/pgtypeslib/datetime.c b/src/interfaces/ecpg/pgtypeslib/datetime.c
index 1e692a5f9ef..ed321febf2b 100644
--- a/src/interfaces/ecpg/pgtypeslib/datetime.c
+++ b/src/interfaces/ecpg/pgtypeslib/datetime.c
@@ -4,7 +4,6 @@
#include <time.h>
#include <ctype.h>
-#include <float.h>
#include <limits.h>
#include "extern.h"
diff --git a/src/interfaces/ecpg/pgtypeslib/timestamp.c b/src/interfaces/ecpg/pgtypeslib/timestamp.c
index abccc268dcc..4cd4fe2da28 100644
--- a/src/interfaces/ecpg/pgtypeslib/timestamp.c
+++ b/src/interfaces/ecpg/pgtypeslib/timestamp.c
@@ -4,7 +4,6 @@
#include "postgres_fe.h"
#include <time.h>
-#include <float.h>
#include <limits.h>
#include <math.h>
diff --git a/src/port/rint.c b/src/port/rint.c
index d27fdfa6b4a..d59d9ab7743 100644
--- a/src/port/rint.c
+++ b/src/port/rint.c
@@ -12,7 +12,6 @@
*/
#include "c.h"
-#include <float.h>
#include <math.h>
/*
diff --git a/src/port/snprintf.c b/src/port/snprintf.c
index 83584259802..a184134ee6b 100644
--- a/src/port/snprintf.c
+++ b/src/port/snprintf.c
@@ -33,9 +33,6 @@
#include "c.h"
#include <ctype.h>
-#ifdef _MSC_VER
-#include <float.h> /* for _isnan */
-#endif
#include <limits.h>
#include <math.h>
#ifndef WIN32
diff --git a/src/test/regress/regress.c b/src/test/regress/regress.c
index 7060b6fbf32..97a50f30e7b 100644
--- a/src/test/regress/regress.c
+++ b/src/test/regress/regress.c
@@ -16,7 +16,6 @@
#include "postgres.h"
-#include <float.h>
#include <math.h>
#include <signal.h>