Displaying 7 results from an estimated 7 matches for "pylong_check".
2019 Aug 13
0
[PATCH libnbd 2/6] generator: Create only one Python wrapper per closure.
...;;
+ pr "\n";
+ pr " if (PyEval_ThreadsInitialized ())\n";
+ pr " PyGILState_Release (py_save);\n";
+ pr "\n";
+ pr " Py_DECREF (py_args);\n";
+ pr "\n";
+ pr " if (py_ret != NULL) {\n";
+ pr " if (PyLong_Check (py_ret))\n";
+ pr " ret = PyLong_AsLong (py_ret);\n";
+ pr " else\n";
+ pr " /* If it's not a long, just assume it's 0. */\n";
+ pr " ret = 0;\n";
+ pr " Py_DECREF (py_ret);\n";
+ pr " }\n&q...
2019 Aug 11
4
[PATCH libnbd v2 0/3] python: Add test for doing asynch copy.
v1 was here:
https://www.redhat.com/archives/libguestfs/2019-August/msg00103.html
In v2 I've made several changes:
- Fix Python callbacks so if they don't return something
which is int-like, we assume they mean to return 0.
- Add nbd.Buffer free() method. Read commit message in
patch 2 to see what this is about.
- Fixed the asynch copy test to deal with the unbelievably
2019 Aug 11
0
[PATCH libnbd v2 1/3] python: Allow Python callbacks to auto-retire by returning an integer.
...ython_binding name { args; optargs; ret; may_set_error } =
pr " Py_DECREF (py_args);\n";
pr "\n";
pr " if (py_ret != NULL) {\n";
- pr " Py_DECREF (py_ret); /* return value is discarded */\n";
+ pr " if (PyLong_Check (py_ret))\n";
+ pr " ret = PyLong_AsLong (py_ret);\n";
+ pr " else\n";
+ pr " /* If it's not a long, just assume it's 0. */\n";
+ pr " ret = 0;\n";
+ pr " Py_DECREF (py_ret);\n&quo...
2019 Aug 13
0
[PATCH libnbd 2/4] api: Add free function and remove valid_flag parameter.
...f (PyEval_ThreadsInitialized ())\n";
+ pr " PyGILState_Release (py_save);\n";
pr "\n";
- pr " Py_DECREF (py_args);\n";
+ pr " Py_DECREF (py_args);\n";
pr "\n";
- pr " if (py_ret != NULL) {\n";
- pr " if (PyLong_Check (py_ret))\n";
- pr " ret = PyLong_AsLong (py_ret);\n";
- pr " else\n";
- pr " /* If it's not a long, just assume it's 0. */\n";
- pr " ret = 0;\n";
- pr " Py_DECREF (py_ret);\n";
- pr " }\n&q...
2010 Sep 09
2
[PATCH]: add libxl python binding
...yObject *genwrap__ull_get(unsigned long long val)
+{
+ return PyLong_FromUnsignedLongLong(val);
+}
+
+int genwrap__ull_set(PyObject *v, unsigned long long *val, unsigned long long mask)
+{
+ unsigned long long tmp;
+ if ( NULL == v ) {
+ *val = 0;
+ return 0;
+ }
+ if ( PyLong_Check(v) ) {
+ tmp = PyLong_AsUnsignedLongLong(v);
+ }else{
+ tmp = (unsigned long long)PyInt_AsLong(v);
+ }
+ if ( tmp & ~mask ) {
+ PyErr_SetString(PyExc_ValueError, "Integer overflow");
+ return -1;
+ }
+ *val = tmp;
+ return 0;
+}
+
+PyObjec...
2019 Aug 13
12
[PATCH 0/6] Implement OClosure.
Patches 1-4 are basically uncontroversial, straightforward refactoring
and IMHO we should just push them. Possibly 1-3 should be squashed
together, but I posted them separately so they are easier to review.
Patches 5 and 6 together implement OClosure. Patch 5 adds the feature
and is simple to understand.
Patch 6 changes the Closure completion callbacks into OClosure, but
because it doesn't
2019 Aug 13
8
[PATCH libnbd 0/4] Add free function to callbacks.
Patches 1 & 2 are rather complex, but the end result is that we pass
closures + user_data + free function in single struct parameters as I
described previously in this email:
https://www.redhat.com/archives/libguestfs/2019-August/msg00210.html
Patch 3 adds a convenient FREE_CALLBACK macro which seems a worthwhile
simplification if you buy into 1 & 2.
Patch 4 adds another macro which is