diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2020-02-13 13:21:54 -0800 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2020-02-13 13:21:54 -0800 |
commit | 573886fa81db2c4b0ae9d296fa0fe1ac9055f3f8 (patch) | |
tree | af5e4cd391951570340176ff43c912696c5df46c | |
parent | f0b87e1f7dc6f666bd48e26b7a1f84975d7b09b8 (diff) | |
download | psutil-573886fa81db2c4b0ae9d296fa0fe1ac9055f3f8.tar.gz |
#1672: warning pre-processor directive don't work on win + py2; also if struct.calcsize('l') < 8 assume int
-rw-r--r-- | psutil/_psutil_common.h | 11 | ||||
-rwxr-xr-x | setup.py | 2 |
2 files changed, 5 insertions, 8 deletions
diff --git a/psutil/_psutil_common.h b/psutil/_psutil_common.h index 9e1ef887..97543206 100644 --- a/psutil/_psutil_common.h +++ b/psutil/_psutil_common.h @@ -38,10 +38,10 @@ static const int PSUTIL_CONN_NONE = 128; // SIZEOF_INT|LONG is missing on Linux + PyPy (only?). // SIZEOF_PID_T is missing on Windows + Python2. -// In we can't determine pid_t size we assume it's an (int). -// On all UNIX platforms I've seen pid_t is defined as an int. -// _getpid() on Windows returns an int. We can't be 100% sure though, -// (in that case we'd probably get compiler warnings). +// In this case we guess it from setup.py. It's not 100% bullet proof, +// If wrong we'll probably get compiler warnings. +// FWIW on all UNIX platforms I've seen pid_t is defined as an int. +// _getpid() on Windows also returns an int. #if !defined(SIZEOF_INT) #define SIZEOF_INT 4 #endif @@ -49,9 +49,6 @@ static const int PSUTIL_CONN_NONE = 128; #define SIZEOF_LONG 8 #endif #if !defined(SIZEOF_PID_T) - #if PSUTIL_SIZEOF_PID_T != 4 - #warning "SIZEOF_PID_T was guessed" - #endif #define SIZEOF_PID_T PSUTIL_SIZEOF_PID_T // set as a macro in setup.py #endif @@ -56,7 +56,7 @@ if BSD: # Needed to determine _Py_PARSE_PID in case it's missing (Python 2, PyPy). # Taken from Lib/test/test_fcntl.py. # XXX: not bullet proof as the (long long) case is missing. -if struct.calcsize('l') == 8: +if struct.calcsize('l') <= 8: macros.append(('PSUTIL_SIZEOF_PID_T', '4')) # int else: macros.append(('PSUTIL_SIZEOF_PID_T', '8')) # long |