Skip to content

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

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

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
Contributor

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.

@kbayes

kbayes commented Aug 26, 2026

Copy link
Copy Markdown
Member

Closing out because we don't support win32.

@kbayes kbayes closed this Aug 26, 2026
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.

2 participants