mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
gh-82616: Add Py_IS_TYPE_SIGNED() macro (#93178)
_posixsubprocess: add a static assertion to ensure that the pid_t type is signed. Replace _Py_IntegralTypeSigned() with _Py_IS_TYPE_SIGNED().
This commit is contained in:
parent
cb04a09d2d
commit
22b75d9bef
4 changed files with 25 additions and 7 deletions
|
@ -56,17 +56,13 @@ static inline void _Py_ADJUST_ERANGE2(double x, double y)
|
|||
}
|
||||
}
|
||||
|
||||
// Return whether integral type *type* is signed or not.
|
||||
#define _Py_IntegralTypeSigned(type) \
|
||||
((type)(-1) < 0)
|
||||
|
||||
// Return the maximum value of integral type *type*.
|
||||
#define _Py_IntegralTypeMax(type) \
|
||||
((_Py_IntegralTypeSigned(type)) ? (((((type)1 << (sizeof(type)*CHAR_BIT - 2)) - 1) << 1) + 1) : ~(type)0)
|
||||
(_Py_IS_TYPE_SIGNED(type) ? (((((type)1 << (sizeof(type)*CHAR_BIT - 2)) - 1) << 1) + 1) : ~(type)0)
|
||||
|
||||
// Return the minimum value of integral type *type*.
|
||||
#define _Py_IntegralTypeMin(type) \
|
||||
((_Py_IntegralTypeSigned(type)) ? -_Py_IntegralTypeMax(type) - 1 : 0)
|
||||
(_Py_IS_TYPE_SIGNED(type) ? -_Py_IntegralTypeMax(type) - 1 : 0)
|
||||
|
||||
// Check whether *v* is in the range of integral type *type*. This is most
|
||||
// useful if *v* is floating-point, since demoting a floating-point *v* to an
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue