Use built-in _WIN32 macro instead of WIN32

This commit is contained in:
Mitchell Livingston 2014-07-04 00:00:07 +00:00
parent d0695b7006
commit 0e01879974
30 changed files with 81 additions and 84 deletions

View File

@ -319,7 +319,7 @@ main (int argc, char ** argv)
}
signal (SIGINT, sigHandler);
#ifndef WIN32
#ifndef _WIN32
signal (SIGHUP, sigHandler);
#endif
tr_torrentStart (tor);
@ -489,7 +489,7 @@ sigHandler (int signal)
gotsig = true;
break;
#ifndef WIN32
#ifndef _WIN32
case SIGHUP:
manualUpdate = true;
break;

View File

@ -448,7 +448,7 @@ case $host_os in
*mingw32*)
have_msw="yes"
CXXFLAGS="$CXXFLAGS -mms-bitfields -mwin32 -mwindows"
CPPFLAGS="$CPPFLAGS -DWIN32 -D_WIN32 -DWIN32_LEAN_AND_MEAN"
CPPFLAGS="$CPPFLAGS -DWIN32_LEAN_AND_MEAN"
LIBS="$LIBS -liphlpapi -lshell32 -lws2_32"
transmissionlocaledir="locale"
if test -z "$host_alias"; then
@ -508,9 +508,6 @@ EOF
exit 1
fi
fi
if test "x$have_msw" = "xyes"; then
AC_DEFINE([HAVE_MSW], 1)
fi
AM_CONDITIONAL(WIN32, test "x$have_msw" = "xyes")
dnl ----------------------------------------------------------------------------

View File

@ -189,7 +189,7 @@ gotsig (int sig)
}
}
#if defined (WIN32)
#if defined (_WIN32)
#define USE_NO_DAEMON
#elif !defined (HAVE_DAEMON) || defined (__UCLIBC__)
#define USE_TR_DAEMON
@ -399,7 +399,7 @@ main (int argc, char ** argv)
signal (SIGINT, gotsig);
signal (SIGTERM, gotsig);
#ifndef WIN32
#ifndef _WIN32
signal (SIGHUP, gotsig);
#endif

View File

@ -15,7 +15,7 @@
#include <stdlib.h>
#include <string.h> /* strcmp */
#ifdef WIN32
#ifdef _WIN32
#include <direct.h> /* getcwd */
#else
#include <unistd.h> /* getcwd */
@ -500,7 +500,7 @@ tr_getcwd (void)
char * result;
char buf[2048];
#ifdef WIN32
#ifdef _WIN32
result = _getcwd (buf, sizeof (buf));
#else
result = getcwd (buf, sizeof (buf));

View File

@ -15,7 +15,7 @@
#include <unistd.h> /* close () */
#ifdef WIN32
#ifdef _WIN32
#include <w32api.h>
#define WINVER WindowsXP
#include <windows.h>
@ -23,7 +23,7 @@
#define MAP_PRIVATE FILE_MAP_COPY
#endif
#ifndef WIN32
#ifndef _WIN32
#include <sys/mman.h>
#endif
#include <sys/types.h>

View File

@ -98,7 +98,7 @@ preallocate_file_full (const char * filename, uint64_t length)
{
bool success = 0;
#ifdef WIN32
#ifdef _WIN32
HANDLE hFile = CreateFile (filename, GENERIC_WRITE, 0, 0, CREATE_NEW, FILE_FLAG_RANDOM_ACCESS, 0);
if (hFile != INVALID_HANDLE_VALUE)
@ -172,7 +172,7 @@ preallocate_file_full (const char * filename, uint64_t length)
int
tr_fsync (int fd)
{
#ifdef WIN32
#ifdef _WIN32
return _commit (fd);
#else
return fsync (fd);

View File

@ -135,7 +135,7 @@ tr_getcwd (void)
char * result;
char buf[2048];
#ifdef WIN32
#ifdef _WIN32
result = _getcwd (buf, sizeof (buf));
#else
result = getcwd (buf, sizeof (buf));

View File

@ -26,7 +26,7 @@ static tr_log_message * myQueue = NULL;
static tr_log_message ** myQueueTail = &myQueue;
static int myQueueLength = 0;
#ifndef WIN32
#ifndef _WIN32
/* make null versions of these win32 functions */
static inline int IsDebuggerPresent (void) { return false; }
static inline void OutputDebugStringA (const void * unused UNUSED) { }

View File

@ -31,7 +31,7 @@
***/
#ifdef WIN32
#ifdef _WIN32
#define PATH_DELIMITER_CHARS "/\\"
#else
#define PATH_DELIMITER_CHARS "/"

View File

@ -29,7 +29,7 @@
#include <sys/types.h>
#ifdef WIN32
#ifdef _WIN32
#define _WIN32_WINNT 0x0501
#include <ws2tcpip.h>
#else
@ -63,7 +63,7 @@ tr_netInit (void)
if (!initialized)
{
#ifdef WIN32
#ifdef _WIN32
WSADATA wsaData;
WSAStartup (MAKEWORD (2, 2), &wsaData);
#endif
@ -75,7 +75,7 @@ char *
tr_net_strerror (char * buf, size_t buflen, int err)
{
*buf = '\0';
#ifdef WIN32
#ifdef _WIN32
FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM, NULL, err, 0, buf, buflen, NULL);
#else
tr_strlcpy (buf, tr_strerror (err), buflen);
@ -274,7 +274,7 @@ tr_netOpenPeerSocket (tr_session * session,
if ((connect (s, (struct sockaddr *) &sock,
addrlen) < 0)
#ifdef WIN32
#ifdef _WIN32
&& (sockerrno != WSAEWOULDBLOCK)
#endif
&& (sockerrno != EINPROGRESS))

View File

@ -29,7 +29,7 @@
#ifndef _TR_NET_H_
#define _TR_NET_H_
#ifdef WIN32
#ifdef _WIN32
#include <inttypes.h>
#include <ws2tcpip.h>
#else
@ -37,7 +37,7 @@
#include <netinet/in.h>
#endif
#ifdef WIN32
#ifdef _WIN32
#define EADDRINUSE WSAEADDRINUSE
#define ECONNREFUSED WSAECONNREFUSED
#define ECONNRESET WSAECONNRESET
@ -154,7 +154,7 @@ char* tr_net_strerror (char * buf, size_t buflen, int err);
const unsigned char *tr_globalIPv6 (void);
#if defined (WIN32) && !defined (QT_DLL)
#if defined (_WIN32) && !defined (QT_DLL)
/* The QT exclusion is because something clashes whith the next include */
#include <ws2tcpip.h> /* socklen_t */

View File

@ -173,7 +173,7 @@ void tr_swarmIncrementActivePeers (struct tr_swarm * swarm, tr_direction directi
***/
#ifdef WIN32
#ifdef _WIN32
#define EMSGSIZE WSAEMSGSIZE
#endif

View File

@ -30,7 +30,7 @@
#include "utils.h"
#ifdef WIN32
#ifdef _WIN32
#define EAGAIN WSAEWOULDBLOCK
#define EINTR WSAEINTR
#define EINPROGRESS WSAEINPROGRESS

View File

@ -16,7 +16,7 @@
#include <inttypes.h> /* uint16_t */
#ifdef WIN32
#ifdef _WIN32
#include <winsock2.h> /* struct in_addr */
#endif

View File

@ -13,7 +13,7 @@
#include <unistd.h> /* getuid() */
#include <event2/util.h> /* evutil_ascii_strcasecmp () */
#ifndef WIN32
#ifndef _WIN32
#include <sys/types.h> /* types needed by quota.h */
#if defined(__FreeBSD__) || defined(__OpenBSD__)
#include <ufs/ufs/quota.h> /* quotactl() */
@ -69,7 +69,7 @@
****
***/
#ifndef WIN32
#ifndef _WIN32
static const char *
getdev (const char * path)
{
@ -337,14 +337,14 @@ getxfsquota (char * device)
return -1;
}
#endif /* HAVE_XQM */
#endif /* WIN32 */
#endif /* _WIN32 */
static int64_t
tr_getQuotaFreeSpace (const struct tr_device_info * info)
{
int64_t ret = -1;
#ifndef WIN32
#ifndef _WIN32
if (info->fstype && !evutil_ascii_strcasecmp(info->fstype, "xfs"))
{
@ -356,7 +356,7 @@ tr_getQuotaFreeSpace (const struct tr_device_info * info)
{
ret = getquota (info->device);
}
#endif /* WIN32 */
#endif /* _WIN32 */
return ret;
}
@ -364,7 +364,7 @@ tr_getQuotaFreeSpace (const struct tr_device_info * info)
static int64_t
tr_getDiskFreeSpace (const char * path)
{
#ifdef WIN32
#ifdef _WIN32
uint64_t freeBytesAvailable = 0;
return GetDiskFreeSpaceEx (path, &freeBytesAvailable, NULL, NULL)
@ -391,7 +391,7 @@ tr_device_info_create (const char * path)
info = tr_new0 (struct tr_device_info, 1);
info->path = tr_strdup (path);
#ifndef WIN32
#ifndef _WIN32
info->device = tr_strdup (getblkdev (path));
info->fstype = tr_strdup (getfstype (path));
#endif

View File

@ -19,7 +19,7 @@
#include <unistd.h> /* getuid(), close() */
#include <sys/stat.h>
#ifdef WIN32
#ifdef _WIN32
#include <w32api.h>
#define WINVER WindowsXP
#include <windows.h>
@ -34,7 +34,7 @@
#include <pthread.h>
#endif
#ifdef WIN32
#ifdef _WIN32
#include <libgen.h> /* dirname() */
#endif
@ -48,7 +48,7 @@
**** THREADS
***/
#ifdef WIN32
#ifdef _WIN32
typedef DWORD tr_thread_id;
#else
typedef pthread_t tr_thread_id;
@ -57,7 +57,7 @@ typedef pthread_t tr_thread_id;
static tr_thread_id
tr_getCurrentThread (void)
{
#ifdef WIN32
#ifdef _WIN32
return GetCurrentThreadId ();
#else
return pthread_self ();
@ -67,7 +67,7 @@ tr_getCurrentThread (void)
static bool
tr_areThreadsEqual (tr_thread_id a, tr_thread_id b)
{
#ifdef WIN32
#ifdef _WIN32
return a == b;
#else
return pthread_equal (a, b) != 0;
@ -80,7 +80,7 @@ struct tr_thread
void (* func)(void *);
void * arg;
tr_thread_id thread;
#ifdef WIN32
#ifdef _WIN32
HANDLE thread_handle;
#endif
};
@ -91,7 +91,7 @@ tr_amInThread (const tr_thread * t)
return tr_areThreadsEqual (tr_getCurrentThread (), t->thread);
}
#ifdef WIN32
#ifdef _WIN32
#define ThreadFuncReturnType unsigned WINAPI
#else
#define ThreadFuncReturnType void
@ -105,7 +105,7 @@ ThreadFunc (void * _t)
t->func (t->arg);
tr_free (t);
#ifdef WIN32
#ifdef _WIN32
_endthreadex (0);
return 0;
#endif
@ -119,7 +119,7 @@ tr_threadNew (void (*func)(void *), void * arg)
t->func = func;
t->arg = arg;
#ifdef WIN32
#ifdef _WIN32
{
unsigned int id;
t->thread_handle = (HANDLE) _beginthreadex (NULL, 0, &ThreadFunc, t, 0, &id);
@ -141,7 +141,7 @@ tr_threadNew (void (*func)(void *), void * arg)
struct tr_lock
{
int depth;
#ifdef WIN32
#ifdef _WIN32
CRITICAL_SECTION lock;
DWORD lockThread;
#else
@ -155,7 +155,7 @@ tr_lockNew (void)
{
tr_lock * l = tr_new0 (tr_lock, 1);
#ifdef WIN32
#ifdef _WIN32
InitializeCriticalSection (&l->lock); /* supports recursion */
#else
pthread_mutexattr_t attr;
@ -170,7 +170,7 @@ tr_lockNew (void)
void
tr_lockFree (tr_lock * l)
{
#ifdef WIN32
#ifdef _WIN32
DeleteCriticalSection (&l->lock);
#else
pthread_mutex_destroy (&l->lock);
@ -181,7 +181,7 @@ tr_lockFree (tr_lock * l)
void
tr_lockLock (tr_lock * l)
{
#ifdef WIN32
#ifdef _WIN32
EnterCriticalSection (&l->lock);
#else
pthread_mutex_lock (&l->lock);
@ -208,7 +208,7 @@ tr_lockUnlock (tr_lock * l)
--l->depth;
assert (l->depth >= 0);
#ifdef WIN32
#ifdef _WIN32
LeaveCriticalSection (&l->lock);
#else
pthread_mutex_unlock (&l->lock);
@ -219,7 +219,7 @@ tr_lockUnlock (tr_lock * l)
**** PATHS
***/
#ifndef WIN32
#ifndef _WIN32
#include <pwd.h>
#endif
@ -234,7 +234,7 @@ getHomeDir (void)
if (!home)
{
#ifdef WIN32
#ifdef _WIN32
char appdata[MAX_PATH]; /* SHGetFolderPath () requires MAX_PATH */
*appdata = '\0';
SHGetFolderPath (NULL, CSIDL_PERSONAL, NULL, 0, appdata);
@ -314,7 +314,7 @@ tr_getDefaultConfigDir (const char * appname)
{
#ifdef __APPLE__
s = tr_buildPath (getHomeDir (), "Library", "Application Support", appname, NULL);
#elif defined (WIN32)
#elif defined (_WIN32)
char appdata[TR_PATH_MAX]; /* SHGetFolderPath () requires MAX_PATH */
SHGetFolderPath (NULL, CSIDL_APPDATA, NULL, 0, appdata);
s = tr_buildPath (appdata, appname, NULL);
@ -458,7 +458,7 @@ tr_getWebClientDir (const tr_session * session UNUSED)
tr_free (appString);
}
#elif defined (WIN32)
#elif defined (_WIN32)
/* SHGetFolderPath explicitly requires MAX_PATH length */
char dir[MAX_PATH];
@ -565,7 +565,7 @@ tr_getWebClientDir (const tr_session * session UNUSED)
}
#ifdef WIN32
#ifdef _WIN32
/* The following mmap functions are by Joerg Walter, and were taken from
* his paper at: http://www.genesys-e.de/jwalter/mix4win.htm */

View File

@ -77,7 +77,7 @@ void tr_lockUnlock (tr_lock *);
/** @brief return nonzero if the specified lock is locked */
int tr_lockHave (const tr_lock *);
#ifdef WIN32
#ifdef _WIN32
void * mmap (void *ptr, long size, long prot, long type, long handle, long arg);
long munmap (void *ptr, long size);

View File

@ -700,7 +700,7 @@ tr_sessionInitImpl (void * vdata)
session->nowTimer = evtimer_new (session->event_base, onNowTimer, session);
onNowTimer (0, 0, session);
#ifndef WIN32
#ifndef _WIN32
/* Don't exit when writing on a broken socket */
signal (SIGPIPE, SIG_IGN);
#endif

View File

@ -10,7 +10,7 @@
#include <signal.h> /* signal () */
#include <sys/types.h> /* stat */
#include <sys/stat.h> /* stat */
#ifndef WIN32
#ifndef _WIN32
#include <sys/wait.h> /* wait () */
#else
#include <process.h>
@ -2080,7 +2080,7 @@ tr_torrentClearIdleLimitHitCallback (tr_torrent * torrent)
static void
onSigCHLD (int i UNUSED)
{
#ifdef WIN32
#ifdef _WIN32
_cwait (NULL, -1, WAIT_CHILD);
@ -2118,7 +2118,7 @@ torrentCallScript (const tr_torrent * tor, const char * script)
tr_logAddTorInfo (tor, "Calling script \"%s\"", script);
#ifdef WIN32
#ifdef _WIN32
if (_spawnvpe (_P_NOWAIT, script, (const char*)cmd, env) == -1)
tr_logAddTorErr (tor, "error executing script \"%s\": %s", cmd[0], tr_strerror (errno));
#else

View File

@ -33,7 +33,7 @@
#include <signal.h> /* sig_atomic_t */
#include <sys/time.h>
#include <unistd.h> /* close () */
#ifdef WIN32
#ifdef _WIN32
#include <inttypes.h>
#define _WIN32_WINNT 0x0501 /* freeaddrinfo (),getaddrinfo (),getnameinfo () */
#include <ws2tcpip.h>

View File

@ -30,7 +30,7 @@ THE SOFTWARE.
#include <sys/time.h>
#include <unistd.h> /* close () */
#include <ctype.h> /* toupper () */
#ifdef WIN32
#ifdef _WIN32
#include <w32api.h>
#define WINDOWS WindowsXP /* freeaddrinfo (),getaddrinfo (),getnameinfo () */
#include <inttypes.h>

View File

@ -29,7 +29,7 @@ extern "C" {
#include <inttypes.h> /* uintN_t */
#include <time.h> /* time_t */
#ifdef WIN32
#ifdef _WIN32
#define __USE_MINGW_ANSI_STDIO 1
#define __STDC_FORMAT_MACROS 1
#endif
@ -45,7 +45,7 @@ extern "C" {
#endif
#ifndef PRId64
#ifdef WIN32
#ifdef _WIN32
#define PRId64 "I64"
#else
#define PRId64 "lld"
@ -53,7 +53,7 @@ extern "C" {
#endif
#ifndef PRIu64
#ifdef WIN32
#ifdef _WIN32
#define PRIu64 "I64u"
#else
#define PRIu64 "llu"
@ -61,7 +61,7 @@ extern "C" {
#endif
#ifndef PRIu32
#ifdef WIN32
#ifdef _WIN32
#define PRIu32 "u"
#else
#define PRIu32 "lu"
@ -76,7 +76,7 @@ extern "C" {
#endif
#endif
#if defined (WIN32) && defined (_MSC_VER)
#if defined (_WIN32) && defined (_MSC_VER)
#define inline __inline
#endif

View File

@ -21,7 +21,7 @@
#include "net.h"
#include "session.h"
#ifdef WIN32
#ifdef _WIN32
#include "utils.h"
#include <winsock2.h>
@ -222,7 +222,7 @@ libeventThreadFunc (void * veh)
struct event_base * base;
tr_event_handle * eh = veh;
#ifndef WIN32
#ifndef _WIN32
/* Don't exit when writing on a broken socket */
signal (SIGPIPE, SIG_IGN);
#endif

View File

@ -41,7 +41,7 @@
#include <event2/buffer.h>
#include <event2/event.h>
#ifdef WIN32
#ifdef _WIN32
#include <w32api.h>
#define WINVER WindowsXP /* freeaddrinfo (), getaddrinfo (), getnameinfo () */
#include <direct.h> /* _getcwd () */
@ -368,7 +368,7 @@ tr_mkdtemp (char * template)
static int
tr_mkdir (const char * path, int permissions UNUSED)
{
#ifdef WIN32
#ifdef _WIN32
if (path && isalpha (path[0]) && path[1] == ':' && !path[2])
return 0;
return mkdir (path);
@ -730,7 +730,7 @@ tr_time_msec (void)
void
tr_wait_msec (long int msec)
{
#ifdef WIN32
#ifdef _WIN32
Sleep ((DWORD)msec);
#else
struct timespec ts;
@ -1710,7 +1710,7 @@ tr_remove (const char * pathname)
bool
tr_is_same_file (const char * filename1, const char * filename2)
{
#ifdef WIN32
#ifdef _WIN32
bool res;
HANDLE fh1, fh2;
@ -1787,7 +1787,7 @@ tr_valloc (size_t bufLen)
char *
tr_realpath (const char * path, char * resolved_path)
{
#ifdef WIN32
#ifdef _WIN32
/* From a message to the Mingw-msys list, Jun 2, 2005 by Mark Junker. */
if (GetFullPathNameA (path, TR_PATH_MAX, resolved_path, NULL) == 0)
return NULL;

View File

@ -87,7 +87,7 @@ const char * tr_strip_positional_args (const char * fmt);
/* #define DISABLE_GETTEXT */
#ifndef DISABLE_GETTEXT
#if defined (WIN32) || defined (TR_LIGHTWEIGHT)
#if defined (_WIN32) || defined (TR_LIGHTWEIGHT)
#define DISABLE_GETTEXT
#endif
#endif
@ -451,7 +451,7 @@ static inline time_t tr_time (void) { return __tr_current_time; }
/** @brief Private libtransmission function to update tr_time ()'s counter */
static inline void tr_timeUpdate (time_t now) { __tr_current_time = now; }
#ifdef WIN32
#ifdef _WIN32
#include <windef.h> /* MAX_PATH */
#define TR_PATH_MAX (MAX_PATH + 1)
#else

View File

@ -21,7 +21,7 @@
#include "libtransmission-test.h"
#ifndef WIN32
#ifndef _WIN32
#define STACK_SMASH_DEPTH (1 * 1000 * 1000)
#else
#define STACK_SMASH_DEPTH ( 100 * 1000)

View File

@ -13,7 +13,7 @@
#include <stdlib.h> /* strtod(), realloc(), qsort(), mkstemp() */
#include <string.h>
#ifdef WIN32 /* tr_mkstemp() */
#ifdef _WIN32 /* tr_mkstemp() */
#include <fcntl.h>
#include <share.h>
#include <sys/stat.h>
@ -1129,7 +1129,7 @@ tr_variantToStr (const tr_variant * v, tr_variant_fmt fmt, int * len)
static int
tr_mkstemp (char * template)
{
#ifdef WIN32
#ifdef _WIN32
const int n = strlen (template) + 1;
const int flags = O_RDWR | O_BINARY | O_CREAT | O_EXCL | _O_SHORT_LIVED;

View File

@ -11,7 +11,7 @@
#include <string.h> /* strlen (), strstr () */
#include <stdlib.h> /* getenv () */
#ifdef WIN32
#ifdef _WIN32
#include <ws2tcpip.h>
#else
#include <sys/select.h>
@ -347,7 +347,7 @@ tr_select (int nfds,
fd_set * r_fd_set, fd_set * w_fd_set, fd_set * c_fd_set,
struct timeval * t)
{
#ifdef WIN32
#ifdef _WIN32
if (!r_fd_set->fd_count && !w_fd_set->fd_count && !c_fd_set->fd_count)
{
const long int msec = t->tv_sec*1000 + t->tv_usec/1000;

View File

@ -9,7 +9,7 @@
#include <iostream>
#ifdef WIN32
#ifdef _WIN32
#include <windows.h>
#include <shellapi.h>
#endif
@ -34,7 +34,7 @@
****
***/
#if defined(WIN32) && QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
#if defined(_WIN32) && QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
// Should be in QtWinExtras soon, but for now let's import it manually
extern QPixmap qt_pixmapFromWinHICON(HICON icon);
#endif
@ -65,7 +65,7 @@ Utils :: toStderr (const QString& str)
std::cerr << qPrintable(str) << std::endl;
}
#ifdef WIN32
#ifdef _WIN32
namespace
{
void
@ -109,7 +109,7 @@ namespace
QIcon
Utils :: guessMimeIcon (const QString& filename)
{
#ifdef WIN32
#ifdef _WIN32
QIcon icon;
if (!filename.isEmpty ())

View File

@ -113,7 +113,7 @@ tr_getcwd (void)
char * result;
char buf[2048];
#ifdef WIN32
#ifdef _WIN32
result = _getcwd (buf, sizeof (buf));
#else
result = getcwd (buf, sizeof (buf));