#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>
#endif
#include <stdlib.h>
+#include <inttypes.h>
+#include <babeltrace/babeltrace-internal.h>
#ifdef BT_DEV_MODE
/*
*/
# define BT_ASSERT_PRE_MSG BT_LIB_LOGF
#else
-# define BT_ASSERT_PRE(_cond, _fmt, ...)
+# define BT_ASSERT_PRE(_cond, _fmt, ...) ((void) sizeof((void) (_cond), 0))
# define BT_ASSERT_PRE_FUNC BT_UNUSED
# define BT_ASSERT_PRE_MSG(_fmt, ...)
#endif /* BT_DEV_MODE */
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 */