diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2014-05-14 15:24:35 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2014-05-14 15:24:35 (GMT) |
commit | 45e8e2f2185fc593ae84a628922c5cbb1799b6ea (patch) | |
tree | 5a6706f3fd37947b574fe44c45f6c4cb6f6f7c53 /Include/pymacro.h | |
parent | 79b49ab553f74560d71dd027db252f4f0ddd0304 (diff) | |
download | cpython-45e8e2f2185fc593ae84a628922c5cbb1799b6ea.zip cpython-45e8e2f2185fc593ae84a628922c5cbb1799b6ea.tar.gz cpython-45e8e2f2185fc593ae84a628922c5cbb1799b6ea.tar.bz2 |
Issue #21490: Add new C macros: Py_ABS() and Py_STRINGIFY()
Keep _Py_STRINGIZE() in PC/pyconfig.h to not introduce a dependency between
pyconfig.h and pymacros.h.
Diffstat (limited to 'Include/pymacro.h')
-rw-r--r-- | Include/pymacro.h | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/Include/pymacro.h b/Include/pymacro.h index 7997c55..3f6f5dc 100644 --- a/Include/pymacro.h +++ b/Include/pymacro.h @@ -1,13 +1,26 @@ #ifndef Py_PYMACRO_H #define Py_PYMACRO_H +/* Minimum value between x and y */ #define Py_MIN(x, y) (((x) > (y)) ? (y) : (x)) + +/* Maximum value between x and y */ #define Py_MAX(x, y) (((x) > (y)) ? (x) : (y)) +/* Absolute value of the number x */ +#define Py_ABS(x) ((x) < 0 ? -(x) : (x)) + +#define _Py_XSTRINGIFY(x) #x + +/* Convert the argument to a string. For example, Py_STRINGIFY(123) is replaced + with "123" by the preprocessor. Defines are also replaced by their value. + For example Py_STRINGIFY(__LINE__) is replaced by the line number, not + by "__LINE__". */ +#define Py_STRINGIFY(x) _Py_XSTRINGIFY(x) + /* Argument must be a char or an int in [-128, 127] or [0, 255]. */ #define Py_CHARMASK(c) ((unsigned char)((c) & 0xff)) - /* Assert a build-time dependency, as an expression. Your compile will fail if the condition isn't true, or can't be evaluated |