@@ -125,6 +125,18 @@ get_c_recursion_remaining(PyObject *self, PyObject *Py_UNUSED(args))
125125 return PyLong_FromLong (remaining );
126126}
127127
128+ static PyObject *
129+ get_stack_pointer (PyObject * self , PyObject * Py_UNUSED (args ))
130+ {
131+ uintptr_t here_addr = _Py_get_machine_stack_pointer ();
132+ return PyLong_FromSize_t (here_addr );
133+ }
134+
135+ static PyObject *
136+ get_stack_margin (PyObject * self , PyObject * Py_UNUSED (args ))
137+ {
138+ return PyLong_FromSize_t (_PyOS_STACK_MARGIN_BYTES );
139+ }
128140
129141static PyObject *
130142test_bswap (PyObject * self , PyObject * Py_UNUSED (args ))
@@ -2381,6 +2393,8 @@ static PyMethodDef module_functions[] = {
23812393 {"get_configs" , get_configs , METH_NOARGS },
23822394 {"get_recursion_depth" , get_recursion_depth , METH_NOARGS },
23832395 {"get_c_recursion_remaining" , get_c_recursion_remaining , METH_NOARGS },
2396+ {"get_stack_pointer" , get_stack_pointer , METH_NOARGS },
2397+ {"get_stack_margin" , get_stack_margin , METH_NOARGS },
23842398 {"test_bswap" , test_bswap , METH_NOARGS },
23852399 {"test_popcount" , test_popcount , METH_NOARGS },
23862400 {"test_bit_length" , test_bit_length , METH_NOARGS },
0 commit comments