Commit 38d8dce6 authored by Peter Eisentraut's avatar Peter Eisentraut

Remove some code for old unsupported versions of MSVC

As of d9dd406f, 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: default avatarMichael Paquier <michael@paquier.xyz>
parent a7471bd8
......@@ -973,7 +973,7 @@ cache_locale_time(void)
static char *
IsoLocaleName(const char *winlocname)
{
#if (_MSC_VER >= 1400) /* VC8.0 or later */
#ifdef _MSC_VER
static char iso_lc_messages[32];
_locale_t loct = NULL;
......@@ -987,7 +987,6 @@ IsoLocaleName(const char *winlocname)
loct = _create_locale(LC_CTYPE, winlocname);
if (loct != NULL)
{
#if (_MSC_VER >= 1700) /* Visual Studio 2012 or later */
size_t rc;
char *hyphen;
......@@ -1014,28 +1013,10 @@ IsoLocaleName(const char *winlocname)
hyphen = strchr(iso_lc_messages, '-');
if (hyphen)
*hyphen = '_';
#else
char isolang[32],
isocrty[32];
LCID lcid;
lcid = loct->locinfo->lc_handle[LC_CTYPE];
if (lcid == 0)
lcid = MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT);
_free_locale(loct);
if (!GetLocaleInfoA(lcid, LOCALE_SISO639LANGNAME, isolang, sizeof(isolang)))
return NULL;
if (!GetLocaleInfoA(lcid, LOCALE_SISO3166CTRYNAME, isocrty, sizeof(isocrty)))
return NULL;
snprintf(iso_lc_messages, sizeof(iso_lc_messages) - 1, "%s_%s", isolang, isocrty);
#endif
return iso_lc_messages;
}
return NULL;
#else
#endif /* _MSC_VER */
return NULL; /* Not supported on this version of msvc/mingw */
#endif /* _MSC_VER >= 1400 */
}
#endif /* WIN32 && LC_MESSAGES */
......
......@@ -4092,20 +4092,7 @@ convert_string_datum(Datum value, Oid typid, Oid collid, bool *failure)
* crashes since it will only give an estimation error and nothing
* fatal.
*/
#if _MSC_VER == 1400 /* VS.Net 2005 */
/*
*
* http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=99694
*/
{
char x[1];
xfrmlen = strxfrm(x, val, 0);
}
#else
xfrmlen = strxfrm(NULL, val, 0);
#endif
#ifdef WIN32
/*
......
......@@ -137,12 +137,7 @@ static void print_msg(const char *msg);
static void adjust_data_dir(void);
#ifdef WIN32
#if (_MSC_VER >= 1800)
#include <versionhelpers.h>
#else
static bool IsWindowsXPOrGreater(void);
static bool IsWindows7OrGreater(void);
#endif
static bool pgwin32_IsInstalled(SC_HANDLE);
static char *pgwin32_CommandLine(bool);
static void pgwin32_doRegister(void);
......@@ -1378,32 +1373,6 @@ do_kill(pgpid_t pid)
#ifdef WIN32
#if (_MSC_VER < 1800)
static bool
IsWindowsXPOrGreater(void)
{
OSVERSIONINFO osv;
osv.dwOSVersionInfoSize = sizeof(osv);
/* Windows XP = Version 5.1 */
return (!GetVersionEx(&osv) || /* could not get version */
osv.dwMajorVersion > 5 || (osv.dwMajorVersion == 5 && osv.dwMinorVersion >= 1));
}
static bool
IsWindows7OrGreater(void)
{
OSVERSIONINFO osv;
osv.dwOSVersionInfoSize = sizeof(osv);
/* Windows 7 = Version 6.0 */
return (!GetVersionEx(&osv) || /* could not get version */
osv.dwMajorVersion > 6 || (osv.dwMajorVersion == 6 && osv.dwMinorVersion >= 0));
}
#endif
static bool
pgwin32_IsInstalled(SC_HANDLE hSCM)
{
......
......@@ -268,14 +268,10 @@
/* #undef HAVE_LONG_INT_64 */
/* Define to 1 if the system has the type `long long int'. */
#if (_MSC_VER > 1200)
#define HAVE_LONG_LONG_INT 1
#endif
/* Define to 1 if `long long int' works and is 64 bits. */
#if (_MSC_VER > 1200)
#define HAVE_LONG_LONG_INT_64 1
#endif
/* Define to 1 if you have the `mbstowcs_l' function. */
#define HAVE_MBSTOWCS_L 1
......@@ -347,10 +343,7 @@
/* #undef HAVE_READLINK */
/* Define to 1 if you have the `rint' function. */
#if (_MSC_VER >= 1800)
#define HAVE_RINT 1
#endif
/* Define to 1 if you have the global variable
'rl_completion_append_character'. */
......@@ -387,9 +380,7 @@
#define HAVE_SSL_GET_CURRENT_COMPRESSION 1
/* Define to 1 if stdbool.h conforms to C99. */
#if (_MSC_VER >= 1800)
#define HAVE_STDBOOL_H 1
#endif
/* Define to 1 if you have the <stdint.h> header file. */
/* #undef HAVE_STDINT_H */
......@@ -415,25 +406,15 @@
/* Define to 1 if you have the `strtoll' function. */
#ifdef HAVE_LONG_LONG_INT_64
#define HAVE_STRTOLL 1
/* Before VS2013, use Microsoft's nonstandard equivalent function */
#if (_MSC_VER < 1800)
#define strtoll _strtoi64
#endif
#endif
/* Define to 1 if you have the `strtoull' function. */
#ifdef HAVE_LONG_LONG_INT_64
#define HAVE_STRTOULL 1
/* Before VS2013, use Microsoft's nonstandard equivalent function */
#if (_MSC_VER < 1800)
#define strtoull _strtoui64
#endif
#endif
/* Define to 1 if the system has the type `struct addrinfo'. */
#if (_MSC_VER > 1200)
#define HAVE_STRUCT_ADDRINFO 1
#endif
/* Define to 1 if the system has the type `struct cmsgcred'. */
/* #undef HAVE_STRUCT_CMSGCRED */
......@@ -445,14 +426,10 @@
/* #undef HAVE_STRUCT_SOCKADDR_SA_LEN */
/* Define to 1 if the system has the type `struct sockaddr_storage'. */
#if (_MSC_VER > 1200)
#define HAVE_STRUCT_SOCKADDR_STORAGE 1
#endif
/* Define to 1 if `ss_family' is member of `struct sockaddr_storage'. */
#if (_MSC_VER > 1200)
#define HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY 1
#endif
/* Define to 1 if `ss_len' is member of `struct sockaddr_storage'. */
/* #undef HAVE_STRUCT_SOCKADDR_STORAGE_SS_LEN */
......@@ -710,17 +687,13 @@
/* #undef USE_PAM */
/* Define to 1 to use software CRC-32C implementation (slicing-by-8). */
#if (_MSC_VER < 1500)
#define USE_SLICING_BY_8_CRC32C 1
#endif
/* #undef USE_SLICING_BY_8_CRC32C */
/* Define to 1 use Intel SSE 4.2 CRC instructions. */
/* #undef USE_SSE42_CRC32C */
/* Define to 1 to use Intel SSE 4.2 CRC instructions with a runtime check. */
#if (_MSC_VER >= 1500)
#define USE_SSE42_CRC32C_WITH_RUNTIME_CHECK
#endif
/* Define to select SysV-style semaphores. */
/* #undef USE_SYSV_SEMAPHORES */
......@@ -758,11 +731,7 @@
/* Define to keyword to use for C99 restrict support, or to nothing if this is
not supported */
/* Works for C and C++ in Visual Studio 2008 and upwards */
#if (_MSC_VER >= 1500)
#define pg_restrict __restrict
#else
#define pg_restrict
#endif
/* Define to the equivalent of the C99 'restrict' keyword, or to
nothing if this is not supported. Do not define if restrict is
......
......@@ -35,7 +35,7 @@
* our errcode() function. Since it's likely to get included by standard
* system headers, pre-emptively include it now.
*/
#if _MSC_VER >= 1400 || defined(HAVE_CRTDEFS_H)
#if defined(_MSC_VER) || defined(HAVE_CRTDEFS_H)
#define errcode __msvc_errcode
#include <crtdefs.h>
#undef errcode
......
......@@ -489,18 +489,6 @@ 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
/* Pulled from Makefile.port in MinGW */
#define DLSUFFIX ".dll"
......
......@@ -63,7 +63,7 @@ extern int float8_cmp_internal(float8 a, float8 b);
* long lived bug in the Microsoft compilers.
* See http://support.microsoft.com/kb/120968/en-us for details
*/
#if (_MSC_VER >= 1800)
#ifdef _MSC_VER
#pragma warning(disable:4756)
#endif
static inline float4
......@@ -73,7 +73,7 @@ get_float4_infinity(void)
/* C99 standard way */
return (float4) INFINITY;
#else
#if (_MSC_VER >= 1800)
#ifdef _MSC_VER
#pragma warning(default:4756)
#endif
......
......@@ -25,13 +25,6 @@
#line 8 "nan_test.pgc"
#ifdef WIN32
#if (_MSC_VER < 1800)
#define isinf(x) ((_fpclass(x) == _FPCLASS_PINF) || (_fpclass(x) == _FPCLASS_NINF))
#define isnan(x) _isnan(x)
#endif
#endif /* WIN32 */
int
main(void)
{
......@@ -41,54 +34,54 @@ main(void)
#line 21 "nan_test.pgc"
#line 14 "nan_test.pgc"
int id , loopcount ;
#line 22 "nan_test.pgc"
#line 15 "nan_test.pgc"
double d ;
#line 23 "nan_test.pgc"
#line 16 "nan_test.pgc"
numeric * num ;
#line 24 "nan_test.pgc"
#line 17 "nan_test.pgc"
char val [ 16 ] ;
/* exec sql end declare section */
#line 25 "nan_test.pgc"
#line 18 "nan_test.pgc"
ECPGdebug(1, stderr);
/* exec sql whenever sqlerror do sqlprint ( ) ; */
#line 28 "nan_test.pgc"
#line 21 "nan_test.pgc"
{ ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , NULL, 0);
#line 30 "nan_test.pgc"
#line 23 "nan_test.pgc"
if (sqlca.sqlcode < 0) sqlprint ( );}
#line 30 "nan_test.pgc"
#line 23 "nan_test.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table nantest1 ( id int4 , d float8 )", ECPGt_EOIT, ECPGt_EORT);
#line 32 "nan_test.pgc"
#line 25 "nan_test.pgc"
if (sqlca.sqlcode < 0) sqlprint ( );}
#line 32 "nan_test.pgc"
#line 25 "nan_test.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into nantest1 ( id , d ) values ( 1 , 'nan' :: float8 ) , ( 2 , 'infinity' :: float8 ) , ( 3 , '-infinity' :: float8 )", ECPGt_EOIT, ECPGt_EORT);
#line 33 "nan_test.pgc"
#line 26 "nan_test.pgc"
if (sqlca.sqlcode < 0) sqlprint ( );}
#line 33 "nan_test.pgc"
#line 26 "nan_test.pgc"
/* declare cur cursor for select id , d , d from nantest1 */
#line 35 "nan_test.pgc"
#line 28 "nan_test.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur cursor for select id , d , d from nantest1", ECPGt_EOIT, ECPGt_EORT);
#line 36 "nan_test.pgc"
#line 29 "nan_test.pgc"
if (sqlca.sqlcode < 0) sqlprint ( );}
#line 36 "nan_test.pgc"
#line 29 "nan_test.pgc"
for (loopcount = 0; loopcount < 100; loopcount++)
{
......@@ -99,10 +92,10 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_char,(val),(long)16,(long)1,(16)*sizeof(char),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 39 "nan_test.pgc"
#line 32 "nan_test.pgc"
if (sqlca.sqlcode < 0) sqlprint ( );}
#line 39 "nan_test.pgc"
#line 32 "nan_test.pgc"
if (sqlca.sqlcode)
break;
......@@ -116,34 +109,34 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_double,&(d),(long)1,(long)1,sizeof(double),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
#line 47 "nan_test.pgc"
#line 40 "nan_test.pgc"
if (sqlca.sqlcode < 0) sqlprint ( );}
#line 47 "nan_test.pgc"
#line 40 "nan_test.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into nantest1 ( id , d ) values ( $1 + 6 , $2 )",
ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_char,(val),(long)16,(long)1,(16)*sizeof(char),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
#line 48 "nan_test.pgc"
#line 41 "nan_test.pgc"
if (sqlca.sqlcode < 0) sqlprint ( );}
#line 48 "nan_test.pgc"
#line 41 "nan_test.pgc"
}
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur", ECPGt_EOIT, ECPGt_EORT);
#line 50 "nan_test.pgc"
#line 43 "nan_test.pgc"
if (sqlca.sqlcode < 0) sqlprint ( );}
#line 50 "nan_test.pgc"
#line 43 "nan_test.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur cursor for select id , d , d from nantest1", ECPGt_EOIT, ECPGt_EORT);
#line 52 "nan_test.pgc"
#line 45 "nan_test.pgc"
if (sqlca.sqlcode < 0) sqlprint ( );}
#line 52 "nan_test.pgc"
#line 45 "nan_test.pgc"
for (loopcount = 0; loopcount < 100; loopcount++)
{
......@@ -154,10 +147,10 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_char,(val),(long)16,(long)1,(16)*sizeof(char),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 55 "nan_test.pgc"
#line 48 "nan_test.pgc"
if (sqlca.sqlcode < 0) sqlprint ( );}
#line 55 "nan_test.pgc"
#line 48 "nan_test.pgc"
if (sqlca.sqlcode)
break;
......@@ -167,25 +160,25 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
printf("%d NaN '%s'\n", id, val);
}
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur", ECPGt_EOIT, ECPGt_EORT);
#line 63 "nan_test.pgc"
#line 56 "nan_test.pgc"
if (sqlca.sqlcode < 0) sqlprint ( );}
#line 63 "nan_test.pgc"
#line 56 "nan_test.pgc"
num = PGTYPESnumeric_new();
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table nantest2 ( id int4 , d numeric )", ECPGt_EOIT, ECPGt_EORT);
#line 67 "nan_test.pgc"
#line 60 "nan_test.pgc"
if (sqlca.sqlcode < 0) sqlprint ( );}
#line 67 "nan_test.pgc"
#line 60 "nan_test.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into nantest2 ( id , d ) values ( 4 , 'nan' :: numeric )", ECPGt_EOIT, ECPGt_EORT);
#line 68 "nan_test.pgc"
#line 61 "nan_test.pgc"
if (sqlca.sqlcode < 0) sqlprint ( );}
#line 68 "nan_test.pgc"
#line 61 "nan_test.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select id , d , d from nantest2 where id = 4", ECPGt_EOIT,
......@@ -195,10 +188,10 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_char,(val),(long)16,(long)1,(16)*sizeof(char),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 70 "nan_test.pgc"
#line 63 "nan_test.pgc"
if (sqlca.sqlcode < 0) sqlprint ( );}
#line 70 "nan_test.pgc"
#line 63 "nan_test.pgc"
printf("%d %s '%s'\n", id, (num->sign == NUMERIC_NAN ? "NaN" : "not NaN"), val);
......@@ -206,28 +199,28 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into nantest2 ( id , d ) values ( 5 , $1 )",
ECPGt_numeric,&(num),(long)1,(long)0,sizeof(numeric),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
#line 74 "nan_test.pgc"
#line 67 "nan_test.pgc"
if (sqlca.sqlcode < 0) sqlprint ( );}
#line 74 "nan_test.pgc"
#line 67 "nan_test.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into nantest2 ( id , d ) values ( 6 , $1 )",
ECPGt_char,(val),(long)16,(long)1,(16)*sizeof(char),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
#line 75 "nan_test.pgc"
#line 68 "nan_test.pgc"
if (sqlca.sqlcode < 0) sqlprint ( );}
#line 75 "nan_test.pgc"
#line 68 "nan_test.pgc"
/* declare cur1 cursor for select id , d , d from nantest2 */
#line 77 "nan_test.pgc"
#line 70 "nan_test.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur1 cursor for select id , d , d from nantest2", ECPGt_EOIT, ECPGt_EORT);
#line 78 "nan_test.pgc"
#line 71 "nan_test.pgc"
if (sqlca.sqlcode < 0) sqlprint ( );}
#line 78 "nan_test.pgc"
#line 71 "nan_test.pgc"
for (loopcount = 0; loopcount < 100; loopcount++)
{
......@@ -238,35 +231,35 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_char,(val),(long)16,(long)1,(16)*sizeof(char),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 81 "nan_test.pgc"
#line 74 "nan_test.pgc"
if (sqlca.sqlcode < 0) sqlprint ( );}
#line 81 "nan_test.pgc"
#line 74 "nan_test.pgc"
if (sqlca.sqlcode)
break;
printf("%d %s '%s'\n", id, (num->sign == NUMERIC_NAN ? "NaN" : "not NaN"), val);
}
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur1", ECPGt_EOIT, ECPGt_EORT);
#line 86 "nan_test.pgc"
#line 79 "nan_test.pgc"
if (sqlca.sqlcode < 0) sqlprint ( );}
#line 86 "nan_test.pgc"
#line 79 "nan_test.pgc"
PGTYPESnumeric_free(num);
{ ECPGtrans(__LINE__, NULL, "rollback");
#line 90 "nan_test.pgc"
#line 83 "nan_test.pgc"
if (sqlca.sqlcode < 0) sqlprint ( );}
#line 90 "nan_test.pgc"
#line 83 "nan_test.pgc"
{ ECPGdisconnect(__LINE__, "CURRENT");
#line 91 "nan_test.pgc"
#line 84 "nan_test.pgc"
if (sqlca.sqlcode < 0) sqlprint ( );}
#line 91 "nan_test.pgc"
#line 84 "nan_test.pgc"
return 0;
......
......@@ -7,13 +7,6 @@
exec sql include ../regression;
#ifdef WIN32
#if (_MSC_VER < 1800)
#define isinf(x) ((_fpclass(x) == _FPCLASS_PINF) || (_fpclass(x) == _FPCLASS_NINF))
#define isnan(x) _isnan(x)
#endif
#endif /* WIN32 */
int
main(void)
{
......
......@@ -212,7 +212,7 @@ win32_langinfo(const char *ctype)
{
char *r = NULL;
#if (_MSC_VER >= 1700) && (_MSC_VER < 1900)
#if defined(_MSC_VER) && (_MSC_VER < 1900)
_locale_t loct = NULL;
loct = _create_locale(LC_CTYPE, ctype);
......@@ -226,7 +226,7 @@ win32_langinfo(const char *ctype)
#else
char *codepage;
#if (_MSC_VER >= 1900)
#if defined(_MSC_VER) && (_MSC_VER >= 1900)
uint32 cp;
WCHAR wctype[LOCALE_NAME_MAX_LENGTH];
......
......@@ -511,10 +511,8 @@ sub GenerateFiles
open(my $o, '>', 'src/interfaces/ecpg/include/ecpg_config.h')
|| confess "Could not open ecpg_config.h";
print $o <<EOF;
#if (_MSC_VER > 1200)
#define HAVE_LONG_LONG_INT 1
#define HAVE_LONG_LONG_INT_64 1
#endif
#define ENABLE_THREAD_SAFETY 1
EOF
close($o);
......
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