summaryrefslogtreecommitdiffstats
path: root/Include
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2018-11-09 12:03:37 (GMT)
committerGitHub <noreply@github.com>2018-11-09 12:03:37 (GMT)
commit130893debfd97c70e3a89d9ba49892f53e6b9d79 (patch)
tree35b45b8939a9ab75ec470f0defb37d1ee1f8c77e /Include
parent0a18e0510a145427d8ff1864a011c81ea02cdcd4 (diff)
downloadcpython-130893debfd97c70e3a89d9ba49892f53e6b9d79.zip
cpython-130893debfd97c70e3a89d9ba49892f53e6b9d79.tar.gz
cpython-130893debfd97c70e3a89d9ba49892f53e6b9d79.tar.bz2
bpo-35081: Internal headers require Py_BUILD_CORE (GH-10363)
* All internal header files now require Py_BUILD_CORE or Py_BUILD_CORE_BUILTIN to be defined. * _json.c is now compiled with Py_BUILD_CORE_BUILTIN to access pycore_accu.h header. * Add an example to Modules/Setup to show how to build _json as a built-in module; it requires non trivial compiler options.
Diffstat (limited to 'Include')
-rw-r--r--Include/internal/pycore_accu.h4
-rw-r--r--Include/internal/pycore_atomic.h4
-rw-r--r--Include/internal/pycore_ceval.h4
-rw-r--r--Include/internal/pycore_condvar.h4
-rw-r--r--Include/internal/pycore_context.h5
-rw-r--r--Include/internal/pycore_getopt.h4
-rw-r--r--Include/internal/pycore_gil.h4
-rw-r--r--Include/internal/pycore_hamt.h3
-rw-r--r--Include/internal/pycore_hash.h4
-rw-r--r--Include/internal/pycore_lifecycle.h4
-rw-r--r--Include/internal/pycore_mem.h4
-rw-r--r--Include/internal/pycore_pathconfig.h4
-rw-r--r--Include/internal/pycore_state.h4
-rw-r--r--Include/internal/pycore_warnings.h4
14 files changed, 44 insertions, 12 deletions
diff --git a/Include/internal/pycore_accu.h b/Include/internal/pycore_accu.h
index ab1aad2..4350db5 100644
--- a/Include/internal/pycore_accu.h
+++ b/Include/internal/pycore_accu.h
@@ -9,6 +9,10 @@ extern "C" {
*** Its definition may be changed or removed at any moment.
***/
+#if !defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_BUILTIN)
+# error "this header requires Py_BUILD_CORE or Py_BUILD_CORE_BUILTIN define"
+#endif
+
/*
* A two-level accumulator of unicode objects that avoids both the overhead
* of keeping a huge number of small separate objects, and the quadratic
diff --git a/Include/internal/pycore_atomic.h b/Include/internal/pycore_atomic.h
index 5f349cc..f430a5c 100644
--- a/Include/internal/pycore_atomic.h
+++ b/Include/internal/pycore_atomic.h
@@ -4,8 +4,8 @@
extern "C" {
#endif
-#ifndef Py_BUILD_CORE
-# error "Py_BUILD_CORE must be defined to include this header"
+#if !defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_BUILTIN)
+# error "this header requires Py_BUILD_CORE or Py_BUILD_CORE_BUILTIN define"
#endif
#include "dynamic_annotations.h"
diff --git a/Include/internal/pycore_ceval.h b/Include/internal/pycore_ceval.h
index ddeeb5c..c8c63b1 100644
--- a/Include/internal/pycore_ceval.h
+++ b/Include/internal/pycore_ceval.h
@@ -4,6 +4,10 @@
extern "C" {
#endif
+#if !defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_BUILTIN)
+# error "this header requires Py_BUILD_CORE or Py_BUILD_CORE_BUILTIN define"
+#endif
+
#include "pycore_atomic.h"
#include "pythread.h"
diff --git a/Include/internal/pycore_condvar.h b/Include/internal/pycore_condvar.h
index f933089..a12b699 100644
--- a/Include/internal/pycore_condvar.h
+++ b/Include/internal/pycore_condvar.h
@@ -1,6 +1,10 @@
#ifndef Py_INTERNAL_CONDVAR_H
#define Py_INTERNAL_CONDVAR_H
+#if !defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_BUILTIN)
+# error "this header requires Py_BUILD_CORE or Py_BUILD_CORE_BUILTIN define"
+#endif
+
#ifndef _POSIX_THREADS
/* This means pthreads are not implemented in libc headers, hence the macro
not present in unistd.h. But they still can be implemented as an external
diff --git a/Include/internal/pycore_context.h b/Include/internal/pycore_context.h
index 57a410c..70701cd 100644
--- a/Include/internal/pycore_context.h
+++ b/Include/internal/pycore_context.h
@@ -1,10 +1,12 @@
#ifndef Py_INTERNAL_CONTEXT_H
#define Py_INTERNAL_CONTEXT_H
+#if !defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_BUILTIN)
+# error "this header requires Py_BUILD_CORE or Py_BUILD_CORE_BUILTIN define"
+#endif
#include "pycore_hamt.h"
-
struct _pycontextobject {
PyObject_HEAD
PyContext *ctx_prev;
@@ -37,5 +39,4 @@ struct _pycontexttokenobject {
int _PyContext_Init(void);
void _PyContext_Fini(void);
-
#endif /* !Py_INTERNAL_CONTEXT_H */
diff --git a/Include/internal/pycore_getopt.h b/Include/internal/pycore_getopt.h
index 8ef2ada..e6f4654 100644
--- a/Include/internal/pycore_getopt.h
+++ b/Include/internal/pycore_getopt.h
@@ -1,6 +1,10 @@
#ifndef Py_INTERNAL_PYGETOPT_H
#define Py_INTERNAL_PYGETOPT_H
+#if !defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_BUILTIN)
+# error "this header requires Py_BUILD_CORE or Py_BUILD_CORE_BUILTIN define"
+#endif
+
extern int _PyOS_opterr;
extern int _PyOS_optind;
extern wchar_t *_PyOS_optarg;
diff --git a/Include/internal/pycore_gil.h b/Include/internal/pycore_gil.h
index 5059850..014e75f 100644
--- a/Include/internal/pycore_gil.h
+++ b/Include/internal/pycore_gil.h
@@ -4,6 +4,10 @@
extern "C" {
#endif
+#if !defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_BUILTIN)
+# error "this header requires Py_BUILD_CORE or Py_BUILD_CORE_BUILTIN define"
+#endif
+
#include "pycore_condvar.h"
#include "pycore_atomic.h"
diff --git a/Include/internal/pycore_hamt.h b/Include/internal/pycore_hamt.h
index 29ad28b..8b2ce1f 100644
--- a/Include/internal/pycore_hamt.h
+++ b/Include/internal/pycore_hamt.h
@@ -1,6 +1,9 @@
#ifndef Py_INTERNAL_HAMT_H
#define Py_INTERNAL_HAMT_H
+#if !defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_BUILTIN)
+# error "this header requires Py_BUILD_CORE or Py_BUILD_CORE_BUILTIN define"
+#endif
#define _Py_HAMT_MAX_TREE_DEPTH 7
diff --git a/Include/internal/pycore_hash.h b/Include/internal/pycore_hash.h
index e14b80a..babbc95 100644
--- a/Include/internal/pycore_hash.h
+++ b/Include/internal/pycore_hash.h
@@ -1,6 +1,10 @@
#ifndef Py_INTERNAL_HASH_H
#define Py_INTERNAL_HASH_H
+#if !defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_BUILTIN)
+# error "this header requires Py_BUILD_CORE or Py_BUILD_CORE_BUILTIN define"
+#endif
+
uint64_t _Py_KeyedHash(uint64_t, const char *, Py_ssize_t);
#endif
diff --git a/Include/internal/pycore_lifecycle.h b/Include/internal/pycore_lifecycle.h
index cf36440..e104316 100644
--- a/Include/internal/pycore_lifecycle.h
+++ b/Include/internal/pycore_lifecycle.h
@@ -4,8 +4,8 @@
extern "C" {
#endif
-#ifndef Py_BUILD_CORE
-# error "Py_BUILD_CORE must be defined to include this header"
+#if !defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_BUILTIN)
+# error "this header requires Py_BUILD_CORE or Py_BUILD_CORE_BUILTIN define"
#endif
PyAPI_FUNC(int) _Py_UnixMain(int argc, char **argv);
diff --git a/Include/internal/pycore_mem.h b/Include/internal/pycore_mem.h
index 4a41b77..247426a 100644
--- a/Include/internal/pycore_mem.h
+++ b/Include/internal/pycore_mem.h
@@ -4,8 +4,8 @@
extern "C" {
#endif
-#ifndef Py_BUILD_CORE
-# error "Py_BUILD_CORE must be defined to include this header"
+#if !defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_BUILTIN)
+# error "this header requires Py_BUILD_CORE or Py_BUILD_CORE_BUILTIN defined"
#endif
#include "objimpl.h"
diff --git a/Include/internal/pycore_pathconfig.h b/Include/internal/pycore_pathconfig.h
index 00d7bbf..267e690 100644
--- a/Include/internal/pycore_pathconfig.h
+++ b/Include/internal/pycore_pathconfig.h
@@ -4,8 +4,8 @@
extern "C" {
#endif
-#ifndef Py_BUILD_CORE
-# error "Py_BUILD_CORE must be defined to include this header"
+#if !defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_BUILTIN)
+# error "this header requires Py_BUILD_CORE or Py_BUILD_CORE_BUILTIN define"
#endif
PyAPI_FUNC(void) _Py_wstrlist_clear(
diff --git a/Include/internal/pycore_state.h b/Include/internal/pycore_state.h
index 6285ecf..01f2140 100644
--- a/Include/internal/pycore_state.h
+++ b/Include/internal/pycore_state.h
@@ -4,8 +4,8 @@
extern "C" {
#endif
-#ifndef Py_BUILD_CORE
-# error "Py_BUILD_CORE must be defined to include this header"
+#if !defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_BUILTIN)
+# error "this header requires Py_BUILD_CORE or Py_BUILD_CORE_BUILTIN define"
#endif
#include "pystate.h"
diff --git a/Include/internal/pycore_warnings.h b/Include/internal/pycore_warnings.h
index 2878a28..91bf902 100644
--- a/Include/internal/pycore_warnings.h
+++ b/Include/internal/pycore_warnings.h
@@ -4,6 +4,10 @@
extern "C" {
#endif
+#if !defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_BUILTIN)
+# error "this header requires Py_BUILD_CORE or Py_BUILD_CORE_BUILTIN define"
+#endif
+
#include "object.h"
struct _warnings_runtime_state {