Added g_unreachable to explicitly notify the compiler of unreachable code.
authorJoao Matos <joao.matos@xamarin.com>
Wed, 4 Jun 2014 18:37:17 +0000 (19:37 +0100)
committerJoao Matos <joao.matos@xamarin.com>
Wed, 4 Jun 2014 20:09:45 +0000 (21:09 +0100)
eglib/src/glib.h

index 6d6dadff448c31b9b07cf6ab691b0c4f8a6624f1..363a33dfe7d251c9857ebacd559ad8895588da71 100644 (file)
@@ -727,6 +727,14 @@ GUnicodeBreakType   g_unichar_break_type (gunichar c);
 #define G_UNLIKELY(x) (x)
 #endif
 
+#if defined(_MSC_VER)
+#define  eg_unreachable() __assume(0)
+#elif defined(__GNUC__) && ((__GNUC__ > 4) || (__GNUC__ == 4 && (__GNUC_MINOR__ >= 5)))
+#define  eg_unreachable() __builtin_unreachable()
+#else
+#define  eg_unreachable()
+#endif
+
 #define  g_assert(x)     G_STMT_START { if (G_UNLIKELY (!(x))) g_assertion_message ("* Assertion at %s:%d, condition `%s' not met\n", __FILE__, __LINE__, #x);  } G_STMT_END
 #define  g_assert_not_reached() G_STMT_START { g_assertion_message ("* Assertion: should not be reached at %s:%d\n", __FILE__, __LINE__); } G_STMT_END