lib: remove unused _NO_SINK graph status
[babeltrace.git] / include / babeltrace / assert-pre-internal.h
index 74a8b9e2254b6d84d82a679bc8bf6adc9472b39a..e1a57dfe5df1dbecaca3f54cc7c3d0c051e340bf 100644 (file)
@@ -1,8 +1,6 @@
 #ifndef BABELTRACE_ASSERT_PRE_INTERNAL_H
 #define BABELTRACE_ASSERT_PRE_INTERNAL_H
 
-#include <babeltrace/babeltrace-internal.h>
-
 /*
  * Copyright (c) 2018 EfficiOS Inc. and Linux Foundation
  * Copyright (c) 2018 Philippe Proulx <pproulx@efficios.com>
  * <babeltrace/assert-pre-internal.h>, you also need to use logging
  * explicitly.
  */
+
 #ifndef BABELTRACE_LIB_LOGGING_INTERNAL_H
 # error Include <babeltrace/lib-logging-internal.h> before this header.
 #endif
 
 #include <stdlib.h>
+#include <inttypes.h>
+#include <babeltrace/babeltrace-internal.h>
 
 #ifdef BT_DEV_MODE
 /*
@@ -57,7 +58,7 @@
 # define BT_ASSERT_PRE(_cond, _fmt, ...)                               \
        do {                                                            \
                if (!(_cond)) {                                         \
-                       BT_LOGF_STR("Library precondition not satisfied:"); \
+                       BT_LOGF_STR("Library precondition not satisfied; error is:"); \
                        BT_LIB_LOGF((_fmt), ##__VA_ARGS__);             \
                        BT_LOGF_STR("Aborting...");                     \
                        abort();                                        \
        BT_ASSERT_PRE(!(_obj)->frozen, "%s is frozen" _fmt, _obj_name,  \
                ##__VA_ARGS__)
 
+/*
+ * Developer mode: asserts that a given index is less than a given size.
+ */
+#define BT_ASSERT_PRE_VALID_INDEX(_index, _length)                     \
+       BT_ASSERT_PRE((_index) < (_length),                             \
+               "Index is out of bounds: index=%" PRIu64 ", "           \
+               "count=%" PRIu64, (uint64_t) (_index), (uint64_t) (_length))
+
 #endif /* BABELTRACE_ASSERT_PRE_INTERNAL_H */
This page took 0.024086 seconds and 4 git commands to generate.