threads_win: fix build error with VS2010 x86 #24405
Open
+210
−11
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
InterlockedAnd64
andInterlockedAdd64
are not available on VS2010 x86. We already have implemented replacements for other functions, such asInterlockedOr64
. Apply the same approach to fix the errors. ACRYPTO_RWLOCK rw_lock
is added torcu_lock_st
.Note that the return values of the replacement atomic functions for VS2010 x86 are not checked, because I did not know how to respond to these errors in each location where they are used. This might happen if the lock is not initialised yet. Though the lock is initialised in the beginning when each object is constructed, so this should not occur.
Replace
InterlockedOr64
andInterlockedOr
withCRYPTO_atomic_load
andCRYPTO_atomic_load_int
, using the existing design pattern.Add documentation and tests for the new atomic functions
CRYPTO_atomic_add64
,CRYPTO_atomic_and
Note:
An alternative or addition to this PR would be to implement
InterlockedAdd64
,InterlockedOr64
, andInterlockedAnd64
in x86 assembly as described here #24109 . This will make them lockless and improve performance on x86 code compiled with VS2010. Please let me know which path is preferred?Fixes:
Fixes: #24326 the original PR that was eventually split in 3 parts.
Build and run tested: Windows 2003 x64, Windows 2003 x86, Visual Studio 2010.
@t8m @tom-cosgrove-arm @paulidale @nhorman @shahsb @levitte @mattcaswell @hlandau @viruscamp @yjh-styx
Checklist