News for hackers. Stuff that matters.
Re:I ported pigz from Unix to Windows by igrunert on Monday June 23, 2025 @06:40PM (#44360930)
I recently ported WebKit's libpas memory allocator[1] to Windows, which used pthreads on the Linux and Darwin ports. Depending on what pthreads features you're using it's not that much code to shim to Windows APIs. It's around ~200 LOC[2] for WebKit's usage, which a lot smaller than pthread-win32.

[1] https://github.com/WebKit/WebKit/pull/41945 [2] https://github.com/WebKit/WebKit/blob/main/Source/bmalloc/li...

Re:I ported pigz from Unix to Windows by malkia on Monday June 23, 2025 @07:37PM (#44361336)
These VirtualAlloc's may intermittently fail if the pagefile is growing...
Re:I ported pigz from Unix to Windows by igrunert on Monday June 23, 2025 @08:04PM (#44361496)
Ah yeah, I see Firefox ran into that and added retries:

https://hacks.mozilla.org/2022/11/improving-firefox-stabilit...

Seems like a worthwhile change, though I'm not sure when I'll get around to it.

Re:I ported pigz from Unix to Windows by account42 on Tuesday June 24, 2025 @04:26AM (#44363993)
This is something you also need to do for other Win32 APIs, e.g. file write access may be temporarily blocked by anti-virus programs or whatever and not handling that makes unhappy users.
Re:I ported pigz from Unix to Windows by adzm on Monday June 23, 2025 @06:42PM (#44360945)
Never knew about the destructor feature for fiber local allocations!
Re:I ported pigz from Unix to Windows by kjksf on Tuesday June 24, 2025 @06:00AM (#44364487)
At the time (11 years ago) I wanted this to run on Windows XP.

The APIs you use there (e.g. SleepConditionVariableSRW()) were only added in Vista.

I assume a big chunk of pthread emulation code at that time was implementing things like that.