Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 38d8dce

Browse files
committed
Remove some code for old unsupported versions of MSVC
As of d9dd406, we require MSVC 2013, which means _MSC_VER >= 1800. This means that conditionals about older versions of _MSC_VER can be removed or simplified. Previous code was also in some cases handling MinGW, where _MSC_VER is not defined at all, incorrectly, such as in pg_ctl.c and win32_port.h, leading to some compiler warnings. This should now be handled better. Reviewed-by: Michael Paquier <michael@paquier.xyz>
1 parent a7471bd commit 38d8dce

File tree

12 files changed

+235
-357
lines changed

12 files changed

+235
-357
lines changed

src/backend/utils/adt/pg_locale.c

+2-21
Original file line numberDiff line numberDiff line change
@@ -973,7 +973,7 @@ cache_locale_time(void)
973973
static char *
974974
IsoLocaleName(const char *winlocname)
975975
{
976-
#if (_MSC_VER >= 1400) /* VC8.0 or later */
976+
#ifdef _MSC_VER
977977
static char iso_lc_messages[32];
978978
_locale_t loct = NULL;
979979

@@ -987,7 +987,6 @@ IsoLocaleName(const char *winlocname)
987987
loct = _create_locale(LC_CTYPE, winlocname);
988988
if (loct != NULL)
989989
{
990-
#if (_MSC_VER >= 1700) /* Visual Studio 2012 or later */
991990
size_t rc;
992991
char *hyphen;
993992

@@ -1014,28 +1013,10 @@ IsoLocaleName(const char *winlocname)
10141013
hyphen = strchr(iso_lc_messages, '-');
10151014
if (hyphen)
10161015
*hyphen = '_';
1017-
#else
1018-
char isolang[32],
1019-
isocrty[32];
1020-
LCID lcid;
1021-
1022-
lcid = loct->locinfo->lc_handle[LC_CTYPE];
1023-
if (lcid == 0)
1024-
lcid = MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT);
1025-
_free_locale(loct);
1026-
1027-
if (!GetLocaleInfoA(lcid, LOCALE_SISO639LANGNAME, isolang, sizeof(isolang)))
1028-
return NULL;
1029-
if (!GetLocaleInfoA(lcid, LOCALE_SISO3166CTRYNAME, isocrty, sizeof(isocrty)))
1030-
return NULL;
1031-
snprintf(iso_lc_messages, sizeof(iso_lc_messages) - 1, "%s_%s", isolang, isocrty);
1032-
#endif
10331016
return iso_lc_messages;
10341017
}
1035-
return NULL;
1036-
#else
1018+
#endif /* _MSC_VER */
10371019
return NULL; /* Not supported on this version of msvc/mingw */
1038-
#endif /* _MSC_VER >= 1400 */
10391020
}
10401021
#endif /* WIN32 && LC_MESSAGES */
10411022

src/backend/utils/adt/selfuncs.c

-13
Original file line numberDiff line numberDiff line change
@@ -4092,20 +4092,7 @@ convert_string_datum(Datum value, Oid typid, Oid collid, bool *failure)
40924092
* crashes since it will only give an estimation error and nothing
40934093
* fatal.
40944094
*/
4095-
#if _MSC_VER == 1400 /* VS.Net 2005 */
4096-
4097-
/*
4098-
*
4099-
* http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=99694
4100-
*/
4101-
{
4102-
char x[1];
4103-
4104-
xfrmlen = strxfrm(x, val, 0);
4105-
}
4106-
#else
41074095
xfrmlen = strxfrm(NULL, val, 0);
4108-
#endif
41094096
#ifdef WIN32
41104097

41114098
/*

src/bin/pg_ctl/pg_ctl.c

-31
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,7 @@ static void print_msg(const char *msg);
137137
static void adjust_data_dir(void);
138138

139139
#ifdef WIN32
140-
#if (_MSC_VER >= 1800)
141140
#include <versionhelpers.h>
142-
#else
143-
static bool IsWindowsXPOrGreater(void);
144-
static bool IsWindows7OrGreater(void);
145-
#endif
146141
static bool pgwin32_IsInstalled(SC_HANDLE);
147142
static char *pgwin32_CommandLine(bool);
148143
static void pgwin32_doRegister(void);
@@ -1378,32 +1373,6 @@ do_kill(pgpid_t pid)
13781373

13791374
#ifdef WIN32
13801375

1381-
#if (_MSC_VER < 1800)
1382-
static bool
1383-
IsWindowsXPOrGreater(void)
1384-
{
1385-
OSVERSIONINFO osv;
1386-
1387-
osv.dwOSVersionInfoSize = sizeof(osv);
1388-
1389-
/* Windows XP = Version 5.1 */
1390-
return (!GetVersionEx(&osv) || /* could not get version */
1391-
osv.dwMajorVersion > 5 || (osv.dwMajorVersion == 5 && osv.dwMinorVersion >= 1));
1392-
}
1393-
1394-
static bool
1395-
IsWindows7OrGreater(void)
1396-
{
1397-
OSVERSIONINFO osv;
1398-
1399-
osv.dwOSVersionInfoSize = sizeof(osv);
1400-
1401-
/* Windows 7 = Version 6.0 */
1402-
return (!GetVersionEx(&osv) || /* could not get version */
1403-
osv.dwMajorVersion > 6 || (osv.dwMajorVersion == 6 && osv.dwMinorVersion >= 0));
1404-
}
1405-
#endif
1406-
14071376
static bool
14081377
pgwin32_IsInstalled(SC_HANDLE hSCM)
14091378
{

src/include/pg_config.h.win32

+1-32
Original file line numberDiff line numberDiff line change
@@ -268,14 +268,10 @@
268268
/* #undef HAVE_LONG_INT_64 */
269269

270270
/* Define to 1 if the system has the type `long long int'. */
271-
#if (_MSC_VER > 1200)
272271
#define HAVE_LONG_LONG_INT 1
273-
#endif
274272

275273
/* Define to 1 if `long long int' works and is 64 bits. */
276-
#if (_MSC_VER > 1200)
277274
#define HAVE_LONG_LONG_INT_64 1
278-
#endif
279275

280276
/* Define to 1 if you have the `mbstowcs_l' function. */
281277
#define HAVE_MBSTOWCS_L 1
@@ -347,10 +343,7 @@
347343
/* #undef HAVE_READLINK */
348344

349345
/* Define to 1 if you have the `rint' function. */
350-
#if (_MSC_VER >= 1800)
351346
#define HAVE_RINT 1
352-
#endif
353-
354347

355348
/* Define to 1 if you have the global variable
356349
'rl_completion_append_character'. */
@@ -387,9 +380,7 @@
387380
#define HAVE_SSL_GET_CURRENT_COMPRESSION 1
388381

389382
/* Define to 1 if stdbool.h conforms to C99. */
390-
#if (_MSC_VER >= 1800)
391383
#define HAVE_STDBOOL_H 1
392-
#endif
393384

394385
/* Define to 1 if you have the <stdint.h> header file. */
395386
/* #undef HAVE_STDINT_H */
@@ -415,25 +406,15 @@
415406
/* Define to 1 if you have the `strtoll' function. */
416407
#ifdef HAVE_LONG_LONG_INT_64
417408
#define HAVE_STRTOLL 1
418-
/* Before VS2013, use Microsoft's nonstandard equivalent function */
419-
#if (_MSC_VER < 1800)
420-
#define strtoll _strtoi64
421-
#endif
422409
#endif
423410

424411
/* Define to 1 if you have the `strtoull' function. */
425412
#ifdef HAVE_LONG_LONG_INT_64
426413
#define HAVE_STRTOULL 1
427-
/* Before VS2013, use Microsoft's nonstandard equivalent function */
428-
#if (_MSC_VER < 1800)
429-
#define strtoull _strtoui64
430-
#endif
431414
#endif
432415

433416
/* Define to 1 if the system has the type `struct addrinfo'. */
434-
#if (_MSC_VER > 1200)
435417
#define HAVE_STRUCT_ADDRINFO 1
436-
#endif
437418

438419
/* Define to 1 if the system has the type `struct cmsgcred'. */
439420
/* #undef HAVE_STRUCT_CMSGCRED */
@@ -445,14 +426,10 @@
445426
/* #undef HAVE_STRUCT_SOCKADDR_SA_LEN */
446427

447428
/* Define to 1 if the system has the type `struct sockaddr_storage'. */
448-
#if (_MSC_VER > 1200)
449429
#define HAVE_STRUCT_SOCKADDR_STORAGE 1
450-
#endif
451430

452431
/* Define to 1 if `ss_family' is member of `struct sockaddr_storage'. */
453-
#if (_MSC_VER > 1200)
454432
#define HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY 1
455-
#endif
456433

457434
/* Define to 1 if `ss_len' is member of `struct sockaddr_storage'. */
458435
/* #undef HAVE_STRUCT_SOCKADDR_STORAGE_SS_LEN */
@@ -710,17 +687,13 @@
710687
/* #undef USE_PAM */
711688

712689
/* Define to 1 to use software CRC-32C implementation (slicing-by-8). */
713-
#if (_MSC_VER < 1500)
714-
#define USE_SLICING_BY_8_CRC32C 1
715-
#endif
690+
/* #undef USE_SLICING_BY_8_CRC32C */
716691

717692
/* Define to 1 use Intel SSE 4.2 CRC instructions. */
718693
/* #undef USE_SSE42_CRC32C */
719694

720695
/* Define to 1 to use Intel SSE 4.2 CRC instructions with a runtime check. */
721-
#if (_MSC_VER >= 1500)
722696
#define USE_SSE42_CRC32C_WITH_RUNTIME_CHECK
723-
#endif
724697

725698
/* Define to select SysV-style semaphores. */
726699
/* #undef USE_SYSV_SEMAPHORES */
@@ -758,11 +731,7 @@
758731
/* Define to keyword to use for C99 restrict support, or to nothing if this is
759732
not supported */
760733
/* Works for C and C++ in Visual Studio 2008 and upwards */
761-
#if (_MSC_VER >= 1500)
762734
#define pg_restrict __restrict
763-
#else
764-
#define pg_restrict
765-
#endif
766735

767736
/* Define to the equivalent of the C99 'restrict' keyword, or to
768737
nothing if this is not supported. Do not define if restrict is

src/include/port/win32.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
* our errcode() function. Since it's likely to get included by standard
3636
* system headers, pre-emptively include it now.
3737
*/
38-
#if _MSC_VER >= 1400 || defined(HAVE_CRTDEFS_H)
38+
#if defined(_MSC_VER) || defined(HAVE_CRTDEFS_H)
3939
#define errcode __msvc_errcode
4040
#include <crtdefs.h>
4141
#undef errcode

src/include/port/win32_port.h

-12
Original file line numberDiff line numberDiff line change
@@ -489,18 +489,6 @@ typedef unsigned short mode_t;
489489
#define W_OK 2
490490
#define R_OK 4
491491

492-
/*
493-
* isinf() and isnan() should per spec be in <math.h>, but MSVC older than
494-
* 2013 does not have them there. It does have _fpclass() and _isnan(), but
495-
* they're in <float.h>, so include that here even though it means float.h
496-
* percolates to our whole tree. Recent versions don't require any of this.
497-
*/
498-
#if (_MSC_VER < 1800)
499-
#include <float.h>
500-
#define isinf(x) ((_fpclass(x) == _FPCLASS_PINF) || (_fpclass(x) == _FPCLASS_NINF))
501-
#define isnan(x) _isnan(x)
502-
#endif
503-
504492
/* Pulled from Makefile.port in MinGW */
505493
#define DLSUFFIX ".dll"
506494

src/include/utils/float.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ extern int float8_cmp_internal(float8 a, float8 b);
6363
* long lived bug in the Microsoft compilers.
6464
* See http://support.microsoft.com/kb/120968/en-us for details
6565
*/
66-
#if (_MSC_VER >= 1800)
66+
#ifdef _MSC_VER
6767
#pragma warning(disable:4756)
6868
#endif
6969
static inline float4
@@ -73,7 +73,7 @@ get_float4_infinity(void)
7373
/* C99 standard way */
7474
return (float4) INFINITY;
7575
#else
76-
#if (_MSC_VER >= 1800)
76+
#ifdef _MSC_VER
7777
#pragma warning(default:4756)
7878
#endif
7979

0 commit comments

Comments
 (0)