bpo-36142: Exclude coreconfig.h from Py_LIMITED_API (GH-12111)

The whole coreconfig.h header is now excluded from Py_LIMITED_API.
Move functions definitions into a new internal pycore_coreconfig.h
header.

* Move Include/coreconfig.h to Include/cpython/coreconfig.h
* coreconfig.h header is now excluded from Py_LIMITED_API
* Move functions to pycore_coreconfig.h
diff --git a/Include/Python.h b/Include/Python.h
index aa60175..55b06ae 100644
--- a/Include/Python.h
+++ b/Include/Python.h
@@ -128,7 +128,7 @@
 #include "codecs.h"
 #include "pyerrors.h"
 
-#include "coreconfig.h"
+#include "cpython/coreconfig.h"
 #include "pystate.h"
 #include "context.h"
 
diff --git a/Include/coreconfig.h b/Include/cpython/coreconfig.h
similarity index 92%
rename from Include/coreconfig.h
rename to Include/cpython/coreconfig.h
index 0ed3222..f7ac3f9 100644
--- a/Include/coreconfig.h
+++ b/Include/cpython/coreconfig.h
@@ -1,11 +1,12 @@
 #ifndef Py_PYCORECONFIG_H
 #define Py_PYCORECONFIG_H
+#ifndef Py_LIMITED_API
 #ifdef __cplusplus
 extern "C" {
 #endif
 
+/* _PyInitError */
 
-#ifndef Py_LIMITED_API
 typedef struct {
     const char *prefix;
     const char *msg;
@@ -32,8 +33,7 @@
 #define _Py_INIT_FAILED(err) \
     (err.msg != NULL)
 
-#endif   /* !defined(Py_LIMITED_API) */
-
+/* _PyCoreConfig */
 
 typedef struct {
     /* Install signal handlers? Yes by default. */
@@ -339,32 +339,12 @@
 /* Note: _PyCoreConfig_INIT sets other fields to 0/NULL */
 
 
-#ifndef Py_LIMITED_API
-PyAPI_FUNC(_PyInitError) _PyCoreConfig_Read(_PyCoreConfig *config);
-PyAPI_FUNC(void) _PyCoreConfig_Clear(_PyCoreConfig *);
-PyAPI_FUNC(int) _PyCoreConfig_Copy(
-    _PyCoreConfig *config,
-    const _PyCoreConfig *config2);
-PyAPI_FUNC(_PyInitError) _PyCoreConfig_InitPathConfig(_PyCoreConfig *config);
-PyAPI_FUNC(_PyInitError) _PyCoreConfig_SetPathConfig(
-    const _PyCoreConfig *config);
-PyAPI_FUNC(void) _PyCoreConfig_GetGlobalConfig(_PyCoreConfig *config);
-PyAPI_FUNC(void) _PyCoreConfig_SetGlobalConfig(const _PyCoreConfig *config);
-PyAPI_FUNC(const char*) _PyCoreConfig_GetEnv(
-    const _PyCoreConfig *config,
-    const char *name);
-PyAPI_FUNC(int) _PyCoreConfig_GetEnvDup(
-    const _PyCoreConfig *config,
-    wchar_t **dest,
-    wchar_t *wname,
-    char *name);
-
-/* Used by _testcapi.get_global_config() and _testcapi.get_core_config() */
+/* Functions used for testing */
 PyAPI_FUNC(PyObject *) _Py_GetGlobalVariablesAsDict(void);
 PyAPI_FUNC(PyObject *) _PyCoreConfig_AsDict(const _PyCoreConfig *config);
-#endif
 
 #ifdef __cplusplus
 }
 #endif
+#endif /* !Py_LIMITED_API */
 #endif /* !Py_PYCORECONFIG_H */
diff --git a/Include/cpython/pystate.h b/Include/cpython/pystate.h
index 0da59d9..3fca78f 100644
--- a/Include/cpython/pystate.h
+++ b/Include/cpython/pystate.h
@@ -6,6 +6,8 @@
 extern "C" {
 #endif
 
+#include "cpython/coreconfig.h"
+
 /* Placeholders while working on the new configuration API
  *
  * See PEP 432 for final anticipated contents
diff --git a/Include/internal/pycore_coreconfig.h b/Include/internal/pycore_coreconfig.h
new file mode 100644
index 0000000..b906ac4
--- /dev/null
+++ b/Include/internal/pycore_coreconfig.h
@@ -0,0 +1,33 @@
+#ifndef Py_INTERNAL_CORECONFIG_H
+#define Py_INTERNAL_CORECONFIG_H
+#ifdef __cplusplus
+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 defined"
+#endif
+
+PyAPI_FUNC(_PyInitError) _PyCoreConfig_Read(_PyCoreConfig *config);
+PyAPI_FUNC(void) _PyCoreConfig_Clear(_PyCoreConfig *);
+PyAPI_FUNC(int) _PyCoreConfig_Copy(
+    _PyCoreConfig *config,
+    const _PyCoreConfig *config2);
+PyAPI_FUNC(_PyInitError) _PyCoreConfig_InitPathConfig(_PyCoreConfig *config);
+PyAPI_FUNC(_PyInitError) _PyCoreConfig_SetPathConfig(
+    const _PyCoreConfig *config);
+PyAPI_FUNC(void) _PyCoreConfig_GetGlobalConfig(_PyCoreConfig *config);
+PyAPI_FUNC(void) _PyCoreConfig_SetGlobalConfig(const _PyCoreConfig *config);
+PyAPI_FUNC(const char*) _PyCoreConfig_GetEnv(
+    const _PyCoreConfig *config,
+    const char *name);
+PyAPI_FUNC(int) _PyCoreConfig_GetEnvDup(
+    const _PyCoreConfig *config,
+    wchar_t **dest,
+    wchar_t *wname,
+    char *name);
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* !Py_INTERNAL_CORECONFIG_H */
diff --git a/Include/pystate.h b/Include/pystate.h
index a541dc8..a79a2e6 100644
--- a/Include/pystate.h
+++ b/Include/pystate.h
@@ -8,7 +8,6 @@
 #endif
 
 #include "pythread.h"
-#include "coreconfig.h"
 
 /* This limitation is for performance and simplicity. If needed it can be
 removed (with effort). */