summaryrefslogtreecommitdiffstats
path: root/Modules/_testlimitedcapi/util.h
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2024-03-11 10:28:16 (GMT)
committerGitHub <noreply@github.com>2024-03-11 10:28:16 (GMT)
commit1cc02ca063f50b8c527fbdde9957b03c145c1575 (patch)
tree84cd4d2d13c8ca869749827d8f91d592e8a01ca2 /Modules/_testlimitedcapi/util.h
parentd8712fa0c75ad5ea56543903fa45674ab47cc647 (diff)
downloadcpython-1cc02ca063f50b8c527fbdde9957b03c145c1575.zip
cpython-1cc02ca063f50b8c527fbdde9957b03c145c1575.tar.gz
cpython-1cc02ca063f50b8c527fbdde9957b03c145c1575.tar.bz2
gh-116417: Move 4 limited C API test files to _testlimitedcapi (#116571)
Move the following files from Modules/_testcapi/ to Modules/_testlimitedcapi/: * bytearray.c * bytes.c * pyos.c * sys.c Changes: * Replace PyBytes_AS_STRING() with PyBytes_AsString(). * Replace PyBytes_GET_SIZE() with PyBytes_Size(). * Update related test_capi tests. * Copy Modules/_testcapi/util.h to Modules/_testlimitedcapi/util.h.
Diffstat (limited to 'Modules/_testlimitedcapi/util.h')
-rw-r--r--Modules/_testlimitedcapi/util.h33
1 files changed, 33 insertions, 0 deletions
diff --git a/Modules/_testlimitedcapi/util.h b/Modules/_testlimitedcapi/util.h
new file mode 100644
index 0000000..f26d765
--- /dev/null
+++ b/Modules/_testlimitedcapi/util.h
@@ -0,0 +1,33 @@
+#define NULLABLE(x) do { \
+ if (x == Py_None) { \
+ x = NULL; \
+ } \
+ } while (0);
+
+#define RETURN_INT(value) do { \
+ int _ret = (value); \
+ if (_ret == -1) { \
+ assert(PyErr_Occurred()); \
+ return NULL; \
+ } \
+ assert(!PyErr_Occurred()); \
+ return PyLong_FromLong(_ret); \
+ } while (0)
+
+#define RETURN_SIZE(value) do { \
+ Py_ssize_t _ret = (value); \
+ if (_ret == -1) { \
+ assert(PyErr_Occurred()); \
+ return NULL; \
+ } \
+ assert(!PyErr_Occurred()); \
+ return PyLong_FromSsize_t(_ret); \
+ } while (0)
+
+/* Marker to check that pointer value was set. */
+static const char uninitialized[] = "uninitialized";
+#define UNINITIALIZED_PTR ((void *)uninitialized)
+/* Marker to check that Py_ssize_t value was set. */
+#define UNINITIALIZED_SIZE ((Py_ssize_t)236892191)
+/* Marker to check that integer value was set. */
+#define UNINITIALIZED_INT (63256717)