Closed GoogleCodeExporter closed 9 years ago
Python.h indirectly includes features.h, which has _FEATURES_H check against
multiple inclusion, so _GNU_SOURCE needs to be defined earlier.
Updated patch:
--- psutil/_psutil_linux.c
+++ psutil/_psutil_linux.c
@@ -6,6 +6,7 @@
* Linux-specific functions.
*/
+#define _GNU_SOURCE
#include <Python.h>
#include <errno.h>
#include <stdlib.h>
Original comment by Arfrever...@gmail.com
on 30 Jun 2013 at 7:40
Fixed in revision b304cfaf3b7c. Thanks for the patch.
Original comment by g.rodola
on 4 Jul 2013 at 2:05
First patch was not working. Please move '#define _GNU_SOURCE' before inclusion
of Python.h.
Original comment by Arfrever...@gmail.com
on 4 Jul 2013 at 2:39
whops! right.
done, thanks.
Original comment by g.rodola
on 6 Jul 2013 at 1:02
Original comment by g.rodola
on 11 Jul 2013 at 8:54
I'm reopening this as right now we're getting a compiler warning because of
this change:
/usr/include/python2.7/pyconfig.h:1139:0: warning: "_GNU_SOURCE" redefined
[enabled by default]
Since I couldn't and still cannot reproduce the original issue, before I commit
can you please tell me if the following patch breaks anything?
diff --git a/psutil/_psutil_linux.c b/psutil/_psutil_linux.c
--- a/psutil/_psutil_linux.c
+++ b/psutil/_psutil_linux.c
@@ -6,22 +6,26 @@
* Linux-specific functions.
*/
-#define _GNU_SOURCE
#include <Python.h>
#include <errno.h>
#include <stdlib.h>
#include <mntent.h>
#include <utmp.h>
-#include <sched.h>
#include <sys/syscall.h>
#include <sys/sysinfo.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <linux/unistd.h>
+// "man sched_setaffinity" dictates to include _GNU_SOURCE but this may
+// be already defined elsewhere
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+#include <sched.h>
+
#include "_psutil_linux.h"
-
#define HAS_IOPRIO defined(__NR_ioprio_get) && defined(__NR_ioprio_set)
#if HAS_IOPRIO
Original comment by g.rodola
on 28 Aug 2013 at 4:24
Closing this out again as I believe the warning is gone now.
Original comment by g.rodola
on 2 Dec 2013 at 7:40
Original issue reported on code.google.com by
Arfrever...@gmail.com
on 29 Jun 2013 at 7:13