Debian Codegraph @

Modules/_testlimitedcapi/version.c

raw
1 /* Test version macros in the limited API */
2
3 #include "pyconfig.h" // Py_GIL_DISABLED
4 #ifndef Py_GIL_DISABLED
5 # define Py_LIMITED_API 0x030e0000 // Added in 3.14
6 #endif
7
8 #include "parts.h"
9 #include "clinic/version.c.h"
10 #include <stdio.h>
11
12 /*[clinic input]
13 module _testlimitedcapi
14 [clinic start generated code]*/
15 /*[clinic end generated code: output=da39a3ee5e6b4b0d input=2700057f9c1135ba]*/
16
17 /*[clinic input]
18 _testlimitedcapi.pack_full_version
19
20 major: int
21 minor: int
22 micro: int
23 level: int
24 serial: int
25 /
26 [clinic start generated code]*/
27
28 static PyObject *
29 _testlimitedcapi_pack_full_version_impl(PyObject *module, int major,
30 int minor, int micro, int level,
31 int serial)
32 /*[clinic end generated code: output=b87a1e9805648861 input=2a304423be61d2ac]*/
33 {
34 uint32_t macro_result = Py_PACK_FULL_VERSION(
35 major, minor, micro, level, serial);
36 #undef Py_PACK_FULL_VERSION
37 uint32_t func_result = Py_PACK_FULL_VERSION(
38 major, minor, micro, level, serial);
39
40 assert(macro_result == func_result);
41 return PyLong_FromUnsignedLong((unsigned long)func_result);
42 }
43
44 /*[clinic input]
45 _testlimitedcapi.pack_version
46
47 major: int
48 minor: int
49 /
50 [clinic start generated code]*/
51
52 static PyObject *
53 _testlimitedcapi_pack_version_impl(PyObject *module, int major, int minor)
54 /*[clinic end generated code: output=771247bbd06e7883 input=3e39e9dcbc09e86a]*/
55 {
56 uint32_t macro_result = Py_PACK_VERSION(major, minor);
57 #undef Py_PACK_VERSION
58 uint32_t func_result = Py_PACK_VERSION(major, minor);
59
60 assert(macro_result == func_result);
61 return PyLong_FromUnsignedLong((unsigned long)func_result);
62 }
63
64 static PyMethodDef TestMethods[] = {
65 _TESTLIMITEDCAPI_PACK_FULL_VERSION_METHODDEF
66 _TESTLIMITEDCAPI_PACK_VERSION_METHODDEF
67 {NULL},
68 };
69
70 int
71 _PyTestLimitedCAPI_Init_Version(PyObject *m)
72 {
73 if (PyModule_AddFunctions(m, TestMethods) < 0) {
74 return -1;
75 }
76 return 0;
77 }