Skip to content

Commit

Permalink
[Minipack] Modify fbfpgaiomodule.c to support both python2 and python3 (
Browse files Browse the repository at this point in the history
#7604)

Modify fbfpgaiomodule.c to support both python2 and python3

Signed-off-by: chiourung_huang <[email protected]>
  • Loading branch information
chiourung authored May 18, 2021
1 parent 8f883fe commit 8e44b9e
Showing 1 changed file with 22 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,7 @@ static PyMethodDef FbfpgaMethods[] = {
{ NULL, NULL, 0, NULL },
};

PyMODINIT_FUNC
initfbfpgaio(void)
{
char docstr[] = "\
static char docstr[] = "\
1. hw_init():\n\
return value: True/False\n\
2. hw_release():\n\
Expand All @@ -122,5 +119,26 @@ initfbfpgaio(void)
In reading operation: data which is read from FPGA\n\
In writing operation: None\n";

#if PY_MAJOR_VERSION < 3
PyMODINIT_FUNC
initfbfpgaio(void)
{
(void) Py_InitModule3("fbfpgaio", FbfpgaMethods, docstr);
}
#else
static struct PyModuleDef FbfpgaModule =
{
PyModuleDef_HEAD_INIT,
"fbfpgaio", /* name of module */
docstr,
-1, /* size of per-interpreter state of the module, or -1 if the module keeps state in global variables. */
FbfpgaMethods
};

PyMODINIT_FUNC
PyInit_fbfpgaio(void)
{
return PyModule_Create(&FbfpgaModule);
}
#endif

0 comments on commit 8e44b9e

Please sign in to comment.