]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-123747: Avoid static_assert() in internal header files (#123779) (#123785)
authorVictor Stinner <vstinner@python.org>
Fri, 6 Sep 2024 14:41:09 +0000 (16:41 +0200)
committerGitHub <noreply@github.com>
Fri, 6 Sep 2024 14:41:09 +0000 (14:41 +0000)
gh-123747: Avoid static_assert() in internal header files (#123779)

(cherry picked from commit ef4b69d2becf49daaea21eb04effee81328a0393)

Include/internal/pycore_code.h
Include/internal/pycore_long.h

index c3553dfa33147663560c7bc220a4796d557e54fa..1fb8cc473c6e98b942d1a083f9fd96cb40f98004 100644 (file)
@@ -537,8 +537,9 @@ write_location_entry_start(uint8_t *ptr, int code, int length)
 #define ADAPTIVE_COOLDOWN_BACKOFF 0
 
 // Can't assert this in pycore_backoff.h because of header order dependencies
-static_assert(COLD_EXIT_INITIAL_VALUE > ADAPTIVE_COOLDOWN_VALUE,
-    "Cold exit value should be larger than adaptive cooldown value");
+#if COLD_EXIT_INITIAL_VALUE <= ADAPTIVE_COOLDOWN_VALUE
+#  error  "Cold exit value should be larger than adaptive cooldown value"
+#endif
 
 static inline _Py_BackoffCounter
 adaptive_counter_bits(uint16_t value, uint16_t backoff) {
index 8513695c22e703eb6138b2111d5d5b32a8629396..ff7d9afc03a4f24ea4602560b49c68fc7b2273cb 100644 (file)
@@ -178,8 +178,12 @@ PyAPI_FUNC(int) _PyLong_Size_t_Converter(PyObject *, void *);
  * we define them to the numbers in both places and then assert that
  * they're the same.
  */
-static_assert(SIGN_MASK == _PyLong_SIGN_MASK, "SIGN_MASK does not match _PyLong_SIGN_MASK");
-static_assert(NON_SIZE_BITS == _PyLong_NON_SIZE_BITS, "NON_SIZE_BITS does not match _PyLong_NON_SIZE_BITS");
+#if SIGN_MASK != _PyLong_SIGN_MASK
+#  error "SIGN_MASK does not match _PyLong_SIGN_MASK"
+#endif
+#if NON_SIZE_BITS != _PyLong_NON_SIZE_BITS
+#  error "NON_SIZE_BITS does not match _PyLong_NON_SIZE_BITS"
+#endif
 
 /* All *compact" values are guaranteed to fit into
  * a Py_ssize_t with at least one bit to spare.