summaryrefslogtreecommitdiff
path: root/perl.h
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2021-05-30 11:55:33 -0600
committerKarl Williamson <khw@cpan.org>2021-06-15 07:40:01 -0600
commitbf578026aedea7702aef5f819d8a56da9d959fb2 (patch)
tree3208e090d3f79b02a0776d341ac56c7f3b98d0f7 /perl.h
parent5ab5717f6c5cffd470fe7dd317d88f0dbc20903c (diff)
downloadperl-bf578026aedea7702aef5f819d8a56da9d959fb2.tar.gz
Fix ASSUME definition
Commit 5d5b9c460e2a06563d2b5e35a1a79991460696eb fixed the definition of ASSUME for some purposes, but broke it on Windows. This commit should fix that.
Diffstat (limited to 'perl.h')
-rw-r--r--perl.h47
1 files changed, 23 insertions, 24 deletions
diff --git a/perl.h b/perl.h
index a4be596713..513de1f609 100644
--- a/perl.h
+++ b/perl.h
@@ -3876,42 +3876,41 @@ intrinsic function, see its documents for more details.
=cut
*/
-#ifdef DEBUGGING
-# define ASSUME(x) assert(x)
-# if __has_builtin(__builtin_unreachable)
+#if __has_builtin(__builtin_unreachable)
# define HAS_BUILTIN_UNREACHABLE
-# elif (defined(__GNUC__) && ( __GNUC__ > 4 \
- || __GNUC__ == 4 && __GNUC_MINOR__ >= 5))
+#elif (defined(__GNUC__) && ( __GNUC__ > 4 \
+ || __GNUC__ == 4 && __GNUC_MINOR__ >= 5))
# define HAS_BUILTIN_UNREACHABLE
-# endif
#endif
-#if defined(__sun) || (defined(__hpux) && !defined(__GNUC__))
-# ifndef ASSUME
-# define ASSUME(x) /* ASSUME() generates warnings on Solaris */
-# endif
-# define NOT_REACHED
+#ifdef DEBUGGING
+# define ASSUME(x) assert(x)
+#elif defined(_MSC_VER)
+# define ASSUME(x) __assume(x)
+#elif defined(__ARMCC_VERSION) /* untested */
+# define ASSUME(x) __promise(x)
#elif defined(HAS_BUILTIN_UNREACHABLE)
-# ifndef ASSUME
+ /* Compilers can take the hint from something being unreachable */
# define ASSUME(x) ((x) ? (void) 0 : __builtin_unreachable())
-# endif
+#else
+ /* Not DEBUGGING, so assert() is a no-op, but a random compiler might
+ * define assert() to its own special optimization token so pass it through
+ * to C lib as a last resort */
+# define ASSUME(x) assert(x)
+#endif
+
+#ifdef HAS_BUILTIN_UNREACHABLE
# define NOT_REACHED \
STMT_START { \
ASSUME(!"UNREACHABLE"); __builtin_unreachable(); \
} STMT_END
+# undef HAS_BUILTIN_UNREACHABLE /* Don't leak out this internal symbol */
+#elif ! defined(__GNUC__) && (defined(__sun) || defined(__hpux))
+ /* These just complain that NOT_REACHED isn't reached */
+# define NOT_REACHED
#else
-# if defined(_MSC_VER)
-# define ASSUME(x) __assume(x)
-# elif defined(__ARMCC_VERSION) /* untested */
-# define ASSUME(x) __promise(x)
-# else
- /* a random compiler might define assert to its own special optimization
- * token so pass it through to C lib as a last resort */
-# define ASSUME(x) assert(x)
-# endif
-# define NOT_REACHED ASSUME(!"UNREACHABLE")
+# define NOT_REACHED ASSUME(!"UNREACHABLE")
#endif
-#undef HAS_BUILTIN_UNREACHABLE
/* Some unistd.h's give a prototype for pause() even though
HAS_PAUSE ends up undefined. This causes the #define