diff options
| author | Giampaolo Rodola <g.rodola@gmail.com> | 2020-02-11 23:04:38 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-02-11 23:04:38 +0100 |
| commit | 9e2ca978b211993066b0dc41da9aa63429655406 (patch) | |
| tree | cb46fc9c1d42d7681a79be303292ee47b33d40b9 /psutil/_psutil_common.h | |
| parent | d8cb832f8cc7ef2695472ec0f752c59c72916274 (diff) | |
| download | psutil-9e2ca978b211993066b0dc41da9aa63429655406.tar.gz | |
Add support for PyPy on Windows (#1686)
Diffstat (limited to 'psutil/_psutil_common.h')
| -rw-r--r-- | psutil/_psutil_common.h | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/psutil/_psutil_common.h b/psutil/_psutil_common.h index 2fccab81..2886d611 100644 --- a/psutil/_psutil_common.h +++ b/psutil/_psutil_common.h @@ -16,7 +16,7 @@ extern int PSUTIL_DEBUG; static const int PSUTIL_CONN_NONE = 128; // ==================================================================== -// --- Python functions and backward compatibility +// --- Backward compatibility with missing Python.h APIs // ==================================================================== #if PY_MAJOR_VERSION < 3 @@ -60,9 +60,14 @@ static const int PSUTIL_CONN_NONE = 128; #endif #endif -#if PY_MAJOR_VERSION < 3 +// Python 2 or PyPy on Windows +#ifndef PyLong_FromPid #if ((SIZEOF_PID_T == SIZEOF_INT) || (SIZEOF_PID_T == SIZEOF_LONG)) - #define PyLong_FromPid PyInt_FromLong + #if PY_MAJOR_VERSION >= 3 + #define PyLong_FromPid PyLong_FromLong + #else + #define PyLong_FromPid PyInt_FromLong + #endif #elif defined(SIZEOF_LONG_LONG) && SIZEOF_PID_T == SIZEOF_LONG_LONG #define PyLong_FromPid PyLong_FromLongLong #else @@ -122,4 +127,9 @@ int psutil_setup(void); PVOID psutil_GetProcAddress(LPCSTR libname, LPCSTR procname); PVOID psutil_GetProcAddressFromLib(LPCSTR libname, LPCSTR procname); PVOID psutil_SetFromNTStatusErr(NTSTATUS Status, const char *syscall); + + #if defined(PYPY_VERSION) && !defined(PyErr_SetFromWindowsErrWithFilename) + PyObject *PyErr_SetFromWindowsErrWithFilename(int ierr, + const char *filename); + #endif #endif |
