From 9326ab68df0a671f63be085cf39d21208f19a20a Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Mon, 11 Jun 2018 16:00:21 -0400 Subject: [PATCH] Fix: freeze field type unconditionally Issue ===== Field types should always be frozen (in both developer or production modes) because they are metadata objects. Currently, they are only frozen in developer mode. Solution ======== Make the bt_field_type_common_freeze() and bt_field_type_freeze() functions always called, not through a macro which is only enabled in developer mode. Known drawbacks =============== Very small performance impact because we're trying to freeze a field type every time bt_field_create() is called, but bt_field_create() is not called often anyway due to field object pooling. The impact could become noticeable eventually if we limit the sizes of object pools. Signed-off-by: Philippe Proulx --- include/babeltrace/ctf-ir/field-types-internal.h | 12 ++---------- lib/ctf-ir/field-types.c | 6 +++--- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/include/babeltrace/ctf-ir/field-types-internal.h b/include/babeltrace/ctf-ir/field-types-internal.h index a15b9c0a..3940b1d4 100644 --- a/include/babeltrace/ctf-ir/field-types-internal.h +++ b/include/babeltrace/ctf-ir/field-types-internal.h @@ -274,14 +274,6 @@ struct bt_field_type_common_string { enum bt_string_encoding encoding; }; -#ifdef BT_DEV_MODE -# define bt_field_type_freeze _bt_field_type_freeze -# define bt_field_type_common_freeze _bt_field_type_common_freeze -#else -# define bt_field_type_freeze(_ft) -# define bt_field_type_common_freeze(_ft) -#endif - typedef struct bt_field_common *(* bt_field_common_create_func)( struct bt_field_type_common *); @@ -620,10 +612,10 @@ enum bt_field_type_id bt_field_type_common_get_type_id( struct bt_field_type_common *ft); BT_HIDDEN -void _bt_field_type_common_freeze(struct bt_field_type_common *ft); +void bt_field_type_common_freeze(struct bt_field_type_common *ft); BT_HIDDEN -void _bt_field_type_freeze(struct bt_field_type *ft); +void bt_field_type_freeze(struct bt_field_type *ft); BT_HIDDEN struct bt_field_type_common * diff --git a/lib/ctf-ir/field-types.c b/lib/ctf-ir/field-types.c index 11764121..a8a41b57 100644 --- a/lib/ctf-ir/field-types.c +++ b/lib/ctf-ir/field-types.c @@ -3431,7 +3431,7 @@ int bt_field_type_is_variant(struct bt_field_type *type) } BT_HIDDEN -void _bt_field_type_common_freeze(struct bt_field_type_common *ft) +void bt_field_type_common_freeze(struct bt_field_type_common *ft) { if (!ft || ft->frozen) { return; @@ -3442,9 +3442,9 @@ void _bt_field_type_common_freeze(struct bt_field_type_common *ft) } BT_HIDDEN -void _bt_field_type_freeze(struct bt_field_type *ft) +void bt_field_type_freeze(struct bt_field_type *ft) { - _bt_field_type_common_freeze((void *) ft); + bt_field_type_common_freeze((void *) ft); } BT_HIDDEN -- 2.34.1