This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] libstdc++/71856 Define _GLIBCXX_PARALLEL_ASSERTIONS


On 13/07/16 18:26 +0100, Jonathan Wakely wrote:
This fixes a conflict between how Parallel Mode has always used the
_GLIBCXX_ASSERTIONS macro and the new meaning we gave it for GCC 6
(enabling the lightweight debug checks).

It doesn't make sense for Parallel Mode to own that macro, and it
might be useful to enable Parallel Mode assertions without the other
checks, so I've changed all the Parallel Mode headers to check
_GLIBCXX_PARALLEL_ASSERTIONS instead. If that's not defined then it
defaults to the value of _GLIBCXX_ASSERTIONS, to preserve the old
behaviour.

	PR libstdc++/71856
	* include/bits/c++config (_GLIBCXX_ASSERTIONS): Define to 1 not empty.
	* include/parallel/compiletime_settings.h (_GLIBCXX_ASSERTIONS):
	Rename to _GLIBCXX_PARALLEL_ASSERTIONS and make default value depend
	on _GLIBCXX_ASSERTIONS.
	* include/parallel/balanced_quicksort.h: Rename _GLIBCXX_ASSERTIONS.
	Include <unistd.h> for sleep.
	* include/parallel/losertree.h: Rename _GLIBCXX_ASSERTIONS.
	* include/parallel/merge.h: Likewise.
	* include/parallel/multiway_merge.h: Likewise.
	* include/parallel/partition.h: Likewise.
	* include/parallel/queue.h: Likewise.
	* include/parallel/sort.h: Likewise.
	* testsuite/25_algorithms/headers/algorithm/
	parallel_algorithm_assert.cc: New.

Here is a smaller patch for the gcc-6-branch, which doesn't rename the
macro, but just makes it possible to include <parallel/*> with
_GLIBCXX_DEBUG defined.

Tested x86_64-linux, committed to gcc-5-branch.

commit 41cc05d22def68878d0d1b3ce87d46976098189a
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Tue Jul 19 19:03:04 2016 +0100

    Do not define _GLIBCXX_ASSERTIONS in Parallel Mode
    
    	PR libstdc++/71856
    	* include/bits/c++config (_GLIBCXX_ASSERTIONS): Define to 1 not empty.
    	* include/parallel/balanced_quicksort.h: Include <unistd.h> for sleep.
    	* include/parallel/compiletime_settings.h (_GLIBCXX_ASSERTIONS):
    	Do not define here.

diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config
index 57024e4..4625607 100644
--- a/libstdc++-v3/include/bits/c++config
+++ b/libstdc++-v3/include/bits/c++config
@@ -414,7 +414,7 @@ namespace std
 
 // Debug Mode implies checking assertions.
 #ifdef _GLIBCXX_DEBUG
-# define _GLIBCXX_ASSERTIONS
+# define _GLIBCXX_ASSERTIONS 1
 #endif
 
 // Disable std::string explicit instantiation declarations in order to assert.
diff --git a/libstdc++-v3/include/parallel/balanced_quicksort.h b/libstdc++-v3/include/parallel/balanced_quicksort.h
index 65dec30..16ef1ef 100644
--- a/libstdc++-v3/include/parallel/balanced_quicksort.h
+++ b/libstdc++-v3/include/parallel/balanced_quicksort.h
@@ -53,6 +53,9 @@
 
 #if _GLIBCXX_ASSERTIONS
 #include <parallel/checkers.h>
+#ifdef _GLIBCXX_HAVE_UNISTD_H
+#include <unistd.h>
+#endif
 #endif
 
 namespace __gnu_parallel
diff --git a/libstdc++-v3/include/parallel/compiletime_settings.h b/libstdc++-v3/include/parallel/compiletime_settings.h
index f4fb404..c1758aa 100644
--- a/libstdc++-v3/include/parallel/compiletime_settings.h
+++ b/libstdc++-v3/include/parallel/compiletime_settings.h
@@ -55,12 +55,6 @@
 #define _GLIBCXX_SCALE_DOWN_FPU 0
 #endif
 
-#ifndef _GLIBCXX_ASSERTIONS
-/** @brief Switch on many _GLIBCXX_PARALLEL_ASSERTions in parallel code.
- *  Should be switched on only locally. */
-#define _GLIBCXX_ASSERTIONS 0
-#endif
-
 #ifndef _GLIBCXX_RANDOM_SHUFFLE_CONSIDER_L1
 /** @brief Switch on many _GLIBCXX_PARALLEL_ASSERTions in parallel code.
  *  Consider the size of the L1 cache for

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]