Commit 5cf9167f authored by Nick Mathewson's avatar Nick Mathewson 🎨
Browse files

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;
 }
parent 23054543
...@@ -15,7 +15,7 @@ ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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.
......
...@@ -21,7 +21,7 @@ ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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 ...@@ -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]) ...@@ -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]) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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
......
...@@ -8,7 +8,7 @@ ...@@ -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 @@ ...@@ -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 @@ ...@@ -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) { ...@@ -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 { ...@@ -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); ...@@ -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); ...@@ -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); ...@@ -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); ...@@ -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); ...@@ -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); ...@@ -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
......
...@@ -205,7 +205,7 @@ tor_libevent_initialize(tor_libevent_cfg *torcfg) ...@@ -205,7 +205,7 @@ tor_libevent_initialize(tor_libevent_cfg *torcfg)
cfg = event_config_new();