Bruno Haible wrote: > > Here is a proposed change to the gnulib 'nproc' module. It will > require changes (simplification) on Giuseppe's side, of course.
Wow, this is great stuff Bruno, thanks! > *** lib/nproc.c.orig 2009-11-01 14:55:37.000000000 +0100 > --- lib/nproc.c 2009-11-01 14:54:52.000000000 +0100 > + if (query == NPROC_CURRENT_OVERRIDABLE) > + { > + /* Test the environment variable OMP_NUM_THREADS, recognized also by > all > + programs that are based on OpenMP. The OpenMP spec says that the > + value assigned to the environment variable "may have leading and > + trailing white space". */ > + const char *envvalue = getenv ("OMP_NUM_THREADS"); > + > + if (envvalue != NULL) > + { > + while (*envvalue != '\0' && c_isspace (*envvalue)) > + envvalue++; A pedantic comment. Could one instead assume strtoul() skips leading whitespace? > + #if HAVE_PTHREAD_AFFINITY_NP && defined __GLIBC__ && 0 > + #elif HAVE_PTHREAD_AFFINITY_NP && defined __NetBSD__ && 0 If you put the "0" first then vim at least will highlight the section as a comment. > *** m4/nproc.m4.orig 2009-11-01 14:55:37.000000000 +0100 > --- m4/nproc.m4 2009-11-01 14:31:13.000000000 +0100 > ! AC_CHECK_FUNCS([sched_getaffinity sched_getaffinity_np \ > ! pstat_getdynamic sysmp sysctl]) > ]) Will this result it a compile failure on glibc-2.3.[23] where sched_getaffinity() has a different prototype? If so it might be nice to not define HAVE_SCHED_GETAFFINITY in that case, or maybe it's not worth worrying about? thanks again, Pádraig.