various sharedarea improvements

This commit is contained in:
Unbit
2014-05-14 16:37:59 +02:00
parent 7681a40d88
commit 0dffa344b4
3 changed files with 157 additions and 11 deletions
+98 -7
View File
@@ -1426,7 +1426,7 @@ PyObject *py_uwsgi_sharedarea_inc64(PyObject * self, PyObject * args) {
uint64_t pos = 0;
int64_t value = 1;
if (!PyArg_ParseTuple(args, "il|l:sharedarea_inc64", &id, &pos, &value)) {
if (!PyArg_ParseTuple(args, "iL|l:sharedarea_inc64", &id, &pos, &value)) {
return NULL;
}
@@ -1443,12 +1443,56 @@ PyObject *py_uwsgi_sharedarea_inc64(PyObject * self, PyObject * args) {
}
PyObject *py_uwsgi_sharedarea_write32(PyObject * self, PyObject * args) {
int id;
uint64_t pos = 0;
int32_t value = 0;
if (!PyArg_ParseTuple(args, "iLI:sharedarea_write32", &id, &pos, &value)) {
return NULL;
}
UWSGI_RELEASE_GIL
int ret = uwsgi_sharedarea_write32(id, pos, &value);
UWSGI_GET_GIL
if (ret) {
return PyErr_Format(PyExc_ValueError, "error calling uwsgi_sharedarea_write32()");
}
Py_INCREF(Py_None);
return Py_None;
}
PyObject *py_uwsgi_sharedarea_write16(PyObject * self, PyObject * args) {
int id;
uint64_t pos = 0;
int16_t value = 0;
if (!PyArg_ParseTuple(args, "iLI:sharedarea_write16", &id, &pos, &value)) {
return NULL;
}
UWSGI_RELEASE_GIL
int ret = uwsgi_sharedarea_write16(id, pos, &value);
UWSGI_GET_GIL
if (ret) {
return PyErr_Format(PyExc_ValueError, "error calling uwsgi_sharedarea_write16()");
}
Py_INCREF(Py_None);
return Py_None;
}
PyObject *py_uwsgi_sharedarea_write64(PyObject * self, PyObject * args) {
int id;
uint64_t pos = 0;
int64_t value = 0;
if (!PyArg_ParseTuple(args, "ill:sharedarea_write64", &id, &pos, &value)) {
if (!PyArg_ParseTuple(args, "iLL:sharedarea_write64", &id, &pos, &value)) {
return NULL;
}
@@ -1470,7 +1514,7 @@ PyObject *py_uwsgi_sharedarea_write(PyObject * self, PyObject * args) {
char *value;
Py_ssize_t value_len = 0;
if (!PyArg_ParseTuple(args, "ils#:sharedarea_write", &id, &pos, &value, &value_len)) {
if (!PyArg_ParseTuple(args, "iLs#:sharedarea_write", &id, &pos, &value, &value_len)) {
return NULL;
}
@@ -1570,7 +1614,7 @@ PyObject *py_uwsgi_sharedarea_write8(PyObject * self, PyObject * args) {
uint64_t pos = 0;
int8_t value;
if (!PyArg_ParseTuple(args, "ilb:sharedarea_write8", &id, &pos, &value)) {
if (!PyArg_ParseTuple(args, "iLb:sharedarea_write8", &id, &pos, &value)) {
return NULL;
}
@@ -1592,7 +1636,7 @@ PyObject *py_uwsgi_sharedarea_read64(PyObject * self, PyObject * args) {
uint64_t pos = 0;
int64_t value;
if (!PyArg_ParseTuple(args, "il:sharedarea_read64", &id, &pos)) {
if (!PyArg_ParseTuple(args, "iL:sharedarea_read64", &id, &pos)) {
return NULL;
}
@@ -1608,12 +1652,55 @@ PyObject *py_uwsgi_sharedarea_read64(PyObject * self, PyObject * args) {
}
PyObject *py_uwsgi_sharedarea_read32(PyObject * self, PyObject * args) {
int id;
uint64_t pos = 0;
int32_t value;
if (!PyArg_ParseTuple(args, "iL:sharedarea_read32", &id, &pos)) {
return NULL;
}
UWSGI_RELEASE_GIL
int ret = uwsgi_sharedarea_read32(id, pos, &value);
UWSGI_GET_GIL
if (ret) {
return PyErr_Format(PyExc_ValueError, "error calling uwsgi_sharedarea_read32()");
}
return PyInt_FromLong(value);
}
PyObject *py_uwsgi_sharedarea_read16(PyObject * self, PyObject * args) {
int id;
uint64_t pos = 0;
int16_t value;
if (!PyArg_ParseTuple(args, "iL:sharedarea_read16", &id, &pos)) {
return NULL;
}
UWSGI_RELEASE_GIL
int ret = uwsgi_sharedarea_read16(id, pos, &value);
UWSGI_GET_GIL
if (ret) {
return PyErr_Format(PyExc_ValueError, "error calling uwsgi_sharedarea_read16()");
}
return PyInt_FromLong(value);
}
PyObject *py_uwsgi_sharedarea_read8(PyObject * self, PyObject * args) {
int id;
uint64_t pos = 0;
int8_t byte;
if (!PyArg_ParseTuple(args, "il:sharedarea_read8", &id, &pos)) {
if (!PyArg_ParseTuple(args, "iL:sharedarea_read8", &id, &pos)) {
return NULL;
}
@@ -1633,7 +1720,7 @@ PyObject *py_uwsgi_sharedarea_read(PyObject * self, PyObject * args) {
uint64_t pos = 0;
uint64_t len = 0;
if (!PyArg_ParseTuple(args, "il|l:sharedarea_read", &id, &pos, &len)) {
if (!PyArg_ParseTuple(args, "iL|L:sharedarea_read", &id, &pos, &len)) {
return NULL;
}
@@ -2459,6 +2546,10 @@ static PyMethodDef uwsgi_sa_methods[] = {
{"sharedarea_writelong", py_uwsgi_sharedarea_write64, METH_VARARGS, ""},
{"sharedarea_read64", py_uwsgi_sharedarea_read64, METH_VARARGS, ""},
{"sharedarea_write64", py_uwsgi_sharedarea_write64, METH_VARARGS, ""},
{"sharedarea_read32", py_uwsgi_sharedarea_read32, METH_VARARGS, ""},
{"sharedarea_write32", py_uwsgi_sharedarea_write32, METH_VARARGS, ""},
{"sharedarea_read16", py_uwsgi_sharedarea_read16, METH_VARARGS, ""},
{"sharedarea_write16", py_uwsgi_sharedarea_write16, METH_VARARGS, ""},
{"sharedarea_inclong", py_uwsgi_sharedarea_inc64, METH_VARARGS, ""},
{"sharedarea_inc64", py_uwsgi_sharedarea_inc64, METH_VARARGS, ""},
{"sharedarea_rlock", py_uwsgi_sharedarea_rlock, METH_VARARGS, ""},