Skip to content

Commit

Permalink
Merge pull request audetto#208 from AppleWin/master
Browse files Browse the repository at this point in the history
Check _WIN32 instead of _MSC_VER (PR AppleWin#1346)
  • Loading branch information
audetto authored Dec 24, 2024
2 parents cebe2ba + cb1366f commit e0bb9f1
Show file tree
Hide file tree
Showing 13 changed files with 35 additions and 27 deletions.
2 changes: 1 addition & 1 deletion source/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ enum AppMode_e
#define WM_USER_FULLSCREEN WM_USER+8
#define VK_SNAPSHOT_TEXT WM_USER+9 // PrintScreen+Ctrl

#ifdef _MSC_VER
#ifdef _WIN32
#define PATH_SEPARATOR '\\'
#else
#define PATH_SEPARATOR '/'
Expand Down
2 changes: 1 addition & 1 deletion source/DiskImage.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

#include "DiskDefs.h"

#ifdef _MSC_VER
#ifdef _WIN32

#define RAND_THRESHOLD(num, den) ((RAND_MAX * num) / den)

Expand Down
4 changes: 2 additions & 2 deletions source/Log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

FILE* g_fh = NULL;

#ifdef _MSC_VER
#ifdef _WIN32
#define LOG_FILENAME "AppleWin.log"
#else
// save to /tmp as otherwise it creates a file in the current folder which can be a bit everywhere
Expand All @@ -49,7 +49,7 @@ inline std::string GetTimeStamp()
{
time_t ltime;
time(&ltime);
#ifdef _MSC_VER
#ifdef _WIN32
char ct[32];
ctime_s(ct, sizeof(ct), &ltime);
#else
Expand Down
8 changes: 4 additions & 4 deletions source/Memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// This is not available in Windows CRT:
// https://en.cppreference.com/w/c/memory/aligned_alloc

#ifdef _MSC_VER
#ifdef _WIN32
// VirtualAlloc is aligned
#define ALIGNED_ALLOC(size) (LPBYTE)VirtualAlloc(NULL, size, MEM_COMMIT, PAGE_READWRITE)
#define ALIGNED_FREE(ptr) VirtualFree(ptr, 0, MEM_RELEASE)
Expand Down Expand Up @@ -244,7 +244,7 @@ static const UINT kNumAnnunciators = 4;
static bool g_Annunciator[kNumAnnunciators] = {};

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)
#else
static FILE * g_hMemTempFile = NULL;
Expand Down Expand Up @@ -1528,7 +1528,7 @@ bool MemIsAddrCodeMemory(const USHORT addr)

static void FreeMemImage(void)
{
#ifdef _MSC_VER
#ifdef _WIN32
if (g_hMemImage)
{
for (UINT i = 0; i < num64KPages; i++)
Expand Down Expand Up @@ -1559,7 +1559,7 @@ static void FreeMemImage(void)

static LPBYTE AllocMemImage(void)
{
#ifdef _MSC_VER
#ifdef _WIN32
LPBYTE baseAddr = NULL;

// Allocate memory for 'memimage' (and the alias 'mem')
Expand Down
12 changes: 9 additions & 3 deletions source/StdAfx.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#ifdef _MSC_VER
#ifdef _WIN32

#ifdef __MINGW32__
#define STRSAFE_NO_DEPRECATE
#endif
#include <tchar.h>

#include <crtdbg.h>
Expand Down Expand Up @@ -33,6 +36,7 @@ typedef UINT64 uint64_t;
#include <ddraw.h>
#include <htmlhelp.h>
#include <assert.h>
#include <winsock.h>

#include <algorithm>
#include <map>
Expand Down Expand Up @@ -66,7 +70,7 @@ typedef UINT64 uint64_t;
#define DWORD_T_FMT "lX"
#endif

#else
#else // !_WIN32

#include <cmath>
#include <map>
Expand All @@ -79,6 +83,8 @@ typedef UINT64 uint64_t;
#include <vector>
#include <cassert>

// 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"

//#define USE_SPEECH_API
Expand All @@ -87,4 +93,4 @@ typedef UINT64 uint64_t;
#define PTRDIFF_T_FMT "td"
#define DWORD_T_FMT "X"

#endif
#endif // _WIN32
2 changes: 1 addition & 1 deletion source/StrFormat.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ typedef UINT16 uint16_t;
#include <cstdint>
#endif

#ifdef _MSC_VER
#ifdef _WIN32
#define ATTRIBUTE_FORMAT_PRINTF(a, b)
#else
#define ATTRIBUTE_FORMAT_PRINTF(a, b) __attribute__((format(printf, a, b)))
Expand Down
2 changes: 1 addition & 1 deletion source/Tfe/DNS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

#include "DNS.h"

#ifndef _MSC_VER
#ifndef _WIN32
#include <arpa/inet.h>
#include <sys/socket.h>
#include <netdb.h>
Expand Down
2 changes: 1 addition & 1 deletion source/Tfe/IPRaw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

#include "IPRaw.h"

#ifndef _MSC_VER
#ifndef _WIN32
#include <arpa/inet.h>
#endif

Expand Down
4 changes: 2 additions & 2 deletions source/Tfe/PCapBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "../Common.h"
#include "../Registry.h"

#ifdef _MSC_VER
#ifdef _WIN32
#include <iphlpapi.h>
#endif

Expand Down Expand Up @@ -76,7 +76,7 @@ void PCapBackend::update(const ULONG /* nExecutedCycles */)
void PCapBackend::getMACAddress(const uint32_t address, MACAddress & mac)
{
// this is only expected to be called for IP addresses on the same network
#ifdef _MSC_VER
#ifdef _WIN32
const DWORD dwSourceAddress = INADDR_ANY;
ULONG len = sizeof(MACAddress::address);
SendARP(address, dwSourceAddress, mac.address, &len);
Expand Down
4 changes: 2 additions & 2 deletions source/Tfe/tfearch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

/* #define WPCAP */

#ifdef _MSC_VER
#ifdef _WIN32

#ifndef NOMINMAX
#define NOMINMAX
Expand Down Expand Up @@ -59,7 +59,7 @@
// once this is set, no further attempts to load npcap will be made
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 void (*pcap_close_t)(pcap_t *);
Expand Down
14 changes: 8 additions & 6 deletions source/Uthernet2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
// (errno == SOCK_EINPROGRESS || errno == SOCK_EWOULDBLOCK)
// 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;
#endif
typedef int socklen_t;

#define sock_error() WSAGetLastError()
Expand Down Expand Up @@ -197,7 +199,7 @@ void Socket::clearFD()
{
if (myFD != INVALID_SOCKET)
{
#ifdef _MSC_VER
#ifdef _WIN32
closesocket(myFD);
#else
close(myFD);
Expand Down Expand Up @@ -268,7 +270,7 @@ void Socket::process()
{
if (myFD != INVALID_SOCKET && mySocketStatus == W5100_SN_SR_SOCK_SYNSENT)
{
#ifdef _MSC_VER
#ifdef _WIN32
FD_SET writefds, exceptfds;
FD_ZERO(&writefds);
FD_ZERO(&exceptfds);
Expand Down Expand Up @@ -368,7 +370,7 @@ const std::string& Uthernet2::GetSnapshotCardName()

Uthernet2::Uthernet2(UINT slot) : NetworkCard(CT_Uthernet2, slot)
{
#ifdef _MSC_VER
#ifdef _WIN32
WSADATA wsaData;
myWSAStartup = WSAStartup(MAKEWORD(2, 2), &wsaData);
if (myWSAStartup)
Expand All @@ -384,7 +386,7 @@ Uthernet2::Uthernet2(UINT slot) : NetworkCard(CT_Uthernet2, slot)

Uthernet2::~Uthernet2()
{
#ifdef _MSC_VER
#ifdef _WIN32
if (myWSAStartup == 0)
{
WSACleanup();
Expand Down Expand Up @@ -917,7 +919,7 @@ void Uthernet2::openSystemSocket(const size_t i, const int type, const int proto
}
else
{
#ifdef _MSC_VER
#ifdef _WIN32
u_long on = 1;
const int res = ioctlsocket(fd, FIONBIO, &on);
#else
Expand Down
4 changes: 2 additions & 2 deletions source/Uthernet2.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ struct MACAddress;

struct Socket
{
#ifdef _MSC_VER
#ifdef _WIN32
typedef SOCKET socket_t;
#else
typedef int socket_t;
Expand Down Expand Up @@ -87,7 +87,7 @@ class Uthernet2 : public NetworkCard
private:
bool myVirtualDNSEnabled; // extended virtualisation of DNS (not present in the real U II card)

#ifdef _MSC_VER
#ifdef _WIN32
int myWSAStartup;
#endif

Expand Down
2 changes: 1 addition & 1 deletion source/Video.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ void Video::Video_MakeScreenShot(FILE *pFile, const VideoScreenShot_e ScreenShot
);

#define EXPECTED_BMP_HEADER_SIZE (14 + 40)
#ifdef _MSC_VER
#ifdef _WIN32
char sIfSizeZeroOrUnknown_BadWinBmpHeaderPackingSize54[ sizeof( WinBmpHeader_t ) == EXPECTED_BMP_HEADER_SIZE];
/**/ sIfSizeZeroOrUnknown_BadWinBmpHeaderPackingSize54[0]=0;
#else
Expand Down

0 comments on commit e0bb9f1

Please sign in to comment.