[beast] BIRNET: use startup assertions for float checks, courtesy stw
- From: Tim Janik <timj src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [beast] BIRNET: use startup assertions for float checks, courtesy stw
- Date: Fri, 6 Apr 2012 02:12:35 +0000 (UTC)
commit 2006848c0aa5dd8843d2149a24bcb6a5c40c228c
Author: Tim Janik <timj gnu org>
Date: Fri Apr 6 04:11:23 2012 +0200
BIRNET: use startup assertions for float checks, courtesy stw
birnet/birnetcdefs.h | 2 ++
birnet/birnetutils.cc | 6 +++---
2 files changed, 5 insertions(+), 3 deletions(-)
---
diff --git a/birnet/birnetcdefs.h b/birnet/birnetcdefs.h
index 0cb882c..45e55ba 100644
--- a/birnet/birnetcdefs.h
+++ b/birnet/birnetcdefs.h
@@ -111,6 +111,8 @@ BIRNET_EXTERN_C_BEGIN();
#define BIRNET_CPP_PASTE2(a,b) BIRNET_CPP_PASTE2i (a,b)
#define BIRNET_STATIC_ASSERT_NAMED(expr,asname) typedef struct { char asname[(expr) ? 1 : -1]; } BIRNET_CPP_PASTE2 (Birnet_StaticAssertion_LINE, __LINE__)
#define BIRNET_STATIC_ASSERT(expr) BIRNET_STATIC_ASSERT_NAMED (expr, compile_time_assertion_failed)
+#define BIRNET_STARTUP_ASSERTi(e, _N) namespace { static struct _N { inline _N() { BIRNET_ASSERT (e); } } _N; }
+#define BIRNET_STARTUP_ASSERT(expr) BIRNET_STARTUP_ASSERTi (expr, BIRNET_CPP_PASTE2 (StartupAssertion, __LINE__))
/* --- attributes --- */
#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)
diff --git a/birnet/birnetutils.cc b/birnet/birnetutils.cc
index 529b336..db76031 100644
--- a/birnet/birnetutils.cc
+++ b/birnet/birnetutils.cc
@@ -250,9 +250,9 @@ BIRNET_STATIC_ASSERT (UINT64_MAX == +18446744073709551615LLU);
BIRNET_STATIC_ASSERT (FLT_MIN <= 1E-37);
BIRNET_STATIC_ASSERT (FLT_MAX >= 1E+37);
BIRNET_STATIC_ASSERT (FLT_EPSILON <= 1E-5);
-BIRNET_STATIC_ASSERT (DBL_MIN <= 1E-37);
-BIRNET_STATIC_ASSERT (DBL_MAX >= 1E+37);
-BIRNET_STATIC_ASSERT (DBL_EPSILON <= 1E-9);
+BIRNET_STARTUP_ASSERT (DBL_MIN <= 1E-37);
+BIRNET_STARTUP_ASSERT (DBL_MAX >= 1E+37);
+BIRNET_STARTUP_ASSERT (DBL_EPSILON <= 1E-9);
BIRNET_STATIC_ASSERT (LDBL_MIN <= 1E-37);
BIRNET_STATIC_ASSERT (LDBL_MAX >= 1E+37);
BIRNET_STATIC_ASSERT (LDBL_EPSILON <= 1E-9);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]