Skip to content

Cast the pointers InterlockedCompareExchangePointer is given - #160

Open
DTW-Thalion wants to merge 1 commit into
gnustep:masterfrom
DTW-Thalion:fix/win32-atomic-pointer-cast
Open

Cast the pointers InterlockedCompareExchangePointer is given#160
DTW-Thalion wants to merge 1 commit into
gnustep:masterfrom
DTW-Thalion:fix/win32-atomic-pointer-cast

Conversation

@DTW-Thalion

Copy link
Copy Markdown
Contributor

Every atomic macro in the _WIN32 branch of GSPrivate.h casts what it is given, to LONGLONG volatile* or LONG volatile*. GSAtomicCompareAndSwapPointer passes its arguments through untouched, and InterlockedCompareExchangePointer takes PVOID volatile*.

A caller holding a typed pointer therefore does not compile. CFTimeZone.c has 6 of them, passing CFTimeZoneRef* and CFDictionaryRef*.

The other branch uses __sync_val_compare_and_swap, which is type generic, so this only appears on Windows.

Found building on MSYS2 ucrt64 with clang 22.

Every other atomic macro in the _WIN32 branch casts its arguments, to
LONGLONG volatile* or LONG volatile*.  The pointer one passed its arguments
through untouched, so a caller holding a typed pointer, such as
CFTimeZoneRef* in CFTimeZone.c, does not compile: the parameter is
PVOID volatile*.

The other branch uses __sync_val_compare_and_swap, which is type generic, so
this only shows up on Windows.
@DTW-Thalion
DTW-Thalion marked this pull request as ready for review August 14, 2026 02:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant