diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2020-01-21 11:34:10 -0800 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2020-01-21 11:34:10 -0800 |
commit | d5a96e2cd8527b395f55bc0c1ff299841e4bac77 (patch) | |
tree | ad7957e378316966c91c9a88800cdfc47357b6b4 | |
parent | 2f65ea74cba1843162c0ea3ee0274782e1c2de50 (diff) | |
download | psutil-d5a96e2cd8527b395f55bc0c1ff299841e4bac77.tar.gz |
use macro
-rw-r--r-- | psutil/_psutil_common.h | 13 | ||||
-rwxr-xr-x | setup.py | 8 |
2 files changed, 12 insertions, 9 deletions
diff --git a/psutil/_psutil_common.h b/psutil/_psutil_common.h index d370cd6e..1e76a305 100644 --- a/psutil/_psutil_common.h +++ b/psutil/_psutil_common.h @@ -26,22 +26,17 @@ static const int PSUTIL_CONN_NONE = 128; // Python 2 compatibility for PyArg_ParseTuple pid arg type handling. #if PY_MAJOR_VERSION == 2 - #if SIZEOF_PID_T == SIZEOF_INT + #if PSUTIL_SIZEOF_PID_T == SIZEOF_INT #define _Py_PARSE_PID "i" - #define PyLong_FromPid PyInt_FromLong - #define PyLong_AsPid PyInt_AsLong - #elif SIZEOF_PID_T == SIZEOF_LONG + #elif PSUTIL_SIZEOF_PID_T == SIZEOF_LONG #define _Py_PARSE_PID "l" - #define PyLong_FromPid PyInt_FromLong - #define PyLong_AsPid PyInt_AsLong - #elif SIZEOF_PID_T == SIZEOF_LONG_LONG + #elif PSUTIL_SIZEOF_PID_T == SIZEOF_LONG_LONG #define _Py_PARSE_PID "L" - #define PyLong_FromPid PyLong_FromLongLong - #define PyLong_AsPid PyInt_AsLongLong #else #error "sizeof(pid_t) is neither sizeof(int), sizeof(long) or " \ "sizeof(long long)" #endif + #undef PSUTIL_SIZEOF_PID_T #endif // ==================================================================== @@ -12,6 +12,7 @@ import io import os import platform import shutil +import struct import sys import tempfile import warnings @@ -85,6 +86,13 @@ def get_version(): VERSION = get_version() macros.append(('PSUTIL_VERSION', int(VERSION.replace('.', '')))) +if not PY3: + # XXX: not bullet proof (long long case is missing). + if struct.calcsize('l') <= 8: + macros.append(('PSUTIL_SIZEOF_PID_T', '4')) # int + else: + macros.append(('PSUTIL_SIZEOF_PID_T', '8')) # long + def get_description(): README = os.path.join(HERE, 'README.rst') |