summaryrefslogtreecommitdiff
path: root/Include/pyport.h
diff options
context:
space:
mode:
Diffstat (limited to 'Include/pyport.h')
-rw-r--r--Include/pyport.h40
1 files changed, 38 insertions, 2 deletions
diff --git a/Include/pyport.h b/Include/pyport.h
index 52a91a0d11..03c664f397 100644
--- a/Include/pyport.h
+++ b/Include/pyport.h
@@ -491,13 +491,49 @@ extern "C" {
* typedef int T1 Py_DEPRECATED(2.4);
* extern int x() Py_DEPRECATED(2.5);
*/
-#if defined(__GNUC__) && ((__GNUC__ >= 4) || \
- (__GNUC__ == 3) && (__GNUC_MINOR__ >= 1))
+#if defined(__GNUC__) \
+ && ((__GNUC__ >= 4) || (__GNUC__ == 3) && (__GNUC_MINOR__ >= 1))
#define Py_DEPRECATED(VERSION_UNUSED) __attribute__((__deprecated__))
#else
#define Py_DEPRECATED(VERSION_UNUSED)
#endif
+
+/* _Py_HOT_FUNCTION
+ * The hot attribute on a function is used to inform the compiler that the
+ * function is a hot spot of the compiled program. The function is optimized
+ * more aggressively and on many target it is placed into special subsection of
+ * the text section so all hot functions appears close together improving
+ * locality.
+ *
+ * Usage:
+ * int _Py_HOT_FUNCTION x(void) { return 3; }
+ *
+ * Issue #28618: This attribute must not be abused, otherwise it can have a
+ * negative effect on performance. Only the functions were Python spend most of
+ * its time must use it. Use a profiler when running performance benchmark
+ * suite to find these functions.
+ */
+#if defined(__GNUC__) \
+ && ((__GNUC__ >= 5) || (__GNUC__ == 4) && (__GNUC_MINOR__ >= 3))
+#define _Py_HOT_FUNCTION __attribute__((hot))
+#else
+#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(__GNUC__) || defined(__clang__)
+# define _Py_NO_INLINE __attribute__((noinline))
+#else
+# define _Py_NO_INLINE
+#endif
+
/**************************************************************************
Prototypes that are missing from the standard include files on some systems
(and possibly only some versions of such systems.)