| 1 |
#ifndef BACKPORTS_ZSTD_COMPAT_H |
| 2 |
#define BACKPORTS_ZSTD_COMPAT_H |
| 3 |
|
| 4 |
#include "Python.h" |
| 5 |
#include <zstd.h> |
| 6 |
|
| 7 |
#include "pythoncapi_compat.h" |
| 8 |
|
| 9 |
#if ZSTD_VERSION_NUMBER < 10405 |
| 10 |
#error "zstd version is too old" |
| 11 |
#endif |
| 12 |
|
| 13 |
#if PY_VERSION_HEX < 0x030E0000 // Python 3.13 and below |
| 14 |
static inline int PyType_Freeze(PyTypeObject *type) |
| 15 |
{ |
| 16 |
// this will not perform the freeze |
| 17 |
// but it is acceptable in the scope of this library |
| 18 |
return -1; |
| 19 |
} |
| 20 |
#endif |
| 21 |
|
| 22 |
#if PY_VERSION_HEX < 0x030D0000 // Python 3.12 and below |
| 23 |
#define Py_mod_gil 0 |
| 24 |
#define Py_MOD_GIL_NOT_USED NULL |
| 25 |
#endif |
| 26 |
|
| 27 |
#if PY_VERSION_HEX < 0x030C0000 // Python 3.11 and below |
| 28 |
#define Py_mod_multiple_interpreters 0 |
| 29 |
#define Py_MOD_PER_INTERPRETER_GIL_SUPPORTED NULL |
| 30 |
#endif |
| 31 |
|
| 32 |
#if PY_VERSION_HEX < 0x030B0000 // Python 3.10 and below |
| 33 |
#define _PyCFunction_CAST(func) _Py_CAST(PyCFunction, _Py_CAST(void (*)(void), (func))) |
| 34 |
#endif |
| 35 |
|
| 36 |
#endif /* !BACKPORTS_ZSTD_COMPAT_H */ |