summaryrefslogtreecommitdiffstats
path: root/Modules/_testlimitedcapi/util.h
diff options
context:
space:
mode:
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)