summaryrefslogtreecommitdiffstats
path: root/Include/internal/pycore_pymath.h
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2022-05-27 13:05:35 (GMT)
committerGitHub <noreply@github.com>2022-05-27 13:05:35 (GMT)
commit22b75d9bef1bffe82bfa1adfcbec0243c9202041 (patch)
tree2f2670227cb3db6e5209b1586c79d5ffa45145fd /Include/internal/pycore_pymath.h
parentcb04a09d2dfd197436a11de504b92773569e19fb (diff)
downloadcpython-22b75d9bef1bffe82bfa1adfcbec0243c9202041.zip
cpython-22b75d9bef1bffe82bfa1adfcbec0243c9202041.tar.gz
cpython-22b75d9bef1bffe82bfa1adfcbec0243c9202041.tar.bz2
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().
Diffstat (limited to 'Include/internal/pycore_pymath.h')
-rw-r--r--Include/internal/pycore_pymath.h8
1 files changed, 2 insertions, 6 deletions
diff --git a/Include/internal/pycore_pymath.h b/Include/internal/pycore_pymath.h
index 5c6aee2..5f3afe4 100644
--- a/Include/internal/pycore_pymath.h
+++ b/Include/internal/pycore_pymath.h
@@ -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