File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed
Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -32,8 +32,10 @@ extern "C" {
3232*/
3333
3434#define BACKOFF_BITS 4
35+ #define BACKOFF_MASK 0xF
3536#define MAX_BACKOFF 12
3637#define UNREACHABLE_BACKOFF 15
38+ #define MAX_VALUE 0xFFF
3739
3840static inline bool
3941is_unreachable_backoff_counter (_Py_BackoffCounter counter )
@@ -44,8 +46,8 @@ is_unreachable_backoff_counter(_Py_BackoffCounter counter)
4446static inline _Py_BackoffCounter
4547make_backoff_counter (uint16_t value , uint16_t backoff )
4648{
47- assert (backoff <= 15 );
48- assert (value <= 0xFFF );
49+ assert (backoff <= UNREACHABLE_BACKOFF );
50+ assert (value <= MAX_VALUE );
4951 _Py_BackoffCounter result ;
5052 result .value_and_backoff = (value << BACKOFF_BITS ) | backoff ;
5153 return result ;
@@ -63,7 +65,7 @@ static inline _Py_BackoffCounter
6365restart_backoff_counter (_Py_BackoffCounter counter )
6466{
6567 assert (!is_unreachable_backoff_counter (counter ));
66- int backoff = counter .value_and_backoff & 15 ;
68+ int backoff = counter .value_and_backoff & BACKOFF_MASK ;
6769 if (backoff < MAX_BACKOFF ) {
6870 return make_backoff_counter ((1 << (backoff + 1 )) - 1 , backoff + 1 );
6971 }
You can’t perform that action at this time.
0 commit comments