Skip to content

Commit

Permalink
adjust PyInit for _psutil_aix.c
Browse files Browse the repository at this point in the history
  • Loading branch information
giampaolo committed Dec 19, 2024
1 parent 8d7bd96 commit d77664c
Showing 1 changed file with 7 additions and 21 deletions.
28 changes: 7 additions & 21 deletions psutil/_psutil_aix.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@


#define TV2DOUBLE(t) (((t).tv_nsec * 0.000000001) + (t).tv_sec)
#define INITERROR return NULL

/*
* Read a file content and fills a C structure with it.
Expand Down Expand Up @@ -1030,18 +1031,12 @@ struct module_state {
PyObject *error;
};

#if PY_MAJOR_VERSION >= 3
#define GETSTATE(m) ((struct module_state*)PyModule_GetState(m))
#else
#define GETSTATE(m) (&_state)
#endif

#ifdef __cplusplus
extern "C" {
#endif

#if PY_MAJOR_VERSION >= 3

static int
psutil_aix_traverse(PyObject *m, visitproc visit, void *arg) {
Py_VISIT(GETSTATE(m)->error);
Expand All @@ -1066,21 +1061,13 @@ static struct PyModuleDef moduledef = {
NULL
};

#define INITERROR return NULL

PyMODINIT_FUNC PyInit__psutil_aix(void)

#else
#define INITERROR return

void init_psutil_aix(void)
#endif
{
#if PY_MAJOR_VERSION >= 3
PyMODINIT_FUNC
PyInit__psutil_aix(void) {
PyObject *module = PyModule_Create(&moduledef);
#else
PyObject *module = Py_InitModule("_psutil_aix", PsutilMethods);
#endif
if (module == NULL)
INITERROR;

#ifdef Py_GIL_DISABLED
PyUnstable_Module_SetGIL(mod, Py_MOD_GIL_NOT_USED);
#endif
Expand Down Expand Up @@ -1109,9 +1096,8 @@ void init_psutil_aix(void)

if (module == NULL)
INITERROR;
#if PY_MAJOR_VERSION >= 3

return module;
#endif
}

#ifdef __cplusplus
Expand Down

0 comments on commit d77664c

Please sign in to comment.