mirror of
https://github.com/python/cpython.git
synced 2025-11-01 10:45:30 +00:00
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:
parent
ad3ca17ff5
commit
7cdaf87ec5
10 changed files with 68 additions and 38 deletions
|
|
@ -6637,19 +6637,19 @@ _datetime_exec(PyObject *module)
|
|||
/* A 4-year cycle has an extra leap day over what we'd get from
|
||||
* pasting together 4 single years.
|
||||
*/
|
||||
Py_BUILD_ASSERT(DI4Y == 4 * 365 + 1);
|
||||
static_assert(DI4Y == 4 * 365 + 1, "DI4Y");
|
||||
assert(DI4Y == days_before_year(4+1));
|
||||
|
||||
/* Similarly, a 400-year cycle has an extra leap day over what we'd
|
||||
* get from pasting together 4 100-year cycles.
|
||||
*/
|
||||
Py_BUILD_ASSERT(DI400Y == 4 * DI100Y + 1);
|
||||
static_assert(DI400Y == 4 * DI100Y + 1, "DI400Y");
|
||||
assert(DI400Y == days_before_year(400+1));
|
||||
|
||||
/* OTOH, a 100-year cycle has one fewer leap day than we'd get from
|
||||
* pasting together 25 4-year cycles.
|
||||
*/
|
||||
Py_BUILD_ASSERT(DI100Y == 25 * DI4Y - 1);
|
||||
static_assert(DI100Y == 25 * DI4Y - 1, "DI100Y");
|
||||
assert(DI100Y == days_before_year(100+1));
|
||||
|
||||
us_per_ms = PyLong_FromLong(1000);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue