lib: validate iterator message packets
[babeltrace.git] / src / common / macros.h
index 533cb9fb56eab9127540004c533b38d86d8c74c1..903219b8779d228aae93efae7a03fc56cba61129 100644 (file)
@@ -29,6 +29,13 @@ extern "C" {
 #define BT_EXPORT __attribute__((visibility("default")))
 #endif
 
+/* Enable `txt` if developer mode is enabled. */
+#ifdef BT_DEV_MODE
+#define BT_IF_DEV_MODE(txt) txt
+#else
+#define BT_IF_DEV_MODE(txt)
+#endif
+
 /*
  * Yield `ref`'s value while setting `ref` to NULL.
  *
@@ -52,6 +59,10 @@ extern "C" {
                _ref;                   \
        })
 
+/* Wrapper for g_array_index that adds bound checking.  */
+#define bt_g_array_index(a, t, i)              \
+       g_array_index((a), t, ({ BT_ASSERT_DBG((i) < (a)->len); (i); }))
+
 /*
  * Copied from:
  * <https://stackoverflow.com/questions/37411809/how-to-elegantly-fix-this-unused-variable-warning/37412551#37412551>:
This page took 0.0258 seconds and 4 git commands to generate.