Browse Source

Use the standard _WIN32, not the Torism MS_WINDOWS or deprecated WIN32

This commit is completely mechanical; I used this perl script to make it:

 #!/usr/bin/perl -w -i.bak -p

 if (/^\s*\#/) {
     s/MS_WINDOWS/_WIN32/g;
     s/\bWIN32\b/_WIN32/g;
 }
Nick Mathewson 12 years ago
parent
commit
5cf9167f91

+ 5 - 5
src/common/address.c

@@ -15,7 +15,7 @@
 #include "torlog.h"
 #include "torlog.h"
 #include "container.h"
 #include "container.h"
 
 
-#ifdef MS_WINDOWS
+#ifdef _WIN32
 #include <process.h>
 #include <process.h>
 #include <windows.h>
 #include <windows.h>
 #include <winsock2.h>
 #include <winsock2.h>
@@ -275,7 +275,7 @@ tor_addr_lookup(const char *name, uint16_t family, tor_addr_t *addr)
     ent = err ? NULL : &hent;
     ent = err ? NULL : &hent;
 #else
 #else
     ent = gethostbyname(name);
     ent = gethostbyname(name);
-#ifdef MS_WINDOWS
+#ifdef _WIN32
     err = WSAGetLastError();
     err = WSAGetLastError();
 #else
 #else
     err = h_errno;
     err = h_errno;
@@ -291,7 +291,7 @@ tor_addr_lookup(const char *name, uint16_t family, tor_addr_t *addr)
       }
       }
       return 0;
       return 0;
     }
     }
-#ifdef MS_WINDOWS
+#ifdef _WIN32
     return (err == WSATRY_AGAIN) ? 1 : -1;
     return (err == WSATRY_AGAIN) ? 1 : -1;
 #else
 #else
     return (err == TRY_AGAIN) ? 1 : -1;
     return (err == TRY_AGAIN) ? 1 : -1;
@@ -1101,7 +1101,7 @@ tor_addr_port_lookup(const char *s, tor_addr_t *addr_out, uint16_t *port_out)
   return -1;
   return -1;
 }
 }
 
 
-#ifdef MS_WINDOWS
+#ifdef _WIN32
 typedef ULONG (WINAPI *GetAdaptersAddresses_fn_t)(
 typedef ULONG (WINAPI *GetAdaptersAddresses_fn_t)(
               ULONG, ULONG, PVOID, PIP_ADAPTER_ADDRESSES, PULONG);
               ULONG, ULONG, PVOID, PIP_ADAPTER_ADDRESSES, PULONG);
 #endif
 #endif
@@ -1140,7 +1140,7 @@ get_interface_addresses_raw(int severity)
 
 
   freeifaddrs(ifa);
   freeifaddrs(ifa);
   return result;
   return result;
-#elif defined(MS_WINDOWS)
+#elif defined(_WIN32)
   /* Windows XP began to provide GetAdaptersAddresses. Windows 2000 had a
   /* Windows XP began to provide GetAdaptersAddresses. Windows 2000 had a
      "GetAdaptersInfo", but that's deprecated; let's just try
      "GetAdaptersInfo", but that's deprecated; let's just try
      GetAdaptersAddresses and fall back to connect+getsockname.
      GetAdaptersAddresses and fall back to connect+getsockname.

+ 31 - 31
src/common/compat.c

@@ -21,7 +21,7 @@
 
 
 #include "compat.h"
 #include "compat.h"
 
 
-#ifdef MS_WINDOWS
+#ifdef _WIN32
 #include <process.h>
 #include <process.h>
 #include <windows.h>
 #include <windows.h>
 #include <sys/locking.h>
 #include <sys/locking.h>
@@ -205,7 +205,7 @@ tor_munmap_file(tor_mmap_t *handle)
   munmap((char*)handle->data, handle->mapping_size);
   munmap((char*)handle->data, handle->mapping_size);
   tor_free(handle);
   tor_free(handle);
 }
 }
-#elif defined(MS_WINDOWS)
+#elif defined(_WIN32)
 tor_mmap_t *
 tor_mmap_t *
 tor_mmap_file(const char *filename)
 tor_mmap_file(const char *filename)
 {
 {
@@ -341,7 +341,7 @@ tor_vsnprintf(char *str, size_t size, const char *format, va_list args)
     return -1; /* no place for the NUL */
     return -1; /* no place for the NUL */
   if (size > SIZE_T_CEILING)
   if (size > SIZE_T_CEILING)
     return -1;
     return -1;
-#ifdef MS_WINDOWS
+#ifdef _WIN32
   r = _vsnprintf(str, size, format, args);
   r = _vsnprintf(str, size, format, args);
 #else
 #else
   r = vsnprintf(str, size, format, args);
   r = vsnprintf(str, size, format, args);
@@ -570,7 +570,7 @@ tor_strtok_r_impl(char *str, const char *sep, char **lasts)
   return start;
   return start;
 }
 }
 
 
-#ifdef MS_WINDOWS
+#ifdef _WIN32
 /** Take a filename and return a pointer to its final element.  This
 /** Take a filename and return a pointer to its final element.  This
  * function is called on __FILE__ to fix a MSVC nit where __FILE__
  * function is called on __FILE__ to fix a MSVC nit where __FILE__
  * contains the full path to the file.  This is bad, because it
  * contains the full path to the file.  This is bad, because it
@@ -670,7 +670,7 @@ set_uint64(void *cp, uint64_t v)
 int
 int
 replace_file(const char *from, const char *to)
 replace_file(const char *from, const char *to)
 {
 {
-#ifndef MS_WINDOWS
+#ifndef _WIN32
   return rename(from,to);
   return rename(from,to);
 #else
 #else
   switch (file_status(to))
   switch (file_status(to))
@@ -739,7 +739,7 @@ tor_lockfile_lock(const char *filename, int blocking, int *locked_out)
     return NULL;
     return NULL;
   }
   }
 
 
-#ifdef WIN32
+#ifdef _WIN32
   _lseek(fd, 0, SEEK_SET);
   _lseek(fd, 0, SEEK_SET);
   if (_locking(fd, blocking ? _LK_LOCK : _LK_NBLCK, 1) < 0) {
   if (_locking(fd, blocking ? _LK_LOCK : _LK_NBLCK, 1) < 0) {
     if (errno != EACCES && errno != EDEADLOCK)
     if (errno != EACCES && errno != EDEADLOCK)
@@ -788,7 +788,7 @@ tor_lockfile_unlock(tor_lockfile_t *lockfile)
   tor_assert(lockfile);
   tor_assert(lockfile);
 
 
   log_info(LD_FS, "Unlocking \"%s\"", lockfile->filename);
   log_info(LD_FS, "Unlocking \"%s\"", lockfile->filename);
-#ifdef WIN32
+#ifdef _WIN32
   _lseek(lockfile->fd, 0, SEEK_SET);
   _lseek(lockfile->fd, 0, SEEK_SET);
   if (_locking(lockfile->fd, _LK_UNLCK, 1) < 0) {
   if (_locking(lockfile->fd, _LK_UNLCK, 1) < 0) {
     log_warn(LD_FS,"Error unlocking \"%s\": %s", lockfile->filename,
     log_warn(LD_FS,"Error unlocking \"%s\": %s", lockfile->filename,
@@ -824,7 +824,7 @@ tor_lockfile_unlock(tor_lockfile_t *lockfile)
 off_t
 off_t
 tor_fd_getpos(int fd)
 tor_fd_getpos(int fd)
 {
 {
-#ifdef WIN32
+#ifdef _WIN32
   return (off_t) _lseek(fd, 0, SEEK_CUR);
   return (off_t) _lseek(fd, 0, SEEK_CUR);
 #else
 #else
   return (off_t) lseek(fd, 0, SEEK_CUR);
   return (off_t) lseek(fd, 0, SEEK_CUR);
@@ -835,7 +835,7 @@ tor_fd_getpos(int fd)
 int
 int
 tor_fd_seekend(int fd)
 tor_fd_seekend(int fd)
 {
 {
-#ifdef WIN32
+#ifdef _WIN32
   return _lseek(fd, 0, SEEK_END) < 0 ? -1 : 0;
   return _lseek(fd, 0, SEEK_END) < 0 ? -1 : 0;
 #else
 #else
   return lseek(fd, 0, SEEK_END) < 0 ? -1 : 0;
   return lseek(fd, 0, SEEK_END) < 0 ? -1 : 0;
@@ -888,7 +888,7 @@ tor_close_socket(tor_socket_t s)
    * tor_close_socket to close sockets, and always using close() on
    * tor_close_socket to close sockets, and always using close() on
    * files.
    * files.
    */
    */
-#if defined(MS_WINDOWS)
+#if defined(_WIN32)
   r = closesocket(s);
   r = closesocket(s);
 #else
 #else
   r = close(s);
   r = close(s);
@@ -909,7 +909,7 @@ tor_close_socket(tor_socket_t s)
   } else {
   } else {
     int err = tor_socket_errno(-1);
     int err = tor_socket_errno(-1);
     log_info(LD_NET, "Close returned an error: %s", tor_socket_strerror(err));
     log_info(LD_NET, "Close returned an error: %s", tor_socket_strerror(err));
-#ifdef WIN32
+#ifdef _WIN32
     if (err != WSAENOTSOCK)
     if (err != WSAENOTSOCK)
       --n_sockets_open;
       --n_sockets_open;
 #else
 #else
@@ -1016,7 +1016,7 @@ get_n_open_sockets(void)
 void
 void
 set_socket_nonblocking(tor_socket_t socket)
 set_socket_nonblocking(tor_socket_t socket)
 {
 {
-#if defined(MS_WINDOWS)
+#if defined(_WIN32)
   unsigned long nonblocking = 1;
   unsigned long nonblocking = 1;
   ioctlsocket(socket, FIONBIO, (unsigned long*) &nonblocking);
   ioctlsocket(socket, FIONBIO, (unsigned long*) &nonblocking);
 #else
 #else
@@ -1045,7 +1045,7 @@ int
 tor_socketpair(int family, int type, int protocol, tor_socket_t fd[2])
 tor_socketpair(int family, int type, int protocol, tor_socket_t fd[2])
 {
 {
 //don't use win32 socketpairs (they are always bad)
 //don't use win32 socketpairs (they are always bad)
-#if defined(HAVE_SOCKETPAIR) && !defined(MS_WINDOWS)
+#if defined(HAVE_SOCKETPAIR) && !defined(_WIN32)
   int r;
   int r;
 #ifdef SOCK_CLOEXEC
 #ifdef SOCK_CLOEXEC
   type |= SOCK_CLOEXEC;
   type |= SOCK_CLOEXEC;
@@ -1089,7 +1089,7 @@ tor_socketpair(int family, int type, int protocol, tor_socket_t fd[2])
         || family != AF_UNIX
         || family != AF_UNIX
 #endif
 #endif
         ) {
         ) {
-#ifdef MS_WINDOWS
+#ifdef _WIN32
       return -WSAEAFNOSUPPORT;
       return -WSAEAFNOSUPPORT;
 #else
 #else
       return -EAFNOSUPPORT;
       return -EAFNOSUPPORT;
@@ -1149,7 +1149,7 @@ tor_socketpair(int family, int type, int protocol, tor_socket_t fd[2])
     return 0;
     return 0;
 
 
   abort_tidy_up_and_fail:
   abort_tidy_up_and_fail:
-#ifdef MS_WINDOWS
+#ifdef _WIN32
     saved_errno = WSAECONNABORTED;
     saved_errno = WSAECONNABORTED;
 #else
 #else
     saved_errno = ECONNABORTED; /* I hope this is portable and appropriate.  */
     saved_errno = ECONNABORTED; /* I hope this is portable and appropriate.  */
@@ -1191,7 +1191,7 @@ set_max_file_descriptors(rlim_t limit, int *max_out)
 #if defined(CYGWIN) || defined(__CYGWIN__)
 #if defined(CYGWIN) || defined(__CYGWIN__)
   const char *platform = "Cygwin";
   const char *platform = "Cygwin";
   const unsigned long MAX_CONNECTIONS = 3200;
   const unsigned long MAX_CONNECTIONS = 3200;
-#elif defined(MS_WINDOWS)
+#elif defined(_WIN32)
   const char *platform = "Windows";
   const char *platform = "Windows";
   const unsigned long MAX_CONNECTIONS = 15000;
   const unsigned long MAX_CONNECTIONS = 15000;
 #else
 #else
@@ -1274,7 +1274,7 @@ set_max_file_descriptors(rlim_t limit, int *max_out)
   return 0;
   return 0;
 }
 }
 
 
-#ifndef MS_WINDOWS
+#ifndef _WIN32
 /** Log details of current user and group credentials. Return 0 on
 /** Log details of current user and group credentials. Return 0 on
  * success. Logs and return -1 on failure.
  * success. Logs and return -1 on failure.
  */
  */
@@ -1380,7 +1380,7 @@ log_credential_status(void)
 int
 int
 switch_id(const char *user)
 switch_id(const char *user)
 {
 {
-#ifndef MS_WINDOWS
+#ifndef _WIN32
   struct passwd *pw = NULL;
   struct passwd *pw = NULL;
   uid_t old_uid;
   uid_t old_uid;
   gid_t old_gid;
   gid_t old_gid;
@@ -1591,7 +1591,7 @@ get_parent_directory(char *fname)
   char *cp;
   char *cp;
   int at_end = 1;
   int at_end = 1;
   tor_assert(fname);
   tor_assert(fname);
-#ifdef MS_WINDOWS
+#ifdef _WIN32
   /* If we start with, say, c:, then don't consider that the start of the path
   /* If we start with, say, c:, then don't consider that the start of the path
    */
    */
   if (fname[0] && fname[1] == ':') {
   if (fname[0] && fname[1] == ':') {
@@ -1608,7 +1608,7 @@ get_parent_directory(char *fname)
   at_end = 1;
   at_end = 1;
   while (--cp > fname) {
   while (--cp > fname) {
     int is_sep = (*cp == '/'
     int is_sep = (*cp == '/'
-#ifdef MS_WINDOWS
+#ifdef _WIN32
                   || *cp == '\\'
                   || *cp == '\\'
 #endif
 #endif
                   );
                   );
@@ -1628,7 +1628,7 @@ get_parent_directory(char *fname)
 char *
 char *
 make_path_absolute(char *fname)
 make_path_absolute(char *fname)
 {
 {
-#ifdef MS_WINDOWS
+#ifdef _WIN32
   char *absfname_malloced = _fullpath(NULL, fname, 1);
   char *absfname_malloced = _fullpath(NULL, fname, 1);
 
 
   /* We don't want to assume that tor_free can free a string allocated
   /* We don't want to assume that tor_free can free a string allocated
@@ -1900,7 +1900,7 @@ tor_lookup_hostname(const char *name, uint32_t *addr)
 void
 void
 tor_init_weak_random(unsigned seed)
 tor_init_weak_random(unsigned seed)
 {
 {
-#ifdef MS_WINDOWS
+#ifdef _WIN32
   srand(seed);
   srand(seed);
 #else
 #else
   srandom(seed);
   srandom(seed);
@@ -1913,7 +1913,7 @@ tor_init_weak_random(unsigned seed)
 long
 long
 tor_weak_random(void)
 tor_weak_random(void)
 {
 {
-#ifdef MS_WINDOWS
+#ifdef _WIN32
   return rand();
   return rand();
 #else
 #else
   return random();
   return random();
@@ -1942,7 +1942,7 @@ get_uname(void)
     } else
     } else
 #endif
 #endif
       {
       {
-#ifdef MS_WINDOWS
+#ifdef _WIN32
         OSVERSIONINFOEX info;
         OSVERSIONINFOEX info;
         int i;
         int i;
         const char *plat = NULL;
         const char *plat = NULL;
@@ -2144,7 +2144,7 @@ spawn_exit(void)
 static int
 static int
 compute_num_cpus_impl(void)
 compute_num_cpus_impl(void)
 {
 {
-#ifdef MS_WINDOWS
+#ifdef _WIN32
   SYSTEM_INFO info;
   SYSTEM_INFO info;
   memset(&info, 0, sizeof(info));
   memset(&info, 0, sizeof(info));
   GetSystemInfo(&info);
   GetSystemInfo(&info);
@@ -2192,7 +2192,7 @@ compute_num_cpus(void)
 void
 void
 tor_gettimeofday(struct timeval *timeval)
 tor_gettimeofday(struct timeval *timeval)
 {
 {
-#ifdef MS_WINDOWS
+#ifdef _WIN32
   /* Epoch bias copied from perl: number of units between windows epoch and
   /* Epoch bias copied from perl: number of units between windows epoch and
    * Unix epoch. */
    * Unix epoch. */
 #define EPOCH_BIAS U64_LITERAL(116444736000000000)
 #define EPOCH_BIAS U64_LITERAL(116444736000000000)
@@ -2237,7 +2237,7 @@ tor_gettimeofday(struct timeval *timeval)
   return;
   return;
 }
 }
 
 
-#if defined(TOR_IS_MULTITHREADED) && !defined(MS_WINDOWS)
+#if defined(TOR_IS_MULTITHREADED) && !defined(_WIN32)
 /** Defined iff we need to add locks when defining fake versions of reentrant
 /** Defined iff we need to add locks when defining fake versions of reentrant
  * versions of time-related functions. */
  * versions of time-related functions. */
 #define TIME_FNS_NEED_LOCKS
 #define TIME_FNS_NEED_LOCKS
@@ -2781,7 +2781,7 @@ in_main_thread(void)
  * should call tor_socket_errno <em>at most once</em> on the failing
  * should call tor_socket_errno <em>at most once</em> on the failing
  * socket to get the error.
  * socket to get the error.
  */
  */
-#if defined(MS_WINDOWS)
+#if defined(_WIN32)
 int
 int
 tor_socket_errno(tor_socket_t sock)
 tor_socket_errno(tor_socket_t sock)
 {
 {
@@ -2797,7 +2797,7 @@ tor_socket_errno(tor_socket_t sock)
 }
 }
 #endif
 #endif
 
 
-#if defined(MS_WINDOWS)
+#if defined(_WIN32)
 #define E(code, s) { code, (s " [" #code " ]") }
 #define E(code, s) { code, (s " [" #code " ]") }
 struct { int code; const char *msg; } windows_socket_errors[] = {
 struct { int code; const char *msg; } windows_socket_errors[] = {
   E(WSAEINTR, "Interrupted function call"),
   E(WSAEINTR, "Interrupted function call"),
@@ -2879,7 +2879,7 @@ tor_socket_strerror(int e)
 int
 int
 network_init(void)
 network_init(void)
 {
 {
-#ifdef MS_WINDOWS
+#ifdef _WIN32
   /* This silly exercise is necessary before windows will allow
   /* This silly exercise is necessary before windows will allow
    * gethostbyname to work. */
    * gethostbyname to work. */
   WSADATA WSAData;
   WSADATA WSAData;
@@ -2901,7 +2901,7 @@ network_init(void)
   return 0;
   return 0;
 }
 }
 
 
-#ifdef MS_WINDOWS
+#ifdef _WIN32
 /** Return a newly allocated string describing the windows system error code
 /** Return a newly allocated string describing the windows system error code
  * <b>err</b>.  Note that error codes are different from errno.  Error codes
  * <b>err</b>.  Note that error codes are different from errno.  Error codes
  * come from GetLastError() when a winapi call fails.  errno is set only when
  * come from GetLastError() when a winapi call fails.  errno is set only when

+ 12 - 12
src/common/compat.h

@@ -8,7 +8,7 @@
 
 
 #include "orconfig.h"
 #include "orconfig.h"
 #include "torint.h"
 #include "torint.h"
-#ifdef MS_WINDOWS
+#ifdef _WIN32
 #ifndef WIN32_WINNT
 #ifndef WIN32_WINNT
 #define WIN32_WINNT 0x400
 #define WIN32_WINNT 0x400
 #endif
 #endif
@@ -35,7 +35,7 @@
 #ifdef HAVE_STRING_H
 #ifdef HAVE_STRING_H
 #include <string.h>
 #include <string.h>
 #endif
 #endif
-#if defined(HAVE_PTHREAD_H) && !defined(MS_WINDOWS)
+#if defined(HAVE_PTHREAD_H) && !defined(_WIN32)
 #include <pthread.h>
 #include <pthread.h>
 #endif
 #endif
 #include <stdarg.h>
 #include <stdarg.h>
@@ -89,7 +89,7 @@
 #endif
 #endif
 
 
 /* inline is __inline on windows. */
 /* inline is __inline on windows. */
-#ifdef MS_WINDOWS
+#ifdef _WIN32
 #define INLINE __inline
 #define INLINE __inline
 #else
 #else
 #define INLINE inline
 #define INLINE inline
@@ -196,7 +196,7 @@ extern INLINE double U64_TO_DBL(uint64_t x) {
 #endif
 #endif
 
 
 /* ===== String compatibility */
 /* ===== String compatibility */
-#ifdef MS_WINDOWS
+#ifdef _WIN32
 /* Windows names string functions differently from most other platforms. */
 /* Windows names string functions differently from most other platforms. */
 #define strncasecmp _strnicmp
 #define strncasecmp _strnicmp
 #define strcasecmp _stricmp
 #define strcasecmp _stricmp
@@ -249,7 +249,7 @@ typedef struct tor_mmap_t {
 #ifdef HAVE_SYS_MMAN_H
 #ifdef HAVE_SYS_MMAN_H
   size_t mapping_size; /**< Size of the actual mapping. (This is this file
   size_t mapping_size; /**< Size of the actual mapping. (This is this file
                         * size, rounded up to the nearest page.) */
                         * size, rounded up to the nearest page.) */
-#elif defined MS_WINDOWS
+#elif defined _WIN32
   HANDLE file_handle;
   HANDLE file_handle;
   HANDLE mmap_handle;
   HANDLE mmap_handle;
 #endif
 #endif
@@ -307,7 +307,7 @@ char *tor_strtok_r_impl(char *str, const char *sep, char **lasts);
 #define tor_strtok_r(str, sep, lasts) tor_strtok_r_impl(str, sep, lasts)
 #define tor_strtok_r(str, sep, lasts) tor_strtok_r_impl(str, sep, lasts)
 #endif
 #endif
 
 
-#ifdef MS_WINDOWS
+#ifdef _WIN32
 #define _SHORT_FILE_ (tor_fix_source_file(__FILE__))
 #define _SHORT_FILE_ (tor_fix_source_file(__FILE__))
 const char *tor_fix_source_file(const char *fname);
 const char *tor_fix_source_file(const char *fname);
 #else
 #else
@@ -386,7 +386,7 @@ void tor_lockfile_unlock(tor_lockfile_t *lockfile);
 off_t tor_fd_getpos(int fd);
 off_t tor_fd_getpos(int fd);
 int tor_fd_seekend(int fd);
 int tor_fd_seekend(int fd);
 
 
-#ifdef MS_WINDOWS
+#ifdef _WIN32
 #define PATH_SEPARATOR "\\"
 #define PATH_SEPARATOR "\\"
 #else
 #else
 #define PATH_SEPARATOR "/"
 #define PATH_SEPARATOR "/"
@@ -398,7 +398,7 @@ int tor_fd_seekend(int fd);
 typedef int socklen_t;
 typedef int socklen_t;
 #endif
 #endif
 
 
-#ifdef MS_WINDOWS
+#ifdef _WIN32
 /* XXX Actually, this should arguably be SOCKET; we use intptr_t here so that
 /* XXX Actually, this should arguably be SOCKET; we use intptr_t here so that
  * any inadvertant checks for the socket being <= 0 or > 0 will probably
  * any inadvertant checks for the socket being <= 0 or > 0 will probably
  * still work. */
  * still work. */
@@ -499,7 +499,7 @@ int network_init(void);
  * errnos against expected values, and use tor_socket_errno to find
  * errnos against expected values, and use tor_socket_errno to find
  * the actual errno after a socket operation fails.
  * the actual errno after a socket operation fails.
  */
  */
-#if defined(MS_WINDOWS)
+#if defined(_WIN32)
 /** Return true if e is EAGAIN or the local equivalent. */
 /** Return true if e is EAGAIN or the local equivalent. */
 #define ERRNO_IS_EAGAIN(e)           ((e) == EAGAIN || (e) == WSAEWOULDBLOCK)
 #define ERRNO_IS_EAGAIN(e)           ((e) == EAGAIN || (e) == WSAEWOULDBLOCK)
 /** Return true if e is EINPROGRESS or the local equivalent. */
 /** Return true if e is EINPROGRESS or the local equivalent. */
@@ -584,7 +584,7 @@ char *make_path_absolute(char *fname);
 int spawn_func(void (*func)(void *), void *data);
 int spawn_func(void (*func)(void *), void *data);
 void spawn_exit(void) ATTR_NORETURN;
 void spawn_exit(void) ATTR_NORETURN;
 
 
-#if defined(ENABLE_THREADS) && defined(MS_WINDOWS)
+#if defined(ENABLE_THREADS) && defined(_WIN32)
 #define USE_WIN32_THREADS
 #define USE_WIN32_THREADS
 #define TOR_IS_MULTITHREADED 1
 #define TOR_IS_MULTITHREADED 1
 #elif (defined(ENABLE_THREADS) && defined(HAVE_PTHREAD_H) && \
 #elif (defined(ENABLE_THREADS) && defined(HAVE_PTHREAD_H) && \
@@ -666,14 +666,14 @@ void tor_cond_signal_all(tor_cond_t *cond);
 #endif
 #endif
 
 
 /* Platform-specific helpers. */
 /* Platform-specific helpers. */
-#ifdef MS_WINDOWS
+#ifdef _WIN32
 char *format_win32_error(DWORD err);
 char *format_win32_error(DWORD err);
 #endif
 #endif
 
 
 /*for some reason my compiler doesn't have these version flags defined
 /*for some reason my compiler doesn't have these version flags defined
   a nice homework assignment for someone one day is to define the rest*/
   a nice homework assignment for someone one day is to define the rest*/
 //these are the values as given on MSDN
 //these are the values as given on MSDN
-#ifdef MS_WINDOWS
+#ifdef _WIN32
 
 
 #ifndef VER_SUITE_EMBEDDEDNT
 #ifndef VER_SUITE_EMBEDDEDNT
 #define VER_SUITE_EMBEDDEDNT 0x00000040
 #define VER_SUITE_EMBEDDEDNT 0x00000040

+ 2 - 2
src/common/compat_libevent.c

@@ -205,7 +205,7 @@ tor_libevent_initialize(tor_libevent_cfg *torcfg)
     cfg = event_config_new();
     cfg = event_config_new();
     tor_assert(cfg);
     tor_assert(cfg);
 
 
-#if defined(MS_WINDOWS) && defined(USE_BUFFEREVENTS)
+#if defined(_WIN32) && defined(USE_BUFFEREVENTS)
     if (! torcfg->disable_iocp) {
     if (! torcfg->disable_iocp) {
       evthread_use_windows_threads();
       evthread_use_windows_threads();
       event_config_set_flag(cfg, EVENT_BASE_FLAG_STARTUP_IOCP);
       event_config_set_flag(cfg, EVENT_BASE_FLAG_STARTUP_IOCP);
@@ -241,7 +241,7 @@ tor_libevent_initialize(tor_libevent_cfg *torcfg)
       /* This could be a socketpair() failure, which can happen sometimes on
       /* This could be a socketpair() failure, which can happen sometimes on
        * windows boxes with obnoxious firewall rules.  Downgrade and try
        * windows boxes with obnoxious firewall rules.  Downgrade and try
        * again. */
        * again. */
-#if defined(MS_WINDOWS) && defined(USE_BUFFEREVENTS)
+#if defined(_WIN32) && defined(USE_BUFFEREVENTS)
       if (torcfg->disable_iocp == 0) {
       if (torcfg->disable_iocp == 0) {
         log_warn(LD_GENERAL, "Unable to initialize Libevent. Trying again "
         log_warn(LD_GENERAL, "Unable to initialize Libevent. Trying again "
                  "with IOCP disabled.");
                  "with IOCP disabled.");

+ 3 - 3
src/common/crypto.c

@@ -12,7 +12,7 @@
 
 
 #include "orconfig.h"
 #include "orconfig.h"
 
 
-#ifdef MS_WINDOWS
+#ifdef _WIN32
 #ifndef WIN32_WINNT
 #ifndef WIN32_WINNT
 #define WIN32_WINNT 0x400
 #define WIN32_WINNT 0x400
 #endif
 #endif
@@ -2409,7 +2409,7 @@ crypto_seed_rng(int startup)
   int rand_poll_status = 0;
   int rand_poll_status = 0;
 
 
   /* local variables */
   /* local variables */
-#ifdef MS_WINDOWS
+#ifdef _WIN32
   unsigned char buf[ADD_ENTROPY];
   unsigned char buf[ADD_ENTROPY];
   static int provider_set = 0;
   static int provider_set = 0;
   static HCRYPTPROV provider;
   static HCRYPTPROV provider;
@@ -2431,7 +2431,7 @@ crypto_seed_rng(int startup)
       log_warn(LD_CRYPTO, "RAND_poll() failed.");
       log_warn(LD_CRYPTO, "RAND_poll() failed.");
   }
   }
 
 
-#ifdef MS_WINDOWS
+#ifdef _WIN32
   if (!provider_set) {
   if (!provider_set) {
     if (!CryptAcquireContext(&provider, NULL, NULL, PROV_RSA_FULL,
     if (!CryptAcquireContext(&provider, NULL, NULL, PROV_RSA_FULL,
                              CRYPT_VERIFYCONTEXT)) {
                              CRYPT_VERIFYCONTEXT)) {

+ 5 - 5
src/common/procmon.c

@@ -21,7 +21,7 @@
 #include <errno.h>
 #include <errno.h>
 #endif
 #endif
 
 
-#ifdef MS_WINDOWS
+#ifdef _WIN32
 #include <windows.h>
 #include <windows.h>
 
 
 /* Windows does not define pid_t, but _getpid() returns an int. */
 /* Windows does not define pid_t, but _getpid() returns an int. */
@@ -91,7 +91,7 @@ struct tor_process_monitor_t {
    * polls. */
    * polls. */
   pid_t pid;
   pid_t pid;
 
 
-#ifdef MS_WINDOWS
+#ifdef _WIN32
   /** Windows-only: Should we poll hproc?  If false, poll pid
   /** Windows-only: Should we poll hproc?  If false, poll pid
    * instead. */
    * instead. */
   int poll_hproc;
   int poll_hproc;
@@ -192,7 +192,7 @@ tor_process_monitor_new(struct event_base *base,
 
 
   procmon->pid = ppspec.pid;
   procmon->pid = ppspec.pid;
 
 
-#ifdef MS_WINDOWS
+#ifdef _WIN32
   procmon->hproc = OpenProcess(PROCESS_QUERY_INFORMATION | SYNCHRONIZE,
   procmon->hproc = OpenProcess(PROCESS_QUERY_INFORMATION | SYNCHRONIZE,
                                FALSE,
                                FALSE,
                                procmon->pid);
                                procmon->pid);
@@ -246,7 +246,7 @@ tor_process_monitor_poll_cb(evutil_socket_t unused1, short unused2,
 
 
   tor_assert(procmon != NULL);
   tor_assert(procmon != NULL);
 
 
-#ifdef MS_WINDOWS
+#ifdef _WIN32
   if (procmon->poll_hproc) {
   if (procmon->poll_hproc) {
     DWORD exit_code;
     DWORD exit_code;
     if (!GetExitCodeProcess(procmon->hproc, &exit_code)) {
     if (!GetExitCodeProcess(procmon->hproc, &exit_code)) {
@@ -323,7 +323,7 @@ tor_process_monitor_free(tor_process_monitor_t *procmon)
   if (procmon == NULL)
   if (procmon == NULL)
     return;
     return;
 
 
-#ifdef MS_WINDOWS
+#ifdef _WIN32
   if (procmon->hproc != NULL)
   if (procmon->hproc != NULL)
     CloseHandle(procmon->hproc);
     CloseHandle(procmon->hproc);
 #endif
 #endif

+ 2 - 2
src/common/tortls.c

@@ -21,7 +21,7 @@
 #endif
 #endif
 
 
 #include <assert.h>
 #include <assert.h>
-#ifdef MS_WINDOWS /*wrkard for dtls1.h >= 0.9.8m of "#include <winsock.h>"*/
+#ifdef _WIN32 /*wrkard for dtls1.h >= 0.9.8m of "#include <winsock.h>"*/
  #ifndef WIN32_WINNT
  #ifndef WIN32_WINNT
  #define WIN32_WINNT 0x400
  #define WIN32_WINNT 0x400
  #endif
  #endif
@@ -333,7 +333,7 @@ tls_log_errors(tor_tls_t *tls, int severity, int domain, const char *doing)
 static int
 static int
 tor_errno_to_tls_error(int e)
 tor_errno_to_tls_error(int e)
 {
 {
-#if defined(MS_WINDOWS)
+#if defined(_WIN32)
   switch (e) {
   switch (e) {
     case WSAECONNRESET: // most common
     case WSAECONNRESET: // most common
       return TOR_TLS_ERROR_CONNRESET;
       return TOR_TLS_ERROR_CONNRESET;

+ 32 - 32
src/common/util.c

@@ -26,7 +26,7 @@
 #include "container.h"
 #include "container.h"
 #include "address.h"
 #include "address.h"
 
 
-#ifdef MS_WINDOWS
+#ifdef _WIN32
 #include <io.h>
 #include <io.h>
 #include <direct.h>
 #include <direct.h>
 #include <process.h>
 #include <process.h>
@@ -915,7 +915,7 @@ tor_parse_uint64(const char *s, int base, uint64_t min,
 
 
 #ifdef HAVE_STRTOULL
 #ifdef HAVE_STRTOULL
   r = (uint64_t)strtoull(s, &endptr, base);
   r = (uint64_t)strtoull(s, &endptr, base);
-#elif defined(MS_WINDOWS)
+#elif defined(_WIN32)
 #if defined(_MSC_VER) && _MSC_VER < 1300
 #if defined(_MSC_VER) && _MSC_VER < 1300
   tor_assert(base <= 10);
   tor_assert(base <= 10);
   r = (uint64_t)_atoi64(s);
   r = (uint64_t)_atoi64(s);
@@ -1731,7 +1731,7 @@ read_all(tor_socket_t fd, char *buf, size_t count, int isSocket)
 static void
 static void
 clean_name_for_stat(char *name)
 clean_name_for_stat(char *name)
 {
 {
-#ifdef MS_WINDOWS
+#ifdef _WIN32
   size_t len = strlen(name);
   size_t len = strlen(name);
   if (!len)
   if (!len)
     return;
     return;
@@ -1790,7 +1790,7 @@ check_private_dir(const char *dirname, cpd_check_t check,
   int r;
   int r;
   struct stat st;
   struct stat st;
   char *f;
   char *f;
-#ifndef MS_WINDOWS
+#ifndef _WIN32
   int mask;
   int mask;
   struct passwd *pw = NULL;
   struct passwd *pw = NULL;
   uid_t running_uid;
   uid_t running_uid;
@@ -1812,7 +1812,7 @@ check_private_dir(const char *dirname, cpd_check_t check,
     }
     }
     if (check & CPD_CREATE) {
     if (check & CPD_CREATE) {
       log_info(LD_GENERAL, "Creating directory %s", dirname);
       log_info(LD_GENERAL, "Creating directory %s", dirname);
-#if defined (MS_WINDOWS) && !defined (WINCE)
+#if defined (_WIN32) && !defined (WINCE)
       r = mkdir(dirname);
       r = mkdir(dirname);
 #else
 #else
       r = mkdir(dirname, 0700);
       r = mkdir(dirname, 0700);
@@ -1834,7 +1834,7 @@ check_private_dir(const char *dirname, cpd_check_t check,
     log_warn(LD_FS, "%s is not a directory", dirname);
     log_warn(LD_FS, "%s is not a directory", dirname);
     return -1;
     return -1;
   }
   }
-#ifndef MS_WINDOWS
+#ifndef _WIN32
   if (effective_user) {
   if (effective_user) {
     /* Look up the user and group information.
     /* Look up the user and group information.
      * If we have a problem, bail out. */
      * If we have a problem, bail out. */
@@ -1921,7 +1921,7 @@ check_private_dir(const char *dirname, cpd_check_t check,
 int
 int
 write_str_to_file(const char *fname, const char *str, int bin)
 write_str_to_file(const char *fname, const char *str, int bin)
 {
 {
-#ifdef MS_WINDOWS
+#ifdef _WIN32
   if (!bin && strchr(str, '\r')) {
   if (!bin && strchr(str, '\r')) {
     log_warn(LD_BUG,
     log_warn(LD_BUG,
              "We're writing a text string that already contains a CR.");
              "We're writing a text string that already contains a CR.");
@@ -2263,7 +2263,7 @@ read_file_to_str(const char *filename, int flags, struct stat *stat_out)
   }
   }
   string[r] = '\0'; /* NUL-terminate the result. */
   string[r] = '\0'; /* NUL-terminate the result. */
 
 
-#ifdef MS_WINDOWS
+#ifdef _WIN32
   if (!bin && strchr(string, '\r')) {
   if (!bin && strchr(string, '\r')) {
     log_debug(LD_FS, "We didn't convert CRLF to LF as well as we hoped "
     log_debug(LD_FS, "We didn't convert CRLF to LF as well as we hoped "
               "when reading %s. Coping.",
               "when reading %s. Coping.",
@@ -2544,7 +2544,7 @@ char *
 expand_filename(const char *filename)
 expand_filename(const char *filename)
 {
 {
   tor_assert(filename);
   tor_assert(filename);
-#ifdef MS_WINDOWS
+#ifdef _WIN32
   return tor_strdup(filename);
   return tor_strdup(filename);
 #else
 #else
   if (*filename == '~') {
   if (*filename == '~') {
@@ -2780,7 +2780,7 @@ smartlist_t *
 tor_listdir(const char *dirname)
 tor_listdir(const char *dirname)
 {
 {
   smartlist_t *result;
   smartlist_t *result;
-#ifdef MS_WINDOWS
+#ifdef _WIN32
   char *pattern=NULL;
   char *pattern=NULL;
   TCHAR tpattern[MAX_PATH] = {0};
   TCHAR tpattern[MAX_PATH] = {0};
   char name[MAX_PATH] = {0};
   char name[MAX_PATH] = {0};
@@ -2843,7 +2843,7 @@ path_is_relative(const char *filename)
 {
 {
   if (filename && filename[0] == '/')
   if (filename && filename[0] == '/')
     return 0;
     return 0;
-#ifdef MS_WINDOWS
+#ifdef _WIN32
   else if (filename && filename[0] == '\\')
   else if (filename && filename[0] == '\\')
     return 0;
     return 0;
   else if (filename && strlen(filename)>3 && TOR_ISALPHA(filename[0]) &&
   else if (filename && strlen(filename)>3 && TOR_ISALPHA(filename[0]) &&
@@ -2858,7 +2858,7 @@ path_is_relative(const char *filename)
  * Process helpers
  * Process helpers
  * ===== */
  * ===== */
 
 
-#ifndef MS_WINDOWS
+#ifndef _WIN32
 /* Based on code contributed by christian grothoff */
 /* Based on code contributed by christian grothoff */
 /** True iff we've called start_daemon(). */
 /** True iff we've called start_daemon(). */
 static int start_daemon_called = 0;
 static int start_daemon_called = 0;
@@ -2995,7 +2995,7 @@ write_pidfile(char *filename)
     log_warn(LD_FS, "Unable to open \"%s\" for writing: %s", filename,
     log_warn(LD_FS, "Unable to open \"%s\" for writing: %s", filename,
              strerror(errno));
              strerror(errno));
   } else {
   } else {
-#ifdef MS_WINDOWS
+#ifdef _WIN32
     fprintf(pidfile, "%d\n", (int)_getpid());
     fprintf(pidfile, "%d\n", (int)_getpid());
 #else
 #else
     fprintf(pidfile, "%d\n", (int)getpid());
     fprintf(pidfile, "%d\n", (int)getpid());
@@ -3004,7 +3004,7 @@ write_pidfile(char *filename)
   }
   }
 }
 }
 
 
-#ifdef MS_WINDOWS
+#ifdef _WIN32
 HANDLE
 HANDLE
 load_windows_system_library(const TCHAR *library_name)
 load_windows_system_library(const TCHAR *library_name)
 {
 {
@@ -3191,7 +3191,7 @@ format_helper_exit_status(unsigned char child_state, int saved_errno,
 int
 int
 tor_terminate_process(process_handle_t *process_handle)
 tor_terminate_process(process_handle_t *process_handle)
 {
 {
-#ifdef MS_WINDOWS
+#ifdef _WIN32
   if (tor_get_exit_code(process_handle, 0, NULL) == PROCESS_EXIT_RUNNING) {
   if (tor_get_exit_code(process_handle, 0, NULL) == PROCESS_EXIT_RUNNING) {
     HANDLE handle;
     HANDLE handle;
     /* If the signal is outside of what GenerateConsoleCtrlEvent can use,
     /* If the signal is outside of what GenerateConsoleCtrlEvent can use,
@@ -3217,14 +3217,14 @@ tor_terminate_process(process_handle_t *process_handle)
 int
 int
 tor_process_get_pid(process_handle_t *process_handle)
 tor_process_get_pid(process_handle_t *process_handle)
 {
 {
-#ifdef MS_WINDOWS
+#ifdef _WIN32
   return (int) process_handle->pid.dwProcessId;
   return (int) process_handle->pid.dwProcessId;
 #else
 #else
   return (int) process_handle->pid;
   return (int) process_handle->pid;
 #endif
 #endif
 }
 }
 
 
-#ifdef MS_WINDOWS
+#ifdef _WIN32
 HANDLE
 HANDLE
 tor_process_get_stdout_pipe(process_handle_t *process_handle)
 tor_process_get_stdout_pipe(process_handle_t *process_handle)
 {
 {
@@ -3243,7 +3243,7 @@ process_handle_new(void)
 {
 {
   process_handle_t *out = tor_malloc_zero(sizeof(process_handle_t));
   process_handle_t *out = tor_malloc_zero(sizeof(process_handle_t));
 
 
-#ifndef MS_WINDOWS
+#ifndef _WIN32
   out->stdout_pipe = -1;
   out->stdout_pipe = -1;
   out->stderr_pipe = -1;
   out->stderr_pipe = -1;
 #endif
 #endif
@@ -3284,14 +3284,14 @@ process_handle_new(void)
  */
  */
 int
 int
 tor_spawn_background(const char *const filename, const char **argv,
 tor_spawn_background(const char *const filename, const char **argv,
-#ifdef MS_WINDOWS
+#ifdef _WIN32
                      LPVOID envp,
                      LPVOID envp,
 #else
 #else
                      const char **envp,
                      const char **envp,
 #endif
 #endif
                      process_handle_t **process_handle_out)
                      process_handle_t **process_handle_out)
 {
 {
-#ifdef MS_WINDOWS
+#ifdef _WIN32
   HANDLE stdout_pipe_read = NULL;
   HANDLE stdout_pipe_read = NULL;
   HANDLE stdout_pipe_write = NULL;
   HANDLE stdout_pipe_write = NULL;
   HANDLE stderr_pipe_read = NULL;
   HANDLE stderr_pipe_read = NULL;
@@ -3393,7 +3393,7 @@ tor_spawn_background(const char *const filename, const char **argv,
   /* TODO: Close pipes on exit */
   /* TODO: Close pipes on exit */
   *process_handle_out = process_handle;
   *process_handle_out = process_handle;
   return status;
   return status;
-#else // MS_WINDOWS
+#else // _WIN32
   pid_t pid;
   pid_t pid;
   int stdout_pipe[2];
   int stdout_pipe[2];
   int stderr_pipe[2];
   int stderr_pipe[2];
@@ -3574,7 +3574,7 @@ tor_spawn_background(const char *const filename, const char **argv,
 
 
   *process_handle_out = process_handle;
   *process_handle_out = process_handle;
   return process_handle->status;
   return process_handle->status;
-#endif // MS_WINDOWS
+#endif // _WIN32
 }
 }
 
 
 /** Destroy all resources allocated by the process handle in
 /** Destroy all resources allocated by the process handle in
@@ -3600,7 +3600,7 @@ tor_process_handle_destroy(process_handle_t *process_handle,
 
 
   process_handle->status = PROCESS_STATUS_NOTRUNNING;
   process_handle->status = PROCESS_STATUS_NOTRUNNING;
 
 
-#ifdef MS_WINDOWS
+#ifdef _WIN32
   if (process_handle->stdout_pipe)
   if (process_handle->stdout_pipe)
     CloseHandle(process_handle->stdout_pipe);
     CloseHandle(process_handle->stdout_pipe);
 
 
@@ -3632,7 +3632,7 @@ int
 tor_get_exit_code(const process_handle_t *process_handle,
 tor_get_exit_code(const process_handle_t *process_handle,
                   int block, int *exit_code)
                   int block, int *exit_code)
 {
 {
-#ifdef MS_WINDOWS
+#ifdef _WIN32
   DWORD retval;
   DWORD retval;
   BOOL success;
   BOOL success;
 
 
@@ -3687,12 +3687,12 @@ tor_get_exit_code(const process_handle_t *process_handle,
 
 
   if (exit_code != NULL)
   if (exit_code != NULL)
     *exit_code = WEXITSTATUS(stat_loc);
     *exit_code = WEXITSTATUS(stat_loc);
-#endif // MS_WINDOWS
+#endif // _WIN32
 
 
   return PROCESS_EXIT_EXITED;
   return PROCESS_EXIT_EXITED;
 }
 }
 
 
-#ifdef MS_WINDOWS
+#ifdef _WIN32
 /** Read from a handle <b>h</b> into <b>buf</b>, up to <b>count</b> bytes.  If
 /** Read from a handle <b>h</b> into <b>buf</b>, up to <b>count</b> bytes.  If
  * <b>hProcess</b> is NULL, the function will return immediately if there is
  * <b>hProcess</b> is NULL, the function will return immediately if there is
  * nothing more to read. Otherwise <b>hProcess</b> should be set to the handle
  * nothing more to read. Otherwise <b>hProcess</b> should be set to the handle
@@ -3814,7 +3814,7 @@ ssize_t
 tor_read_all_from_process_stdout(const process_handle_t *process_handle,
 tor_read_all_from_process_stdout(const process_handle_t *process_handle,
                                  char *buf, size_t count)
                                  char *buf, size_t count)
 {
 {
-#ifdef MS_WINDOWS
+#ifdef _WIN32
   return tor_read_all_handle(process_handle->stdout_pipe, buf, count,
   return tor_read_all_handle(process_handle->stdout_pipe, buf, count,
                              process_handle);
                              process_handle);
 #else
 #else
@@ -3828,7 +3828,7 @@ ssize_t
 tor_read_all_from_process_stderr(const process_handle_t *process_handle,
 tor_read_all_from_process_stderr(const process_handle_t *process_handle,
                                  char *buf, size_t count)
                                  char *buf, size_t count)
 {
 {
-#ifdef MS_WINDOWS
+#ifdef _WIN32
   return tor_read_all_handle(process_handle->stderr_pipe, buf, count,
   return tor_read_all_handle(process_handle->stderr_pipe, buf, count,
                              process_handle);
                              process_handle);
 #else
 #else
@@ -3890,7 +3890,7 @@ tor_split_lines(smartlist_t *sl, char *buf, int len)
   return smartlist_len(sl);
   return smartlist_len(sl);
 }
 }
 
 
-#ifdef MS_WINDOWS
+#ifdef _WIN32
 /** Read from stream, and send lines to log at the specified log level.
 /** Read from stream, and send lines to log at the specified log level.
  * Returns -1 if there is a error reading, and 0 otherwise.
  * Returns -1 if there is a error reading, and 0 otherwise.
  * If the generated stream is flushed more often than on new lines, or
  * If the generated stream is flushed more often than on new lines, or
@@ -4103,7 +4103,7 @@ tor_check_port_forwarding(const char *filename, int dir_port, int or_port,
       child_handle = NULL;
       child_handle = NULL;
     }
     }
 
 
-#ifdef MS_WINDOWS
+#ifdef _WIN32
     /* Passing NULL as lpApplicationName makes Windows search for the .exe */
     /* Passing NULL as lpApplicationName makes Windows search for the .exe */
     status = tor_spawn_background(NULL, argv, NULL, &child_handle);
     status = tor_spawn_background(NULL, argv, NULL, &child_handle);
 #else
 #else
@@ -4126,7 +4126,7 @@ tor_check_port_forwarding(const char *filename, int dir_port, int or_port,
   if (child_handle && PROCESS_STATUS_RUNNING == child_handle->status) {
   if (child_handle && PROCESS_STATUS_RUNNING == child_handle->status) {
     /* Read from stdout/stderr and log result */
     /* Read from stdout/stderr and log result */
     retval = 0;
     retval = 0;
-#ifdef MS_WINDOWS
+#ifdef _WIN32
     stdout_status = log_from_handle(child_handle->stdout_pipe, LOG_INFO);
     stdout_status = log_from_handle(child_handle->stdout_pipe, LOG_INFO);
     stderr_status = log_from_handle(child_handle->stderr_pipe, LOG_WARN);
     stderr_status = log_from_handle(child_handle->stderr_pipe, LOG_WARN);
     /* If we got this far (on Windows), the process started */
     /* If we got this far (on Windows), the process started */
@@ -4146,7 +4146,7 @@ tor_check_port_forwarding(const char *filename, int dir_port, int or_port,
     if (-1 == stdout_status || -1 == stderr_status)
     if (-1 == stdout_status || -1 == stderr_status)
       /* There was a failure */
       /* There was a failure */
       retval = -1;
       retval = -1;
-#ifdef MS_WINDOWS
+#ifdef _WIN32
     else if (!child_handle || tor_get_exit_code(child_handle, 0, NULL) !=
     else if (!child_handle || tor_get_exit_code(child_handle, 0, NULL) !=
              PROCESS_EXIT_RUNNING) {
              PROCESS_EXIT_RUNNING) {
       /* process has exited or there was an error */
       /* process has exited or there was an error */

+ 6 - 6
src/common/util.h

@@ -364,7 +364,7 @@ void tor_check_port_forwarding(const char *filename,
 
 
 typedef struct process_handle_t process_handle_t;
 typedef struct process_handle_t process_handle_t;
 int tor_spawn_background(const char *const filename, const char **argv,
 int tor_spawn_background(const char *const filename, const char **argv,
-#ifdef MS_WINDOWS
+#ifdef _WIN32
                          LPVOID envp,
                          LPVOID envp,
 #else
 #else
                          const char **envp,
                          const char **envp,
@@ -373,7 +373,7 @@ int tor_spawn_background(const char *const filename, const char **argv,
 
 
 #define SPAWN_ERROR_MESSAGE "ERR: Failed to spawn background process - code "
 #define SPAWN_ERROR_MESSAGE "ERR: Failed to spawn background process - code "
 
 
-#ifdef MS_WINDOWS
+#ifdef _WIN32
 HANDLE load_windows_system_library(const TCHAR *library_name);
 HANDLE load_windows_system_library(const TCHAR *library_name);
 #endif
 #endif
 
 
@@ -388,7 +388,7 @@ HANDLE load_windows_system_library(const TCHAR *library_name);
 /*DOCDOC*/
 /*DOCDOC*/
 struct process_handle_t {
 struct process_handle_t {
   int status;
   int status;
-#ifdef MS_WINDOWS
+#ifdef _WIN32
   HANDLE stdout_pipe;
   HANDLE stdout_pipe;
   HANDLE stderr_pipe;
   HANDLE stderr_pipe;
   PROCESS_INFORMATION pid;
   PROCESS_INFORMATION pid;
@@ -398,7 +398,7 @@ struct process_handle_t {
   FILE *stdout_handle;
   FILE *stdout_handle;
   FILE *stderr_handle;
   FILE *stderr_handle;
   pid_t pid;
   pid_t pid;
-#endif // MS_WINDOWS
+#endif // _WIN32
 };
 };
 #endif
 #endif
 
 
@@ -409,7 +409,7 @@ struct process_handle_t {
 int tor_get_exit_code(const process_handle_t *process_handle,
 int tor_get_exit_code(const process_handle_t *process_handle,
                       int block, int *exit_code);
                       int block, int *exit_code);
 int tor_split_lines(struct smartlist_t *sl, char *buf, int len);
 int tor_split_lines(struct smartlist_t *sl, char *buf, int len);
-#ifdef MS_WINDOWS
+#ifdef _WIN32
 ssize_t tor_read_all_handle(HANDLE h, char *buf, size_t count,
 ssize_t tor_read_all_handle(HANDLE h, char *buf, size_t count,
                             const process_handle_t *process);
                             const process_handle_t *process);
 #else
 #else
@@ -424,7 +424,7 @@ ssize_t tor_read_all_from_process_stderr(
 char *tor_join_win_cmdline(const char *argv[]);
 char *tor_join_win_cmdline(const char *argv[]);
 
 
 int tor_process_get_pid(process_handle_t *process_handle);
 int tor_process_get_pid(process_handle_t *process_handle);
-#ifdef MS_WINDOWS
+#ifdef _WIN32
 HANDLE tor_process_get_stdout_pipe(process_handle_t *process_handle);
 HANDLE tor_process_get_stdout_pipe(process_handle_t *process_handle);
 #else
 #else
 FILE *tor_process_get_stdout_pipe(process_handle_t *process_handle);
 FILE *tor_process_get_stdout_pipe(process_handle_t *process_handle);

+ 2 - 2
src/or/buffers.c

@@ -633,7 +633,7 @@ read_to_chunk(buf_t *buf, chunk_t *chunk, tor_socket_t fd, size_t at_most,
   if (read_result < 0) {
   if (read_result < 0) {
     int e = tor_socket_errno(fd);
     int e = tor_socket_errno(fd);
     if (!ERRNO_IS_EAGAIN(e)) { /* it's a real error */
     if (!ERRNO_IS_EAGAIN(e)) { /* it's a real error */
-#ifdef MS_WINDOWS
+#ifdef _WIN32
       if (e == WSAENOBUFS)
       if (e == WSAENOBUFS)
         log_warn(LD_NET,"recv() failed: WSAENOBUFS. Not enough ram?");
         log_warn(LD_NET,"recv() failed: WSAENOBUFS. Not enough ram?");
 #endif
 #endif
@@ -790,7 +790,7 @@ flush_chunk(tor_socket_t s, buf_t *buf, chunk_t *chunk, size_t sz,
   if (write_result < 0) {
   if (write_result < 0) {
     int e = tor_socket_errno(s);
     int e = tor_socket_errno(s);
     if (!ERRNO_IS_EAGAIN(e)) { /* it's a real error */
     if (!ERRNO_IS_EAGAIN(e)) { /* it's a real error */
-#ifdef MS_WINDOWS
+#ifdef _WIN32
       if (e == WSAENOBUFS)
       if (e == WSAENOBUFS)
         log_warn(LD_NET,"write() failed: WSAENOBUFS. Not enough ram?");
         log_warn(LD_NET,"write() failed: WSAENOBUFS. Not enough ram?");
 #endif
 #endif

+ 11 - 11
src/or/config.c

@@ -36,7 +36,7 @@
 #include "util.h"
 #include "util.h"
 #include "routerlist.h"
 #include "routerlist.h"
 #include "transports.h"
 #include "transports.h"
-#ifdef MS_WINDOWS
+#ifdef _WIN32
 #include <shlobj.h>
 #include <shlobj.h>
 #endif
 #endif
 
 
@@ -289,7 +289,7 @@ static config_var_t _option_vars[] = {
   V(FetchHidServDescriptors,     BOOL,     "1"),
   V(FetchHidServDescriptors,     BOOL,     "1"),
   V(FetchUselessDescriptors,     BOOL,     "0"),
   V(FetchUselessDescriptors,     BOOL,     "0"),
   V(FetchV2Networkstatus,        BOOL,     "0"),
   V(FetchV2Networkstatus,        BOOL,     "0"),
-#ifdef WIN32
+#ifdef _WIN32
   V(GeoIPFile,                   FILENAME, "<default>"),
   V(GeoIPFile,                   FILENAME, "<default>"),
 #else
 #else
   V(GeoIPFile,                   FILENAME,
   V(GeoIPFile,                   FILENAME,
@@ -573,7 +573,7 @@ typedef struct {
                *(uint32_t*)STRUCT_VAR_P(cfg,fmt->magic_offset));        \
                *(uint32_t*)STRUCT_VAR_P(cfg,fmt->magic_offset));        \
   STMT_END
   STMT_END
 
 
-#ifdef MS_WINDOWS
+#ifdef _WIN32
 static char *get_windows_conf_root(void);
 static char *get_windows_conf_root(void);
 #endif
 #endif
 static void config_line_append(config_line_t **lst,
 static void config_line_append(config_line_t **lst,
@@ -1644,7 +1644,7 @@ options_act(const or_options_t *old_options)
      * understand prefixes somehow. -NM */
      * understand prefixes somehow. -NM */
     /* XXXX023 Reload GeoIPFile on SIGHUP. -NM */
     /* XXXX023 Reload GeoIPFile on SIGHUP. -NM */
     char *actual_fname = tor_strdup(options->GeoIPFile);
     char *actual_fname = tor_strdup(options->GeoIPFile);
-#ifdef WIN32
+#ifdef _WIN32
     if (!strcmp(actual_fname, "<default>")) {
     if (!strcmp(actual_fname, "<default>")) {
       const char *conf_root = get_windows_conf_root();
       const char *conf_root = get_windows_conf_root();
       tor_free(actual_fname);
       tor_free(actual_fname);
@@ -3357,7 +3357,7 @@ options_validate(or_options_t *old_options, or_options_t *options,
       REJECT("Failed to resolve/guess local address. See logs for details.");
       REJECT("Failed to resolve/guess local address. See logs for details.");
   }
   }
 
 
-#ifndef MS_WINDOWS
+#ifndef _WIN32
   if (options->RunAsDaemon && torrc_fname && path_is_relative(torrc_fname))
   if (options->RunAsDaemon && torrc_fname && path_is_relative(torrc_fname))
     REJECT("Can't use a relative path to torrc when RunAsDaemon is set.");
     REJECT("Can't use a relative path to torrc when RunAsDaemon is set.");
 #endif
 #endif
@@ -4247,7 +4247,7 @@ options_transition_affects_descriptor(const or_options_t *old_options,
   return 0;
   return 0;
 }
 }
 
 
-#ifdef MS_WINDOWS
+#ifdef _WIN32
 /** Return the directory on windows where we expect to find our application
 /** Return the directory on windows where we expect to find our application
  * data. */
  * data. */
 static char *
 static char *
@@ -4310,7 +4310,7 @@ get_windows_conf_root(void)
 static const char *
 static const char *
 get_default_conf_file(int defaults_file)
 get_default_conf_file(int defaults_file)
 {
 {
-#ifdef MS_WINDOWS
+#ifdef _WIN32
   if (defaults_file) {
   if (defaults_file) {
     static char defaults_path[MAX_PATH+1];
     static char defaults_path[MAX_PATH+1];
     tor_snprintf(defaults_path, MAX_PATH, "%s\\torrc-defaults",
     tor_snprintf(defaults_path, MAX_PATH, "%s\\torrc-defaults",
@@ -4400,7 +4400,7 @@ find_torrc_filename(int argc, char **argv,
     if (dflt && file_status(dflt) == FN_FILE) {
     if (dflt && file_status(dflt) == FN_FILE) {
       fname = tor_strdup(dflt);
       fname = tor_strdup(dflt);
     } else {
     } else {
-#ifndef MS_WINDOWS
+#ifndef _WIN32
       char *fn = NULL;
       char *fn = NULL;
       if (!defaults_file)
       if (!defaults_file)
         fn = expand_filename("~/.torrc");
         fn = expand_filename("~/.torrc");
@@ -4789,7 +4789,7 @@ options_init_logs(or_options_t *options, int validate_only)
   int ok;
   int ok;
   smartlist_t *elts;
   smartlist_t *elts;
   int daemon =
   int daemon =
-#ifdef MS_WINDOWS
+#ifdef _WIN32
                0;
                0;
 #else
 #else
                options->RunAsDaemon;
                options->RunAsDaemon;
@@ -5964,7 +5964,7 @@ check_server_ports(const smartlist_t *ports,
     } else {
     } else {
       continue;
       continue;
     }
     }
-#ifndef MS_WINDOWS
+#ifndef _WIN32
     if (!port->no_advertise && port->port < 1024)
     if (!port->no_advertise && port->port < 1024)
       ++n_low_port;
       ++n_low_port;
 #endif
 #endif
@@ -6041,7 +6041,7 @@ get_first_advertised_port_by_type_af(int listener_type, int address_family)
 static int
 static int
 normalize_data_directory(or_options_t *options)
 normalize_data_directory(or_options_t *options)
 {
 {
-#ifdef MS_WINDOWS
+#ifdef _WIN32
   char *p;
   char *p;
   if (options->DataDirectory)
   if (options->DataDirectory)
     return 0; /* all set */
     return 0; /* all set */

+ 2 - 2
src/or/connection.c

@@ -837,7 +837,7 @@ check_location_for_unix_socket(const or_options_t *options, const char *path)
 static void
 static void
 make_socket_reuseable(tor_socket_t sock)
 make_socket_reuseable(tor_socket_t sock)
 {
 {
-#ifdef MS_WINDOWS
+#ifdef _WIN32
   (void) sock;
   (void) sock;
 #else
 #else
   int one=1;
   int one=1;
@@ -1317,7 +1317,7 @@ connection_connect(connection_t *conn, const char *address,
      * Warn if we do, and refuse to make the connection. */
      * Warn if we do, and refuse to make the connection. */
     static ratelim_t disablenet_violated = RATELIM_INIT(30*60);
     static ratelim_t disablenet_violated = RATELIM_INIT(30*60);
     char *m;
     char *m;
-#ifdef MS_WINDOWS
+#ifdef _WIN32
     *socket_error = WSAENETUNREACH;
     *socket_error = WSAENETUNREACH;
 #else
 #else
     *socket_error = ENETUNREACH;
     *socket_error = ENETUNREACH;

+ 7 - 7
src/or/control.c

@@ -34,7 +34,7 @@
 #include "routerlist.h"
 #include "routerlist.h"
 #include "routerparse.h"
 #include "routerparse.h"
 
 
-#ifndef MS_WINDOWS
+#ifndef _WIN32
 #include <pwd.h>
 #include <pwd.h>
 #include <sys/resource.h>
 #include <sys/resource.h>
 #endif
 #endif
@@ -542,7 +542,7 @@ control_ports_write_to_file(void)
     log_warn(LD_CONTROL, "Writing %s failed: %s",
     log_warn(LD_CONTROL, "Writing %s failed: %s",
              options->ControlPortWriteToFile, strerror(errno));
              options->ControlPortWriteToFile, strerror(errno));
   }
   }
-#ifndef MS_WINDOWS
+#ifndef _WIN32
   if (options->ControlPortFileGroupReadable) {
   if (options->ControlPortFileGroupReadable) {
     if (chmod(options->ControlPortWriteToFile, 0640)) {
     if (chmod(options->ControlPortWriteToFile, 0640)) {
       log_warn(LD_FS,"Unable to make %s group-readable.",
       log_warn(LD_FS,"Unable to make %s group-readable.",
@@ -1392,7 +1392,7 @@ getinfo_helper_misc(control_connection_t *conn, const char *question,
   } else if (!strcmp(question, "process/pid")) {
   } else if (!strcmp(question, "process/pid")) {
     int myPid = -1;
     int myPid = -1;
 
 
-    #ifdef MS_WINDOWS
+    #ifdef _WIN32
       myPid = _getpid();
       myPid = _getpid();
     #else
     #else
       myPid = getpid();
       myPid = getpid();
@@ -1400,14 +1400,14 @@ getinfo_helper_misc(control_connection_t *conn, const char *question,
 
 
     tor_asprintf(answer, "%d", myPid);
     tor_asprintf(answer, "%d", myPid);
   } else if (!strcmp(question, "process/uid")) {
   } else if (!strcmp(question, "process/uid")) {
-    #ifdef MS_WINDOWS
+    #ifdef _WIN32
       *answer = tor_strdup("-1");
       *answer = tor_strdup("-1");
     #else
     #else
       int myUid = geteuid();
       int myUid = geteuid();
       tor_asprintf(answer, "%d", myUid);
       tor_asprintf(answer, "%d", myUid);
     #endif
     #endif
   } else if (!strcmp(question, "process/user")) {
   } else if (!strcmp(question, "process/user")) {
-    #ifdef MS_WINDOWS
+    #ifdef _WIN32
       *answer = tor_strdup("");
       *answer = tor_strdup("");
     #else
     #else
       int myUid = geteuid();
       int myUid = geteuid();
@@ -1435,7 +1435,7 @@ getinfo_helper_misc(control_connection_t *conn, const char *question,
       }
       }
     #elif defined(CYGWIN) || defined(__CYGWIN__)
     #elif defined(CYGWIN) || defined(__CYGWIN__)
       *answer = tor_strdup("3200");
       *answer = tor_strdup("3200");
-    #elif defined(MS_WINDOWS)
+    #elif defined(_WIN32)
       *answer = tor_strdup("15000");
       *answer = tor_strdup("15000");
     #else
     #else
       *answer = tor_strdup("15000");
       *answer = tor_strdup("15000");
@@ -4231,7 +4231,7 @@ init_cookie_authentication(int enabled)
     tor_free(fname);
     tor_free(fname);
     return -1;
     return -1;
   }
   }
-#ifndef MS_WINDOWS
+#ifndef _WIN32
   if (get_options()->CookieAuthFileGroupReadable) {
   if (get_options()->CookieAuthFileGroupReadable) {
     if (chmod(fname, 0640)) {
     if (chmod(fname, 0640)) {
       log_warn(LD_FS,"Unable to make %s group-readable.", escaped(fname));
       log_warn(LD_FS,"Unable to make %s group-readable.", escaped(fname));

+ 2 - 2
src/or/dns.c

@@ -1183,7 +1183,7 @@ configure_nameservers(int force)
   int r;
   int r;
   options = get_options();
   options = get_options();
   conf_fname = options->ServerDNSResolvConfFile;
   conf_fname = options->ServerDNSResolvConfFile;
-#ifndef MS_WINDOWS
+#ifndef _WIN32
   if (!conf_fname)
   if (!conf_fname)
     conf_fname = "/etc/resolv.conf";
     conf_fname = "/etc/resolv.conf";
 #endif
 #endif
@@ -1251,7 +1251,7 @@ configure_nameservers(int force)
     if (nameservers_configured)
     if (nameservers_configured)
       evdns_base_resume(the_evdns_base);
       evdns_base_resume(the_evdns_base);
   }
   }
-#ifdef MS_WINDOWS
+#ifdef _WIN32
   else {
   else {
     if (nameservers_configured) {
     if (nameservers_configured) {
       evdns_base_search_clear(the_evdns_base);
       evdns_base_search_clear(the_evdns_base);

+ 7 - 7
src/or/eventdns.c

@@ -96,7 +96,7 @@
 
 
 #include "eventdns.h"
 #include "eventdns.h"
 
 
-#ifdef WIN32
+#ifdef _WIN32
 #include <windows.h>
 #include <windows.h>
 #include <winsock2.h>
 #include <winsock2.h>
 #include <iphlpapi.h>
 #include <iphlpapi.h>
@@ -110,7 +110,7 @@
 #include <netinet/in6.h>
 #include <netinet/in6.h>
 #endif
 #endif
 
 
-#ifdef WIN32
+#ifdef _WIN32
 typedef int socklen_t;
 typedef int socklen_t;
 #endif
 #endif
 
 
@@ -343,7 +343,7 @@ static void server_port_ready_callback(int fd, short events, void *arg);
 
 
 static int strtoint(const char *const str);
 static int strtoint(const char *const str);
 
 
-#ifdef WIN32
+#ifdef _WIN32
 static int
 static int
 last_error(int sock)
 last_error(int sock)
 {
 {
@@ -432,7 +432,7 @@ _evdns_log(int warn, const char *fmt, ...)
 	if (!evdns_log_fn)
 	if (!evdns_log_fn)
 		return;
 		return;
 	va_start(args,fmt);
 	va_start(args,fmt);
-#ifdef WIN32
+#ifdef _WIN32
 	_vsnprintf(buf, sizeof(buf), fmt, args);
 	_vsnprintf(buf, sizeof(buf), fmt, args);
 #else
 #else
 	vsnprintf(buf, sizeof(buf), fmt, args);
 	vsnprintf(buf, sizeof(buf), fmt, args);
@@ -2298,7 +2298,7 @@ _evdns_nameserver_add_impl(const struct sockaddr *address,
 
 
 	ns->socket = tor_open_socket(address->sa_family, SOCK_DGRAM, 0);
 	ns->socket = tor_open_socket(address->sa_family, SOCK_DGRAM, 0);
 	if (ns->socket < 0) { err = 1; goto out1; }
 	if (ns->socket < 0) { err = 1; goto out1; }
-#ifdef WIN32
+#ifdef _WIN32
 	{
 	{
 		u_long nonblocking = 1;
 		u_long nonblocking = 1;
 		ioctlsocket(ns->socket, FIONBIO, &nonblocking);
 		ioctlsocket(ns->socket, FIONBIO, &nonblocking);
@@ -3101,7 +3101,7 @@ out1:
 	return err;
 	return err;
 }
 }
 
 
-#ifdef WIN32
+#ifdef _WIN32
 /* Add multiple nameservers from a space-or-comma-separated list. */
 /* Add multiple nameservers from a space-or-comma-separated list. */
 static int
 static int
 evdns_nameserver_ip_add_line(const char *ips) {
 evdns_nameserver_ip_add_line(const char *ips) {
@@ -3309,7 +3309,7 @@ int
 evdns_init(void)
 evdns_init(void)
 {
 {
 		int res = 0;
 		int res = 0;
-#ifdef WIN32
+#ifdef _WIN32
 		evdns_config_windows_nameservers();
 		evdns_config_windows_nameservers();
 #else
 #else
 		res = evdns_resolv_conf_parse(DNS_OPTIONS_ALL, "/etc/resolv.conf");
 		res = evdns_resolv_conf_parse(DNS_OPTIONS_ALL, "/etc/resolv.conf");

+ 1 - 1
src/or/eventdns.h

@@ -273,7 +273,7 @@ int evdns_resolve_reverse(const struct in_addr *in, int flags, evdns_callback_ty
 int evdns_resolve_reverse_ipv6(const struct in6_addr *in, int flags, evdns_callback_type callback, void *ptr);
 int evdns_resolve_reverse_ipv6(const struct in6_addr *in, int flags, evdns_callback_type callback, void *ptr);
 int evdns_set_option(const char *option, const char *val, int flags);
 int evdns_set_option(const char *option, const char *val, int flags);
 int evdns_resolv_conf_parse(int flags, const char *);
 int evdns_resolv_conf_parse(int flags, const char *);
-#ifdef MS_WINDOWS
+#ifdef _WIN32
 int evdns_config_windows_nameservers(void);
 int evdns_config_windows_nameservers(void);
 #endif
 #endif
 void evdns_search_clear(void);
 void evdns_search_clear(void);

+ 3 - 3
src/or/eventdns_tor.h

@@ -9,14 +9,14 @@ typedef unsigned int uint;
 #ifndef HAVE_U_CHAR
 #ifndef HAVE_U_CHAR
 typedef unsigned char u_char;
 typedef unsigned char u_char;
 #endif
 #endif
-#ifdef MS_WINDOWS
+#ifdef _WIN32
 #define inline __inline
 #define inline __inline
 #endif
 #endif
 #include "torint.h"
 #include "torint.h"
 
 
-#if defined(MS_WINDOWS) && !defined(WIN32)
+#if defined(_WIN32) && !defined(_WIN32)
 /* How did _this_ happen? */
 /* How did _this_ happen? */
-#define WIN32
+#define _WIN32
 #endif
 #endif
 
 
 /* These are for debugging possible memory leaks. */
 /* These are for debugging possible memory leaks. */

+ 12 - 12
src/or/main.c

@@ -196,7 +196,7 @@ free_old_inbuf(connection_t *conn)
 }
 }
 #endif
 #endif
 
 
-#if defined(MS_WINDOWS) && defined(USE_BUFFEREVENTS)
+#if defined(_WIN32) && defined(USE_BUFFEREVENTS)
 /** Remove the kernel-space send and receive buffers for <b>s</b>. For use
 /** Remove the kernel-space send and receive buffers for <b>s</b>. For use
  * with IOCP only. */
  * with IOCP only. */
 static int
 static int
@@ -237,7 +237,7 @@ connection_add_impl(connection_t *conn, int is_connecting)
   if (connection_type_uses_bufferevent(conn)) {
   if (connection_type_uses_bufferevent(conn)) {
     if (SOCKET_OK(conn->s) && !conn->linked) {
     if (SOCKET_OK(conn->s) && !conn->linked) {
 
 
-#ifdef MS_WINDOWS
+#ifdef _WIN32
       if (tor_libevent_using_iocp_bufferevents() &&
       if (tor_libevent_using_iocp_bufferevents() &&
           get_options()->UserspaceIOCPBuffers) {
           get_options()->UserspaceIOCPBuffers) {
         set_buffer_lengths_to_zero(conn->s);
         set_buffer_lengths_to_zero(conn->s);
@@ -701,7 +701,7 @@ conn_read_callback(evutil_socket_t fd, short event, void *_conn)
 
 
   if (connection_handle_read(conn) < 0) {
   if (connection_handle_read(conn) < 0) {
     if (!conn->marked_for_close) {
     if (!conn->marked_for_close) {
-#ifndef MS_WINDOWS
+#ifndef _WIN32
       log_warn(LD_BUG,"Unhandled error on read for %s connection "
       log_warn(LD_BUG,"Unhandled error on read for %s connection "
                "(fd %d); removing",
                "(fd %d); removing",
                conn_type_to_string(conn->type), (int)conn->s);
                conn_type_to_string(conn->type), (int)conn->s);
@@ -1689,7 +1689,7 @@ refill_callback(periodic_timer_t *timer, void *arg)
 }
 }
 #endif
 #endif
 
 
-#ifndef MS_WINDOWS
+#ifndef _WIN32
 /** Called when a possibly ignorable libevent error occurs; ensures that we
 /** Called when a possibly ignorable libevent error occurs; ensures that we
  * don't get into an infinite loop by ignoring too many errors from
  * don't get into an infinite loop by ignoring too many errors from
  * libevent. */
  * libevent. */
@@ -1908,7 +1908,7 @@ do_main_loop(void)
     if (nt_service_is_stopping())
     if (nt_service_is_stopping())
       return 0;
       return 0;
 
 
-#ifndef MS_WINDOWS
+#ifndef _WIN32
     /* Make it easier to tell whether libevent failure is our fault or not. */
     /* Make it easier to tell whether libevent failure is our fault or not. */
     errno = 0;
     errno = 0;
 #endif
 #endif
@@ -1932,7 +1932,7 @@ do_main_loop(void)
         log_err(LD_NET,"libevent call with %s failed: %s [%d]",
         log_err(LD_NET,"libevent call with %s failed: %s [%d]",
                 tor_libevent_get_method(), tor_socket_strerror(e), e);
                 tor_libevent_get_method(), tor_socket_strerror(e), e);
         return -1;
         return -1;
-#ifndef MS_WINDOWS
+#ifndef _WIN32
       } else if (e == EINVAL) {
       } else if (e == EINVAL) {
         log_warn(LD_NET, "EINVAL from libevent: should you upgrade libevent?");
         log_warn(LD_NET, "EINVAL from libevent: should you upgrade libevent?");
         if (got_libevent_error())
         if (got_libevent_error())
@@ -1951,7 +1951,7 @@ do_main_loop(void)
   }
   }
 }
 }
 
 
-#ifndef MS_WINDOWS /* Only called when we're willing to use signals */
+#ifndef _WIN32 /* Only called when we're willing to use signals */
 /** Libevent callback: invoked when we get a signal.
 /** Libevent callback: invoked when we get a signal.
  */
  */
 static void
 static void
@@ -2168,7 +2168,7 @@ exit_function(void)
 {
 {
   /* NOTE: If we ever daemonize, this gets called immediately.  That's
   /* NOTE: If we ever daemonize, this gets called immediately.  That's
    * okay for now, because we only use this on Windows.  */
    * okay for now, because we only use this on Windows.  */
-#ifdef MS_WINDOWS
+#ifdef _WIN32
   WSACleanup();
   WSACleanup();
 #endif
 #endif
 }
 }
@@ -2177,7 +2177,7 @@ exit_function(void)
 void
 void
 handle_signals(int is_parent)
 handle_signals(int is_parent)
 {
 {
-#ifndef MS_WINDOWS /* do signal stuff only on Unix */
+#ifndef _WIN32 /* do signal stuff only on Unix */
   int i;
   int i;
   static const int signals[] = {
   static const int signals[] = {
     SIGINT,  /* do a controlled slow shutdown */
     SIGINT,  /* do a controlled slow shutdown */
@@ -2300,7 +2300,7 @@ tor_init(int argc, char *argv[])
     return -1;
     return -1;
   }
   }
 
 
-#ifndef MS_WINDOWS
+#ifndef _WIN32
   if (geteuid()==0)
   if (geteuid()==0)
     log_warn(LD_GENERAL,"You are running Tor as root. You don't need to, "
     log_warn(LD_GENERAL,"You are running Tor as root. You don't need to, "
              "and you probably shouldn't.");
              "and you probably shouldn't.");
@@ -2342,7 +2342,7 @@ try_locking(const or_options_t *options, int err_if_locked)
         log_warn(LD_GENERAL, "It looks like another Tor process is running "
         log_warn(LD_GENERAL, "It looks like another Tor process is running "
                  "with the same data directory.  Waiting 5 seconds to see "
                  "with the same data directory.  Waiting 5 seconds to see "
                  "if it goes away.");
                  "if it goes away.");
-#ifndef WIN32
+#ifndef _WIN32
         sleep(5);
         sleep(5);
 #else
 #else
         Sleep(5000);
         Sleep(5000);
@@ -2578,7 +2578,7 @@ tor_main(int argc, char *argv[])
   }
   }
 #endif
 #endif
 
 
-#ifdef MS_WINDOWS
+#ifdef _WIN32
   /* Call SetProcessDEPPolicy to permanently enable DEP.
   /* Call SetProcessDEPPolicy to permanently enable DEP.
      The function will not resolve on earlier versions of Windows,
      The function will not resolve on earlier versions of Windows,
      and failure is not dangerous. */
      and failure is not dangerous. */

+ 1 - 1
src/or/ntmain.h

@@ -12,7 +12,7 @@
 #ifndef _TOR_NTMAIN_H
 #ifndef _TOR_NTMAIN_H
 #define _TOR_NTMAIN_H
 #define _TOR_NTMAIN_H
 
 
-#ifdef MS_WINDOWS
+#ifdef _WIN32
 #if !defined (WINCE)
 #if !defined (WINCE)
 #define NT_SERVICE
 #define NT_SERVICE
 #endif
 #endif

+ 2 - 2
src/or/or.h

@@ -22,7 +22,7 @@
 #endif
 #endif
 #endif
 #endif
 
 
-#ifdef MS_WINDOWS
+#ifdef _WIN32
 #ifndef WIN32_WINNT
 #ifndef WIN32_WINNT
 #define WIN32_WINNT 0x400
 #define WIN32_WINNT 0x400
 #endif
 #endif
@@ -79,7 +79,7 @@
 #include <time.h>
 #include <time.h>
 #endif
 #endif
 
 
-#ifdef MS_WINDOWS
+#ifdef _WIN32
 #include <io.h>
 #include <io.h>
 #include <process.h>
 #include <process.h>
 #include <direct.h>
 #include <direct.h>

+ 1 - 1
src/or/reasons.c

@@ -143,7 +143,7 @@ stream_end_reason_to_socks5_response(int reason)
  * E_CASE is for errors where windows has both a EFOO and a WSAEFOO
  * E_CASE is for errors where windows has both a EFOO and a WSAEFOO
  * version, and S_CASE is for errors where windows has only a WSAEFOO
  * version, and S_CASE is for errors where windows has only a WSAEFOO
  * version.  (The E is for 'error', the S is for 'socket'). */
  * version.  (The E is for 'error', the S is for 'socket'). */
-#ifdef MS_WINDOWS
+#ifdef _WIN32
 #define E_CASE(s) case s: case WSA ## s
 #define E_CASE(s) case s: case WSA ## s
 #define S_CASE(s) case WSA ## s
 #define S_CASE(s) case WSA ## s
 #else
 #else

+ 8 - 8
src/or/transports.c

@@ -91,7 +91,7 @@
 #include "util.h"
 #include "util.h"
 #include "router.h"
 #include "router.h"
 
 
-#ifdef MS_WINDOWS
+#ifdef _WIN32
 static void set_managed_proxy_environment(LPVOID *envp,
 static void set_managed_proxy_environment(LPVOID *envp,
                                           const managed_proxy_t *mp);
                                           const managed_proxy_t *mp);
 #else
 #else
@@ -263,7 +263,7 @@ launch_managed_proxy(managed_proxy_t *mp)
 {
 {
   int retval;
   int retval;
 
 
-#ifdef MS_WINDOWS
+#ifdef _WIN32
 
 
   LPVOID envp=NULL;
   LPVOID envp=NULL;
 
 
@@ -349,7 +349,7 @@ pt_configure_remaining_proxies(void)
   } SMARTLIST_FOREACH_END(mp);
   } SMARTLIST_FOREACH_END(mp);
 }
 }
 
 
-#ifdef MS_WINDOWS
+#ifdef _WIN32
 
 
 /** Attempt to continue configuring managed proxy <b>mp</b>. */
 /** Attempt to continue configuring managed proxy <b>mp</b>. */
 static void
 static void
@@ -406,7 +406,7 @@ configure_proxy(managed_proxy_t *mp)
     smartlist_free(lines);
     smartlist_free(lines);
 }
 }
 
 
-#else /* MS_WINDOWS */
+#else /* _WIN32 */
 
 
 /** Attempt to continue configuring managed proxy <b>mp</b>. */
 /** Attempt to continue configuring managed proxy <b>mp</b>. */
 static void
 static void
@@ -451,7 +451,7 @@ configure_proxy(managed_proxy_t *mp)
   }
   }
 }
 }
 
 
-#endif /* MS_WINDOWS */
+#endif /* _WIN32 */
 
 
 /** Register server managed proxy <b>mp</b> transports to state */
 /** Register server managed proxy <b>mp</b> transports to state */
 static void
 static void
@@ -941,7 +941,7 @@ get_bindaddr_for_server_proxy(const managed_proxy_t *mp)
   return bindaddr_result;
   return bindaddr_result;
 }
 }
 
 
-#ifdef MS_WINDOWS
+#ifdef _WIN32
 
 
 /** Prepare the environment <b>envp</b> of managed proxy <b>mp</b>.
 /** Prepare the environment <b>envp</b> of managed proxy <b>mp</b>.
  *  <b>envp</b> is allocated on the heap and should be freed by the
  *  <b>envp</b> is allocated on the heap and should be freed by the
@@ -1043,7 +1043,7 @@ set_managed_proxy_environment(LPVOID *envp, const managed_proxy_t *mp)
   smartlist_free(envs);
   smartlist_free(envs);
 }
 }
 
 
-#else /* MS_WINDOWS */
+#else /* _WIN32 */
 
 
 /** Prepare the environment <b>envp</b> of managed proxy <b>mp</b>.
 /** Prepare the environment <b>envp</b> of managed proxy <b>mp</b>.
  *  <b>envp</b> is allocated on the heap and should be freed by the
  *  <b>envp</b> is allocated on the heap and should be freed by the
@@ -1104,7 +1104,7 @@ set_managed_proxy_environment(char ***envp, const managed_proxy_t *mp)
   return r;
   return r;
 }
 }
 
 
-#endif /* MS_WINDOWS */
+#endif /* _WIN32 */
 
 
 /** Create and return a new managed proxy for <b>transport</b> using
 /** Create and return a new managed proxy for <b>transport</b> using
  *  <b>proxy_argv</b>. If <b>is_server</b> is true, it's a server
  *  <b>proxy_argv</b>. If <b>is_server</b> is true, it's a server

+ 3 - 3
src/test/test-child.c

@@ -1,6 +1,6 @@
 #include <stdio.h>
 #include <stdio.h>
 #include "orconfig.h"
 #include "orconfig.h"
-#ifdef MS_WINDOWS
+#ifdef _WIN32
 #define WINDOWS_LEAN_AND_MEAN
 #define WINDOWS_LEAN_AND_MEAN
 #include <windows.h>
 #include <windows.h>
 #else
 #else
@@ -23,13 +23,13 @@ main(int argc, char **argv)
      succeed. Otherwise ReadFile() will get the entire output in one */
      succeed. Otherwise ReadFile() will get the entire output in one */
   // XXX: Can we make stdio flush on newline?
   // XXX: Can we make stdio flush on newline?
   fflush(stdout);
   fflush(stdout);
-#ifdef MS_WINDOWS
+#ifdef _WIN32
   Sleep(1000);
   Sleep(1000);
 #else
 #else
   sleep(1);
   sleep(1);
 #endif
 #endif
   fprintf(stdout, "DONE\n");
   fprintf(stdout, "DONE\n");
-#ifdef MS_WINDOWS
+#ifdef _WIN32
   Sleep(1000);
   Sleep(1000);
 #else
 #else
   sleep(1);
   sleep(1);

+ 2 - 2
src/test/test.c

@@ -19,7 +19,7 @@ const char tor_git_revision[] = "";
 #include <fcntl.h>
 #include <fcntl.h>
 #endif
 #endif
 
 
-#ifdef MS_WINDOWS
+#ifdef _WIN32
 /* For mkdir() */
 /* For mkdir() */
 #include <direct.h>
 #include <direct.h>
 #else
 #else
@@ -83,7 +83,7 @@ setup_directory(void)
   int r;
   int r;
   if (is_setup) return;
   if (is_setup) return;
 
 
-#ifdef MS_WINDOWS
+#ifdef _WIN32
   {
   {
     char buf[MAX_PATH];
     char buf[MAX_PATH];
     const char *tmp = buf;
     const char *tmp = buf;

+ 2 - 2
src/test/test_microdesc.c

@@ -9,7 +9,7 @@
 
 
 #include "test.h"
 #include "test.h"
 
 
-#ifdef MS_WINDOWS
+#ifdef _WIN32
 /* For mkdir() */
 /* For mkdir() */
 #include <direct.h>
 #include <direct.h>
 #else
 #else
@@ -66,7 +66,7 @@ test_md_cache(void *data)
   /* Possibly, turn this into a test setup/cleanup pair */
   /* Possibly, turn this into a test setup/cleanup pair */
   tor_free(options->DataDirectory);
   tor_free(options->DataDirectory);
   options->DataDirectory = tor_strdup(get_fname("md_datadir_test"));
   options->DataDirectory = tor_strdup(get_fname("md_datadir_test"));
-#ifdef MS_WINDOWS
+#ifdef _WIN32
   tt_int_op(0, ==, mkdir(options->DataDirectory));
   tt_int_op(0, ==, mkdir(options->DataDirectory));
 #else
 #else
   tt_int_op(0, ==, mkdir(options->DataDirectory, 0700));
   tt_int_op(0, ==, mkdir(options->DataDirectory, 0700));

+ 14 - 14
src/test/test_util.c

@@ -530,7 +530,7 @@ test_util_threads(void)
   char *s1 = NULL, *s2 = NULL;
   char *s1 = NULL, *s2 = NULL;
   int done = 0, timedout = 0;
   int done = 0, timedout = 0;
   time_t started;
   time_t started;
-#ifndef MS_WINDOWS
+#ifndef _WIN32
   struct timeval tv;
   struct timeval tv;
   tv.tv_sec=0;
   tv.tv_sec=0;
   tv.tv_usec=10;
   tv.tv_usec=10;
@@ -564,7 +564,7 @@ test_util_threads(void)
       timedout = done = 1;
       timedout = done = 1;
     }
     }
     tor_mutex_release(_thread_test_mutex);
     tor_mutex_release(_thread_test_mutex);
-#ifndef MS_WINDOWS
+#ifndef _WIN32
     /* Prevent the main thread from starving the worker threads. */
     /* Prevent the main thread from starving the worker threads. */
     select(0, NULL, NULL, NULL, &tv);
     select(0, NULL, NULL, NULL, &tv);
 #endif
 #endif
@@ -735,7 +735,7 @@ test_util_mmap(void)
   test_assert(mapping);
   test_assert(mapping);
   test_eq(mapping->size, strlen("Short file."));
   test_eq(mapping->size, strlen("Short file."));
   test_streq(mapping->data, "Short file.");
   test_streq(mapping->data, "Short file.");
-#ifdef MS_WINDOWS
+#ifdef _WIN32
   tor_munmap_file(mapping);
   tor_munmap_file(mapping);
   mapping = NULL;
   mapping = NULL;
   test_assert(unlink(fname1) == 0);
   test_assert(unlink(fname1) == 0);
@@ -1260,7 +1260,7 @@ test_util_parent_dir(void *ptr)
   tor_free(cp);
   tor_free(cp);
 }
 }
 
 
-#ifdef MS_WINDOWS
+#ifdef _WIN32
 static void
 static void
 test_util_load_win_lib(void *ptr)
 test_util_load_win_lib(void *ptr)
 {
 {
@@ -1312,7 +1312,7 @@ test_util_exit_status(void *ptr)
   ;
   ;
 }
 }
 
 
-#ifndef MS_WINDOWS
+#ifndef _WIN32
 /** Check that fgets waits until a full line, and not return a partial line, on
 /** Check that fgets waits until a full line, and not return a partial line, on
  * a EAGAIN with a non-blocking pipe */
  * a EAGAIN with a non-blocking pipe */
 static void
 static void
@@ -1412,7 +1412,7 @@ run_util_spawn_background(const char *argv[], const char *expected_out,
   int status;
   int status;
 
 
   /* Start the program */
   /* Start the program */
-#ifdef MS_WINDOWS
+#ifdef _WIN32
   status = tor_spawn_background(NULL, argv, NULL, &process_handle);
   status = tor_spawn_background(NULL, argv, NULL, &process_handle);
 #else
 #else
   status = tor_spawn_background(argv[0], argv, NULL, &process_handle);
   status = tor_spawn_background(argv[0], argv, NULL, &process_handle);
@@ -1459,7 +1459,7 @@ run_util_spawn_background(const char *argv[], const char *expected_out,
 static void
 static void
 test_util_spawn_background_ok(void *ptr)
 test_util_spawn_background_ok(void *ptr)
 {
 {
-#ifdef MS_WINDOWS
+#ifdef _WIN32
   const char *argv[] = {"test-child.exe", "--test", NULL};
   const char *argv[] = {"test-child.exe", "--test", NULL};
   const char *expected_out = "OUT\r\n--test\r\nSLEEPING\r\nDONE\r\n";
   const char *expected_out = "OUT\r\n--test\r\nSLEEPING\r\nDONE\r\n";
   const char *expected_err = "ERR\r\n";
   const char *expected_err = "ERR\r\n";
@@ -1483,7 +1483,7 @@ test_util_spawn_background_fail(void *ptr)
   const char *expected_err = "";
   const char *expected_err = "";
   char expected_out[1024];
   char expected_out[1024];
   char code[32];
   char code[32];
-#ifdef MS_WINDOWS
+#ifdef _WIN32
   const int expected_status = PROCESS_STATUS_ERROR;
   const int expected_status = PROCESS_STATUS_ERROR;
 #else
 #else
   /* TODO: Once we can signal failure to exec, set this to be
   /* TODO: Once we can signal failure to exec, set this to be
@@ -1515,7 +1515,7 @@ test_util_spawn_background_partial_read(void *ptr)
   process_handle_t *process_handle=NULL;
   process_handle_t *process_handle=NULL;
   int status;
   int status;
   char stdout_buf[100], stderr_buf[100];
   char stdout_buf[100], stderr_buf[100];
-#ifdef MS_WINDOWS
+#ifdef _WIN32
   const char *argv[] = {"test-child.exe", "--test", NULL};
   const char *argv[] = {"test-child.exe", "--test", NULL};
   const char *expected_out[] = { "OUT\r\n--test\r\nSLEEPING\r\n",
   const char *expected_out[] = { "OUT\r\n--test\r\nSLEEPING\r\n",
                                  "DONE\r\n",
                                  "DONE\r\n",
@@ -1533,7 +1533,7 @@ test_util_spawn_background_partial_read(void *ptr)
   (void)ptr;
   (void)ptr;
 
 
   /* Start the program */
   /* Start the program */
-#ifdef MS_WINDOWS
+#ifdef _WIN32
   status = tor_spawn_background(NULL, argv, NULL, &process_handle);
   status = tor_spawn_background(NULL, argv, NULL, &process_handle);
 #else
 #else
   status = tor_spawn_background(argv[0], argv, NULL, &process_handle);
   status = tor_spawn_background(argv[0], argv, NULL, &process_handle);
@@ -1544,7 +1544,7 @@ test_util_spawn_background_partial_read(void *ptr)
 
 
   /* Check stdout */
   /* Check stdout */
   for (expected_out_ctr = 0; expected_out[expected_out_ctr] != NULL;) {
   for (expected_out_ctr = 0; expected_out[expected_out_ctr] != NULL;) {
-#ifdef MS_WINDOWS
+#ifdef _WIN32
     pos = tor_read_all_handle(process_handle->stdout_pipe, stdout_buf,
     pos = tor_read_all_handle(process_handle->stdout_pipe, stdout_buf,
                               sizeof(stdout_buf) - 1, NULL);
                               sizeof(stdout_buf) - 1, NULL);
 #else
 #else
@@ -1567,7 +1567,7 @@ test_util_spawn_background_partial_read(void *ptr)
   }
   }
 
 
   /* The process should have exited without writing more */
   /* The process should have exited without writing more */
-#ifdef MS_WINDOWS
+#ifdef _WIN32
   pos = tor_read_all_handle(process_handle->stdout_pipe, stdout_buf,
   pos = tor_read_all_handle(process_handle->stdout_pipe, stdout_buf,
                             sizeof(stdout_buf) - 1,
                             sizeof(stdout_buf) - 1,
                             process_handle);
                             process_handle);
@@ -1881,11 +1881,11 @@ struct testcase_t util_tests[] = {
   UTIL_TEST(asprintf, 0),
   UTIL_TEST(asprintf, 0),
   UTIL_TEST(listdir, 0),
   UTIL_TEST(listdir, 0),
   UTIL_TEST(parent_dir, 0),
   UTIL_TEST(parent_dir, 0),
-#ifdef MS_WINDOWS
+#ifdef _WIN32
   UTIL_TEST(load_win_lib, 0),
   UTIL_TEST(load_win_lib, 0),
 #endif
 #endif
   UTIL_TEST(exit_status, 0),
   UTIL_TEST(exit_status, 0),
-#ifndef MS_WINDOWS
+#ifndef _WIN32
   UTIL_TEST(fgets_eagain, TT_SKIP),
   UTIL_TEST(fgets_eagain, TT_SKIP),
 #endif
 #endif
   UTIL_TEST(spawn_background_ok, 0),
   UTIL_TEST(spawn_background_ok, 0),

+ 2 - 2
src/tools/tor-fw-helper/tor-fw-helper-natpmp.c

@@ -9,14 +9,14 @@
 
 
 #include "orconfig.h"
 #include "orconfig.h"
 #ifdef NAT_PMP
 #ifdef NAT_PMP
-#ifdef MS_WINDOWS
+#ifdef _WIN32
 #define STATICLIB
 #define STATICLIB
 #endif
 #endif
 #include <stdint.h>
 #include <stdint.h>
 #include <stdio.h>
 #include <stdio.h>
 #include <string.h>
 #include <string.h>
 #include <errno.h>
 #include <errno.h>
-#ifndef MS_WINDOWS
+#ifndef _WIN32
 #include <arpa/inet.h>
 #include <arpa/inet.h>
 #endif
 #endif
 
 

+ 1 - 1
src/tools/tor-fw-helper/tor-fw-helper-upnp.c

@@ -9,7 +9,7 @@
 
 
 #include "orconfig.h"
 #include "orconfig.h"
 #ifdef MINIUPNPC
 #ifdef MINIUPNPC
-#ifdef MS_WINDOWS
+#ifdef _WIN32
 #define STATICLIB
 #define STATICLIB
 #endif
 #endif
 #include <stdint.h>
 #include <stdint.h>

+ 2 - 2
src/tools/tor-fw-helper/tor-fw-helper.c

@@ -21,7 +21,7 @@
 #include <time.h>
 #include <time.h>
 #include <string.h>
 #include <string.h>
 
 
-#ifdef MS_WINDOWS
+#ifdef _WIN32
 #include <winsock2.h>
 #include <winsock2.h>
 #endif
 #endif
 
 
@@ -229,7 +229,7 @@ tor_fw_add_dir_port(tor_fw_options_t *tor_fw_options,
 static int
 static int
 network_init(void)
 network_init(void)
 {
 {
-#ifdef MS_WINDOWS
+#ifdef _WIN32
   /* This silly exercise is necessary before windows will allow
   /* This silly exercise is necessary before windows will allow
    * gethostbyname to work. */
    * gethostbyname to work. */
   WSADATA WSAData;
   WSADATA WSAData;

+ 1 - 1
src/tools/tor-resolve.c

@@ -32,7 +32,7 @@
 #include <errno.h>
 #include <errno.h>
 #endif
 #endif
 
 
-#ifdef MS_WINDOWS
+#ifdef _WIN32
 #if defined(_MSC_VER) && (_MSC_VER <= 1300)
 #if defined(_MSC_VER) && (_MSC_VER <= 1300)
 #include <winsock.h>
 #include <winsock.h>
 #else
 #else

+ 1 - 2
src/win32/orconfig.h

@@ -3,8 +3,7 @@
  */
  */
 
 
 /* Windows-only defines. */
 /* Windows-only defines. */
-#define MS_WINDOWS
-#define MS_WIN32
+#define _WIN32
 #define CONFDIR ""
 #define CONFDIR ""
 
 
 /* Define to 1 if you have the <arpa/inet.h> header file. */
 /* Define to 1 if you have the <arpa/inet.h> header file. */