summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2020-02-09 21:55:23 +0100
committerGiampaolo Rodola <g.rodola@gmail.com>2020-02-09 21:55:23 +0100
commit05758f6978aefea709150898ae285b3ff3688c7c (patch)
treed9cc698fd83fb857fc27ca71e0399a3a113f43cb
parent796b2dda2e0d8751eee0a4d16ab8c027839f8908 (diff)
downloadpsutil-05758f6978aefea709150898ae285b3ff3688c7c.tar.gz
#1672, #1682: SIZEOF_INT is not available on pypy3; assume that on systems where pid_t size can't be determined at runtime pid_t is an int
-rw-r--r--psutil/_psutil_common.h23
-rw-r--r--psutil/_psutil_linux.c2
2 files changed, 16 insertions, 9 deletions
diff --git a/psutil/_psutil_common.h b/psutil/_psutil_common.h
index 60ea6298..e91bf2dd 100644
--- a/psutil/_psutil_common.h
+++ b/psutil/_psutil_common.h
@@ -27,15 +27,22 @@ static const int PSUTIL_CONN_NONE = 128;
#define PyUnicode_DecodeFSDefaultAndSize PyString_FromStringAndSize
#endif
-// Python 2: SIZEOF_PID_T not defined but _getpid() returns an int.
-#if defined(PSUTIL_WINDOWS) && !defined(SIZEOF_PID_T)
- #define SIZEOF_PID_T SIZEOF_INT
+// --- _Py_PARSE_PID
+
+// SIZEOF_INT|LONG is missing on Linux + PyPy (only?)
+// SIZEOF_PID_T is missing on Windows + Python2
+// In we can't determine we assume PID is an (int).
+// On major UNIX platforms I've seen pid_t is treated as int.
+// On Windows _getpid() returns an int. We can't be 100% certain though,
+// (in that case we'd probably get compiler warnings).
+#if !defined(SIZEOF_INT)
+ #define SIZEOF_INT 4
#endif
-
-#if !defined(_Py_PARSE_PID) || PY_MAJOR_VERSION < 3
- #if !defined(SIZEOF_PID_T) || !defined(SIZEOF_INT) || !defined(SIZEOF_LONG)
- #error "missing SIZEOF* definition"
- #endif
+#if !defined(SIZEOF_LONG)
+ #define SIZEOF_LONG 8
+#endif
+#if !defined(SIZEOF_PID_T)
+ #define SIZEOF_PID_T 4 // assume int
#endif
// _Py_PARSE_PID is Python 3 only, but since it's private make sure it's
diff --git a/psutil/_psutil_linux.c b/psutil/_psutil_linux.c
index 93cc071b..ec8b433a 100644
--- a/psutil/_psutil_linux.c
+++ b/psutil/_psutil_linux.c
@@ -204,7 +204,7 @@ static PyObject *
psutil_disk_partitions(PyObject *self, PyObject *args) {
FILE *file = NULL;
struct mntent *entry;
- const char *mtab_path;
+ char *mtab_path;
PyObject *py_dev = NULL;
PyObject *py_mountp = NULL;
PyObject *py_tuple = NULL;