gh-111545: Add Include/cpython/pyhash.h header file (#112063)

Move non-limited C API to a new Include/cpython/pyhash.h header file.
This commit is contained in:
Victor Stinner 2023-11-15 01:19:20 +01:00 committed by GitHub
parent 9302f05f9a
commit 62802b6228
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 24 additions and 13 deletions

13
Include/cpython/pyhash.h Normal file
View file

@ -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);

View 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

View 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 \

View file

@ -172,6 +172,7 @@
<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" />

View file

@ -468,6 +468,9 @@
<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>