forked from agrover/python-rds
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrdmahelpermodule.c
46 lines (35 loc) · 983 Bytes
/
rdmahelpermodule.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <Python.h>
static PyObject *
rdma_get_read_buffer_info(PyObject *self, PyObject *args)
{
char *ptr;
Py_ssize_t len;
unsigned long long addr_as_u64;
if (!PyArg_ParseTuple(args, "s#", &ptr, &len))
return NULL;
addr_as_u64 = (unsigned long)ptr;
return Py_BuildValue("Kn", addr_as_u64, len);
}
static PyObject *
rdma_get_write_buffer_info(PyObject *self, PyObject *args)
{
char *ptr;
Py_ssize_t len;
unsigned long long addr_as_u64;
if (!PyArg_ParseTuple(args, "w#", &ptr, &len))
return NULL;
addr_as_u64 = (unsigned long)ptr;
return Py_BuildValue("Kn", addr_as_u64, len);
}
static PyMethodDef rdma_methods[] = {
{"get_read_buffer_info", rdma_get_read_buffer_info, METH_VARARGS,
"Object -> (address, length)"},
{"get_write_buffer_info", rdma_get_write_buffer_info, METH_VARARGS,
"Object -> (address, length)"},
{NULL, NULL, 0, NULL} /* Sentinel */
};
PyMODINIT_FUNC
initrdmahelper(void)
{
Py_InitModule("rdmahelper", rdma_methods);
}