projects
/
babeltrace.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Always evaluate BT_ASSERT(); add BT_ASSERT_DBG() for debug mode only
[babeltrace.git]
/
src
/
ctf-writer
/
object.h
diff --git
a/src/ctf-writer/object.h
b/src/ctf-writer/object.h
index 32317218537339be28901b88dad996df12715e52..70032c2306992ee1f106fbd8fe2d322e9931ee5c 100644
(file)
--- a/
src/ctf-writer/object.h
+++ b/
src/ctf-writer/object.h
@@
-25,7
+25,7
@@
* SOFTWARE.
*/
* SOFTWARE.
*/
-#include "common/
babeltrace
.h"
+#include "common/
macros
.h"
#include "common/assert.h"
#include <stdbool.h>
#include "common/assert.h"
#include <stdbool.h>
@@
-91,16
+91,16
@@
struct bt_ctf_object {
static inline
unsigned long long bt_ctf_object_get_ref_count(struct bt_ctf_object *obj)
{
static inline
unsigned long long bt_ctf_object_get_ref_count(struct bt_ctf_object *obj)
{
- BT_ASSERT(obj);
- BT_ASSERT(obj->is_shared);
+ BT_ASSERT
_DBG
(obj);
+ BT_ASSERT
_DBG
(obj->is_shared);
return obj->ref_count;
}
static inline
struct bt_ctf_object *bt_ctf_object_borrow_parent(struct bt_ctf_object *obj)
{
return obj->ref_count;
}
static inline
struct bt_ctf_object *bt_ctf_object_borrow_parent(struct bt_ctf_object *obj)
{
- BT_ASSERT(obj);
- BT_ASSERT(obj->is_shared);
+ BT_ASSERT
_DBG
(obj);
+ BT_ASSERT
_DBG
(obj->is_shared);
return obj->parent;
}
return obj->parent;
}
@@
-119,11
+119,11
@@
struct bt_ctf_object *bt_ctf_object_get_parent(struct bt_ctf_object *obj)
static inline
void bt_ctf_object_set_parent(struct bt_ctf_object *child, struct bt_ctf_object *parent)
{
static inline
void bt_ctf_object_set_parent(struct bt_ctf_object *child, struct bt_ctf_object *parent)
{
- BT_ASSERT(child);
- BT_ASSERT(child->is_shared);
+ BT_ASSERT
_DBG
(child);
+ BT_ASSERT
_DBG
(child->is_shared);
-#ifdef BT_LOG
V
- BT_LOG
V
("Setting object's parent: addr=%p, parent-addr=%p",
+#ifdef BT_LOG
T
+ BT_LOG
T
("Setting object's parent: addr=%p, parent-addr=%p",
child, parent);
#endif
child, parent);
#endif
@@
-134,7
+134,7
@@
void bt_ctf_object_set_parent(struct bt_ctf_object *child, struct bt_ctf_object
* object's reference count falls to zero.
*/
if (parent) {
* object's reference count falls to zero.
*/
if (parent) {
- BT_ASSERT(!child->parent);
+ BT_ASSERT
_DBG
(!child->parent);
child->parent = parent;
bt_ctf_object_get_no_null_check(parent);
} else {
child->parent = parent;
bt_ctf_object_get_no_null_check(parent);
} else {
@@
-149,9
+149,9
@@
void bt_ctf_object_set_parent(struct bt_ctf_object *child, struct bt_ctf_object
static inline
void bt_ctf_object_try_spec_release(struct bt_ctf_object *obj)
{
static inline
void bt_ctf_object_try_spec_release(struct bt_ctf_object *obj)
{
- BT_ASSERT(obj);
- BT_ASSERT(obj->is_shared);
- BT_ASSERT(obj->spec_release_func);
+ BT_ASSERT
_DBG
(obj);
+ BT_ASSERT
_DBG
(obj->is_shared);
+ BT_ASSERT
_DBG
(obj->spec_release_func);
if (bt_ctf_object_get_ref_count(obj) == 0) {
obj->spec_release_func(obj);
if (bt_ctf_object_get_ref_count(obj) == 0) {
obj->spec_release_func(obj);
@@
-169,8
+169,8
@@
void bt_ctf_object_with_parent_release_func(struct bt_ctf_object *obj)
*/
struct bt_ctf_object *parent = obj->parent;
*/
struct bt_ctf_object *parent = obj->parent;
-#ifdef BT_LOG
V
- BT_LOG
V
("Releasing parented object: addr=%p, ref-count=%llu, "
+#ifdef BT_LOG
T
+ BT_LOG
T
("Releasing parented object: addr=%p, ref-count=%llu, "
"parent-addr=%p, parent-ref-count=%llu",
obj, obj->ref_count,
parent, parent->ref_count);
"parent-addr=%p, parent-ref-count=%llu",
obj, obj->ref_count,
parent, parent->ref_count);
@@
-197,8
+197,8
@@
static inline
void bt_ctf_object_init(struct bt_ctf_object *obj, bool is_shared,
bt_ctf_object_release_func release_func)
{
void bt_ctf_object_init(struct bt_ctf_object *obj, bool is_shared,
bt_ctf_object_release_func release_func)
{
- BT_ASSERT(obj);
- BT_ASSERT(!is_shared || release_func);
+ BT_ASSERT
_DBG
(obj);
+ BT_ASSERT
_DBG
(!is_shared || release_func);
obj->is_shared = is_shared;
obj->release_func = release_func;
obj->parent_is_owner_listener_func = NULL;
obj->is_shared = is_shared;
obj->release_func = release_func;
obj->parent_is_owner_listener_func = NULL;
@@
-224,8
+224,8
@@
static inline
void bt_ctf_object_init_shared_with_parent(struct bt_ctf_object *obj,
bt_ctf_object_release_func spec_release_func)
{
void bt_ctf_object_init_shared_with_parent(struct bt_ctf_object *obj,
bt_ctf_object_release_func spec_release_func)
{
- BT_ASSERT(obj);
- BT_ASSERT(spec_release_func);
+ BT_ASSERT
_DBG
(obj);
+ BT_ASSERT
_DBG
(spec_release_func);
bt_ctf_object_init_shared(obj, bt_ctf_object_with_parent_release_func);
obj->spec_release_func = spec_release_func;
}
bt_ctf_object_init_shared(obj, bt_ctf_object_with_parent_release_func);
obj->spec_release_func = spec_release_func;
}
@@
-234,29
+234,29
@@
static inline
void bt_ctf_object_set_parent_is_owner_listener_func(struct bt_ctf_object *obj,
bt_ctf_object_parent_is_owner_listener_func func)
{
void bt_ctf_object_set_parent_is_owner_listener_func(struct bt_ctf_object *obj,
bt_ctf_object_parent_is_owner_listener_func func)
{
- BT_ASSERT(obj);
- BT_ASSERT(obj->is_shared);
- BT_ASSERT(obj->spec_release_func);
+ BT_ASSERT
_DBG
(obj);
+ BT_ASSERT
_DBG
(obj->is_shared);
+ BT_ASSERT
_DBG
(obj->spec_release_func);
((struct bt_ctf_object *) obj)->parent_is_owner_listener_func = func;
}
static inline
void bt_ctf_object_inc_ref_count(struct bt_ctf_object *obj)
{
((struct bt_ctf_object *) obj)->parent_is_owner_listener_func = func;
}
static inline
void bt_ctf_object_inc_ref_count(struct bt_ctf_object *obj)
{
- BT_ASSERT(obj);
- BT_ASSERT(obj->is_shared);
+ BT_ASSERT
_DBG
(obj);
+ BT_ASSERT
_DBG
(obj->is_shared);
obj->ref_count++;
obj->ref_count++;
- BT_ASSERT(obj->ref_count != 0);
+ BT_ASSERT
_DBG
(obj->ref_count != 0);
}
static inline
void *bt_ctf_object_get_no_null_check_no_parent_check(struct bt_ctf_object *obj)
{
}
static inline
void *bt_ctf_object_get_no_null_check_no_parent_check(struct bt_ctf_object *obj)
{
- BT_ASSERT(obj);
- BT_ASSERT(obj->is_shared);
+ BT_ASSERT
_DBG
(obj);
+ BT_ASSERT
_DBG
(obj->is_shared);
-#ifdef BT_LOG
V
- BT_LOG
V
("Incrementing object's reference count: %llu -> %llu: "
+#ifdef BT_LOG
T
+ BT_LOG
T
("Incrementing object's reference count: %llu -> %llu: "
"addr=%p, cur-count=%llu, new-count=%llu",
obj->ref_count, obj->ref_count + 1,
obj, obj->ref_count, obj->ref_count + 1);
"addr=%p, cur-count=%llu, new-count=%llu",
obj->ref_count, obj->ref_count + 1,
obj, obj->ref_count, obj->ref_count + 1);
@@
-269,20
+269,20
@@
void *bt_ctf_object_get_no_null_check_no_parent_check(struct bt_ctf_object *obj)
static inline
void *bt_ctf_object_get_no_null_check(struct bt_ctf_object *obj)
{
static inline
void *bt_ctf_object_get_no_null_check(struct bt_ctf_object *obj)
{
- BT_ASSERT(obj);
- BT_ASSERT(obj->is_shared);
+ BT_ASSERT
_DBG
(obj);
+ BT_ASSERT
_DBG
(obj->is_shared);
- if (
unlikely
(obj->parent && bt_ctf_object_get_ref_count(obj) == 0)) {
-#ifdef BT_LOG
V
- BT_LOG
V
("Incrementing object's parent's reference count: "
+ if (
G_UNLIKELY
(obj->parent && bt_ctf_object_get_ref_count(obj) == 0)) {
+#ifdef BT_LOG
T
+ BT_LOG
T
("Incrementing object's parent's reference count: "
"addr=%p, parent-addr=%p", obj, obj->parent);
#endif
bt_ctf_object_get_no_null_check(obj->parent);
}
"addr=%p, parent-addr=%p", obj, obj->parent);
#endif
bt_ctf_object_get_no_null_check(obj->parent);
}
-#ifdef BT_LOG
V
- BT_LOG
V
("Incrementing object's reference count: %llu -> %llu: "
+#ifdef BT_LOG
T
+ BT_LOG
T
("Incrementing object's reference count: %llu -> %llu: "
"addr=%p, cur-count=%llu, new-count=%llu",
obj->ref_count, obj->ref_count + 1,
obj, obj->ref_count, obj->ref_count + 1);
"addr=%p, cur-count=%llu, new-count=%llu",
obj->ref_count, obj->ref_count + 1,
obj, obj->ref_count, obj->ref_count + 1);
@@
-295,12
+295,12
@@
void *bt_ctf_object_get_no_null_check(struct bt_ctf_object *obj)
static inline
void bt_ctf_object_put_no_null_check(struct bt_ctf_object *obj)
{
static inline
void bt_ctf_object_put_no_null_check(struct bt_ctf_object *obj)
{
- BT_ASSERT(obj);
- BT_ASSERT(obj->is_shared);
- BT_ASSERT(obj->ref_count > 0);
+ BT_ASSERT
_DBG
(obj);
+ BT_ASSERT
_DBG
(obj->is_shared);
+ BT_ASSERT
_DBG
(obj->ref_count > 0);
-#ifdef BT_LOG
V
- BT_LOG
V
("Decrementing object's reference count: %llu -> %llu: "
+#ifdef BT_LOG
T
+ BT_LOG
T
("Decrementing object's reference count: %llu -> %llu: "
"addr=%p, cur-count=%llu, new-count=%llu",
obj->ref_count, obj->ref_count - 1,
obj, obj->ref_count, obj->ref_count - 1);
"addr=%p, cur-count=%llu, new-count=%llu",
obj->ref_count, obj->ref_count - 1,
obj, obj->ref_count, obj->ref_count - 1);
@@
-309,7
+309,7
@@
void bt_ctf_object_put_no_null_check(struct bt_ctf_object *obj)
obj->ref_count--;
if (obj->ref_count == 0) {
obj->ref_count--;
if (obj->ref_count == 0) {
- BT_ASSERT(obj->release_func);
+ BT_ASSERT
_DBG
(obj->release_func);
obj->release_func(obj);
}
}
obj->release_func(obj);
}
}
This page took
0.034551 seconds
and
4
git commands to generate.