Skip to content

Fix size_t atomic add on 32-bit MSVC - #3512

Open
sylvesterkaczmarek wants to merge 1 commit into
google-deepmind:mainfrom
sylvesterkaczmarek:fix/msvc-x86-atomic-size-t
Open

Fix size_t atomic add on 32-bit MSVC#3512
sylvesterkaczmarek wants to merge 1 commit into
google-deepmind:mainfrom
sylvesterkaczmarek:fix/msvc-x86-atomic-size-t

Conversation

@sylvesterkaczmarek

Copy link
Copy Markdown

Summary

Use the width-appropriate MSVC interlocked intrinsic for size_t.

engine_crossplatform.h currently maps mj_atomic_add_size_t to _InterlockedExchangeAdd64 for every non-Clang MSVC build. That is correct on 64-bit Windows, but 32-bit Windows uses a 32-bit size_t and the x86 build can fail to link with an unresolved __InterlockedExchangeAdd64.

This keeps _InterlockedExchangeAdd64 on _WIN64 and uses _InterlockedExchangeAdd on 32-bit MSVC.

This revives the still-relevant fix from closed, unmerged PR #3358 by @BillyONeal, rebased onto current main.

Validation

Final diff is one file and one commit. The 64-bit branch is unchanged; the new branch is selected only for 32-bit MSVC.

An x86 MSVC toolchain is not available in this environment, so the Windows build was not run locally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant