mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
gh-130740: Move some `stdbool.h` includes after `Python.h` (#130738)
Move some `#include <stdbool.h>` after `#include "Python.h"` when `pyconfig.h` is not
included first and when we are in a platform-agnostic context. This is to avoid having
features defined by `stdbool.h` before those decided by `Python.h` (this caused some
build failures when compiling CPython with `zig cc`).
(cherry-picked from commit 214562ed4d
)
---------
Co-authored-by: Hugo Beauzée-Luyssen <hugo@beauzee.fr>
This commit is contained in:
parent
519dec97e7
commit
7ce5f15981
9 changed files with 18 additions and 13 deletions
|
@ -0,0 +1,2 @@
|
||||||
|
Ensure that ``Python.h`` is included before ``stdbool.h`` unless ``pyconfig.h``
|
||||||
|
is included before or in some platform-specific contexts.
|
|
@ -1,5 +1,3 @@
|
||||||
#include <stdbool.h>
|
|
||||||
|
|
||||||
#include "Python.h"
|
#include "Python.h"
|
||||||
#include "opcode.h"
|
#include "opcode.h"
|
||||||
#include "structmember.h" // PyMemberDef
|
#include "structmember.h" // PyMemberDef
|
||||||
|
@ -11,6 +9,8 @@
|
||||||
#include "pycore_tuple.h" // _PyTuple_ITEMS()
|
#include "pycore_tuple.h" // _PyTuple_ITEMS()
|
||||||
#include "clinic/codeobject.c.h"
|
#include "clinic/codeobject.c.h"
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
static PyObject* code_repr(PyCodeObject *co);
|
static PyObject* code_repr(PyCodeObject *co);
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
#include <stdbool.h>
|
|
||||||
|
|
||||||
#include <Python.h>
|
#include <Python.h>
|
||||||
|
|
||||||
#include "tokenizer.h"
|
#include "tokenizer.h"
|
||||||
#include "pegen.h"
|
#include "pegen.h"
|
||||||
#include "string_parser.h"
|
#include "string_parser.h"
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
//// STRING HANDLING FUNCTIONS ////
|
//// STRING HANDLING FUNCTIONS ////
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
#include <stdbool.h>
|
|
||||||
|
|
||||||
#include "Python.h"
|
#include "Python.h"
|
||||||
#include "pycore_code.h" // write_location_entry_start()
|
#include "pycore_code.h" // write_location_entry_start()
|
||||||
#include "pycore_compile.h"
|
#include "pycore_compile.h"
|
||||||
#include "pycore_opcode.h" // _PyOpcode_Caches[] and opcode category macros
|
#include "pycore_opcode.h" // _PyOpcode_Caches[] and opcode category macros
|
||||||
#include "pycore_pymem.h" // _PyMem_IsPtrFreed()
|
#include "pycore_pymem.h" // _PyMem_IsPtrFreed()
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
#define DEFAULT_CODE_SIZE 128
|
#define DEFAULT_CODE_SIZE 128
|
||||||
#define DEFAULT_LNOTAB_SIZE 16
|
#define DEFAULT_LNOTAB_SIZE 16
|
||||||
|
|
|
@ -21,8 +21,6 @@
|
||||||
* objects.
|
* objects.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdbool.h>
|
|
||||||
|
|
||||||
#include "Python.h"
|
#include "Python.h"
|
||||||
#include "pycore_ast.h" // _PyAST_GetDocString()
|
#include "pycore_ast.h" // _PyAST_GetDocString()
|
||||||
#define NEED_OPCODE_TABLES
|
#define NEED_OPCODE_TABLES
|
||||||
|
@ -38,6 +36,8 @@
|
||||||
|
|
||||||
#include "opcode_metadata.h" // _PyOpcode_opcode_metadata, _PyOpcode_num_popped/pushed
|
#include "opcode_metadata.h" // _PyOpcode_opcode_metadata, _PyOpcode_num_popped/pushed
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
#define DEFAULT_CODE_SIZE 128
|
#define DEFAULT_CODE_SIZE 128
|
||||||
#define DEFAULT_LNOTAB_SIZE 16
|
#define DEFAULT_LNOTAB_SIZE 16
|
||||||
#define DEFAULT_CNOTAB_SIZE 32
|
#define DEFAULT_CNOTAB_SIZE 32
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
|
|
||||||
#include <stdbool.h>
|
|
||||||
|
|
||||||
#include "Python.h"
|
#include "Python.h"
|
||||||
#include "pycore_flowgraph.h"
|
#include "pycore_flowgraph.h"
|
||||||
#include "pycore_compile.h"
|
#include "pycore_compile.h"
|
||||||
|
@ -11,6 +8,8 @@
|
||||||
#include "opcode_metadata.h" // _PyOpcode_opcode_metadata, _PyOpcode_num_popped/pushed
|
#include "opcode_metadata.h" // _PyOpcode_opcode_metadata, _PyOpcode_num_popped/pushed
|
||||||
#undef NEED_OPCODE_METADATA
|
#undef NEED_OPCODE_METADATA
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
|
||||||
#undef SUCCESS
|
#undef SUCCESS
|
||||||
#undef ERROR
|
#undef ERROR
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
// Python/bytecodes.c
|
// Python/bytecodes.c
|
||||||
// Do not edit!
|
// Do not edit!
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
#ifndef NEED_OPCODE_METADATA
|
#ifndef NEED_OPCODE_METADATA
|
||||||
extern int _PyOpcode_num_popped(int opcode, int oparg, bool jump);
|
extern int _PyOpcode_num_popped(int opcode, int oparg, bool jump);
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -8,8 +8,6 @@
|
||||||
|
|
||||||
/* TODO: Cull includes following phase split */
|
/* TODO: Cull includes following phase split */
|
||||||
|
|
||||||
#include <stdbool.h>
|
|
||||||
|
|
||||||
#include "Python.h"
|
#include "Python.h"
|
||||||
|
|
||||||
#include "pycore_ast.h" // PyAST_mod2obj
|
#include "pycore_ast.h" // PyAST_mod2obj
|
||||||
|
@ -27,6 +25,8 @@
|
||||||
#include "errcode.h" // E_EOF
|
#include "errcode.h" // E_EOF
|
||||||
#include "marshal.h" // PyMarshal_ReadLongFromFile()
|
#include "marshal.h" // PyMarshal_ReadLongFromFile()
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
#ifdef MS_WINDOWS
|
#ifdef MS_WINDOWS
|
||||||
# include "malloc.h" // alloca()
|
# include "malloc.h" // alloca()
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -986,6 +986,9 @@ class Analyzer:
|
||||||
self.out.write_raw(self.from_source_files())
|
self.out.write_raw(self.from_source_files())
|
||||||
self.out.write_raw(f"// Do not edit!\n")
|
self.out.write_raw(f"// Do not edit!\n")
|
||||||
|
|
||||||
|
self.out.write_raw("\n")
|
||||||
|
self.out.write_raw("#include <stdbool.h>")
|
||||||
|
self.out.write_raw("\n")
|
||||||
|
|
||||||
self.write_stack_effect_functions()
|
self.write_stack_effect_functions()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue