Skip to content

Commit 542497a

Browse files
authored
bpo-35059: Remove Py_STATIC_INLINE() macro (GH-10216)
"static inline" should be used directly. Forcing the compiler to inline is not recommended.
1 parent 2aaf0c1 commit 542497a

File tree

3 files changed

+25
-42
lines changed

3 files changed

+25
-42
lines changed

Include/objimpl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ PyAPI_FUNC(PyVarObject *) _PyObject_NewVar(PyTypeObject *, Py_ssize_t);
144144
See also pymem.h.
145145
146146
These inline functions expect non-NULL object pointers. */
147-
Py_STATIC_INLINE(PyObject*)
147+
static inline PyObject*
148148
PyObject_INIT(PyObject *op, PyTypeObject *typeobj)
149149
{
150150
assert(op != NULL);
@@ -153,7 +153,7 @@ PyObject_INIT(PyObject *op, PyTypeObject *typeobj)
153153
return op;
154154
}
155155

156-
Py_STATIC_INLINE(PyVarObject*)
156+
static inline PyVarObject*
157157
PyObject_INIT_VAR(PyVarObject *op, PyTypeObject *typeobj, Py_ssize_t size)
158158
{
159159
assert(op != NULL);

Include/pydtrace.h

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -25,29 +25,29 @@ extern "C" {
2525

2626
/* Without DTrace, compile to nothing. */
2727

28-
Py_STATIC_INLINE(void) PyDTrace_LINE(const char *arg0, const char *arg1, int arg2) {}
29-
Py_STATIC_INLINE(void) PyDTrace_FUNCTION_ENTRY(const char *arg0, const char *arg1, int arg2) {}
30-
Py_STATIC_INLINE(void) PyDTrace_FUNCTION_RETURN(const char *arg0, const char *arg1, int arg2) {}
31-
Py_STATIC_INLINE(void) PyDTrace_GC_START(int arg0) {}
32-
Py_STATIC_INLINE(void) PyDTrace_GC_DONE(int arg0) {}
33-
Py_STATIC_INLINE(void) PyDTrace_INSTANCE_NEW_START(int arg0) {}
34-
Py_STATIC_INLINE(void) PyDTrace_INSTANCE_NEW_DONE(int arg0) {}
35-
Py_STATIC_INLINE(void) PyDTrace_INSTANCE_DELETE_START(int arg0) {}
36-
Py_STATIC_INLINE(void) PyDTrace_INSTANCE_DELETE_DONE(int arg0) {}
37-
Py_STATIC_INLINE(void) PyDTrace_IMPORT_FIND_LOAD_START(const char *arg0) {}
38-
Py_STATIC_INLINE(void) PyDTrace_IMPORT_FIND_LOAD_DONE(const char *arg0, int arg1) {}
39-
40-
Py_STATIC_INLINE(int) PyDTrace_LINE_ENABLED(void) { return 0; }
41-
Py_STATIC_INLINE(int) PyDTrace_FUNCTION_ENTRY_ENABLED(void) { return 0; }
42-
Py_STATIC_INLINE(int) PyDTrace_FUNCTION_RETURN_ENABLED(void) { return 0; }
43-
Py_STATIC_INLINE(int) PyDTrace_GC_START_ENABLED(void) { return 0; }
44-
Py_STATIC_INLINE(int) PyDTrace_GC_DONE_ENABLED(void) { return 0; }
45-
Py_STATIC_INLINE(int) PyDTrace_INSTANCE_NEW_START_ENABLED(void) { return 0; }
46-
Py_STATIC_INLINE(int) PyDTrace_INSTANCE_NEW_DONE_ENABLED(void) { return 0; }
47-
Py_STATIC_INLINE(int) PyDTrace_INSTANCE_DELETE_START_ENABLED(void) { return 0; }
48-
Py_STATIC_INLINE(int) PyDTrace_INSTANCE_DELETE_DONE_ENABLED(void) { return 0; }
49-
Py_STATIC_INLINE(int) PyDTrace_IMPORT_FIND_LOAD_START_ENABLED(void) { return 0; }
50-
Py_STATIC_INLINE(int) PyDTrace_IMPORT_FIND_LOAD_DONE_ENABLED(void) { return 0; }
28+
static inline void PyDTrace_LINE(const char *arg0, const char *arg1, int arg2) {}
29+
static inline void PyDTrace_FUNCTION_ENTRY(const char *arg0, const char *arg1, int arg2) {}
30+
static inline void PyDTrace_FUNCTION_RETURN(const char *arg0, const char *arg1, int arg2) {}
31+
static inline void PyDTrace_GC_START(int arg0) {}
32+
static inline void PyDTrace_GC_DONE(int arg0) {}
33+
static inline void PyDTrace_INSTANCE_NEW_START(int arg0) {}
34+
static inline void PyDTrace_INSTANCE_NEW_DONE(int arg0) {}
35+
static inline void PyDTrace_INSTANCE_DELETE_START(int arg0) {}
36+
static inline void PyDTrace_INSTANCE_DELETE_DONE(int arg0) {}
37+
static inline void PyDTrace_IMPORT_FIND_LOAD_START(const char *arg0) {}
38+
static inline void PyDTrace_IMPORT_FIND_LOAD_DONE(const char *arg0, int arg1) {}
39+
40+
static inline int PyDTrace_LINE_ENABLED(void) { return 0; }
41+
static inline int PyDTrace_FUNCTION_ENTRY_ENABLED(void) { return 0; }
42+
static inline int PyDTrace_FUNCTION_RETURN_ENABLED(void) { return 0; }
43+
static inline int PyDTrace_GC_START_ENABLED(void) { return 0; }
44+
static inline int PyDTrace_GC_DONE_ENABLED(void) { return 0; }
45+
static inline int PyDTrace_INSTANCE_NEW_START_ENABLED(void) { return 0; }
46+
static inline int PyDTrace_INSTANCE_NEW_DONE_ENABLED(void) { return 0; }
47+
static inline int PyDTrace_INSTANCE_DELETE_START_ENABLED(void) { return 0; }
48+
static inline int PyDTrace_INSTANCE_DELETE_DONE_ENABLED(void) { return 0; }
49+
static inline int PyDTrace_IMPORT_FIND_LOAD_START_ENABLED(void) { return 0; }
50+
static inline int PyDTrace_IMPORT_FIND_LOAD_DONE_ENABLED(void) { return 0; }
5151

5252
#endif /* !WITH_DTRACE */
5353

Include/pyport.h

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -178,23 +178,6 @@ typedef int Py_ssize_clean_t;
178178
# define Py_LOCAL_INLINE(type) static inline type
179179
#endif
180180

181-
/* Declare a "static inline" function. Typical usage:
182-
183-
Py_STATIC_INLINE(int) add(int a, int b) { return a + b; }
184-
185-
If the compiler supports it, try to always inline the function even if no
186-
optimization level was specified. */
187-
#if defined(__GNUC__) || defined(__clang__)
188-
# define Py_STATIC_INLINE(TYPE) \
189-
__attribute__((always_inline)) static inline TYPE
190-
#elif defined(_MSC_VER)
191-
# define Py_STATIC_INLINE(TYPE) \
192-
static __forceinline TYPE
193-
#else
194-
# define Py_STATIC_INLINE(TYPE) static inline TYPE
195-
#endif
196-
197-
198181
/* Py_MEMCPY is kept for backwards compatibility,
199182
* see https://bugs.python.org/issue28126 */
200183
#define Py_MEMCPY memcpy

0 commit comments

Comments
 (0)