mirror of https://github.com/python/cpython.git
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.
This commit is contained in:
parent
be9de8721d
commit
7974c30b9f
|
@ -105,6 +105,71 @@ defined closer to where they are useful (e.g. :c:macro:`Py_RETURN_NONE`).
|
|||
Others of a more general utility are defined here. This is not necessarily a
|
||||
complete listing.
|
||||
|
||||
.. c:macro:: Py_ABS(x)
|
||||
|
||||
Return the absolute value of ``x``.
|
||||
|
||||
.. versionadded:: 3.3
|
||||
|
||||
.. c:macro:: Py_CHARMASK(c)
|
||||
|
||||
Argument must be a character or an integer in the range [-128, 127] or [0,
|
||||
255]. This macro returns ``c`` cast to an ``unsigned char``.
|
||||
|
||||
.. c:macro:: Py_DEPRECATED(version)
|
||||
|
||||
Use this for deprecated declarations. The macro must be placed before the
|
||||
symbol name.
|
||||
|
||||
Example::
|
||||
|
||||
Py_DEPRECATED(3.8) PyAPI_FUNC(int) Py_OldFunction(void);
|
||||
|
||||
.. versionchanged:: 3.8
|
||||
MSVC support was added.
|
||||
|
||||
.. c:macro:: Py_GETENV(s)
|
||||
|
||||
Like ``getenv(s)``, but returns ``NULL`` if :option:`-E` was passed on the
|
||||
command line (i.e. if ``Py_IgnoreEnvironmentFlag`` is set).
|
||||
|
||||
.. c:macro:: Py_MAX(x, y)
|
||||
|
||||
Return the maximum value between ``x`` and ``y``.
|
||||
|
||||
.. versionadded:: 3.3
|
||||
|
||||
.. c:macro:: Py_MEMBER_SIZE(type, member)
|
||||
|
||||
Return the size of a structure (``type``) ``member`` in bytes.
|
||||
|
||||
.. versionadded:: 3.6
|
||||
|
||||
.. c:macro:: Py_MIN(x, y)
|
||||
|
||||
Return the minimum value between ``x`` and ``y``.
|
||||
|
||||
.. versionadded:: 3.3
|
||||
|
||||
.. c:macro:: 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
|
||||
:issue:`33720`).
|
||||
|
||||
Usage::
|
||||
|
||||
Py_NO_INLINE static int random(void) { return 4; }
|
||||
|
||||
.. versionadded:: 3.11
|
||||
|
||||
.. c:macro:: Py_STRINGIFY(x)
|
||||
|
||||
Convert ``x`` to a C string. E.g. ``Py_STRINGIFY(123)`` returns
|
||||
``"123"``.
|
||||
|
||||
.. versionadded:: 3.4
|
||||
|
||||
.. c:macro:: Py_UNREACHABLE()
|
||||
|
||||
Use this when you have a code path that cannot be reached by design.
|
||||
|
@ -127,47 +192,6 @@ complete listing.
|
|||
|
||||
.. versionadded:: 3.7
|
||||
|
||||
.. c:macro:: Py_ABS(x)
|
||||
|
||||
Return the absolute value of ``x``.
|
||||
|
||||
.. versionadded:: 3.3
|
||||
|
||||
.. c:macro:: Py_MIN(x, y)
|
||||
|
||||
Return the minimum value between ``x`` and ``y``.
|
||||
|
||||
.. versionadded:: 3.3
|
||||
|
||||
.. c:macro:: Py_MAX(x, y)
|
||||
|
||||
Return the maximum value between ``x`` and ``y``.
|
||||
|
||||
.. versionadded:: 3.3
|
||||
|
||||
.. c:macro:: Py_STRINGIFY(x)
|
||||
|
||||
Convert ``x`` to a C string. E.g. ``Py_STRINGIFY(123)`` returns
|
||||
``"123"``.
|
||||
|
||||
.. versionadded:: 3.4
|
||||
|
||||
.. c:macro:: Py_MEMBER_SIZE(type, member)
|
||||
|
||||
Return the size of a structure (``type``) ``member`` in bytes.
|
||||
|
||||
.. versionadded:: 3.6
|
||||
|
||||
.. c:macro:: Py_CHARMASK(c)
|
||||
|
||||
Argument must be a character or an integer in the range [-128, 127] or [0,
|
||||
255]. This macro returns ``c`` cast to an ``unsigned char``.
|
||||
|
||||
.. c:macro:: Py_GETENV(s)
|
||||
|
||||
Like ``getenv(s)``, but returns ``NULL`` if :option:`-E` was passed on the
|
||||
command line (i.e. if ``Py_IgnoreEnvironmentFlag`` is set).
|
||||
|
||||
.. c:macro:: Py_UNUSED(arg)
|
||||
|
||||
Use this for unused arguments in a function definition to silence compiler
|
||||
|
@ -175,18 +199,6 @@ complete listing.
|
|||
|
||||
.. versionadded:: 3.4
|
||||
|
||||
.. c:macro:: Py_DEPRECATED(version)
|
||||
|
||||
Use this for deprecated declarations. The macro must be placed before the
|
||||
symbol name.
|
||||
|
||||
Example::
|
||||
|
||||
Py_DEPRECATED(3.8) PyAPI_FUNC(int) Py_OldFunction(void);
|
||||
|
||||
.. versionchanged:: 3.8
|
||||
MSVC support was added.
|
||||
|
||||
.. c:macro:: PyDoc_STRVAR(name, str)
|
||||
|
||||
Creates a variable with name ``name`` that can be used in docstrings.
|
||||
|
@ -221,6 +233,7 @@ complete listing.
|
|||
{NULL, NULL}
|
||||
};
|
||||
|
||||
|
||||
.. _api-objects:
|
||||
|
||||
Objects, Types and Reference Counts
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
||||
/**************************************************************************
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
Add the :c:macro:`Py_NO_INLINE` macro to disable inlining on a function.
|
||||
Patch by Victor Stinner.
|
|
@ -186,7 +186,7 @@ partial_dealloc(partialobject *pto)
|
|||
/* Merging keyword arguments using the vectorcall convention is messy, so
|
||||
* if we would need to do that, we stop using vectorcall and fall back
|
||||
* to using partial_call() instead. */
|
||||
_Py_NO_INLINE static PyObject *
|
||||
Py_NO_INLINE static PyObject *
|
||||
partial_vectorcall_fallback(PyThreadState *tstate, partialobject *pto,
|
||||
PyObject *const *args, size_t nargsf,
|
||||
PyObject *kwnames)
|
||||
|
|
|
@ -176,7 +176,7 @@ resize_buffer(bytesio *self, size_t size)
|
|||
object. Returns the number of bytes written, or -1 on error.
|
||||
Inlining is disabled because it's significantly decreases performance
|
||||
of writelines() in PGO build. */
|
||||
_Py_NO_INLINE static Py_ssize_t
|
||||
Py_NO_INLINE static Py_ssize_t
|
||||
write_bytes(bytesio *self, PyObject *b)
|
||||
{
|
||||
if (check_closed(self)) {
|
||||
|
|
|
@ -451,7 +451,7 @@ reset_signal_handlers(const sigset_t *child_sigmask)
|
|||
* If vfork-unsafe functionality is desired after vfork(), consider using
|
||||
* syscall() to obtain it.
|
||||
*/
|
||||
_Py_NO_INLINE static void
|
||||
Py_NO_INLINE static void
|
||||
child_exec(char *const exec_array[],
|
||||
char *const argv[],
|
||||
char *const envp[],
|
||||
|
@ -650,7 +650,7 @@ child_exec(char *const exec_array[],
|
|||
* child_exec() should not be inlined to avoid spurious -Wclobber warnings from
|
||||
* GCC (see bpo-35823).
|
||||
*/
|
||||
_Py_NO_INLINE static pid_t
|
||||
Py_NO_INLINE static pid_t
|
||||
do_fork_exec(char *const exec_array[],
|
||||
char *const argv[],
|
||||
char *const envp[],
|
||||
|
|
|
@ -891,7 +891,7 @@ r_float_bin(RFILE *p)
|
|||
|
||||
/* Issue #33720: Disable inlining for reducing the C stack consumption
|
||||
on PGO builds. */
|
||||
_Py_NO_INLINE static double
|
||||
Py_NO_INLINE static double
|
||||
r_float_str(RFILE *p)
|
||||
{
|
||||
int n;
|
||||
|
|
Loading…
Reference in New Issue