diff --git a/changes/win-macros b/changes/win-macros index a3519c39d..a46a474d0 100644 --- a/changes/win-macros +++ b/changes/win-macros @@ -2,6 +2,6 @@ - Define WINVER and _WIN32_WINNT centrally, in orconfig.h, in order to ensure they remain consistent and visible everywhere. - - Remove vestigial workarounds for some ancient versions of the MSVC - compiler. + - Remove some vestigial workarounds for the MSVC6 compiler. We haven't + supported that in ages. diff --git a/configure.ac b/configure.ac index 23d4c98f5..0f93e461f 100644 --- a/configure.ac +++ b/configure.ac @@ -335,6 +335,12 @@ bwin32=true; AC_MSG_RESULT([yes]), bwin32=false; AC_MSG_RESULT([no])) fi +if test "$bwin32" = yes; then + AC_DEFINE(WIN32_LEAN_AND_MEAN, 1, [Defined to avoid including some windows headers]) + AC_DEFINE(WINVER, 0x0501, [Defined to access windows functions and definitions for >=WinXP]) + AC_DEFINE(_WIN32_WINNT, 0x0501, [Defined to access windows functions and definitions for >=WinXP]) +fi + AM_CONDITIONAL(BUILD_NT_SERVICES, test x$bwin32 = xtrue) dnl Enable C99 when compiling with MIPSpro @@ -1122,13 +1128,9 @@ AC_CHECK_TYPES([struct in6_addr, struct sockaddr_in6, sa_family_t], , , #ifdef _WIN32 #define _WIN32_WINNT 0x0501 #define WIN32_LEAN_AND_MEAN -#if defined(_MSC_VER) && (_MSC_VER < 1300) -#include -#else #include #include #endif -#endif ]) AC_CHECK_MEMBERS([struct in6_addr.s6_addr32, struct in6_addr.s6_addr16, struct sockaddr_in.sin_len, struct sockaddr_in6.sin6_len], , , [#ifdef HAVE_SYS_TYPES_H @@ -1146,9 +1148,6 @@ AC_CHECK_MEMBERS([struct in6_addr.s6_addr32, struct in6_addr.s6_addr16, struct s #ifdef _WIN32 #define _WIN32_WINNT 0x0501 #define WIN32_LEAN_AND_MEAN -#if defined(_MSC_VER) && (_MSC_VER < 1300) -#include -#else #include #include #endif diff --git a/src/common/address.c b/src/common/address.c index 6bd107889..d7d815e40 100644 --- a/src/common/address.c +++ b/src/common/address.c @@ -10,17 +10,16 @@ #define ADDRESS_PRIVATE +#include "orconfig.h" + #ifdef _WIN32 /* For access to structs needed by GetAdaptersAddresses */ -#undef _WIN32_WINNT -#define _WIN32_WINNT 0x0501 #include #include #include #include #endif -#include "orconfig.h" #include "compat.h" #include "util.h" #include "address.h" diff --git a/src/common/aes.c b/src/common/aes.c index 8b9d81fa1..5f2c3f2f0 100644 --- a/src/common/aes.c +++ b/src/common/aes.c @@ -12,16 +12,8 @@ #include "orconfig.h" #ifdef _WIN32 /*wrkard for dtls1.h >= 0.9.8m of "#include "*/ - #ifndef _WIN32_WINNT - #define _WIN32_WINNT 0x0501 - #endif - #define WIN32_LEAN_AND_MEAN - #if defined(_MSC_VER) && (_MSC_VER < 1300) - #include - #else - #include - #include - #endif + #include + #include #endif #include diff --git a/src/common/compat.h b/src/common/compat.h index e1b860f22..fbaeb6fe0 100644 --- a/src/common/compat.h +++ b/src/common/compat.h @@ -10,17 +10,9 @@ #include "torint.h" #include "testsupport.h" #ifdef _WIN32 -#ifndef _WIN32_WINNT -#define _WIN32_WINNT 0x0501 -#endif -#define WIN32_LEAN_AND_MEAN -#if defined(_MSC_VER) && (_MSC_VER < 1300) -#include -#else #include #include #endif -#endif #ifdef HAVE_SYS_PARAM_H #include #endif @@ -90,13 +82,8 @@ /* Try to get a reasonable __func__ substitute in place. */ #if defined(_MSC_VER) -/* MSVC compilers before VC7 don't have __func__ at all; later ones call it - * __FUNCTION__. */ -#if _MSC_VER < 1300 -#define __func__ "???" -#else + #define __func__ __FUNCTION__ -#endif #else /* For platforms where autoconf works, make sure __func__ is defined @@ -112,18 +99,8 @@ #endif /* ifndef MAVE_MACRO__func__ */ #endif /* if not windows */ -#if defined(_MSC_VER) && (_MSC_VER < 1300) -/* MSVC versions before 7 apparently don't believe that you can cast uint64_t - * to double and really mean it. */ -extern INLINE double U64_TO_DBL(uint64_t x) { - int64_t i = (int64_t) x; - return (i < 0) ? ((double) INT64_MAX) : (double) i; -} -#define DBL_TO_U64(x) ((uint64_t)(int64_t) (x)) -#else #define U64_TO_DBL(x) ((double) (x)) #define DBL_TO_U64(x) ((uint64_t) (x)) -#endif #ifdef ENUM_VALS_ARE_SIGNED #define ENUM_BF(t) unsigned diff --git a/src/common/crypto.c b/src/common/crypto.c index afaf93aed..984fe952e 100644 --- a/src/common/crypto.c +++ b/src/common/crypto.c @@ -13,10 +13,6 @@ #include "orconfig.h" #ifdef _WIN32 -#ifndef _WIN32_WINNT -#define _WIN32_WINNT 0x0501 -#endif -#define WIN32_LEAN_AND_MEAN #include #include /* Windows defines this; so does OpenSSL 0.9.8h and later. We don't actually diff --git a/src/common/torlog.h b/src/common/torlog.h index 8923a9e21..710313a9a 100644 --- a/src/common/torlog.h +++ b/src/common/torlog.h @@ -210,16 +210,6 @@ void log_notice_(log_domain_mask_t domain, const char *format, ...); void log_warn_(log_domain_mask_t domain, const char *format, ...); void log_err_(log_domain_mask_t domain, const char *format, ...); -#if defined(_MSC_VER) && _MSC_VER < 1300 -/* MSVC 6 and earlier don't have __func__, or even __LINE__. */ -#define log_fn log_fn_ -#define log_fn_ratelim log_fn_ratelim_ -#define log_debug log_debug_ -#define log_info log_info_ -#define log_notice log_notice_ -#define log_warn log_warn_ -#define log_err log_err_ -#else /* We don't have GCC's varargs macros, so use a global variable to pass the * function name to log_fn */ extern const char *log_fn_function_name_; @@ -233,7 +223,6 @@ extern const char *log_fn_function_name_; #define log_notice (log_fn_function_name_=__func__),log_notice_ #define log_warn (log_fn_function_name_=__func__),log_warn_ #define log_err (log_fn_function_name_=__func__),log_err_ -#endif #endif /* !GNUC */ diff --git a/src/common/tortls.c b/src/common/tortls.c index bd0eaffa2..7447822d4 100644 --- a/src/common/tortls.c +++ b/src/common/tortls.c @@ -18,16 +18,8 @@ #include #ifdef _WIN32 /*wrkard for dtls1.h >= 0.9.8m of "#include "*/ - #ifndef _WIN32_WINNT - #define _WIN32_WINNT 0x0501 - #endif - #define WIN32_LEAN_AND_MEAN - #if defined(_MSC_VER) && (_MSC_VER < 1300) - #include - #else - #include - #include - #endif + #include + #include #endif #ifdef __GNUC__ diff --git a/src/or/or.h b/src/or/or.h index d3a476ecf..0950277bb 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -22,13 +22,6 @@ #endif #endif -#ifdef _WIN32 -#ifndef _WIN32_WINNT -#define _WIN32_WINNT 0x0501 -#endif -#define WIN32_LEAN_AND_MEAN -#endif - #ifdef HAVE_UNISTD_H #include #endif diff --git a/src/test/test_address.c b/src/test/test_address.c index d13d678f3..9d6456315 100644 --- a/src/test/test_address.c +++ b/src/test/test_address.c @@ -3,11 +3,11 @@ #define ADDRESS_PRIVATE +#include "orconfig.h" + #ifdef _WIN32 #include /* For access to structs needed by GetAdaptersAddresses */ -#undef _WIN32_WINNT -#define _WIN32_WINNT 0x0501 #include #endif diff --git a/src/tools/tor-resolve.c b/src/tools/tor-resolve.c index 19e3a554f..08bce15e6 100644 --- a/src/tools/tor-resolve.c +++ b/src/tools/tor-resolve.c @@ -33,13 +33,9 @@ #endif #ifdef _WIN32 -#if defined(_MSC_VER) && (_MSC_VER <= 1300) -#include -#else #include #include #endif -#endif #define RESPONSE_LEN_4 8 #define log_sock_error(act, _s) \