gh-108216: Cleanup #include in internal header files (#108228) · python/cpython@0dd3fc2

GitHub

Original file line numberDiff line numberDiff line change@@ -8,19 +8,19 @@ extern "C" {

88# error "this header requires Py_BUILD_CORE define"

99#endif

101011-#include"dynamic_annotations.h"/* _Py_ANNOTATE_MEMORY_ORDER */

12-#include"pyconfig.h"

11+#include"pyconfig.h"// HAVE_STD_ATOMIC

12+#include"dynamic_annotations.h"// _Py_ANNOTATE_MEMORY_ORDER

13131414#ifdefHAVE_STD_ATOMIC

15-# include<stdatomic.h>

15+# include<stdatomic.h>// atomic_store_explicit()

1616#endif

171718181919#if defined(_MSC_VER)

20-#include<intrin.h>

21-#if defined(_M_IX86) || defined(_M_X64)

22-# include<immintrin.h>

23-#endif

20+#include<intrin.h>// _InterlockedExchange64()

21+#if defined(_M_IX86) || defined(_M_X64)

22+# include<immintrin.h>// _InterlockedExchange_HLEAcquire()

23+#endif

2424#endif

25252626/* This is modeled after the atomics interface from C1x, according to

Original file line numberDiff line numberDiff line change@@ -26,10 +26,10 @@ extern "C" {

2626#endif

27272828#ifdef_MSC_VER

29-/* Get _byteswap_ushort(), _byteswap_ulong(), _byteswap_uint64() */

30-# include<intrin.h>

29+# include<intrin.h>// _byteswap_uint64()

3130#endif

323132+3333staticinlineuint16_t

3434_Py_bswap16(uint16_tword)

3535{

Original file line numberDiff line numberDiff line change@@ -8,6 +8,9 @@ extern "C" {

88# error "this header requires Py_BUILD_CORE define"

99#endif

101011+#include"pycore_interp.h"// PyInterpreterState.eval_frame

12+#include"pycore_pystate.h"// _PyThreadState_GET()

13+1114/* Forward declarations */

1215structpyruntimestate;

1316struct_ceval_runtime_state;

@@ -16,10 +19,6 @@ struct _ceval_runtime_state;

1619# definePy_DEFAULT_RECURSION_LIMIT 1000

1720#endif

182119-#include"pycore_interp.h"// PyInterpreterState.eval_frame

20-#include"pycore_pystate.h"// _PyThreadState_GET()

21-22-2322externvoid_Py_FinishPendingCalls(PyThreadState*tstate);

2423externvoid_PyEval_InitState(PyInterpreterState*, PyThread_type_lock);

2524externvoid_PyEval_FiniState(struct_ceval_state*ceval);

Original file line numberDiff line numberDiff line change@@ -8,8 +8,6 @@ extern "C" {

88# error "this header requires Py_BUILD_CORE define"

99#endif

101011-12-#include"pycore_atomic.h"/* _Py_atomic_address */

1311#include"pycore_gil.h"// struct _gil_runtime_state

14121513Original file line numberDiff line numberDiff line change@@ -10,7 +10,7 @@

1010 not present in unistd.h. But they still can be implemented as an external

1111 library (e.g. gnu pth in pthread emulation) */

1212# ifdefHAVE_PTHREAD_H

13-# include<pthread.h>/* _POSIX_THREADS */

13+# include<pthread.h>// _POSIX_THREADS

1414# endif

1515#endif

1616@@ -21,7 +21,7 @@

2121#definePy_HAVE_CONDVAR

22222323#ifdefHAVE_PTHREAD_H

24-# include<pthread.h>

24+# include<pthread.h>// pthread_mutex_t

2525#endif

26262727#definePyMUTEX_T pthread_mutex_t

@@ -38,7 +38,7 @@

38383939/* include windows if it hasn't been done before */

4040#defineWIN32_LEAN_AND_MEAN

41-#include<windows.h>

41+#include<windows.h>// CRITICAL_SECTION

42424343/* options */

4444/* non-emulated condition variables are provided for those that want

Original file line numberDiff line numberDiff line change@@ -5,7 +5,7 @@

55# error "this header requires Py_BUILD_CORE define"

66#endif

778-#include"pycore_hamt.h"/* PyHamtObject */

8+#include"pycore_hamt.h"// PyHamtObject

9910101111externPyTypeObject_PyContextTokenMissing_Type;

Original file line numberDiff line numberDiff line change@@ -9,9 +9,7 @@ extern "C" {

99# error "this header requires Py_BUILD_CORE define"

1010#endif

111112-#include"pycore_dict_state.h"

13-#include"pycore_object.h"

14-#include"pycore_runtime.h"// _PyRuntime

12+#include"pycore_object.h"// PyDictOrValues

15131614// Unsafe flavor of PyDict_GetItemWithError(): no error checking

1715externPyObject*_PyDict_GetItemWithError(PyObject*dp, PyObject*key);

Original file line numberDiff line numberDiff line change@@ -9,7 +9,7 @@ extern "C" {

99#endif

10101111#ifdefHAVE_SIGACTION

12-# include<signal.h>

12+# include<signal.h>// sigaction

1313#endif

14141515Original file line numberDiff line numberDiff line change@@ -8,7 +8,8 @@ extern "C" {

88# error "this header requires Py_BUILD_CORE define"

99#endif

101011-#include<locale.h>/* struct lconv */

11+#include<locale.h>// struct lconv

12+12131314/* A routine to check if a file descriptor can be select()-ed. */

1415#ifdef_MSC_VER

@@ -268,7 +269,7 @@ extern wchar_t *_Py_normpath_and_size(wchar_t *path, Py_ssize_t size, Py_ssize_t

268269// so provide our own implementations. Remove them in case they get added

269270// to the Games API family

270271#if defined(MS_WINDOWS_GAMES) && !defined(MS_WINDOWS_DESKTOP)

271-#include<winerror.h>

272+#include<winerror.h>// HRESULT

272273273274externHRESULTPathCchSkipRoot(constwchar_t*pszPath, constwchar_t**ppszRootEnd);

274275#endif/* defined(MS_WINDOWS_GAMES) && !defined(MS_WINDOWS_DESKTOP) */