gh-91731: Replace Py_BUILD_ASSERT() with static_assert() (#91730)

Python 3.11 now uses C11 standard which adds static_assert()
to <assert.h>.

* In pytime.c, replace Py_BUILD_ASSERT() with preprocessor checks on
  SIZEOF_TIME_T with #error.
* On macOS, py_mach_timebase_info() now accepts timebase members with
  the same size than _PyTime_t.
* py_get_monotonic_clock() now saturates GetTickCount64() to
  _PyTime_MAX: GetTickCount64() is unsigned, whereas _PyTime_t is
  signed.
This commit is contained in:
Victor Stinner 2022-04-20 19:26:40 +02:00 committed by GitHub
parent ad3ca17ff5
commit 7cdaf87ec5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 68 additions and 38 deletions

View file

@ -206,7 +206,8 @@ PySlice_Unpack(PyObject *_r,
PySliceObject *r = (PySliceObject*)_r;
/* this is harder to get right than you might think */
Py_BUILD_ASSERT(PY_SSIZE_T_MIN + 1 <= -PY_SSIZE_T_MAX);
static_assert(PY_SSIZE_T_MIN + 1 <= -PY_SSIZE_T_MAX,
"-PY_SSIZE_T_MAX < PY_SSIZE_T_MIN + 1");
if (r->step == Py_None) {
*step = 1;