-
-
Notifications
You must be signed in to change notification settings - Fork 30.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
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/. * configure: add _testlimitedcapi test extension. * Update generate_stdlib_module_names.py. * Update make check-c-globals. Co-authored-by: Erlend E. Aasland <[email protected]>
- Loading branch information
1 parent
d9ccde2
commit d9bcdda
Showing
23 changed files
with
394 additions
and
109 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.
6 changes: 0 additions & 6 deletions
6
Modules/_testcapi/heaptype_relative.c → Modules/_testlimitedcapi/heaptype_relative.c
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,27 @@ | ||
#ifndef Py_TESTLIMITEDCAPI_PARTS_H | ||
#define Py_TESTLIMITEDCAPI_PARTS_H | ||
|
||
// Always enable assertions | ||
#undef NDEBUG | ||
|
||
#include "pyconfig.h" // Py_GIL_DISABLED | ||
|
||
// 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 |
Oops, something went wrong.