aboutsummaryrefslogtreecommitdiff
path: root/gcc/system.h
diff options
context:
space:
mode:
authorAlexander Monakov <amonakov@ispras.ru>2017-09-29 19:00:15 +0300
committerAlexander Monakov <amonakov@gcc.gnu.org>2017-09-29 19:00:15 +0300
commit9e686ea1c952dd513cf98c2cec464b3533ba763c (patch)
tree1cfc0484d5e64853823c1322638c2787aa3877ce /gcc/system.h
parentcd644ae2bc0ce62b88f786ce5a68ad0ba2509ec6 (diff)
downloadgcc-9e686ea1c952dd513cf98c2cec464b3533ba763c.zip
gcc-9e686ea1c952dd513cf98c2cec464b3533ba763c.tar.gz
gcc-9e686ea1c952dd513cf98c2cec464b3533ba763c.tar.bz2
qsort comparator consistency checking
* genmodes.c (calc_wider_mode): Suppress qsort macro. * system.h [CHECKING_P] (qsort): Redirect to qsort_chk. (qsort_chk): Declare. * vec.c [CHECKING_P] (qsort_chk_error): New static function. (qsort_chk): New function. From-SVN: r253295
Diffstat (limited to 'gcc/system.h')
-rw-r--r--gcc/system.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/gcc/system.h b/gcc/system.h
index 59449f1..f0664e9 100644
--- a/gcc/system.h
+++ b/gcc/system.h
@@ -1181,4 +1181,14 @@ helper_const_non_const_cast (const char *p)
/* Get definitions of HOST_WIDE_INT. */
#include "hwint.h"
+/* qsort comparator consistency checking: except in release-checking compilers,
+ redirect 4-argument qsort calls to qsort_chk; keep 1-argument invocations
+ corresponding to vec::qsort (cmp): they use C qsort internally anyway. */
+#if CHECKING_P
+#define PP_5th(a1, a2, a3, a4, a5, ...) a5
+#undef qsort
+#define qsort(...) PP_5th (__VA_ARGS__, qsort_chk, 3, 2, qsort, 0) (__VA_ARGS__)
+void qsort_chk (void *, size_t, size_t, int (*)(const void *, const void *));
+#endif
+
#endif /* ! GCC_SYSTEM_H */