33
44#pragma once
55
6- // Undefine YieldProcessor to encourage using the normalized versions below instead. System_YieldProcessor() can be used where
7- // the intention is to use the system-default implementation of YieldProcessor().
8- #define HAS_SYSTEM_YIELDPROCESSOR
6+ # ifdef FEATURE_NATIVEAOT
7+ FORCEINLINE void System_YieldProcessor () { PalYieldProcessor (); }
8+ #else
99FORCEINLINE void System_YieldProcessor () { YieldProcessor (); }
10- #ifdef YieldProcessor
11- #undef YieldProcessor
1210#endif
13- #define YieldProcessor Dont_Use_YieldProcessor
1411
1512#define DISABLE_COPY (T ) \
1613 T (const T &) = delete; \
@@ -144,17 +141,17 @@ FORCEINLINE void YieldProcessorNormalized(const YieldProcessorNormalizationInfo
144141{
145142 _ASSERTE (count != 0 );
146143
147- if (sizeof (SIZE_T ) <= sizeof (unsigned int ))
144+ if (sizeof (size_t ) <= sizeof (unsigned int ))
148145 {
149- // On platforms with a small SIZE_T , prevent overflow on the multiply below
146+ // On platforms with a small size_t , prevent overflow on the multiply below
150147 const unsigned int MaxCount = UINT_MAX / YieldProcessorNormalization::MaxYieldsPerNormalizedYield;
151148 if (count > MaxCount)
152149 {
153150 count = MaxCount;
154151 }
155152 }
156153
157- SIZE_T n = (SIZE_T )count * normalizationInfo.yieldsPerNormalizedYield ;
154+ size_t n = (size_t )count * normalizationInfo.yieldsPerNormalizedYield ;
158155 _ASSERTE (n != 0 );
159156 do
160157 {
@@ -189,9 +186,9 @@ FORCEINLINE void YieldProcessorNormalizedForPreSkylakeCount(
189186{
190187 _ASSERTE (preSkylakeCount != 0 );
191188
192- if (sizeof (SIZE_T ) <= sizeof (unsigned int ))
189+ if (sizeof (size_t ) <= sizeof (unsigned int ))
193190 {
194- // On platforms with a small SIZE_T , prevent overflow on the multiply below
191+ // On platforms with a small size_t , prevent overflow on the multiply below
195192 const unsigned int MaxCount = UINT_MAX / YieldProcessorNormalization::MaxYieldsPerNormalizedYield;
196193 if (preSkylakeCount > MaxCount)
197194 {
@@ -200,7 +197,7 @@ FORCEINLINE void YieldProcessorNormalizedForPreSkylakeCount(
200197 }
201198
202199 const unsigned int PreSkylakeCountToSkylakeCountDivisor = 8 ;
203- SIZE_T n = (SIZE_T )preSkylakeCount * normalizationInfo.yieldsPerNormalizedYield / PreSkylakeCountToSkylakeCountDivisor;
200+ size_t n = (size_t )preSkylakeCount * normalizationInfo.yieldsPerNormalizedYield / PreSkylakeCountToSkylakeCountDivisor;
204201 if (n == 0 )
205202 {
206203 n = 1 ;
@@ -227,9 +224,9 @@ FORCEINLINE void YieldProcessorNormalizedForPreSkylakeCount(unsigned int preSkyl
227224
228225 _ASSERTE (preSkylakeCount != 0 );
229226
230- if (sizeof (SIZE_T ) <= sizeof (unsigned int ))
227+ if (sizeof (size_t ) <= sizeof (unsigned int ))
231228 {
232- // On platforms with a small SIZE_T , prevent overflow on the multiply below
229+ // On platforms with a small size_t , prevent overflow on the multiply below
233230 const unsigned int MaxCount = UINT_MAX / YieldProcessorNormalization::MaxYieldsPerNormalizedYield;
234231 if (preSkylakeCount > MaxCount)
235232 {
@@ -238,8 +235,8 @@ FORCEINLINE void YieldProcessorNormalizedForPreSkylakeCount(unsigned int preSkyl
238235 }
239236
240237 const unsigned int PreSkylakeCountToSkylakeCountDivisor = 8 ;
241- SIZE_T n =
242- (SIZE_T )preSkylakeCount *
238+ size_t n =
239+ (size_t )preSkylakeCount *
243240 YieldProcessorNormalization::s_yieldsPerNormalizedYield /
244241 PreSkylakeCountToSkylakeCountDivisor;
245242 if (n == 0 )
@@ -268,11 +265,11 @@ FORCEINLINE void YieldProcessorWithBackOffNormalized(
268265 unsigned int spinIteration)
269266{
270267 // This shift value should be adjusted based on the asserted conditions below
271- const UINT8 MaxShift = 3 ;
272- static_assert_no_msg (
273- ((unsigned int )1 << MaxShift) <= YieldProcessorNormalization::MaxOptimalMaxNormalizedYieldsPerSpinIteration);
274- static_assert_no_msg (
275- ((unsigned int )1 << (MaxShift + 1 )) > YieldProcessorNormalization::MaxOptimalMaxNormalizedYieldsPerSpinIteration);
268+ const uint8_t MaxShift = 3 ;
269+ static_assert (
270+ ((unsigned int )1 << MaxShift) <= YieldProcessorNormalization::MaxOptimalMaxNormalizedYieldsPerSpinIteration, " " );
271+ static_assert (
272+ ((unsigned int )1 << (MaxShift + 1 )) > YieldProcessorNormalization::MaxOptimalMaxNormalizedYieldsPerSpinIteration, " " );
276273
277274 unsigned int n;
278275 if (spinIteration <= MaxShift &&
0 commit comments