From f2c587067a8eb9cf1c8f009262381a6576ba3dd0 Mon Sep 17 00:00:00 2001 From: Alvaro Herrera Date: Wed, 11 Jul 2018 09:09:59 -0400 Subject: [PATCH] Rethink how to get float.h in old Windows API for isnan/isinf MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit We include 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 --- contrib/cube/cube.c | 1 - contrib/jsonb_plperl/jsonb_plperl.c | 1 - contrib/tsm_system_time/tsm_system_time.c | 3 --- src/backend/access/gist/gistproc.c | 1 - src/backend/access/gist/gistutil.c | 1 - src/backend/access/tablesample/bernoulli.c | 3 --- src/backend/access/tablesample/system.c | 3 --- src/backend/optimizer/path/costsize.c | 3 --- src/backend/utils/adt/arrayfuncs.c | 3 --- src/backend/utils/adt/datetime.c | 1 - src/backend/utils/adt/int8.c | 1 - src/backend/utils/adt/nabstime.c | 1 - src/backend/utils/adt/orderedsetaggs.c | 1 - src/backend/utils/adt/selfuncs.c | 1 - src/backend/utils/adt/timestamp.c | 1 - src/backend/utils/misc/help_config.c | 1 - src/include/port/win32_port.h | 7 +++++++ src/interfaces/ecpg/ecpglib/data.c | 1 - src/interfaces/ecpg/ecpglib/execute.c | 1 - src/interfaces/ecpg/pgtypeslib/datetime.c | 1 - src/interfaces/ecpg/pgtypeslib/timestamp.c | 1 - src/port/rint.c | 1 - src/port/snprintf.c | 3 --- src/test/regress/regress.c | 1 - 24 files changed, 7 insertions(+), 35 deletions(-) diff --git a/contrib/cube/cube.c b/contrib/cube/cube.c index 092ef149cf..f02ac24ea1 100644 --- a/contrib/cube/cube.c +++ b/contrib/cube/cube.c @@ -8,7 +8,6 @@ #include "postgres.h" -#include #include #include "access/gist.h" diff --git a/contrib/jsonb_plperl/jsonb_plperl.c b/contrib/jsonb_plperl/jsonb_plperl.c index e847ae5369..79c5f57d8f 100644 --- a/contrib/jsonb_plperl/jsonb_plperl.c +++ b/contrib/jsonb_plperl/jsonb_plperl.c @@ -1,6 +1,5 @@ #include "postgres.h" -#include #include /* Defined by Perl */ diff --git a/contrib/tsm_system_time/tsm_system_time.c b/contrib/tsm_system_time/tsm_system_time.c index f0c220aa4a..249d6f4d46 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 /* for _isnan */ -#endif #include #include "access/relscan.h" diff --git a/src/backend/access/gist/gistproc.c b/src/backend/access/gist/gistproc.c index 97e6dc9910..0536b318cc 100644 --- a/src/backend/access/gist/gistproc.c +++ b/src/backend/access/gist/gistproc.c @@ -17,7 +17,6 @@ */ #include "postgres.h" -#include #include #include "access/gist.h" diff --git a/src/backend/access/gist/gistutil.c b/src/backend/access/gist/gistutil.c index 55cccd247a..12804c321c 100644 --- a/src/backend/access/gist/gistutil.c +++ b/src/backend/access/gist/gistutil.c @@ -13,7 +13,6 @@ */ #include "postgres.h" -#include #include #include "access/gist_private.h" diff --git a/src/backend/access/tablesample/bernoulli.c b/src/backend/access/tablesample/bernoulli.c index 1f2a933935..fba62e7b16 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 /* for _isnan */ -#endif #include #include "access/hash.h" diff --git a/src/backend/access/tablesample/system.c b/src/backend/access/tablesample/system.c index f888e04f40..4d937b4258 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 /* for _isnan */ -#endif #include #include "access/hash.h" diff --git a/src/backend/optimizer/path/costsize.c b/src/backend/optimizer/path/costsize.c index a2a7e0c520..a6811e0338 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 /* for _isnan */ -#endif #include #include "access/amapi.h" diff --git a/src/backend/utils/adt/arrayfuncs.c b/src/backend/utils/adt/arrayfuncs.c index 0cbdbe5587..0c6c9da253 100644 --- a/src/backend/utils/adt/arrayfuncs.c +++ b/src/backend/utils/adt/arrayfuncs.c @@ -15,9 +15,6 @@ #include "postgres.h" #include -#ifdef _MSC_VER -#include /* for _isnan */ -#endif #include #include "access/hash.h" diff --git a/src/backend/utils/adt/datetime.c b/src/backend/utils/adt/datetime.c index 979f6fd7b2..017cc1a7b1 100644 --- a/src/backend/utils/adt/datetime.c +++ b/src/backend/utils/adt/datetime.c @@ -15,7 +15,6 @@ #include "postgres.h" #include -#include #include #include diff --git a/src/backend/utils/adt/int8.c b/src/backend/utils/adt/int8.c index 96686ccb2c..73798e7796 100644 --- a/src/backend/utils/adt/int8.c +++ b/src/backend/utils/adt/int8.c @@ -14,7 +14,6 @@ #include "postgres.h" #include -#include /* for _isnan */ #include #include diff --git a/src/backend/utils/adt/nabstime.c b/src/backend/utils/adt/nabstime.c index fae97135db..6ecb41b98f 100644 --- a/src/backend/utils/adt/nabstime.c +++ b/src/backend/utils/adt/nabstime.c @@ -17,7 +17,6 @@ #include "postgres.h" #include -#include #include #include #include diff --git a/src/backend/utils/adt/orderedsetaggs.c b/src/backend/utils/adt/orderedsetaggs.c index 5867f3df07..be9422dcfb 100644 --- a/src/backend/utils/adt/orderedsetaggs.c +++ b/src/backend/utils/adt/orderedsetaggs.c @@ -14,7 +14,6 @@ */ #include "postgres.h" -#include #include #include "catalog/pg_aggregate.h" diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c index 4b08cdb721..f1c78ffb65 100644 --- a/src/backend/utils/adt/selfuncs.c +++ b/src/backend/utils/adt/selfuncs.c @@ -98,7 +98,6 @@ #include "postgres.h" #include -#include #include #include "access/brin.h" diff --git a/src/backend/utils/adt/timestamp.c b/src/backend/utils/adt/timestamp.c index 1d75caebe1..b98036f200 100644 --- a/src/backend/utils/adt/timestamp.c +++ b/src/backend/utils/adt/timestamp.c @@ -17,7 +17,6 @@ #include #include -#include #include #include diff --git a/src/backend/utils/misc/help_config.c b/src/backend/utils/misc/help_config.c index 25f5c82804..871c535756 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 #include #include diff --git a/src/include/port/win32_port.h b/src/include/port/win32_port.h index d31c28f7d4..b398cd3b97 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 , but MSVC older than + * 2013 does not have them there. It does have _fpclass() and _isnan(), but + * they're in , 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 #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 bd8553f1f5..f3d326a50b 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 #include #include "ecpgtype.h" diff --git a/src/interfaces/ecpg/ecpglib/execute.c b/src/interfaces/ecpg/ecpglib/execute.c index c1b44d36f2..6f6819a8f4 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 #include #include "catalog/pg_type_d.h" diff --git a/src/interfaces/ecpg/pgtypeslib/datetime.c b/src/interfaces/ecpg/pgtypeslib/datetime.c index 1e692a5f9e..ed321febf2 100644 --- a/src/interfaces/ecpg/pgtypeslib/datetime.c +++ b/src/interfaces/ecpg/pgtypeslib/datetime.c @@ -4,7 +4,6 @@ #include #include -#include #include #include "extern.h" diff --git a/src/interfaces/ecpg/pgtypeslib/timestamp.c b/src/interfaces/ecpg/pgtypeslib/timestamp.c index abccc268dc..4cd4fe2da2 100644 --- a/src/interfaces/ecpg/pgtypeslib/timestamp.c +++ b/src/interfaces/ecpg/pgtypeslib/timestamp.c @@ -4,7 +4,6 @@ #include "postgres_fe.h" #include -#include #include #include diff --git a/src/port/rint.c b/src/port/rint.c index d27fdfa6b4..d59d9ab774 100644 --- a/src/port/rint.c +++ b/src/port/rint.c @@ -12,7 +12,6 @@ */ #include "c.h" -#include #include /* diff --git a/src/port/snprintf.c b/src/port/snprintf.c index 8358425980..a184134ee6 100644 --- a/src/port/snprintf.c +++ b/src/port/snprintf.c @@ -33,9 +33,6 @@ #include "c.h" #include -#ifdef _MSC_VER -#include /* for _isnan */ -#endif #include #include #ifndef WIN32 diff --git a/src/test/regress/regress.c b/src/test/regress/regress.c index 7060b6fbf3..97a50f30e7 100644 --- a/src/test/regress/regress.c +++ b/src/test/regress/regress.c @@ -16,7 +16,6 @@ #include "postgres.h" -#include #include #include -- 2.40.0