On FreeBSD, compiling openmp trunk results in the following warning,
because PTHREADS_THREADS_MAX is 0xffffffffffffffffU there:
runtime/src/kmp_global.c:117:35: warning: implicit conversion from 'unsigned long' to 'int' changes value from 18446744073709551615 to -1 [-Wconstant-conversion]
int __kmp_sys_max_nth = KMP_MAX_NTH;
~~~~~~~~~~~~~~~~~ ^~~~~~~~~~~
runtime/src/kmp.h:849:34: note: expanded from macro 'KMP_MAX_NTH'
# define KMP_MAX_NTH PTHREAD_THREADS_MAX
^~~~~~~~~~~~~~~~~~~
/usr/include/pthread.h:55:31: note: expanded from macro 'PTHREAD_THREADS_MAX'
#define PTHREAD_THREADS_MAX __ULONG_MAX
^~~~~~~~~~~
/usr/include/x86/_limits.h:61:21: note: expanded from macro '__ULONG_MAX'
#define __ULONG_MAX 0xffffffffffffffff /* max for an unsigned long */
^~~~~~~~~~~~~~~~~~
1 warning generated.This patch attempts to avoid it. The first iteration of this patch used
PTHREAD_THREADS_MAX < INT_MAX ? PTHREAD_THREADS_MAX : INT_MAX as the
definition of KMP_MAX_NTH, but Joerg noted that it isn't a constant
expression then, and advised this approach.