8000 [3.13] gh-123747: Avoid static_assert() in internal header files (#12… · python/cpython@d053204 · GitHub
[go: up one dir, main page]

Skip to content

Commit d053204

Browse files
authored
[3.13] gh-123747: Avoid static_assert() in internal header files (#123779) (#123785)
gh-123747: Avoid static_assert() in internal header files (#123779) (cherry picked from commit ef4b69d)
1 parent 2cc1899 commit d053204

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

Include/internal/pycore_code.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -537,8 +537,9 @@ write_location_entry_start(uint8_t *ptr, int code, int length)
537537
#define ADAPTIVE_COOLDOWN_BACKOFF 0
538538

539539
// Can't assert this in pycore_backoff.h because of header order dependencies
540-
static_assert(COLD_EXIT_INITIAL_VALUE > ADAPTIVE_COOLDOWN_VALUE,
541-
"Cold exit value should be larger than adaptive cooldown value");
540+
#if COLD_EXIT_INITIAL_VALUE <= ADAPTIVE_COOLDOWN_VALUE
541+
# error "Cold exit value should be larger than adaptive cooldown value"
542+
#endif
542543

543544
static inline _Py_BackoffCounter
544545
adaptive_counter_bits(uint16_t value, uint16_t backoff) {

Include/internal/pycore_long.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,12 @@ PyAPI_FUNC(int) _PyLong_Size_t_Converter(PyObject *, void *);
178178
* we define them to the numbers in both places and then assert that
179179
* they're the same.
180180
*/
181-
static_assert(SIGN_MASK == _PyLong_SIGN_MASK, "SIGN_MASK does not match _PyLong_SIGN_MASK");
182-
static_assert(NON_SIZE_BITS == _PyLong_NON_SIZE_BITS, "NON_SIZE_BITS does not match _PyLong_NON_SIZE_BITS");
181+
#if SIGN_MASK != _PyLong_SIGN_MASK
182+
# error "SIGN_MASK does not match _PyLong_SIGN_MASK"
183+
#endif
184+
#if NON_SIZE_BITS != _PyLong_NON_SIZE_BITS
185+
# error "NON_SIZE_BITS does not match _PyLong_NON_SIZE_BITS"
186+
#endif
183187

184188
/* All *compact" values are guaranteed to fit into
185189
* a Py_ssize_t with at least one bit to spare.

0 commit comments

Comments
 (0)
0