Skip to content

Commit f7b3664

Browse files
committed
dlmalloc: cast Win32 spin-lock word to LONG volatile* in CAS_LOCK/CLEAR_LOCK
MLOCK_T is int, but on the Win32 MSC path CAS_LOCK/CLEAR_LOCK map to _InterlockedExchange(LONG volatile *, LONG), so the int* lock word is passed to a LONG volatile * parameter. clang 22 promotes -Wincompatible-pointer-types to an error by default, which breaks the clang-cl build (32- and 64-bit) with: error: incompatible pointer types passing 'int *' to parameter of type 'volatile long *' [-Wincompatible-pointer-types] Cast to (LONG volatile *), matching what the ffi_spin_peek macro just below already does in its _MSC_VER branch. LONG and int are both 32-bit on Windows, so this is a type-correctness fix with no behavioral change.
1 parent c93f942 commit f7b3664

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎src/dlmalloc.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1916,8 +1916,8 @@ static FORCEINLINE void x86_clear_lock(int* sl) {
19161916
#define CLEAR_LOCK(sl) x86_clear_lock(sl)
19171917

19181918
#else /* Win32 MSC */
1919-
#define CAS_LOCK(sl) interlockedexchange(sl, (LONG)1)
1920-
#define CLEAR_LOCK(sl) interlockedexchange (sl, (LONG)0)
1919+
#define CAS_LOCK(sl) interlockedexchange((LONG volatile *)(sl), (LONG)1)
1920+
#define CLEAR_LOCK(sl) interlockedexchange ((LONG volatile *)(sl), (LONG)0)
19211921

19221922
#endif /* ... gcc spins locks ... */
19231923

0 commit comments

Comments
 (0)