[mpich-devel] helpful preprocessor check for CPU_ZERO and CPU_SET
Jeff Hammond
jhammond at alcf.anl.gov
Mon Dec 31 12:54:31 CST 2012
Having been frustrated in a related development effort because I was
unaware that sched.h was previously and indirectly included without
the __USE_GNU macro active, thereby preventing me from using CPU_ZERO
and CPU_SET, I suggest the inclusion of the following preprocessor
macro in MPICH so that it is plainly obvious should this occur in the
future due to the prior inclusion of sched.h before the following
code, which is actually quite far down in the source.
I recognize that this is currently not a problem nor is the code below
even active right now, but (1) should it ever be active and (2) some
developer includes sched.h without __USE_GNU prior to line 1050 in
this file (there are ~10 MPICH internal headers that could cause this
right now), there will be a problem that is only detected when e.g.
cpi is linked, which is later than one would otherwise prefer.
Best,
Jeff
$ svn diff pm/util/process.c
Index: pm/util/process.c
===================================================================
--- pm/util/process.c (revision 10808)
+++ pm/util/process.c (working copy)
@@ -1031,6 +1031,11 @@
#define __USE_GNU
#endif
#include <sched.h>
+
+#if !defined(CPU_ZERO) || !defined(CPU_SET)
+#error CPU_ZERO and/or CPU_SET were not defined because of prior
inclusion of sched.h without __USE_GNU
+#endif
+
/*
* Set the processor affinity for the calling process. Normally, this will
* be used in the "postfork" routine provided by the process manager, before
--
Jeff Hammond
Argonne Leadership Computing Facility
University of Chicago Computation Institute
jhammond at alcf.anl.gov / (630) 252-5381
http://www.linkedin.com/in/jeffhammond
https://wiki.alcf.anl.gov/parts/index.php/User:Jhammond
More information about the devel
mailing list