aboutsummaryrefslogtreecommitdiff
path: root/Include
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2021-09-03 16:44:02 +0200
committerGitHub <noreply@github.com>2021-09-03 16:44:02 +0200
commit7974c30b9fd84fa56ea1515ed2c08b38edf1a383 (patch)
tree2d638f338e1e6f90765fa731ff27ef6265524723 /Include
parentbe9de8721d63b9d8e032d508069daf88c06542c6 (diff)
downloadcpython3-7974c30b9fd84fa56ea1515ed2c08b38edf1a383.tar.gz
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.h7
-rw-r--r--Include/pyport.h25
2 files changed, 14 insertions, 18 deletions
diff --git a/Include/pymath.h b/Include/pymath.h
index f869724334..ebb3b05f1b 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 b2b53dd2f7..0aaa4eedd3 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
/**************************************************************************