[Openmp-commits] [openmp] r250708 - On FreeBSD, PTHREADS_THREADS_MAX does not fit into an int, leading to

Dimitry Andric via Openmp-commits openmp-commits at lists.llvm.org
Mon Oct 19 10:32:04 PDT 2015


Author: dim
Date: Mon Oct 19 12:32:04 2015
New Revision: 250708

URL: http://llvm.org/viewvc/llvm-project?rev=250708&view=rev
Log:
On FreeBSD, PTHREADS_THREADS_MAX does not fit into an int, leading to
warnings similar to the following:

    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
                                     ^~~~~~~~~~~~~~~~~~~

Clamp KMP_MAX_NTH to INT_MAX to avoid these warnings.  Also use INT_MAX
whenever PTHREAD_THREADS_MAX is not defined at all.

Differential Revision: http://reviews.llvm.org/D13827

Modified:
    openmp/trunk/runtime/src/kmp.h

Modified: openmp/trunk/runtime/src/kmp.h
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp.h?rev=250708&r1=250707&r2=250708&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp.h (original)
+++ openmp/trunk/runtime/src/kmp.h Mon Oct 19 12:32:04 2015
@@ -845,10 +845,10 @@ extern int __kmp_place_num_threads_per_c
 #define KMP_MIN_NTH           1
 
 #ifndef KMP_MAX_NTH
-#  ifdef PTHREAD_THREADS_MAX
+#  if defined(PTHREAD_THREADS_MAX) && PTHREAD_THREADS_MAX < INT_MAX
 #    define KMP_MAX_NTH          PTHREAD_THREADS_MAX
 #  else
-#    define KMP_MAX_NTH          (32 * 1024)
+#    define KMP_MAX_NTH          INT_MAX
 #  endif
 #endif /* KMP_MAX_NTH */
 




More information about the Openmp-commits mailing list