Skip to content

Commit ec27072

Browse files
Another try to fix Windows build
1 parent 2600236 commit ec27072

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

Include/internal/pycore_backoff.h

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,29 +36,36 @@ extern "C" {
3636
#define MAX_BACKOFF 6
3737
#define UNREACHABLE_BACKOFF 7
3838

39-
#define MAKE_BACKOFF_COUNTER(value, backoff) \
40-
((_Py_BackoffCounter){ .value_and_backoff = (value << BACKOFF_BITS) | backoff })
39+
#define MAKE_VALUE_AND_BACKOFF(value, backoff) \
40+
((value << BACKOFF_BITS) | backoff)
41+
42+
#define MAKE_BACKOFF_COUNTER(value, backoff) \
43+
((_Py_BackoffCounter){ \
44+
.value_and_backoff = MAKE_VALUE_AND_BACKOFF(value, backoff) \
45+
})
4146

4247
// We only use values x and backoffs b such that
4348
// x + 1 is near to 2**(2*b+1) and x + 1 is prime.
44-
static _Py_BackoffCounter backoff_counter_next_table[] = {
45-
MAKE_BACKOFF_COUNTER(6, 1),
46-
MAKE_BACKOFF_COUNTER(30, 2),
47-
MAKE_BACKOFF_COUNTER(126, 3),
48-
MAKE_BACKOFF_COUNTER(508, 4),
49-
MAKE_BACKOFF_COUNTER(2052, 5),
50-
MAKE_BACKOFF_COUNTER(8190, 6),
49+
static uint16_t value_and_backoff_next[] = {
50+
MAKE_VALUE_AND_BACKOFF(6, 1),
51+
MAKE_VALUE_AND_BACKOFF(30, 2),
52+
MAKE_VALUE_AND_BACKOFF(126, 3),
53+
MAKE_VALUE_AND_BACKOFF(508, 4),
54+
MAKE_VALUE_AND_BACKOFF(2052, 5),
55+
MAKE_VALUE_AND_BACKOFF(8190, 6),
5156
// We use the same backoff counter for all backoffs >= MAX_BACKOFF.
52-
MAKE_BACKOFF_COUNTER(8190, 6),
53-
MAKE_BACKOFF_COUNTER(8190, 6),
57+
MAKE_VALUE_AND_BACKOFF(8190, 6),
58+
MAKE_VALUE_AND_BACKOFF(8190, 6),
5459
};
5560

5661
static inline _Py_BackoffCounter
5762
restart_backoff_counter(_Py_BackoffCounter counter)
5863
{
5964
uint16_t backoff = counter.value_and_backoff & BACKOFF_MASK;
6065
assert(backoff <= MAX_BACKOFF);
61-
return backoff_counter_next_table[backoff];
66+
return ((_Py_BackoffCounter){
67+
.value_and_backoff = value_and_backoff_next[backoff]
68+
});
6269
}
6370

6471
static inline _Py_BackoffCounter

0 commit comments

Comments
 (0)