]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-111545: Add Include/cpython/pyhash.h header file (#112063)
authorVictor Stinner <vstinner@python.org>
Wed, 15 Nov 2023 00:19:20 +0000 (01:19 +0100)
committerGitHub <noreply@github.com>
Wed, 15 Nov 2023 00:19:20 +0000 (01:19 +0100)
Move non-limited C API to a new Include/cpython/pyhash.h header file.

Include/cpython/pyhash.h [new file with mode: 0644]
Include/pyhash.h
Makefile.pre.in
PCbuild/pythoncore.vcxproj
PCbuild/pythoncore.vcxproj.filters

diff --git a/Include/cpython/pyhash.h b/Include/cpython/pyhash.h
new file mode 100644 (file)
index 0000000..62ae608
--- /dev/null
@@ -0,0 +1,13 @@
+#ifndef Py_CPYTHON_HASH_H
+#  error "this header file must not be included directly"
+#endif
+
+/* hash function definition */
+typedef struct {
+    Py_hash_t (*const hash)(const void *, Py_ssize_t);
+    const char *name;
+    const int hash_bits;
+    const int seed_bits;
+} PyHash_FuncDef;
+
+PyAPI_FUNC(PyHash_FuncDef*) PyHash_GetFuncDef(void);
index 6e969f86fa2625638223bb99ed1d8febad9bb49b..3e23e2758808d793ae8ffe716e898a0bceb6f3d3 100644 (file)
@@ -4,19 +4,6 @@
 extern "C" {
 #endif
 
-#ifndef Py_LIMITED_API
-/* hash function definition */
-typedef struct {
-    Py_hash_t (*const hash)(const void *, Py_ssize_t);
-    const char *name;
-    const int hash_bits;
-    const int seed_bits;
-} PyHash_FuncDef;
-
-PyAPI_FUNC(PyHash_FuncDef*) PyHash_GetFuncDef(void);
-#endif
-
-
 /* Cutoff for small string DJBX33A optimization in range [1, cutoff).
  *
  * About 50% of the strings in a typical Python application are smaller than
@@ -60,6 +47,12 @@ PyAPI_FUNC(PyHash_FuncDef*) PyHash_GetFuncDef(void);
 #  endif /* uint64_t && uint32_t && aligned */
 #endif /* Py_HASH_ALGORITHM */
 
+#ifndef Py_LIMITED_API
+#  define Py_CPYTHON_HASH_H
+#  include "cpython/pyhash.h"
+#  undef Py_CPYTHON_HASH_H
+#endif
+
 #ifdef __cplusplus
 }
 #endif
index a74cb7ebc706d9a910c83afa6f41931d9309ac2f..4fa0337fcc7777a2dadd4ad0af6f9aa9799f74cc 100644 (file)
@@ -1768,6 +1768,7 @@ PYTHON_HEADERS= \
                $(srcdir)/Include/cpython/pyerrors.h \
                $(srcdir)/Include/cpython/pyfpe.h \
                $(srcdir)/Include/cpython/pyframe.h \
+               $(srcdir)/Include/cpython/pyhash.h \
                $(srcdir)/Include/cpython/pylifecycle.h \
                $(srcdir)/Include/cpython/pymem.h \
                $(srcdir)/Include/cpython/pystate.h \
index f6fbd0fccc3f9be2a6a97ad108ef84637a41bd0c..be1b98dba02fc5c1b8faf1c1cbc2b21c305020c3 100644 (file)
     <ClInclude Include="..\Include\cpython\pyerrors.h" />
     <ClInclude Include="..\Include\cpython\pyfpe.h" />
     <ClInclude Include="..\Include\cpython\pyframe.h" />
+    <ClInclude Include="..\Include\cpython\pyhash.h" />
     <ClInclude Include="..\Include\cpython\pylifecycle.h" />
     <ClInclude Include="..\Include\cpython\pymem.h" />
     <ClInclude Include="..\Include\cpython\pystate.h" />
index eb7ba0417c8146911eccb74e5a607ec1791b79f6..4f0da8f35998b76332e5178bdb96084a13087822 100644 (file)
     <ClInclude Include="..\Include\cpython\pyframe.h">
       <Filter>Include\cpython</Filter>
     </ClInclude>
+    <ClInclude Include="..\Include\cpython\pyhash.h">
+      <Filter>Include\cpython</Filter>
+    </ClInclude>
     <ClInclude Include="..\Include\cpython\pylifecycle.h">
       <Filter>Include\cpython</Filter>
     </ClInclude>