X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=src%2Flib%2Fassert-pre.h;h=138977558f95daf67d542e679ba5a005d0dddc3e;hb=17f3083a0b4d318d3303c8a5bfa63db6a874ec73;hp=03d86de368fd8d5d4f61a15eba644525029fee5f;hpb=6ecdcca3de0dea694cdfb252160c7939f7dc2ef1;p=babeltrace.git diff --git a/src/lib/assert-pre.h b/src/lib/assert-pre.h index 03d86de3..13897755 100644 --- a/src/lib/assert-pre.h +++ b/src/lib/assert-pre.h @@ -116,6 +116,20 @@ "Index is out of bounds: index=%" PRIu64 ", " \ "count=%" PRIu64, (uint64_t) (_index), (uint64_t) (_length)) +/* + * Asserts that the current thread has no error set. + */ +#define BT_ASSERT_PRE_NO_ERROR() \ + do { \ + const struct bt_error *err = bt_current_thread_take_error(); \ + if (err) { \ + bt_current_thread_move_error(err); \ + } \ + BT_ASSERT_PRE(!err, \ + "API function called while current thread has an " \ + "error: function=%s", __func__); \ + } while (0) + #ifdef BT_DEV_MODE /* Developer mode version of BT_ASSERT_PRE_MSG(). */ # define BT_ASSERT_PRE_DEV_MSG(_fmt, ...) \ @@ -146,6 +160,10 @@ # define BT_ASSERT_PRE_DEV_VALID_INDEX(_index, _length) \ BT_ASSERT_PRE_VALID_INDEX((_index), (_length)) +/* Developer mode version of BT_ASSERT_PRE_NO_ERROR(). */ +# define BT_ASSERT_PRE_DEV_NO_ERROR() \ + BT_ASSERT_PRE_NO_ERROR() + /* * Marks a function as being only used within a BT_ASSERT_PRE_DEV() * context. @@ -160,6 +178,7 @@ ((void) sizeof((void) (_obj), (void) (_obj_name), 0)) # define BT_ASSERT_PRE_DEV_VALID_INDEX(_index, _length) \ ((void) sizeof((void) (_index), (void) (_length), 0)) +# define BT_ASSERT_PRE_DEV_NO_ERROR() # define BT_ASSERT_PRE_DEV_FUNC __attribute__((unused)) #endif /* BT_DEV_MODE */