Check _WIN32 instead of _MSC_VER (PR #1346)

This commit is contained in:
Jamiras 2024-12-24 05:06:37 -07:00 committed by GitHub
parent 35f176e4d8
commit cb1366f485
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 35 additions and 27 deletions

View File

@ -140,7 +140,7 @@ enum AppMode_e
#define WM_USER_FULLSCREEN WM_USER+8 #define WM_USER_FULLSCREEN WM_USER+8
#define VK_SNAPSHOT_TEXT WM_USER+9 // PrintScreen+Ctrl #define VK_SNAPSHOT_TEXT WM_USER+9 // PrintScreen+Ctrl
#ifdef _MSC_VER #ifdef _WIN32
#define PATH_SEPARATOR '\\' #define PATH_SEPARATOR '\\'
#else #else
#define PATH_SEPARATOR '/' #define PATH_SEPARATOR '/'

View File

@ -25,7 +25,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "DiskDefs.h" #include "DiskDefs.h"
#ifdef _MSC_VER #ifdef _WIN32
#define RAND_THRESHOLD(num, den) ((RAND_MAX * num) / den) #define RAND_THRESHOLD(num, den) ((RAND_MAX * num) / den)

View File

@ -34,7 +34,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
FILE* g_fh = NULL; FILE* g_fh = NULL;
#ifdef _MSC_VER #ifdef _WIN32
#define LOG_FILENAME "AppleWin.log" #define LOG_FILENAME "AppleWin.log"
#else #else
// save to /tmp as otherwise it creates a file in the current folder which can be a bit everywhere // save to /tmp as otherwise it creates a file in the current folder which can be a bit everywhere
@ -49,7 +49,7 @@ inline std::string GetTimeStamp()
{ {
time_t ltime; time_t ltime;
time(&ltime); time(&ltime);
#ifdef _MSC_VER #ifdef _WIN32
char ct[32]; char ct[32];
ctime_s(ct, sizeof(ct), &ltime); ctime_s(ct, sizeof(ct), &ltime);
#else #else

View File

@ -60,7 +60,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// This is not available in Windows CRT: // This is not available in Windows CRT:
// https://en.cppreference.com/w/c/memory/aligned_alloc // https://en.cppreference.com/w/c/memory/aligned_alloc
#ifdef _MSC_VER #ifdef _WIN32
// VirtualAlloc is aligned // VirtualAlloc is aligned
#define ALIGNED_ALLOC(size) (LPBYTE)VirtualAlloc(NULL, size, MEM_COMMIT, PAGE_READWRITE) #define ALIGNED_ALLOC(size) (LPBYTE)VirtualAlloc(NULL, size, MEM_COMMIT, PAGE_READWRITE)
#define ALIGNED_FREE(ptr) VirtualFree(ptr, 0, MEM_RELEASE) #define ALIGNED_FREE(ptr) VirtualFree(ptr, 0, MEM_RELEASE)
@ -244,7 +244,7 @@ static const UINT kNumAnnunciators = 4;
static bool g_Annunciator[kNumAnnunciators] = {}; static bool g_Annunciator[kNumAnnunciators] = {};
static const UINT num64KPages = 2; // number of 64K pages used to create hardware circular buffer static const UINT num64KPages = 2; // number of 64K pages used to create hardware circular buffer
#ifdef _MSC_VER #ifdef _WIN32
static HANDLE g_hMemImage = NULL; // NB. When not initialised, this handle is NULL (not INVALID_HANDLE_VALUE) static HANDLE g_hMemImage = NULL; // NB. When not initialised, this handle is NULL (not INVALID_HANDLE_VALUE)
#else #else
static FILE * g_hMemTempFile = NULL; static FILE * g_hMemTempFile = NULL;
@ -1523,7 +1523,7 @@ bool MemIsAddrCodeMemory(const USHORT addr)
static void FreeMemImage(void) static void FreeMemImage(void)
{ {
#ifdef _MSC_VER #ifdef _WIN32
if (g_hMemImage) if (g_hMemImage)
{ {
for (UINT i = 0; i < num64KPages; i++) for (UINT i = 0; i < num64KPages; i++)
@ -1554,7 +1554,7 @@ static void FreeMemImage(void)
static LPBYTE AllocMemImage(void) static LPBYTE AllocMemImage(void)
{ {
#ifdef _MSC_VER #ifdef _WIN32
LPBYTE baseAddr = NULL; LPBYTE baseAddr = NULL;
// Allocate memory for 'memimage' (and the alias 'mem') // Allocate memory for 'memimage' (and the alias 'mem')

View File

@ -1,5 +1,8 @@
#ifdef _MSC_VER #ifdef _WIN32
#ifdef __MINGW32__
#define STRSAFE_NO_DEPRECATE
#endif
#include <tchar.h> #include <tchar.h>
#include <crtdbg.h> #include <crtdbg.h>
@ -33,6 +36,7 @@ typedef UINT64 uint64_t;
#include <ddraw.h> #include <ddraw.h>
#include <htmlhelp.h> #include <htmlhelp.h>
#include <assert.h> #include <assert.h>
#include <winsock.h>
#include <algorithm> #include <algorithm>
#include <map> #include <map>
@ -66,7 +70,7 @@ typedef UINT64 uint64_t;
#define DWORD_T_FMT "lX" #define DWORD_T_FMT "lX"
#endif #endif
#else #else // !_WIN32
#include <cmath> #include <cmath>
#include <map> #include <map>
@ -78,6 +82,8 @@ typedef UINT64 uint64_t;
#include <string> #include <string>
#include <vector> #include <vector>
// NOTE: this is a local version of windows.h with aliases for windows functions when not
// building in a windows environment (!_WIN32)
#include "windows.h" #include "windows.h"
//#define USE_SPEECH_API //#define USE_SPEECH_API
@ -86,4 +92,4 @@ typedef UINT64 uint64_t;
#define PTRDIFF_T_FMT "td" #define PTRDIFF_T_FMT "td"
#define DWORD_T_FMT "X" #define DWORD_T_FMT "X"
#endif #endif // _WIN32

View File

@ -11,7 +11,7 @@ typedef UINT16 uint16_t;
#include <cstdint> #include <cstdint>
#endif #endif
#ifdef _MSC_VER #ifdef _WIN32
#define ATTRIBUTE_FORMAT_PRINTF(a, b) #define ATTRIBUTE_FORMAT_PRINTF(a, b)
#else #else
#define ATTRIBUTE_FORMAT_PRINTF(a, b) __attribute__((format(printf, a, b))) #define ATTRIBUTE_FORMAT_PRINTF(a, b) __attribute__((format(printf, a, b)))

View File

@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "DNS.h" #include "DNS.h"
#ifndef _MSC_VER #ifndef _WIN32
#include <arpa/inet.h> #include <arpa/inet.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <netdb.h> #include <netdb.h>

View File

@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "IPRaw.h" #include "IPRaw.h"
#ifndef _MSC_VER #ifndef _WIN32
#include <arpa/inet.h> #include <arpa/inet.h>
#endif #endif

View File

@ -25,7 +25,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "../Common.h" #include "../Common.h"
#include "../Registry.h" #include "../Registry.h"
#ifdef _MSC_VER #ifdef _WIN32
#include <iphlpapi.h> #include <iphlpapi.h>
#endif #endif
@ -76,7 +76,7 @@ void PCapBackend::update(const ULONG /* nExecutedCycles */)
void PCapBackend::getMACAddress(const uint32_t address, MACAddress & mac) void PCapBackend::getMACAddress(const uint32_t address, MACAddress & mac)
{ {
// this is only expected to be called for IP addresses on the same network // this is only expected to be called for IP addresses on the same network
#ifdef _MSC_VER #ifdef _WIN32
const DWORD dwSourceAddress = INADDR_ANY; const DWORD dwSourceAddress = INADDR_ANY;
ULONG len = sizeof(MACAddress::address); ULONG len = sizeof(MACAddress::address);
SendARP(address, dwSourceAddress, mac.address, &len); SendARP(address, dwSourceAddress, mac.address, &len);

View File

@ -27,7 +27,7 @@
/* #define WPCAP */ /* #define WPCAP */
#ifdef _MSC_VER #ifdef _WIN32
#ifndef NOMINMAX #ifndef NOMINMAX
#define NOMINMAX #define NOMINMAX
@ -59,7 +59,7 @@
// once this is set, no further attempts to load npcap will be made // once this is set, no further attempts to load npcap will be made
static int tfe_cannot_use = 0; static int tfe_cannot_use = 0;
#ifdef _MSC_VER #ifdef _WIN32
typedef pcap_t *(*pcap_open_live_t)(const char *, int, int, int, char *); typedef pcap_t *(*pcap_open_live_t)(const char *, int, int, int, char *);
typedef void (*pcap_close_t)(pcap_t *); typedef void (*pcap_close_t)(pcap_t *);

View File

@ -43,9 +43,11 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// in the checks below we allow both in all cases // in the checks below we allow both in all cases
// (errno == SOCK_EINPROGRESS || errno == SOCK_EWOULDBLOCK) // (errno == SOCK_EINPROGRESS || errno == SOCK_EWOULDBLOCK)
// this works, bu we could instead define 2 functions and check only the correct one // this works, bu we could instead define 2 functions and check only the correct one
#ifdef _MSC_VER #ifdef _WIN32
#ifndef _SSIZE_T_DEFINED
typedef int ssize_t; typedef int ssize_t;
#endif
typedef int socklen_t; typedef int socklen_t;
#define sock_error() WSAGetLastError() #define sock_error() WSAGetLastError()
@ -197,7 +199,7 @@ void Socket::clearFD()
{ {
if (myFD != INVALID_SOCKET) if (myFD != INVALID_SOCKET)
{ {
#ifdef _MSC_VER #ifdef _WIN32
closesocket(myFD); closesocket(myFD);
#else #else
close(myFD); close(myFD);
@ -268,7 +270,7 @@ void Socket::process()
{ {
if (myFD != INVALID_SOCKET && mySocketStatus == W5100_SN_SR_SOCK_SYNSENT) if (myFD != INVALID_SOCKET && mySocketStatus == W5100_SN_SR_SOCK_SYNSENT)
{ {
#ifdef _MSC_VER #ifdef _WIN32
FD_SET writefds, exceptfds; FD_SET writefds, exceptfds;
FD_ZERO(&writefds); FD_ZERO(&writefds);
FD_ZERO(&exceptfds); FD_ZERO(&exceptfds);
@ -368,7 +370,7 @@ const std::string& Uthernet2::GetSnapshotCardName()
Uthernet2::Uthernet2(UINT slot) : Card(CT_Uthernet2, slot) Uthernet2::Uthernet2(UINT slot) : Card(CT_Uthernet2, slot)
{ {
#ifdef _MSC_VER #ifdef _WIN32
WSADATA wsaData; WSADATA wsaData;
myWSAStartup = WSAStartup(MAKEWORD(2, 2), &wsaData); myWSAStartup = WSAStartup(MAKEWORD(2, 2), &wsaData);
if (myWSAStartup) if (myWSAStartup)
@ -384,7 +386,7 @@ Uthernet2::Uthernet2(UINT slot) : Card(CT_Uthernet2, slot)
Uthernet2::~Uthernet2() Uthernet2::~Uthernet2()
{ {
#ifdef _MSC_VER #ifdef _WIN32
if (myWSAStartup == 0) if (myWSAStartup == 0)
{ {
WSACleanup(); WSACleanup();
@ -917,7 +919,7 @@ void Uthernet2::openSystemSocket(const size_t i, const int type, const int proto
} }
else else
{ {
#ifdef _MSC_VER #ifdef _WIN32
u_long on = 1; u_long on = 1;
const int res = ioctlsocket(fd, FIONBIO, &on); const int res = ioctlsocket(fd, FIONBIO, &on);
#else #else

View File

@ -10,7 +10,7 @@ struct MACAddress;
struct Socket struct Socket
{ {
#ifdef _MSC_VER #ifdef _WIN32
typedef SOCKET socket_t; typedef SOCKET socket_t;
#else #else
typedef int socket_t; typedef int socket_t;
@ -85,7 +85,7 @@ public:
private: private:
bool myVirtualDNSEnabled; // extended virtualisation of DNS (not present in the real U II card) bool myVirtualDNSEnabled; // extended virtualisation of DNS (not present in the real U II card)
#ifdef _MSC_VER #ifdef _WIN32
int myWSAStartup; int myWSAStartup;
#endif #endif

View File

@ -518,7 +518,7 @@ void Video::Video_MakeScreenShot(FILE *pFile, const VideoScreenShot_e ScreenShot
); );
#define EXPECTED_BMP_HEADER_SIZE (14 + 40) #define EXPECTED_BMP_HEADER_SIZE (14 + 40)
#ifdef _MSC_VER #ifdef _WIN32
char sIfSizeZeroOrUnknown_BadWinBmpHeaderPackingSize54[ sizeof( WinBmpHeader_t ) == EXPECTED_BMP_HEADER_SIZE]; char sIfSizeZeroOrUnknown_BadWinBmpHeaderPackingSize54[ sizeof( WinBmpHeader_t ) == EXPECTED_BMP_HEADER_SIZE];
/**/ sIfSizeZeroOrUnknown_BadWinBmpHeaderPackingSize54[0]=0; /**/ sIfSizeZeroOrUnknown_BadWinBmpHeaderPackingSize54[0]=0;
#else #else