diff options
author | Victor Stinner <vstinner@python.org> | 2021-09-03 14:44:02 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-03 14:44:02 (GMT) |
commit | 7974c30b9fd84fa56ea1515ed2c08b38edf1a383 (patch) | |
tree | 2d638f338e1e6f90765fa731ff27ef6265524723 /Include | |
parent | be9de8721d63b9d8e032d508069daf88c06542c6 (diff) | |
download | cpython-7974c30b9fd84fa56ea1515ed2c08b38edf1a383.zip cpython-7974c30b9fd84fa56ea1515ed2c08b38edf1a383.tar.gz cpython-7974c30b9fd84fa56ea1515ed2c08b38edf1a383.tar.bz2 |
bpo-45094: Add Py_NO_INLINE macro (GH-28140)
* Rename _Py_NO_INLINE macro to Py_NO_INLINE: make it public and
document it.
* Sort macros in the C API documentation.
Diffstat (limited to 'Include')
-rw-r--r-- | Include/pymath.h | 7 | ||||
-rw-r--r-- | Include/pyport.h | 25 |
2 files changed, 14 insertions, 18 deletions
diff --git a/Include/pymath.h b/Include/pymath.h index f869724..ebb3b05 100644 --- a/Include/pymath.h +++ b/Include/pymath.h @@ -163,12 +163,7 @@ PyAPI_FUNC(void) _Py_set_387controlword(unsigned short); #pragma float_control(push) #pragma float_control(precise, on) #pragma float_control(except, on) - #if defined(_MSC_VER) - __declspec(noinline) - #else /* Linux */ - __attribute__((noinline)) - #endif /* _MSC_VER */ - static double __icc_nan() + Py_NO_INLINE static double __icc_nan() { return sqrt(-1.0); } diff --git a/Include/pyport.h b/Include/pyport.h index b2b53dd..0aaa4ee 100644 --- a/Include/pyport.h +++ b/Include/pyport.h @@ -557,19 +557,20 @@ extern "C" { #define _Py_HOT_FUNCTION #endif -/* _Py_NO_INLINE - * Disable inlining on a function. For example, it helps to reduce the C stack - * consumption. - * - * Usage: - * int _Py_NO_INLINE x(void) { return 3; } - */ -#if defined(_MSC_VER) -# define _Py_NO_INLINE __declspec(noinline) -#elif defined(__GNUC__) || defined(__clang__) -# define _Py_NO_INLINE __attribute__ ((noinline)) +// Py_NO_INLINE +// Disable inlining on a function. For example, it reduces the C stack +// consumption: useful on LTO+PGO builds which heavily inline code (see +// bpo-33720). +// +// Usage: +// +// Py_NO_INLINE static int random(void) { return 4; } +#if defined(__GNUC__) || defined(__clang__) || defined(__INTEL_COMPILER) +# define Py_NO_INLINE __attribute__ ((noinline)) +#elif defined(_MSC_VER) +# define Py_NO_INLINE __declspec(noinline) #else -# define _Py_NO_INLINE +# define Py_NO_INLINE #endif /************************************************************************** |