From 43e454a0c80438afba5a8c7fdbe493ae394ff926 Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Fri, 16 Apr 2021 15:47:08 +0200 Subject: [PATCH 1/2] boolobject.h: One declaration per line This makes static analysis easier. From discussion at https://discuss.python.org/t/pep-652-maintaining-the-stable-abi/6986/13 it is clear that: - parsing C to get information is okay (though I personally prefer to *generate* it) - writing a full C parser is a monumental task (and adding an existing one as a dependency is not feasible) I think it's reasonable to simplify our declarations in order to make header checks easier, rather than write a parser that can handle all C. --- Include/boolobject.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Include/boolobject.h b/Include/boolobject.h index e1c8699ee70faa..cda6f89a99e9a2 100644 --- a/Include/boolobject.h +++ b/Include/boolobject.h @@ -15,7 +15,8 @@ PyAPI_DATA(PyTypeObject) PyBool_Type; Don't forget to apply Py_INCREF() when returning either!!! */ /* Don't use these directly */ -PyAPI_DATA(struct _longobject) _Py_FalseStruct, _Py_TrueStruct; +PyAPI_DATA(struct _longobject) _Py_FalseStruct; +PyAPI_DATA(struct _longobject) _Py_TrueStruct; /* Use these macros */ #define Py_False ((PyObject *) &_Py_FalseStruct) From e415076c950ae1f3d7a30baad302b4e509bcf837 Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Fri, 16 Apr 2021 15:28:13 +0200 Subject: [PATCH 2/2] Include/pyport.h: Don't define _Py_NO_RETURN if already defined This makes static analysis of the headers easier. --- Include/pyport.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Include/pyport.h b/Include/pyport.h index fe27fbc7483229..6ab0ae4007922a 100644 --- a/Include/pyport.h +++ b/Include/pyport.h @@ -861,6 +861,7 @@ extern _invalid_parameter_handler _Py_silent_invalid_parameter_handler; PyAPI_FUNC(void) _Py_NO_RETURN PyThread_exit_thread(void); XLC support is intentionally omitted due to bpo-40244 */ +#ifndef _Py_NO_RETURN #if defined(__clang__) || \ (defined(__GNUC__) && \ ((__GNUC__ >= 3) || \ @@ -871,6 +872,7 @@ extern _invalid_parameter_handler _Py_silent_invalid_parameter_handler; #else # define _Py_NO_RETURN #endif +#endif // Preprocessor check for a builtin preprocessor function. Always return 0