Skip to content

Commit 62802b6

Browse files
authored
pythongh-111545: Add Include/cpython/pyhash.h header file (python#112063)
Move non-limited C API to a new Include/cpython/pyhash.h header file.
1 parent 9302f05 commit 62802b6

File tree

5 files changed

+24
-13
lines changed

5 files changed

+24
-13
lines changed

Include/cpython/pyhash.h

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#ifndef Py_CPYTHON_HASH_H
2+
# error "this header file must not be included directly"
3+
#endif
4+
5+
/* hash function definition */
6+
typedef struct {
7+
Py_hash_t (*const hash)(const void *, Py_ssize_t);
8+
const char *name;
9+
const int hash_bits;
10+
const int seed_bits;
11+
} PyHash_FuncDef;
12+
13+
PyAPI_FUNC(PyHash_FuncDef*) PyHash_GetFuncDef(void);

Include/pyhash.h

+6-13
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,6 @@
44
extern "C" {
55
#endif
66

7-
#ifndef Py_LIMITED_API
8-
/* hash function definition */
9-
typedef struct {
10-
Py_hash_t (*const hash)(const void *, Py_ssize_t);
11-
const char *name;
12-
const int hash_bits;
13-
const int seed_bits;
14-
} PyHash_FuncDef;
15-
16-
PyAPI_FUNC(PyHash_FuncDef*) PyHash_GetFuncDef(void);
17-
#endif
18-
19-
207
/* Cutoff for small string DJBX33A optimization in range [1, cutoff).
218
*
229
* About 50% of the strings in a typical Python application are smaller than
@@ -60,6 +47,12 @@ PyAPI_FUNC(PyHash_FuncDef*) PyHash_GetFuncDef(void);
6047
# endif /* uint64_t && uint32_t && aligned */
6148
#endif /* Py_HASH_ALGORITHM */
6249

50+
#ifndef Py_LIMITED_API
51+
# define Py_CPYTHON_HASH_H
52+
# include "cpython/pyhash.h"
53+
# undef Py_CPYTHON_HASH_H
54+
#endif
55+
6356
#ifdef __cplusplus
6457
}
6558
#endif

Makefile.pre.in

+1
Original file line numberDiff line numberDiff line change
@@ -1768,6 +1768,7 @@ PYTHON_HEADERS= \
17681768
$(srcdir)/Include/cpython/pyerrors.h \
17691769
$(srcdir)/Include/cpython/pyfpe.h \
17701770
$(srcdir)/Include/cpython/pyframe.h \
1771+
$(srcdir)/Include/cpython/pyhash.h \
17711772
$(srcdir)/Include/cpython/pylifecycle.h \
17721773
$(srcdir)/Include/cpython/pymem.h \
17731774
$(srcdir)/Include/cpython/pystate.h \

PCbuild/pythoncore.vcxproj

+1
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@
172172
<ClInclude Include="..\Include\cpython\pyerrors.h" />
173173
<ClInclude Include="..\Include\cpython\pyfpe.h" />
174174
<ClInclude Include="..\Include\cpython\pyframe.h" />
175+
<ClInclude Include="..\Include\cpython\pyhash.h" />
175176
<ClInclude Include="..\Include\cpython\pylifecycle.h" />
176177
<ClInclude Include="..\Include\cpython\pymem.h" />
177178
<ClInclude Include="..\Include\cpython\pystate.h" />

PCbuild/pythoncore.vcxproj.filters

+3
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,9 @@
468468
<ClInclude Include="..\Include\cpython\pyframe.h">
469469
<Filter>Include\cpython</Filter>
470470
</ClInclude>
471+
<ClInclude Include="..\Include\cpython\pyhash.h">
472+
<Filter>Include\cpython</Filter>
473+
</ClInclude>
471474
<ClInclude Include="..\Include\cpython\pylifecycle.h">
472475
<Filter>Include\cpython</Filter>
473476
</ClInclude>

0 commit comments

Comments
 (0)