forked from python/cpython
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pythongh-116417: Add _testlimitedcapi C extension
Add a new C extension "_testlimitedcapi" which is only built with the limited C API. Move heaptype_relative.c and vectorcall_limited.c from Modules/_testcapi/ to Modules/_testlimitedcapi/.
- Loading branch information
Showing
21 changed files
with
344 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Test the limited C API. | ||
* | ||
* The 'test_*' functions exported by this module are run as part of the | ||
* standard Python regression test, via Lib/test/test_capi.py. | ||
*/ | ||
|
||
#include "_testlimitedcapi/parts.h" | ||
|
||
static PyMethodDef TestMethods[] = { | ||
{NULL, NULL} /* sentinel */ | ||
}; | ||
|
||
static struct PyModuleDef _testlimitedcapimodule = { | ||
PyModuleDef_HEAD_INIT, | ||
.m_name = "_testlimitedcapi", | ||
.m_size = 0, | ||
.m_methods = TestMethods, | ||
}; | ||
|
||
PyMODINIT_FUNC | ||
PyInit__testlimitedcapi(void) | ||
{ | ||
PyObject *mod = PyModule_Create(&_testlimitedcapimodule); | ||
if (mod == NULL) { | ||
return NULL; | ||
} | ||
|
||
if (_PyTestCapi_Init_VectorcallLimited(mod) < 0) { | ||
return NULL; | ||
} | ||
if (_PyTestCapi_Init_HeaptypeRelative(mod) < 0) { | ||
return NULL; | ||
} | ||
return mod; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#ifndef Py_TESTLIMITEDCAPI_PARTS_H | ||
#define Py_TESTLIMITEDCAPI_PARTS_H | ||
|
||
// Always enable assertions | ||
#undef NDEBUG | ||
|
||
// Use the limited C API | ||
#ifndef Py_GIL_DISABLED | ||
# define Py_LIMITED_API 0x030c0000 // 3.12 | ||
#endif | ||
|
||
// Make sure that the internal C API cannot be used. | ||
#undef Py_BUILD_CORE_MODULE | ||
#undef Py_BUILD_CORE_BUILTIN | ||
|
||
#include "Python.h" | ||
|
||
#ifdef Py_BUILD_CORE | ||
# error "Py_BUILD_CORE macro must not be defined" | ||
#endif | ||
|
||
int _PyTestCapi_Init_VectorcallLimited(PyObject *module); | ||
int _PyTestCapi_Init_HeaptypeRelative(PyObject *module); | ||
|
||
#endif // Py_TESTLIMITEDCAPI_PARTS_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.