[beast: 2/43] SFI: provide assert_return and assert_return_unreached for BSE_CONVENIENCE
- From: Tim Janik <timj src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [beast: 2/43] SFI: provide assert_return and assert_return_unreached for BSE_CONVENIENCE
- Date: Mon, 26 Jun 2017 23:27:28 +0000 (UTC)
commit 03f97c8a1e857ca1183929a573519db00c6d8795
Author: Tim Janik <timj gnu org>
Date: Sat Jun 24 02:34:35 2017 +0200
SFI: provide assert_return and assert_return_unreached for BSE_CONVENIENCE
Signed-off-by: Tim Janik <timj gnu org>
sfi/bcore.hh | 22 ++++++++++++++++------
1 files changed, 16 insertions(+), 6 deletions(-)
---
diff --git a/sfi/bcore.hh b/sfi/bcore.hh
index d856ceb..857316e 100644
--- a/sfi/bcore.hh
+++ b/sfi/bcore.hh
@@ -2,13 +2,7 @@
#ifndef __BSE_BCORE_HH__
#define __BSE_BCORE_HH__
-#ifdef BSE_CONVENIENCE
-#define RAPICORN_CONVENIENCE BSE_CONVENIENCE
-#endif
#include <rapicorn-core.hh>
-#ifdef RAPICORN_CONVENIENCE
-#undef fatal // avoid easy clashes
-#endif
#include <sfi/glib-extra.hh>
namespace Bse {
@@ -142,6 +136,22 @@ info (const char *format, const Args &...args)
Internal::diagnostic ('I', string_format (format, args...));
}
+// == Assertions ==
+/// Return from the current function if @a cond is unmet and issue an assertion warning.
+#define BSE_ASSERT_RETURN(cond, ...) AIDA_ASSERT_RETURN (cond, __VA_ARGS__)
+/// Return from the current function and issue an assertion warning.
+#define BSE_ASSERT_RETURN_UNREACHED(...) AIDA_ASSERT_RETURN_UNREACHED (__VA_ARGS__)
+#ifdef BSE_CONVENIENCE
+/// Return from the current function if @a cond is unmet and issue an assertion warning.
+#define assert_return(cond, ...) BSE_ASSERT_RETURN (cond, __VA_ARGS__)
+/// Return from the current function and issue an assertion warning.
+#define assert_return_unreached(...) BSE_ASSERT_RETURN_UNREACHED (__VA_ARGS__)
+/// Hint to the compiler to optimize for @a cond == TRUE.
+#define ISLIKELY(cond) BSE_ISLIKELY (cond)
+/// Hint to the compiler to optimize for @a cond == FALSE.
+#define UNLIKELY(cond) BSE_UNLIKELY (cond)
+#endif // BSE_CONVENIENCE
+
} // Bse
#endif // __BSE_BCORE_HH__
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]