[Python-checkins] bpo-35081: Move Include/pyatomic.c to Include/internal/ (GH-10239)

Victor Stinner webhook-mailer at python.org
Tue Oct 30 10:14:32 EDT 2018


https://github.com/python/cpython/commit/31368a4f0e531c19affe2a1becd25fc316bc7501
commit: 31368a4f0e531c19affe2a1becd25fc316bc7501
branch: master
author: Victor Stinner <vstinner at redhat.com>
committer: GitHub <noreply at github.com>
date: 2018-10-30T15:14:25+01:00
summary:

bpo-35081: Move Include/pyatomic.c to Include/internal/ (GH-10239)

Add pyatomic.h to the VS project (it wasn't referenced).

files:
A Include/internal/pyatomic.h
D Include/pyatomic.h
M Include/Python.h
M Include/internal/ceval.h
M Include/internal/gil.h
M Include/internal/pystate.h
M Makefile.pre.in
M Modules/signalmodule.c
M PCbuild/pythoncore.vcxproj
M PCbuild/pythoncore.vcxproj.filters
M Python/ceval_gil.h

diff --git a/Include/Python.h b/Include/Python.h
index 80200feb9033..cf87a5ce7a70 100644
--- a/Include/Python.h
+++ b/Include/Python.h
@@ -53,8 +53,6 @@
 #include "pyport.h"
 #include "pymacro.h"
 
-#include "pyatomic.h"
-
 /* Debug-mode build with pymalloc implies PYMALLOC_DEBUG.
  *  PYMALLOC_DEBUG is in error if pymalloc is not in use.
  */
diff --git a/Include/internal/ceval.h b/Include/internal/ceval.h
index cdabb9521d10..4297b5a51ce4 100644
--- a/Include/internal/ceval.h
+++ b/Include/internal/ceval.h
@@ -4,7 +4,7 @@
 extern "C" {
 #endif
 
-#include "pyatomic.h"
+#include "internal/pyatomic.h"
 #include "pythread.h"
 
 struct _pending_calls {
diff --git a/Include/internal/gil.h b/Include/internal/gil.h
index 6139bd215c38..7743b3f0aa8b 100644
--- a/Include/internal/gil.h
+++ b/Include/internal/gil.h
@@ -4,11 +4,11 @@
 extern "C" {
 #endif
 
-#include "pyatomic.h"
-
 #include "internal/condvar.h"
+#include "internal/pyatomic.h"
+
 #ifndef Py_HAVE_CONDVAR
-#error You need either a POSIX-compatible or a Windows system!
+#  error You need either a POSIX-compatible or a Windows system!
 #endif
 
 /* Enable if you want to force the switching of threads at least
diff --git a/Include/pyatomic.h b/Include/internal/pyatomic.h
similarity index 99%
rename from Include/pyatomic.h
rename to Include/internal/pyatomic.h
index 9a497a683688..5f349cc3e9e9 100644
--- a/Include/pyatomic.h
+++ b/Include/internal/pyatomic.h
@@ -1,6 +1,12 @@
 #ifndef Py_ATOMIC_H
 #define Py_ATOMIC_H
-#ifdef Py_BUILD_CORE
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef Py_BUILD_CORE
+#  error "Py_BUILD_CORE must be defined to include this header"
+#endif
 
 #include "dynamic_annotations.h"
 
@@ -531,5 +537,8 @@ typedef struct _Py_atomic_int {
     _Py_atomic_store_explicit(ATOMIC_VAL, NEW_VAL, _Py_memory_order_relaxed)
 #define _Py_atomic_load_relaxed(ATOMIC_VAL) \
     _Py_atomic_load_explicit(ATOMIC_VAL, _Py_memory_order_relaxed)
-#endif  /* Py_BUILD_CORE */
+
+#ifdef __cplusplus
+}
+#endif
 #endif  /* Py_ATOMIC_H */
diff --git a/Include/internal/pystate.h b/Include/internal/pystate.h
index c93dda28954a..38845d32ecaf 100644
--- a/Include/internal/pystate.h
+++ b/Include/internal/pystate.h
@@ -5,7 +5,6 @@ extern "C" {
 #endif
 
 #include "pystate.h"
-#include "pyatomic.h"
 #include "pythread.h"
 
 #include "internal/mem.h"
diff --git a/Makefile.pre.in b/Makefile.pre.in
index 61b469d4504e..232025f1cb61 100644
--- a/Makefile.pre.in
+++ b/Makefile.pre.in
@@ -988,7 +988,6 @@ PYTHON_HEADERS= \
 		$(srcdir)/Include/pgen.h \
 		$(srcdir)/Include/pgenheaders.h \
 		$(srcdir)/Include/pyarena.h \
-		$(srcdir)/Include/pyatomic.h \
 		$(srcdir)/Include/pycapsule.h \
 		$(srcdir)/Include/pyctype.h \
 		$(srcdir)/Include/pydebug.h \
@@ -1029,6 +1028,7 @@ PYTHON_HEADERS= \
 		$(srcdir)/Include/internal/ceval.h \
 		$(srcdir)/Include/internal/gil.h \
 		$(srcdir)/Include/internal/mem.h \
+		$(srcdir)/Include/internal/pyatomic.h \
 		$(srcdir)/Include/internal/pygetopt.h \
 		$(srcdir)/Include/internal/pystate.h \
 		$(srcdir)/Include/internal/context.h \
diff --git a/Modules/signalmodule.c b/Modules/signalmodule.c
index d12094858273..a81de6ab6462 100644
--- a/Modules/signalmodule.c
+++ b/Modules/signalmodule.c
@@ -4,6 +4,8 @@
 /* XXX Signals should be recorded per thread, now we have thread state. */
 
 #include "Python.h"
+#include "internal/pyatomic.h"
+
 #ifndef MS_WINDOWS
 #include "posixmodule.h"
 #endif
diff --git a/PCbuild/pythoncore.vcxproj b/PCbuild/pythoncore.vcxproj
index cb835390ee13..f65bb5b2197c 100644
--- a/PCbuild/pythoncore.vcxproj
+++ b/PCbuild/pythoncore.vcxproj
@@ -118,6 +118,7 @@
     <ClInclude Include="..\Include\internal\gil.h" />
     <ClInclude Include="..\Include\internal\hamt.h" />
     <ClInclude Include="..\Include\internal\mem.h" />
+    <ClInclude Include="..\Include\internal\pyatomic.h" />
     <ClInclude Include="..\Include\internal\pystate.h" />
     <ClInclude Include="..\Include\internal\warnings.h" />
     <ClInclude Include="..\Include\intrcheck.h" />
diff --git a/PCbuild/pythoncore.vcxproj.filters b/PCbuild/pythoncore.vcxproj.filters
index 510a9c2b2e4e..7fdadc81676d 100644
--- a/PCbuild/pythoncore.vcxproj.filters
+++ b/PCbuild/pythoncore.vcxproj.filters
@@ -153,6 +153,9 @@
     <ClInclude Include="..\Include\internal\mem.h">
       <Filter>Include</Filter>
     </ClInclude>
+    <ClInclude Include="..\Include\internal\pyatomic.h">
+      <Filter>Include</Filter>
+    </ClInclude>
     <ClInclude Include="..\Include\internal\pystate.h">
       <Filter>Include</Filter>
     </ClInclude>
diff --git a/Python/ceval_gil.h b/Python/ceval_gil.h
index ef5189068e0c..4a054a97f710 100644
--- a/Python/ceval_gil.h
+++ b/Python/ceval_gil.h
@@ -5,6 +5,7 @@
 #include <stdlib.h>
 #include <errno.h>
 
+#include "internal/pyatomic.h"
 
 /* First some general settings */
 



More information about the Python-checkins mailing list