Our great sponsors
-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
WinMain and main are both called by invoke_main: https://github.com/ojdkbuild/tools_toolchain_vs2017bt_1416/b...
(that does not look like an official repo, but it's the best I could find in terms of a github link. The file pretty much matches c:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\crt\src\vcruntime\exe_common.inl on my PC.)
I use mingw-w64 with a recent GCC (I'd assume the latest would work too) to target Windows 95, using the mxe toolchain to crosscompile from Linux for convenience. However recently I had to patch mxe to restore support for Win 95 through 2000, which they'd broken only for the sake of implementing SetThreadName [1]
[1] https://github.com/rversteegen/mxe/commit/aa87b55a77a62d4cff...
Yes, I guess I could do that, then maybe I can get it upstreamed.
However I was misremembering a bit and misspoke before both about how easy it's been to support Windows 95 (it was easy up until a few mingw-w64 releases ago... except for spawning processes) and how recent my mingw-w64 is (I'm using 7.0.0, 3.5 years old, and simply haven't tried anything newer). Also I have no idea the minimum Windows targetted by mingw-w64 actually is, they don't say. I think they don't actually care about Windows 9x support, they just never did anything to break it before 6.0.0. So I doubt they'd accept such a patch.
The most important trick was you have to use a build of mingw-w64 with 'win32' rather than 'posix' threading ([1], and the rest of that thread is relevant too):
> the 'win32' threading support in mingw-w64 is the original one and supports all 32-bit Windows, while 'posix' threading (winpthreads) is a recent addition which is necessary to support C++11 mutexes and threads, but has higher system requirements. ... That's why mxe switched to posix threads by default in 2019.
[1] https://github.com/ohrrpgce/ohrrpgce/issues/1241#issuecommen...
The kernel just puts the data contiguously on the stack. Obtaining pointers to them can seem somewhat magical if you're writing a nolibc program but I wouldn't call it horrible.
I implemented it for my programming language with some rather simple assembly code:
https://github.com/lone-lang/lone/blob/master/arch/x86_64.c#...
https://github.com/lone-lang/lone/blob/master/arch/aarch64.c...