From 977e372d5099e34ec88e59f3728c7944d97ed424 Mon Sep 17 00:00:00 2001 From: Shamus Hammons Date: Mon, 20 Mar 2023 14:57:12 -0500 Subject: [PATCH] Fix to placate the Visual Studio(TM) gods. N.B.: Even MXE (which makes Windows(TM) executables), doesn't need this kind of special treatment. So, meh. :-/ --- cross-compile | 3 ++- dirent_lose.c | 35 +++++++++++++++++++++++++++++++++++ dirent_lose.h | 18 ++++++++++++++++++ makefile | 3 ++- rmac.h | 24 ++++++++++++------------ version.h | 2 +- 6 files changed, 70 insertions(+), 15 deletions(-) create mode 100644 dirent_lose.c create mode 100644 dirent_lose.h diff --git a/cross-compile b/cross-compile index 91fc44b..4e46f11 100755 --- a/cross-compile +++ b/cross-compile @@ -7,6 +7,7 @@ # echo "Cross compiling for Win32..." export PATH=/opt/mxe/usr/bin:$PATH -make CROSS=i686-pc-mingw32- +#make CROSS=i686-pc-mingw32- +make CROSS=i686-w64-mingw32.static- rel=`git log -1 --pretty=format:%ci | cut -d ' ' -f 1 | tr -d -` mv rmac rmac.exe && upx -9v rmac.exe && zip -9v rmac-$rel.zip rmac.exe diff --git a/dirent_lose.c b/dirent_lose.c new file mode 100644 index 0000000..716051b --- /dev/null +++ b/dirent_lose.c @@ -0,0 +1,35 @@ +#if defined(WIN32) || defined(WIN64) + +// Microsoft™ Windows™ dependent code + +// There is one, and only one case where this is needed and that's in a Visual +// Studio™ environment. Even building a Windows™ executable with MXE doesn't +// require this. So, even though this kind of thing is POSIX, it can't be +// included in a Visual Studio™ environment without adding a 3rd party shim. +// So we've made our own shim. +// +// The shim is minimal because the code in RMAC that uses it is minimal. If it +// gets expanded in the future for some reason, the shim will have to expand +// too. :-/ But that will never happen, right? ;-) +// + +#include "dirent_lose.h" + +#define WIN32_LEAN_AND_MEAN +#include + +static DIR dummy; + +DIR * opendir(const char * name) +{ + BOOL test = ((GetFileAttributesA(name) & FILE_ATTRIBUTE_DIRECTORY) != INVALID_FILE_ATTRIBUTES); + + return (test ? &dummy : NULL); +} + +int closedir(DIR * dir) +{ + return 0; +} + +#endif diff --git a/dirent_lose.h b/dirent_lose.h new file mode 100644 index 0000000..3e6bef2 --- /dev/null +++ b/dirent_lose.h @@ -0,0 +1,18 @@ +#ifndef __DIRENT_LOSE_H__ +#define __DIRENT_LOSE_H__ + +#if defined(WIN32) || defined(WIN64) + +// Microsoft™ Windows™ dependent code + +// This is only needed to keep the compiler from throwing a fit, it's not meant +// to be used except as a sentinel (NULL/non-NULL). +typedef struct { int i; /* dummy member */ } DIR; + +// These are the only two functions used from +DIR * opendir(const char *); +int closedir(DIR *); + +#endif + +#endif // __DIRENT_LOSE_H__ diff --git a/makefile b/makefile index 9f6d9ac..094eff4 100644 --- a/makefile +++ b/makefile @@ -27,7 +27,7 @@ HOSTCC = gcc #CFLAGS = -std=$(STD) -D_DEFAULT_SOURCE -g -D__GCCUNIX__ -I. -O2 -MMD CFLAGS = -std=$(STD) -D_DEFAULT_SOURCE -g -D__GCCUNIX__ -I. -O2 -OBJS = 6502.o amode.o debug.o direct.o dsp56k.o dsp56k_amode.o dsp56k_mach.o eagen.o error.o expr.o fltpoint.o listing.o mach.o macro.o mark.o object.o op.o procln.o riscasm.o rmac.o sect.o symbol.o token.o +OBJS = 6502.o amode.o debug.o direct.o dsp56k.o dsp56k_amode.o dsp56k_mach.o eagen.o error.o expr.o fltpoint.o listing.o mach.o macro.o mark.o object.o op.o procln.o riscasm.o rmac.o sect.o symbol.o token.o dirent_lose.o # # Build everything @@ -162,3 +162,4 @@ symbol.o: symbol.c symbol.h error.h rmac.h listing.h object.h procln.h \ token.h token.o: token.c token.h rmac.h symbol.h direct.h error.h macro.h \ procln.h sect.h riscasm.h kwtab.h unarytab.h +dirent_lose.o: dirent_lose.h diff --git a/rmac.h b/rmac.h index 00dcd3b..48a6545 100644 --- a/rmac.h +++ b/rmac.h @@ -22,6 +22,7 @@ #if defined(WIN32) || defined(WIN64) #include #include + #include "dirent_lose.h" // Release platform - windows #define PLATFORM "Win32" #define _OPEN_FLAGS _O_TRUNC|_O_CREAT|_O_BINARY|_O_RDWR @@ -54,8 +55,19 @@ #endif + // Ever since Visual Studio... 2017? 2019? the following constants come + // defined in the platform SDK, which leads to endless warnings from the + // compiler. So let's just put the pacifier on and undef them, sheesh! (No, + // we won't rename the defines, we've been here since 1986, Visual Studio + // wasn't even a glimpse in the milkman's eyes, if you catch my drift) + #undef CONST + #undef ERROR + #undef TEXT + #else + #include + #ifdef __GCCUNIX__ #include @@ -156,20 +168,8 @@ // Non-target specific stuff // #include -#include #include "symbol.h" -#if defined(WIN32) || defined(WIN64) -// Ever since Visual Studio... 2017? 2019? the following constants come defined in the -// platform SDK, which leads to endless warnings from the compiler. So let's just -// put the pacifier on and undef them, sheesh! (No, we won't rename the defines, -// we've been here since 1986, Visual Studio wasn't even a glimpse in the milkman's eyes, -// if you catch my drift) -#undef CONST -#undef ERROR -#undef TEXT -#endif - #define BYTE uint8_t #define WORD uint16_t #define LONG uint32_t diff --git a/version.h b/version.h index f9fe987..48787ae 100644 --- a/version.h +++ b/version.h @@ -15,6 +15,6 @@ #define MAJOR 2 // Major version number #define MINOR 2 // Minor version number -#define PATCH 16 // Patch release number +#define PATCH 17 // Patch release number #endif // __VERSION_H__ -- 2.37.2