From: Michael Jeanson Date: Wed, 12 Jun 2019 22:09:37 +0000 (-0400) Subject: Cleanup: remove private babeltrace.h X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=91d8147391efdc4d42cc4e1c171a65c0372a008f Cleanup: remove private babeltrace.h * Remove unused macros * Replace duplicated macros with their glib equivalent * Move the *safe* static inlines to their own header * Namespace the remaining macros and move them to macros.h * Explicitly include 'common/macros.h' in all private headers that use 'BT_HIDDEN'. * Remove BT_UNUSED, the attribute is a hard requirement anyway * Remove zmalloc and replace the only callsite with calloc Change-Id: I1bd765ad27c808c8bbe5ef232062267cb4a230d9 Signed-off-by: Michael Jeanson Reviewed-on: https://review.lttng.org/c/babeltrace/+/1424 Tested-by: jenkins Reviewed-by: Philippe Proulx --- diff --git a/src/cli/babeltrace2-cfg-cli-args-connect.c b/src/cli/babeltrace2-cfg-cli-args-connect.c index 7e1657e0..7f2ff92b 100644 --- a/src/cli/babeltrace2-cfg-cli-args-connect.c +++ b/src/cli/babeltrace2-cfg-cli-args-connect.c @@ -20,7 +20,9 @@ * SOFTWARE. */ +#include #include +#include #include #include "common/common.h" #include "babeltrace2-cfg.h" diff --git a/src/common/Makefile.am b/src/common/Makefile.am index 1a73672f..7db98d7a 100644 --- a/src/common/Makefile.am +++ b/src/common/Makefile.am @@ -12,9 +12,10 @@ libbabeltrace2_common_la_SOURCES = \ noinst_HEADERS = \ align.h \ - babeltrace.h \ list.h \ + macros.h \ mmap-align.h \ + safe.h \ version.h \ version.i diff --git a/src/common/assert.c b/src/common/assert.c index 056e2f26..c4a18c4e 100644 --- a/src/common/assert.c +++ b/src/common/assert.c @@ -20,6 +20,8 @@ * SOFTWARE. */ +#include + #include "common/assert.h" #include "common/common.h" diff --git a/src/common/assert.h b/src/common/assert.h index 27fdeadb..e24231a9 100644 --- a/src/common/assert.h +++ b/src/common/assert.h @@ -25,7 +25,9 @@ */ #include -#include "common/babeltrace.h" +#include + +#include "common/macros.h" #ifdef BT_DEBUG_MODE @@ -41,7 +43,7 @@ extern void bt_common_assert_failed(const char *file, int line, do { \ if (!(_cond)) { \ bt_common_assert_failed(__FILE__, __LINE__, __func__, \ - TOSTRING(_cond)); \ + G_STRINGIFY(_cond)); \ } \ } while (0) @@ -61,7 +63,7 @@ extern void bt_common_assert_failed(const char *file, int line, * In-depth explanation: https://stackoverflow.com/questions/37411809/how-to-elegantly-fix-this-unused-variable-warning/37412551#37412551 */ # define BT_ASSERT(_cond) ((void) sizeof((void) (_cond), 0)) -# define BT_ASSERT_FUNC BT_UNUSED +# define BT_ASSERT_FUNC __attribute__((unused)) #endif /* BT_DEBUG_MODE */ #endif /* BABELTRACE_ASSERT_INTERNAL_H */ diff --git a/src/common/babeltrace.h b/src/common/babeltrace.h deleted file mode 100644 index 49dfb1b3..00000000 --- a/src/common/babeltrace.h +++ /dev/null @@ -1,121 +0,0 @@ -#ifndef _BABELTRACE_INTERNAL_H -#define _BABELTRACE_INTERNAL_H - -/* - * Copyright 2012 - Mathieu Desnoyers - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include -#include -#include -#include -#include -#include -#include "compat/string.h" -#include - -#define PERROR_BUFLEN 200 - -#ifndef likely -# ifdef __GNUC__ -# define likely(x) __builtin_expect(!!(x), 1) -# else -# define likely(x) (!!(x)) -# endif -#endif - -#ifndef unlikely -# ifdef __GNUC__ -# define unlikely(x) __builtin_expect(!!(x), 0) -# else -# define unlikely(x) (!!(x)) -# endif -#endif - -#ifndef min -#define min(a, b) (((a) < (b)) ? (a) : (b)) -#endif - -#ifndef max -#define max(a, b) (((a) > (b)) ? (a) : (b)) -#endif - -#ifndef max_t -#define max_t(type, a, b) \ - ((type) (a) > (type) (b) ? (type) (a) : (type) (b)) -#endif - -static inline -bool bt_safe_to_mul_int64(int64_t a, int64_t b) -{ - if (a == 0 || b == 0) { - return true; - } - - return a < INT64_MAX / b; -} - -static inline -bool bt_safe_to_mul_uint64(uint64_t a, uint64_t b) -{ - if (a == 0 || b == 0) { - return true; - } - - return a < UINT64_MAX / b; -} - -static inline -bool bt_safe_to_add_int64(int64_t a, int64_t b) -{ - return a <= INT64_MAX - b; -} - -static inline -bool bt_safe_to_add_uint64(uint64_t a, uint64_t b) -{ - return a <= UINT64_MAX - b; -} - -/* - * Memory allocation zeroed - */ -#define zmalloc(x) calloc(1, x) - -/* - * BT_HIDDEN: set the hidden attribute for internal functions - * On Windows, symbols are local unless explicitly exported, - * see https://gcc.gnu.org/wiki/Visibility - */ -#if defined(_WIN32) || defined(__CYGWIN__) -#define BT_HIDDEN -#else -#define BT_HIDDEN __attribute__((visibility("hidden"))) -#endif - -#ifndef __STRINGIFY -#define __STRINGIFY(x) #x -#endif - -#define TOSTRING(x) __STRINGIFY(x) - -#define BT_UNUSED __attribute__((unused)) - -#endif diff --git a/src/common/common.c b/src/common/common.c index f37bec41..a81f8e79 100644 --- a/src/common/common.c +++ b/src/common/common.c @@ -39,7 +39,7 @@ #include #include #include -#include "common/babeltrace.h" +#include "common/macros.h" #include "common/common.h" #include "compat/unistd.h" diff --git a/src/common/common.h b/src/common/common.h index 13dbaf49..d5f2d096 100644 --- a/src/common/common.h +++ b/src/common/common.h @@ -24,19 +24,24 @@ * SOFTWARE. */ -#include -#include "common/assert.h" -#include "common/babeltrace.h" -#include -#include -#include -#include -#include +#include +#include #include #include +#include #include +#include #include -#include + +#include +#include +#include +#include +#include + +#include "common/assert.h" +#include "common/macros.h" +#include "common/safe.h" #define BT_COMMON_COLOR_RESET "\033[0m" #define BT_COMMON_COLOR_BOLD "\033[1m" diff --git a/src/common/macros.h b/src/common/macros.h new file mode 100644 index 00000000..23d4b310 --- /dev/null +++ b/src/common/macros.h @@ -0,0 +1,41 @@ +#ifndef _BABELTRACE_INTERNAL_H +#define _BABELTRACE_INTERNAL_H + +/* + * Copyright 2012 Mathieu Desnoyers + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + + +#define bt_max_t(type, a, b) \ + ((type) (a) > (type) (b) ? (type) (a) : (type) (b)) + +/* + * BT_HIDDEN: set the hidden attribute for internal functions + * On Windows, symbols are local unless explicitly exported, + * see https://gcc.gnu.org/wiki/Visibility + */ +#if defined(_WIN32) || defined(__CYGWIN__) +#define BT_HIDDEN +#else +#define BT_HIDDEN __attribute__((visibility("hidden"))) +#endif + +#endif diff --git a/src/common/safe.h b/src/common/safe.h new file mode 100644 index 00000000..26df90a4 --- /dev/null +++ b/src/common/safe.h @@ -0,0 +1,35 @@ + +#include +#include + +static inline +bool bt_safe_to_mul_int64(int64_t a, int64_t b) +{ + if (a == 0 || b == 0) { + return true; + } + + return a < INT64_MAX / b; +} + +static inline +bool bt_safe_to_mul_uint64(uint64_t a, uint64_t b) +{ + if (a == 0 || b == 0) { + return true; + } + + return a < UINT64_MAX / b; +} + +static inline +bool bt_safe_to_add_int64(int64_t a, int64_t b) +{ + return a <= INT64_MAX - b; +} + +static inline +bool bt_safe_to_add_uint64(uint64_t a, uint64_t b) +{ + return a <= UINT64_MAX - b; +} diff --git a/src/compat/mman.c b/src/compat/mman.c index d0cea9df..aa319980 100644 --- a/src/compat/mman.c +++ b/src/compat/mman.c @@ -29,6 +29,8 @@ #define BT_LOG_TAG "COMPAT-MMAN" #include "logging.h" +#include "common/macros.h" + #ifdef __APPLE__ /* * On macOS, we need a dummy symbol so that the linker won't diff --git a/src/ctf-writer/assert-pre.h b/src/ctf-writer/assert-pre.h index 8f66d514..5811d7d4 100644 --- a/src/ctf-writer/assert-pre.h +++ b/src/ctf-writer/assert-pre.h @@ -43,7 +43,7 @@ #include #include -#include "common/babeltrace.h" +#include "common/macros.h" #ifdef BT_DEV_MODE /* @@ -100,7 +100,7 @@ # define BT_CTF_ASSERT_PRE_MSG BT_LOGF #else # define BT_CTF_ASSERT_PRE(_cond, _fmt, ...) ((void) sizeof((void) (_cond), 0)) -# define BT_CTF_ASSERT_PRE_FUNC BT_UNUSED +# define BT_CTF_ASSERT_PRE_FUNC __attribute__((unused)) # define BT_CTF_ASSERT_PRE_MSG(_fmt, ...) #endif /* BT_DEV_MODE */ diff --git a/src/ctf-writer/attributes.c b/src/ctf-writer/attributes.c index e79dc58f..961879e4 100644 --- a/src/ctf-writer/attributes.c +++ b/src/ctf-writer/attributes.c @@ -29,7 +29,7 @@ #include "logging.h" #include "common/assert.h" -#include "common/babeltrace.h" +#include "common/macros.h" #include "compat/string.h" #include #include diff --git a/src/ctf-writer/attributes.h b/src/ctf-writer/attributes.h index a9906533..47dc0471 100644 --- a/src/ctf-writer/attributes.h +++ b/src/ctf-writer/attributes.h @@ -29,7 +29,7 @@ extern "C" { #endif #include -#include "common/babeltrace.h" +#include "common/macros.h" #include "values.h" diff --git a/src/ctf-writer/clock-class.h b/src/ctf-writer/clock-class.h index d3175085..b7bd7014 100644 --- a/src/ctf-writer/clock-class.h +++ b/src/ctf-writer/clock-class.h @@ -25,7 +25,7 @@ * SOFTWARE. */ -#include "common/babeltrace.h" +#include "common/macros.h" #include "lib/object-pool.h" #include "compat/uuid.h" #include diff --git a/src/ctf-writer/clock.h b/src/ctf-writer/clock.h index f510d736..d38d8ea5 100644 --- a/src/ctf-writer/clock.h +++ b/src/ctf-writer/clock.h @@ -24,7 +24,7 @@ */ #include -#include "common/babeltrace.h" +#include "common/macros.h" #include #include "compat/uuid.h" diff --git a/src/ctf-writer/event-class.h b/src/ctf-writer/event-class.h index c5ebb85f..e37e754d 100644 --- a/src/ctf-writer/event-class.h +++ b/src/ctf-writer/event-class.h @@ -26,7 +26,7 @@ */ #include "common/assert.h" -#include "common/babeltrace.h" +#include "common/macros.h" #include #include #include diff --git a/src/ctf-writer/event.h b/src/ctf-writer/event.h index 1a8138ab..69077a84 100644 --- a/src/ctf-writer/event.h +++ b/src/ctf-writer/event.h @@ -29,7 +29,7 @@ */ #include "common/assert.h" -#include "common/babeltrace.h" +#include "common/macros.h" #include #include #include diff --git a/src/ctf-writer/field-path.h b/src/ctf-writer/field-path.h index cf9edd3f..76d3793e 100644 --- a/src/ctf-writer/field-path.h +++ b/src/ctf-writer/field-path.h @@ -28,6 +28,7 @@ #include "common/common.h" #include "common/assert.h" +#include "common/macros.h" #include #include diff --git a/src/ctf-writer/field-types.h b/src/ctf-writer/field-types.h index e1f75fd6..89fbf97e 100644 --- a/src/ctf-writer/field-types.h +++ b/src/ctf-writer/field-types.h @@ -34,7 +34,7 @@ #include #include -#include "common/babeltrace.h" +#include "common/macros.h" #include "assert-pre.h" #include "clock-class.h" diff --git a/src/ctf-writer/field-wrapper.h b/src/ctf-writer/field-wrapper.h index 55aee6cf..a146a451 100644 --- a/src/ctf-writer/field-wrapper.h +++ b/src/ctf-writer/field-wrapper.h @@ -23,7 +23,7 @@ * SOFTWARE. */ -#include "common/babeltrace.h" +#include "common/macros.h" #include "fields.h" #include "object.h" diff --git a/src/ctf-writer/fields.c b/src/ctf-writer/fields.c index 832f8f2c..11f649cd 100644 --- a/src/ctf-writer/fields.c +++ b/src/ctf-writer/fields.c @@ -908,7 +908,7 @@ int bt_ctf_field_integer_serialize(struct bt_ctf_field_common *field, LITTLE_ENDIAN : BIG_ENDIAN); } - if (unlikely(ret)) { + if (G_UNLIKELY(ret)) { BT_LOGE("Cannot serialize integer field: ret=%d", ret); goto end; } @@ -966,7 +966,7 @@ int bt_ctf_field_floating_point_serialize(struct bt_ctf_field_common *field, abort(); } - if (unlikely(ret)) { + if (G_UNLIKELY(ret)) { BT_LOGE("Cannot serialize floating point number field: " "ret=%d", ret); goto end; @@ -989,7 +989,7 @@ int bt_ctf_field_structure_serialize_recursive(struct bt_ctf_field_common *field field, bt_ctf_byte_order_string(native_byte_order)); ret = bt_ctfser_align_offset_in_current_packet(ctfser, field->type->alignment); - if (unlikely(ret)) { + if (G_UNLIKELY(ret)) { BT_LOGE("Cannot align offset before serializing structure field: " "ret=%d", ret); goto end; @@ -1005,7 +1005,7 @@ int bt_ctf_field_structure_serialize_recursive(struct bt_ctf_field_common *field bt_ctfser_get_offset_in_current_packet_bits(ctfser), member, i); - if (unlikely(!member)) { + if (G_UNLIKELY(!member)) { ret = bt_ctf_field_type_common_structure_borrow_field_by_index( field->type, &field_name, NULL, i); BT_ASSERT(ret == 0); @@ -1019,7 +1019,7 @@ int bt_ctf_field_structure_serialize_recursive(struct bt_ctf_field_common *field ret = bt_ctf_field_serialize_recursive((void *) member, ctfser, native_byte_order); - if (unlikely(ret)) { + if (G_UNLIKELY(ret)) { ret = bt_ctf_field_type_common_structure_borrow_field_by_index( field->type, &field_name, NULL, i); BT_ASSERT(ret == 0); @@ -1071,7 +1071,7 @@ int bt_ctf_field_array_serialize_recursive(struct bt_ctf_field_common *field, elem_field, i); ret = bt_ctf_field_serialize_recursive( (void *) elem_field, ctfser, native_byte_order); - if (unlikely(ret)) { + if (G_UNLIKELY(ret)) { BT_LOGW("Cannot serialize array field's element field: " "array-field-addr=%p, field-addr=%p, " "index=%" PRId64, field, elem_field, i); @@ -1105,7 +1105,7 @@ int bt_ctf_field_sequence_serialize_recursive(struct bt_ctf_field_common *field, elem_field, i); ret = bt_ctf_field_serialize_recursive( (void *) elem_field, ctfser, native_byte_order); - if (unlikely(ret)) { + if (G_UNLIKELY(ret)) { BT_LOGW("Cannot serialize sequence field's element field: " "sequence-field-addr=%p, field-addr=%p, " "index=%" PRId64, field, elem_field, i); @@ -1129,7 +1129,7 @@ int bt_ctf_field_string_serialize(struct bt_ctf_field_common *field, BT_LOGV("Serializing string field: addr=%p, native-bo=%s", field, bt_ctf_byte_order_string((int) native_byte_order)); ret = bt_ctfser_write_string(ctfser, (const char *) string->buf->data); - if (unlikely(ret)) { + if (G_UNLIKELY(ret)) { BT_LOGE("Cannot serialize string field: ret=%d", ret); goto end; } diff --git a/src/ctf-writer/fields.h b/src/ctf-writer/fields.h index b1525e46..9cba266d 100644 --- a/src/ctf-writer/fields.h +++ b/src/ctf-writer/fields.h @@ -38,7 +38,7 @@ #include #include -#include "common/babeltrace.h" +#include "common/macros.h" #include "common/common.h" #include "ctfser/ctfser.h" @@ -393,7 +393,7 @@ int bt_ctf_field_common_sequence_set_length(struct bt_ctf_field_common *field, length); BT_CTF_ASSERT_PRE_CTF_FIELD_COMMON_HOT(field, "Sequence field"); - if (unlikely(length > sequence->elements->len)) { + if (G_UNLIKELY(length > sequence->elements->len)) { /* Make more room */ struct bt_ctf_field_type_common_sequence *sequence_ft; uint64_t cur_len = sequence->elements->len; @@ -656,7 +656,7 @@ int bt_ctf_field_common_string_append_len(struct bt_ctf_field_common *field, new_size = string_field->size + length; - if (unlikely(new_size + 1 > string_field->buf->len)) { + if (G_UNLIKELY(new_size + 1 > string_field->buf->len)) { g_array_set_size(string_field->buf, new_size + 1); } diff --git a/src/ctf-writer/functor.h b/src/ctf-writer/functor.h index 628f63ca..5a289371 100644 --- a/src/ctf-writer/functor.h +++ b/src/ctf-writer/functor.h @@ -26,7 +26,7 @@ */ #include -#include "common/babeltrace.h" +#include "common/macros.h" BT_HIDDEN void value_exists(gpointer element, gpointer search_query); diff --git a/src/ctf-writer/object.c b/src/ctf-writer/object.c index 616fcf36..db799082 100644 --- a/src/ctf-writer/object.c +++ b/src/ctf-writer/object.c @@ -24,7 +24,7 @@ void *bt_ctf_object_get_ref(void *obj) { - if (unlikely(!obj)) { + if (G_UNLIKELY(!obj)) { goto end; } @@ -36,7 +36,7 @@ end: void bt_ctf_object_put_ref(void *obj) { - if (unlikely(!obj)) { + if (G_UNLIKELY(!obj)) { return; } diff --git a/src/ctf-writer/object.h b/src/ctf-writer/object.h index 32317218..00356547 100644 --- a/src/ctf-writer/object.h +++ b/src/ctf-writer/object.h @@ -25,7 +25,7 @@ * SOFTWARE. */ -#include "common/babeltrace.h" +#include "common/macros.h" #include "common/assert.h" #include @@ -272,7 +272,7 @@ void *bt_ctf_object_get_no_null_check(struct bt_ctf_object *obj) BT_ASSERT(obj); BT_ASSERT(obj->is_shared); - if (unlikely(obj->parent && bt_ctf_object_get_ref_count(obj) == 0)) { + if (G_UNLIKELY(obj->parent && bt_ctf_object_get_ref_count(obj) == 0)) { #ifdef BT_LOGV BT_LOGV("Incrementing object's parent's reference count: " "addr=%p, parent-addr=%p", obj, obj->parent); diff --git a/src/ctf-writer/resolve.c b/src/ctf-writer/resolve.c index 6e9e2006..fd59c873 100644 --- a/src/ctf-writer/resolve.c +++ b/src/ctf-writer/resolve.c @@ -41,7 +41,7 @@ #include #include -#include "common/babeltrace.h" +#include "common/macros.h" #include "common/assert.h" #include "field-path.h" diff --git a/src/ctf-writer/resolve.h b/src/ctf-writer/resolve.h index f153d1c9..930b22c4 100644 --- a/src/ctf-writer/resolve.h +++ b/src/ctf-writer/resolve.h @@ -28,7 +28,7 @@ */ #include -#include "common/babeltrace.h" +#include "common/macros.h" #include #include "field-types.h" diff --git a/src/ctf-writer/stream-class.h b/src/ctf-writer/stream-class.h index c008a1fa..f7fc4dbb 100644 --- a/src/ctf-writer/stream-class.h +++ b/src/ctf-writer/stream-class.h @@ -29,7 +29,7 @@ */ #include "common/assert.h" -#include "common/babeltrace.h" +#include "common/macros.h" #include "common/common.h" #include #include diff --git a/src/ctf-writer/stream.h b/src/ctf-writer/stream.h index 8c3d7d7c..253fb606 100644 --- a/src/ctf-writer/stream.h +++ b/src/ctf-writer/stream.h @@ -29,7 +29,7 @@ */ #include "common/assert.h" -#include "common/babeltrace.h" +#include "common/macros.h" #include #include "ctfser/ctfser.h" #include diff --git a/src/ctf-writer/trace.h b/src/ctf-writer/trace.h index ae5f1ec3..ca6328fb 100644 --- a/src/ctf-writer/trace.h +++ b/src/ctf-writer/trace.h @@ -28,7 +28,7 @@ * http://www.efficios.com/ctf */ -#include "common/babeltrace.h" +#include "common/macros.h" #include "compat/uuid.h" #include #include diff --git a/src/ctf-writer/utils.h b/src/ctf-writer/utils.h index 488251ce..6cb0609a 100644 --- a/src/ctf-writer/utils.h +++ b/src/ctf-writer/utils.h @@ -21,7 +21,7 @@ * SOFTWARE. */ -#include "common/babeltrace.h" +#include "common/macros.h" #include #include #include diff --git a/src/ctf-writer/validation.c b/src/ctf-writer/validation.c index 1d50d4d6..6522f865 100644 --- a/src/ctf-writer/validation.c +++ b/src/ctf-writer/validation.c @@ -29,7 +29,7 @@ #include -#include "common/babeltrace.h" +#include "common/macros.h" #include "assert-pre.h" #include "event-class.h" diff --git a/src/ctf-writer/validation.h b/src/ctf-writer/validation.h index 18e6ff7e..ccedba25 100644 --- a/src/ctf-writer/validation.h +++ b/src/ctf-writer/validation.h @@ -23,7 +23,7 @@ * SOFTWARE. */ -#include "common/babeltrace.h" +#include "common/macros.h" #include "values.h" diff --git a/src/ctf-writer/values.h b/src/ctf-writer/values.h index b9137ef9..08b0fbcf 100644 --- a/src/ctf-writer/values.h +++ b/src/ctf-writer/values.h @@ -24,7 +24,9 @@ * SOFTWARE. */ -#include "common/babeltrace.h" +#include + +#include "common/macros.h" struct bt_ctf_value; struct bt_ctf_private_value; diff --git a/src/ctf-writer/visitor.c b/src/ctf-writer/visitor.c index 6cb5bab4..ca943f87 100644 --- a/src/ctf-writer/visitor.c +++ b/src/ctf-writer/visitor.c @@ -28,7 +28,7 @@ #include -#include "common/babeltrace.h" +#include "common/macros.h" #include "visitor.h" diff --git a/src/ctf-writer/visitor.h b/src/ctf-writer/visitor.h index 549285e2..51216117 100644 --- a/src/ctf-writer/visitor.h +++ b/src/ctf-writer/visitor.h @@ -25,8 +25,9 @@ * SOFTWARE. */ +#include #include -#include "common/babeltrace.h" +#include "common/macros.h" typedef void *(*bt_ctf_child_accessor)(void *object, int index); typedef int64_t (*bt_ctf_child_count_accessor)(void *object); diff --git a/src/ctf-writer/writer.h b/src/ctf-writer/writer.h index 37e6a58a..15b08856 100644 --- a/src/ctf-writer/writer.h +++ b/src/ctf-writer/writer.h @@ -32,7 +32,7 @@ #include #include -#include "common/babeltrace.h" +#include "common/macros.h" #include "object.h" diff --git a/src/ctfser/ctfser.c b/src/ctfser/ctfser.c index 62032469..9e970f19 100644 --- a/src/ctfser/ctfser.c +++ b/src/ctfser/ctfser.c @@ -37,7 +37,7 @@ #include #include #include -#include "common/babeltrace.h" +#include "common/macros.h" #include "common/common.h" #include "ctfser/ctfser.h" #include "compat/unistd.h" diff --git a/src/ctfser/ctfser.h b/src/ctfser/ctfser.h index c270faf9..c59af924 100644 --- a/src/ctfser/ctfser.h +++ b/src/ctfser/ctfser.h @@ -41,6 +41,7 @@ #include "common/mmap-align.h" #include #include "common/assert.h" +#include "common/macros.h" #include "compat/bitfield.h" #include @@ -140,13 +141,13 @@ bool _bt_ctfser_has_space_left(struct bt_ctfser *ctfser, uint64_t size_bits) { bool has_space_left = true; - if (unlikely((ctfser->offset_in_cur_packet_bits + size_bits > + if (G_UNLIKELY((ctfser->offset_in_cur_packet_bits + size_bits > _bt_ctfser_cur_packet_size_bits(ctfser)))) { has_space_left = false; goto end; } - if (unlikely(size_bits > UINT64_MAX - ctfser->offset_in_cur_packet_bits)) { + if (G_UNLIKELY(size_bits > UINT64_MAX - ctfser->offset_in_cur_packet_bits)) { has_space_left = false; goto end; } @@ -177,9 +178,9 @@ int bt_ctfser_align_offset_in_current_packet(struct bt_ctfser *ctfser, align_size_bits = ALIGN(ctfser->offset_in_cur_packet_bits, alignment_bits) - ctfser->offset_in_cur_packet_bits; - if (unlikely(!_bt_ctfser_has_space_left(ctfser, align_size_bits))) { + if (G_UNLIKELY(!_bt_ctfser_has_space_left(ctfser, align_size_bits))) { ret = _bt_ctfser_increase_cur_packet_size(ctfser); - if (unlikely(ret)) { + if (G_UNLIKELY(ret)) { goto end; } } @@ -328,20 +329,20 @@ int bt_ctfser_write_byte_aligned_unsigned_int(struct bt_ctfser *ctfser, BT_ASSERT(alignment_bits % 8 == 0); ret = bt_ctfser_align_offset_in_current_packet(ctfser, alignment_bits); - if (unlikely(ret)) { + if (G_UNLIKELY(ret)) { goto end; } - if (unlikely(!_bt_ctfser_has_space_left(ctfser, size_bits))) { + if (G_UNLIKELY(!_bt_ctfser_has_space_left(ctfser, size_bits))) { ret = _bt_ctfser_increase_cur_packet_size(ctfser); - if (unlikely(ret)) { + if (G_UNLIKELY(ret)) { goto end; } } ret = _bt_ctfser_write_byte_aligned_unsigned_int_no_align(ctfser, value, size_bits, byte_order); - if (unlikely(ret)) { + if (G_UNLIKELY(ret)) { goto end; } @@ -363,20 +364,20 @@ int bt_ctfser_write_byte_aligned_signed_int(struct bt_ctfser *ctfser, BT_ASSERT(alignment_bits % 8 == 0); ret = bt_ctfser_align_offset_in_current_packet(ctfser, alignment_bits); - if (unlikely(ret)) { + if (G_UNLIKELY(ret)) { goto end; } - if (unlikely(!_bt_ctfser_has_space_left(ctfser, size_bits))) { + if (G_UNLIKELY(!_bt_ctfser_has_space_left(ctfser, size_bits))) { ret = _bt_ctfser_increase_cur_packet_size(ctfser); - if (unlikely(ret)) { + if (G_UNLIKELY(ret)) { goto end; } } ret = _bt_ctfser_write_byte_aligned_signed_int_no_align(ctfser, value, size_bits, byte_order); - if (unlikely(ret)) { + if (G_UNLIKELY(ret)) { goto end; } @@ -396,13 +397,13 @@ int bt_ctfser_write_unsigned_int(struct bt_ctfser *ctfser, uint64_t value, int ret = 0; ret = bt_ctfser_align_offset_in_current_packet(ctfser, alignment_bits); - if (unlikely(ret)) { + if (G_UNLIKELY(ret)) { goto end; } - if (unlikely(!_bt_ctfser_has_space_left(ctfser, size_bits))) { + if (G_UNLIKELY(!_bt_ctfser_has_space_left(ctfser, size_bits))) { ret = _bt_ctfser_increase_cur_packet_size(ctfser); - if (unlikely(ret)) { + if (G_UNLIKELY(ret)) { goto end; } } @@ -441,13 +442,13 @@ int bt_ctfser_write_signed_int(struct bt_ctfser *ctfser, int64_t value, int ret = 0; ret = bt_ctfser_align_offset_in_current_packet(ctfser, alignment_bits); - if (unlikely(ret)) { + if (G_UNLIKELY(ret)) { goto end; } - if (unlikely(!_bt_ctfser_has_space_left(ctfser, size_bits))) { + if (G_UNLIKELY(!_bt_ctfser_has_space_left(ctfser, size_bits))) { ret = _bt_ctfser_increase_cur_packet_size(ctfser); - if (unlikely(ret)) { + if (G_UNLIKELY(ret)) { goto end; } } @@ -521,14 +522,14 @@ int bt_ctfser_write_string(struct bt_ctfser *ctfser, const char *value) const char *at = value; ret = bt_ctfser_align_offset_in_current_packet(ctfser, 8); - if (unlikely(ret)) { + if (G_UNLIKELY(ret)) { goto end; } while (true) { - if (unlikely(!_bt_ctfser_has_space_left(ctfser, 8))) { + if (G_UNLIKELY(!_bt_ctfser_has_space_left(ctfser, 8))) { ret = _bt_ctfser_increase_cur_packet_size(ctfser); - if (unlikely(ret)) { + if (G_UNLIKELY(ret)) { goto end; } } @@ -536,7 +537,7 @@ int bt_ctfser_write_string(struct bt_ctfser *ctfser, const char *value) memcpy(_bt_ctfser_get_addr(ctfser), at, sizeof(*at)); _bt_ctfser_incr_offset(ctfser, 8); - if (unlikely(*at == '\0')) { + if (G_UNLIKELY(*at == '\0')) { break; } diff --git a/src/fd-cache/fd-cache.h b/src/fd-cache/fd-cache.h index fb70a076..977aaf4d 100644 --- a/src/fd-cache/fd-cache.h +++ b/src/fd-cache/fd-cache.h @@ -28,7 +28,7 @@ * SOFTWARE. */ -#include "common/babeltrace.h" +#include "common/macros.h" struct bt_fd_cache_handle { int fd; diff --git a/src/lib/assert-pre.h b/src/lib/assert-pre.h index 6264c8ac..c28ec4c4 100644 --- a/src/lib/assert-pre.h +++ b/src/lib/assert-pre.h @@ -43,7 +43,7 @@ #include #include -#include "common/babeltrace.h" +#include "common/macros.h" #ifdef BT_DEV_MODE /* @@ -100,7 +100,7 @@ # define BT_ASSERT_PRE_MSG BT_LIB_LOGF #else # define BT_ASSERT_PRE(_cond, _fmt, ...) ((void) sizeof((void) (_cond), 0)) -# define BT_ASSERT_PRE_FUNC BT_UNUSED +# define BT_ASSERT_PRE_FUNC __attribute__((unused)) # define BT_ASSERT_PRE_MSG(_fmt, ...) #endif /* BT_DEV_MODE */ diff --git a/src/lib/graph/component-class.h b/src/lib/graph/component-class.h index 1c49a769..b1e60f0f 100644 --- a/src/lib/graph/component-class.h +++ b/src/lib/graph/component-class.h @@ -31,7 +31,7 @@ #include #include #include -#include "common/babeltrace.h" +#include "common/macros.h" #include "lib/object.h" #include "common/list.h" #include diff --git a/src/lib/graph/component-filter.h b/src/lib/graph/component-filter.h index 7d5a792e..194bab0f 100644 --- a/src/lib/graph/component-filter.h +++ b/src/lib/graph/component-filter.h @@ -24,7 +24,7 @@ * SOFTWARE. */ -#include "common/babeltrace.h" +#include "common/macros.h" #include #include "component-class.h" diff --git a/src/lib/graph/component-sink.h b/src/lib/graph/component-sink.h index a6706351..7eaff9af 100644 --- a/src/lib/graph/component-sink.h +++ b/src/lib/graph/component-sink.h @@ -24,7 +24,7 @@ * SOFTWARE. */ -#include "common/babeltrace.h" +#include "common/macros.h" #include "compat/compiler.h" #include diff --git a/src/lib/graph/component-source.h b/src/lib/graph/component-source.h index 747d760e..5166faee 100644 --- a/src/lib/graph/component-source.h +++ b/src/lib/graph/component-source.h @@ -24,7 +24,7 @@ * SOFTWARE. */ -#include "common/babeltrace.h" +#include "common/macros.h" #include "component-class.h" #include "component.h" diff --git a/src/lib/graph/component.c b/src/lib/graph/component.c index f4e4be1e..5b202d73 100644 --- a/src/lib/graph/component.c +++ b/src/lib/graph/component.c @@ -31,7 +31,7 @@ #include #include #include -#include "common/babeltrace.h" +#include "common/macros.h" #include "compat/compiler.h" #include #include diff --git a/src/lib/graph/component.h b/src/lib/graph/component.h index 2753cfe9..285a8e9a 100644 --- a/src/lib/graph/component.h +++ b/src/lib/graph/component.h @@ -24,7 +24,7 @@ * SOFTWARE. */ -#include "common/babeltrace.h" +#include "common/macros.h" #include #include "lib/object.h" #include diff --git a/src/lib/graph/connection.h b/src/lib/graph/connection.h index e6190fa5..f54cf240 100644 --- a/src/lib/graph/connection.h +++ b/src/lib/graph/connection.h @@ -28,6 +28,7 @@ #include #include "lib/object.h" #include "common/assert.h" +#include "common/macros.h" #include #include "message/iterator.h" diff --git a/src/lib/graph/graph.c b/src/lib/graph/graph.c index 4b87d735..72e57553 100644 --- a/src/lib/graph/graph.c +++ b/src/lib/graph/graph.c @@ -609,7 +609,7 @@ enum bt_graph_status consume_sink_node(struct bt_graph *graph, GList *node) sink = node->data; status = consume_graph_sink(sink); - if (unlikely(status != BT_GRAPH_STATUS_END)) { + if (G_UNLIKELY(status != BT_GRAPH_STATUS_END)) { g_queue_push_tail_link(graph->sinks_to_consume, node); goto end; } @@ -672,7 +672,7 @@ enum bt_graph_status consume_no_check(struct bt_graph *graph) "Graph has no sink component: %!+g", graph); BT_LIB_LOGV("Making next sink consume: %![graph-]+g", graph); - if (unlikely(g_queue_is_empty(graph->sinks_to_consume))) { + if (G_UNLIKELY(g_queue_is_empty(graph->sinks_to_consume))) { BT_LOGV_STR("Graph's sink queue is empty: end of graph."); status = BT_GRAPH_STATUS_END; goto end; @@ -699,7 +699,7 @@ enum bt_graph_status bt_graph_consume(struct bt_graph *graph) "Graph is in a faulty state: %!+g", graph); bt_graph_set_can_consume(graph, false); status = bt_graph_configure(graph); - if (unlikely(status)) { + if (G_UNLIKELY(status)) { /* bt_graph_configure() logs errors */ goto end; } @@ -723,7 +723,7 @@ enum bt_graph_status bt_graph_run(struct bt_graph *graph) "Graph is in a faulty state: %!+g", graph); bt_graph_set_can_consume(graph, false); status = bt_graph_configure(graph); - if (unlikely(status)) { + if (G_UNLIKELY(status)) { /* bt_graph_configure() logs errors */ goto end; } @@ -737,7 +737,7 @@ enum bt_graph_status bt_graph_run(struct bt_graph *graph) * signal handler, this is not a warning nor an error, * it was intentional: log with a DEBUG level only. */ - if (unlikely(graph->canceled)) { + if (G_UNLIKELY(graph->canceled)) { BT_LIB_LOGD("Stopping the graph: graph is canceled: " "%!+g", graph); status = BT_GRAPH_STATUS_CANCELED; @@ -745,7 +745,7 @@ enum bt_graph_status bt_graph_run(struct bt_graph *graph) } status = consume_no_check(graph); - if (unlikely(status == BT_GRAPH_STATUS_AGAIN)) { + if (G_UNLIKELY(status == BT_GRAPH_STATUS_AGAIN)) { /* * If AGAIN is received and there are multiple * sinks, go ahead and consume from the next diff --git a/src/lib/graph/graph.h b/src/lib/graph/graph.h index c41d1316..71328fae 100644 --- a/src/lib/graph/graph.h +++ b/src/lib/graph/graph.h @@ -26,7 +26,7 @@ #include #include -#include "common/babeltrace.h" +#include "common/macros.h" #include "lib/object.h" #include "lib/object-pool.h" #include "common/assert.h" @@ -215,7 +215,7 @@ enum bt_graph_status bt_graph_configure(struct bt_graph *graph) BT_ASSERT(graph->config_state != BT_GRAPH_CONFIGURATION_STATE_FAULTY); - if (likely(graph->config_state == + if (G_LIKELY(graph->config_state == BT_GRAPH_CONFIGURATION_STATE_CONFIGURED)) { goto end; } diff --git a/src/lib/graph/message/event.c b/src/lib/graph/message/event.c index 00b428c2..1d74e1dd 100644 --- a/src/lib/graph/message/event.c +++ b/src/lib/graph/message/event.c @@ -108,7 +108,7 @@ struct bt_message *create_event_message( event_class, stream_class, with_cs, raw_value); BT_LIB_LOGD("Creating event message object: %![ec-]+E", event_class); event = bt_event_create(event_class, packet); - if (unlikely(!event)) { + if (G_UNLIKELY(!event)) { BT_LIB_LOGE("Cannot create event from event class: " "%![ec-]+E", event_class); goto error; @@ -131,7 +131,7 @@ struct bt_message *create_event_message( */ message = (void *) bt_message_create_from_pool( &msg_iter->graph->event_msg_pool, msg_iter->graph); - if (unlikely(!message)) { + if (G_UNLIKELY(!message)) { /* bt_message_create_from_pool() logs errors */ goto error; } @@ -210,7 +210,7 @@ void bt_message_event_recycle(struct bt_message *msg) BT_ASSERT(event_msg); - if (unlikely(!msg->graph)) { + if (G_UNLIKELY(!msg->graph)) { bt_message_event_destroy(msg); return; } diff --git a/src/lib/graph/message/event.h b/src/lib/graph/message/event.h index b53b6e2f..d1a57458 100644 --- a/src/lib/graph/message/event.h +++ b/src/lib/graph/message/event.h @@ -28,6 +28,7 @@ #include #include #include "common/assert.h" +#include "common/macros.h" #include "message.h" diff --git a/src/lib/graph/message/iterator.h b/src/lib/graph/message/iterator.h index bae41b19..475abf55 100644 --- a/src/lib/graph/message/iterator.h +++ b/src/lib/graph/message/iterator.h @@ -24,7 +24,7 @@ * SOFTWARE. */ -#include "common/babeltrace.h" +#include "common/macros.h" #include "lib/object.h" #include #include diff --git a/src/lib/graph/message/message.h b/src/lib/graph/message/message.h index 98437707..98d27b93 100644 --- a/src/lib/graph/message/message.h +++ b/src/lib/graph/message/message.h @@ -24,7 +24,7 @@ * SOFTWARE. */ -#include "common/babeltrace.h" +#include "common/macros.h" #include "lib/object.h" #include "common/assert.h" #include @@ -73,7 +73,7 @@ struct bt_message *bt_message_create_from_pool( { struct bt_message *msg = bt_object_pool_create_object(pool); - if (unlikely(!msg)) { + if (G_UNLIKELY(!msg)) { #ifdef BT_LIB_LOGE BT_LIB_LOGE("Cannot allocate one message from message pool: " "%![pool-]+o, %![graph-]+g", pool, graph); @@ -81,7 +81,7 @@ struct bt_message *bt_message_create_from_pool( goto error; } - if (likely(!msg->graph)) { + if (G_LIKELY(!msg->graph)) { msg->graph = graph; } diff --git a/src/lib/graph/message/packet.c b/src/lib/graph/message/packet.c index 6bce7129..1a6169a2 100644 --- a/src/lib/graph/message/packet.c +++ b/src/lib/graph/message/packet.c @@ -246,7 +246,7 @@ void bt_message_packet_beginning_recycle(struct bt_message *msg) { BT_ASSERT(msg); - if (unlikely(!msg->graph)) { + if (G_UNLIKELY(!msg->graph)) { bt_message_packet_destroy(msg); return; } @@ -259,7 +259,7 @@ void bt_message_packet_end_recycle(struct bt_message *msg) { BT_ASSERT(msg); - if (unlikely(!msg->graph)) { + if (G_UNLIKELY(!msg->graph)) { bt_message_packet_destroy(msg); return; } diff --git a/src/lib/graph/message/packet.h b/src/lib/graph/message/packet.h index 7738788c..ebd272d9 100644 --- a/src/lib/graph/message/packet.h +++ b/src/lib/graph/message/packet.h @@ -28,6 +28,7 @@ #include #include "lib/trace-ir/clock-snapshot.h" #include "common/assert.h" +#include "common/macros.h" #include "message.h" diff --git a/src/lib/graph/port.h b/src/lib/graph/port.h index c1be31ad..a10fb7fa 100644 --- a/src/lib/graph/port.h +++ b/src/lib/graph/port.h @@ -25,6 +25,7 @@ */ #include +#include "common/macros.h" struct bt_port { struct bt_object base; diff --git a/src/lib/lib-logging.h b/src/lib/lib-logging.h index 59e85591..9ec1fd9b 100644 --- a/src/lib/lib-logging.h +++ b/src/lib/lib-logging.h @@ -23,7 +23,7 @@ * SOFTWARE. */ -#include "common/babeltrace.h" +#include "common/macros.h" #include #ifndef BT_LOG_TAG diff --git a/src/lib/object.h b/src/lib/object.h index c3afd73f..61a502f4 100644 --- a/src/lib/object.h +++ b/src/lib/object.h @@ -24,7 +24,7 @@ * SOFTWARE. */ -#include "common/babeltrace.h" +#include "common/macros.h" #include "common/assert.h" #include @@ -281,7 +281,7 @@ void bt_object_get_no_null_check(const void *c_obj) BT_ASSERT(obj); BT_ASSERT(obj->is_shared); - if (unlikely(obj->parent && bt_object_get_ref_count(obj) == 0)) { + if (G_UNLIKELY(obj->parent && bt_object_get_ref_count(obj) == 0)) { #ifdef BT_LOGV BT_LOGV("Incrementing object's parent's reference count: " "addr=%p, parent-addr=%p", obj, obj->parent); @@ -329,7 +329,7 @@ void bt_object_get_ref(const void *ptr) { struct bt_object *obj = (void *) ptr; - if (unlikely(!obj)) { + if (G_UNLIKELY(!obj)) { return; } @@ -345,7 +345,7 @@ void bt_object_put_ref(const void *ptr) { struct bt_object *obj = (void *) ptr; - if (unlikely(!obj)) { + if (G_UNLIKELY(!obj)) { return; } diff --git a/src/lib/plugin/plugin-so.c b/src/lib/plugin/plugin-so.c index 621353c0..3b2be152 100644 --- a/src/lib/plugin/plugin-so.c +++ b/src/lib/plugin/plugin-so.c @@ -50,7 +50,7 @@ #define LIBTOOL_PLUGIN_SUFFIX ".la" #define LIBTOOL_PLUGIN_SUFFIX_LEN sizeof(LIBTOOL_PLUGIN_SUFFIX) -#define PLUGIN_SUFFIX_LEN max_t(size_t, sizeof(NATIVE_PLUGIN_SUFFIX), \ +#define PLUGIN_SUFFIX_LEN bt_max_t(size_t, sizeof(NATIVE_PLUGIN_SUFFIX), \ sizeof(LIBTOOL_PLUGIN_SUFFIX)) BT_PLUGIN_MODULE(); diff --git a/src/lib/plugin/plugin-so.h b/src/lib/plugin/plugin-so.h index 094b87ad..328cc148 100644 --- a/src/lib/plugin/plugin-so.h +++ b/src/lib/plugin/plugin-so.h @@ -27,6 +27,7 @@ #include #include #include +#include "common/macros.h" struct bt_plugin; struct bt_component_class; diff --git a/src/lib/plugin/plugin.c b/src/lib/plugin/plugin.c index 53b783ff..31641df3 100644 --- a/src/lib/plugin/plugin.c +++ b/src/lib/plugin/plugin.c @@ -28,7 +28,7 @@ #include "common/assert.h" #include "lib/assert-pre.h" -#include "common/babeltrace.h" +#include "common/macros.h" #include "compat/compiler.h" #include "common/common.h" #include @@ -49,7 +49,7 @@ #define PYTHON_PLUGIN_PROVIDER_FILENAME "libbabeltrace2-python-plugin-provider." G_MODULE_SUFFIX #define PYTHON_PLUGIN_PROVIDER_SYM_NAME bt_plugin_python_create_all_from_file -#define PYTHON_PLUGIN_PROVIDER_SYM_NAME_STR TOSTRING(PYTHON_PLUGIN_PROVIDER_SYM_NAME) +#define PYTHON_PLUGIN_PROVIDER_SYM_NAME_STR G_STRINGIFY(PYTHON_PLUGIN_PROVIDER_SYM_NAME) #define APPEND_ALL_FROM_DIR_NFDOPEN_MAX 8 diff --git a/src/lib/plugin/plugin.h b/src/lib/plugin/plugin.h index cdd20d69..d7f2d68f 100644 --- a/src/lib/plugin/plugin.h +++ b/src/lib/plugin/plugin.h @@ -24,7 +24,7 @@ * SOFTWARE. */ -#include "common/babeltrace.h" +#include "common/macros.h" #include "lib/graph/component-class.h" #include #include diff --git a/src/lib/prio-heap/prio-heap.c b/src/lib/prio-heap/prio-heap.c index 29e90688..952b3b86 100644 --- a/src/lib/prio-heap/prio-heap.c +++ b/src/lib/prio-heap/prio-heap.c @@ -23,7 +23,7 @@ * SOFTWARE. */ -#include "common/babeltrace.h" +#include "common/macros.h" #include "common/assert.h" #include #include @@ -70,14 +70,14 @@ int heap_grow(struct ptr_heap *heap, size_t new_len) { void **new_ptrs; - if (likely(heap->alloc_len >= new_len)) + if (G_LIKELY(heap->alloc_len >= new_len)) return 0; - heap->alloc_len = max_t(size_t, new_len, heap->alloc_len << 1); + heap->alloc_len = bt_max_t(size_t, new_len, heap->alloc_len << 1); new_ptrs = calloc(heap->alloc_len, sizeof(void *)); - if (unlikely(!new_ptrs)) + if (G_UNLIKELY(!new_ptrs)) return -ENOMEM; - if (likely(heap->ptrs)) + if (G_LIKELY(heap->ptrs)) memcpy(new_ptrs, heap->ptrs, heap->len * sizeof(void *)); free(heap->ptrs); heap->ptrs = new_ptrs; @@ -90,7 +90,7 @@ int heap_set_len(struct ptr_heap *heap, size_t new_len) int ret; ret = heap_grow(heap, new_len); - if (unlikely(ret)) + if (G_UNLIKELY(ret)) return ret; heap->len = new_len; return 0; @@ -107,7 +107,7 @@ int bt_heap_init(struct ptr_heap *heap, size_t alloc_len, * Minimum size allocated is 1 entry to ensure memory allocation * never fails within bt_heap_replace_max. */ - return heap_grow(heap, max_t(size_t, 1, alloc_len)); + return heap_grow(heap, bt_max_t(size_t, 1, alloc_len)); } void bt_heap_free(struct ptr_heap *heap) @@ -131,7 +131,7 @@ static void heapify(struct ptr_heap *heap, size_t i) largest = i; if (r < heap->len && heap->gt(ptrs[r], ptrs[largest])) largest = r; - if (unlikely(largest == i)) + if (G_UNLIKELY(largest == i)) break; tmp = ptrs[i]; ptrs[i] = ptrs[largest]; @@ -145,7 +145,7 @@ void *bt_heap_replace_max(struct ptr_heap *heap, void *p) { void *res; - if (unlikely(!heap->len)) { + if (G_UNLIKELY(!heap->len)) { (void) heap_set_len(heap, 1); heap->ptrs[0] = p; check_heap(heap); @@ -166,7 +166,7 @@ int bt_heap_insert(struct ptr_heap *heap, void *p) int ret; ret = heap_set_len(heap, heap->len + 1); - if (unlikely(ret)) + if (G_UNLIKELY(ret)) return ret; ptrs = heap->ptrs; pos = heap->len - 1; @@ -200,11 +200,11 @@ void *bt_heap_cherrypick(struct ptr_heap *heap, void *p) size_t pos, len = heap->len; for (pos = 0; pos < len; pos++) - if (unlikely(heap->ptrs[pos] == p)) + if (G_UNLIKELY(heap->ptrs[pos] == p)) goto found; return NULL; found: - if (unlikely(heap->len == 1)) { + if (G_UNLIKELY(heap->len == 1)) { (void) heap_set_len(heap, 0); check_heap(heap); return heap->ptrs[0]; diff --git a/src/lib/prio-heap/prio-heap.h b/src/lib/prio-heap/prio-heap.h index 8ea51bc1..bbf1b3bf 100644 --- a/src/lib/prio-heap/prio-heap.h +++ b/src/lib/prio-heap/prio-heap.h @@ -27,7 +27,7 @@ */ #include -#include "common/babeltrace.h" +#include "common/macros.h" struct ptr_heap { size_t len, alloc_len; @@ -54,7 +54,7 @@ void check_heap(const struct ptr_heap *heap) static inline void *bt_heap_maximum(const struct ptr_heap *heap) { check_heap(heap); - return likely(heap->len) ? heap->ptrs[0] : NULL; + return G_LIKELY(heap->len) ? heap->ptrs[0] : NULL; } /** diff --git a/src/lib/trace-ir/attributes.c b/src/lib/trace-ir/attributes.c index 7d20c1e5..4391f276 100644 --- a/src/lib/trace-ir/attributes.c +++ b/src/lib/trace-ir/attributes.c @@ -24,7 +24,7 @@ #define BT_LOG_TAG "ATTRS" #include "lib/lib-logging.h" -#include "common/babeltrace.h" +#include "common/macros.h" #include #include "lib/assert-pre.h" #include "lib/object.h" diff --git a/src/lib/trace-ir/attributes.h b/src/lib/trace-ir/attributes.h index e493815c..60b46d42 100644 --- a/src/lib/trace-ir/attributes.h +++ b/src/lib/trace-ir/attributes.h @@ -29,7 +29,7 @@ extern "C" { #endif #include -#include "common/babeltrace.h" +#include "common/macros.h" #include BT_HIDDEN diff --git a/src/lib/trace-ir/clock-class.h b/src/lib/trace-ir/clock-class.h index e6e57e90..4cbf77ea 100644 --- a/src/lib/trace-ir/clock-class.h +++ b/src/lib/trace-ir/clock-class.h @@ -26,7 +26,7 @@ #include #include "lib/object.h" -#include "common/babeltrace.h" +#include "common/macros.h" #include "common/common.h" #include "lib/object-pool.h" #include "compat/uuid.h" diff --git a/src/lib/trace-ir/clock-snapshot.c b/src/lib/trace-ir/clock-snapshot.c index 04ef345e..e2e98411 100644 --- a/src/lib/trace-ir/clock-snapshot.c +++ b/src/lib/trace-ir/clock-snapshot.c @@ -82,7 +82,7 @@ struct bt_clock_snapshot *bt_clock_snapshot_create( goto error; } - if (likely(!clock_snapshot->clock_class)) { + if (G_LIKELY(!clock_snapshot->clock_class)) { clock_snapshot->clock_class = clock_class; bt_object_get_no_null_check(clock_class); } diff --git a/src/lib/trace-ir/clock-snapshot.h b/src/lib/trace-ir/clock-snapshot.h index 5375f3ab..20831baf 100644 --- a/src/lib/trace-ir/clock-snapshot.h +++ b/src/lib/trace-ir/clock-snapshot.h @@ -23,7 +23,7 @@ * SOFTWARE. */ -#include "common/babeltrace.h" +#include "common/macros.h" #include "lib/object.h" #include #include diff --git a/src/lib/trace-ir/event-class.h b/src/lib/trace-ir/event-class.h index b368a286..66d53670 100644 --- a/src/lib/trace-ir/event-class.h +++ b/src/lib/trace-ir/event-class.h @@ -27,7 +27,7 @@ #include "lib/assert-pre.h" #include #include -#include "common/babeltrace.h" +#include "common/macros.h" #include #include #include diff --git a/src/lib/trace-ir/event.h b/src/lib/trace-ir/event.h index 308c451e..8cd6419c 100644 --- a/src/lib/trace-ir/event.h +++ b/src/lib/trace-ir/event.h @@ -30,7 +30,7 @@ #endif #include "lib/assert-pre.h" -#include "common/babeltrace.h" +#include "common/macros.h" #include #include #include @@ -80,7 +80,7 @@ void _bt_event_set_is_frozen(const struct bt_event *event, bool is_frozen); # define bt_event_set_is_frozen(_event, _is_frozen) #endif -BT_UNUSED +__attribute__((unused)) static inline void _bt_event_reset_dev_mode(struct bt_event *event) { @@ -186,13 +186,13 @@ struct bt_event *bt_event_create(struct bt_event_class *event_class, BT_ASSERT(event_class); event = bt_object_pool_create_object(&event_class->event_pool); - if (unlikely(!event)) { + if (G_UNLIKELY(!event)) { BT_LIB_LOGE("Cannot allocate one event from event class's event pool: " "%![ec-]+E", event_class); goto end; } - if (likely(!event->class)) { + if (G_LIKELY(!event->class)) { event->class = event_class; bt_object_get_no_null_check(&event_class->base); } diff --git a/src/lib/trace-ir/field-class.h b/src/lib/trace-ir/field-class.h index b5692dae..6947c937 100644 --- a/src/lib/trace-ir/field-class.h +++ b/src/lib/trace-ir/field-class.h @@ -27,7 +27,7 @@ #include "lib/assert-pre.h" #include #include -#include "common/babeltrace.h" +#include "common/macros.h" #include "lib/object.h" #include #include diff --git a/src/lib/trace-ir/field-path.h b/src/lib/trace-ir/field-path.h index 506c0063..9241d077 100644 --- a/src/lib/trace-ir/field-path.h +++ b/src/lib/trace-ir/field-path.h @@ -29,6 +29,7 @@ #include "lib/object.h" #include #include "common/assert.h" +#include "common/macros.h" #include struct bt_field_path_item { diff --git a/src/lib/trace-ir/field-wrapper.h b/src/lib/trace-ir/field-wrapper.h index 97728e0d..db4ae79a 100644 --- a/src/lib/trace-ir/field-wrapper.h +++ b/src/lib/trace-ir/field-wrapper.h @@ -23,6 +23,7 @@ * SOFTWARE. */ +#include "common/macros.h" #include "lib/object-pool.h" #include "lib/object.h" diff --git a/src/lib/trace-ir/field.c b/src/lib/trace-ir/field.c index 4f75c344..31d9803e 100644 --- a/src/lib/trace-ir/field.c +++ b/src/lib/trace-ir/field.c @@ -666,7 +666,7 @@ enum bt_field_status bt_field_string_append_with_length(struct bt_field *field, new_length = length + string_field->length; - if (unlikely(new_length + 1 > string_field->buf->len)) { + if (G_UNLIKELY(new_length + 1 > string_field->buf->len)) { g_array_set_size(string_field->buf, new_length + 1); } @@ -708,7 +708,7 @@ enum bt_field_status bt_field_dynamic_array_set_length(struct bt_field *field, BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY, "Field"); BT_ASSERT_PRE_FIELD_HOT(field, "Field"); - if (unlikely(length > array_field->fields->len)) { + if (G_UNLIKELY(length > array_field->fields->len)) { /* Make more room */ struct bt_field_class_array *array_fc; uint64_t cur_len = array_field->fields->len; diff --git a/src/lib/trace-ir/field.h b/src/lib/trace-ir/field.h index 3cd4bfe5..96df03e7 100644 --- a/src/lib/trace-ir/field.h +++ b/src/lib/trace-ir/field.h @@ -27,7 +27,7 @@ #include "lib/assert-pre.h" #include "common/common.h" #include "lib/object.h" -#include "common/babeltrace.h" +#include "common/macros.h" #include #include #include diff --git a/src/lib/trace-ir/packet.c b/src/lib/trace-ir/packet.c index 585ed48b..ade0a3f2 100644 --- a/src/lib/trace-ir/packet.c +++ b/src/lib/trace-ir/packet.c @@ -220,13 +220,13 @@ struct bt_packet *bt_packet_create(const struct bt_stream *c_stream) BT_ASSERT_PRE_NON_NULL(stream, "Stream"); packet = bt_object_pool_create_object(&stream->packet_pool); - if (unlikely(!packet)) { + if (G_UNLIKELY(!packet)) { BT_LIB_LOGE("Cannot allocate one packet from stream's packet pool: " "%![stream-]+s", stream); goto end; } - if (likely(!packet->stream)) { + if (G_LIKELY(!packet->stream)) { packet->stream = stream; bt_object_get_no_null_check_no_parent_check( &packet->stream->base); diff --git a/src/lib/trace-ir/packet.h b/src/lib/trace-ir/packet.h index 7b19760c..e2d825c6 100644 --- a/src/lib/trace-ir/packet.h +++ b/src/lib/trace-ir/packet.h @@ -30,7 +30,7 @@ #include #include #include "lib/object.h" -#include "common/babeltrace.h" +#include "common/macros.h" #include "lib/property.h" #include "field-wrapper.h" diff --git a/src/lib/trace-ir/resolve-field-path.h b/src/lib/trace-ir/resolve-field-path.h index 48f14acf..92e277b8 100644 --- a/src/lib/trace-ir/resolve-field-path.h +++ b/src/lib/trace-ir/resolve-field-path.h @@ -26,6 +26,7 @@ * http://www.efficios.com/ctf */ +#include "common/macros.h" #include "lib/object.h" #include #include diff --git a/src/lib/trace-ir/stream-class.h b/src/lib/trace-ir/stream-class.h index 1efa7707..7610b902 100644 --- a/src/lib/trace-ir/stream-class.h +++ b/src/lib/trace-ir/stream-class.h @@ -29,7 +29,7 @@ #include #include "lib/object.h" #include "lib/object-pool.h" -#include "common/babeltrace.h" +#include "common/macros.h" #include #include diff --git a/src/lib/trace-ir/stream.h b/src/lib/trace-ir/stream.h index 96985a93..cd320ca1 100644 --- a/src/lib/trace-ir/stream.h +++ b/src/lib/trace-ir/stream.h @@ -27,7 +27,7 @@ #include #include "lib/object.h" #include "lib/object-pool.h" -#include "common/babeltrace.h" +#include "common/macros.h" #include #include "utils.h" diff --git a/src/lib/trace-ir/trace-class.h b/src/lib/trace-ir/trace-class.h index 7c8add5c..09f1e7d4 100644 --- a/src/lib/trace-ir/trace-class.h +++ b/src/lib/trace-ir/trace-class.h @@ -30,7 +30,7 @@ #include #include "lib/object.h" #include "lib/object-pool.h" -#include "common/babeltrace.h" +#include "common/macros.h" #include #include #include diff --git a/src/lib/trace-ir/trace.h b/src/lib/trace-ir/trace.h index 3a12fd78..f10cdba9 100644 --- a/src/lib/trace-ir/trace.h +++ b/src/lib/trace-ir/trace.h @@ -30,7 +30,7 @@ #include #include "lib/object.h" #include "lib/object-pool.h" -#include "common/babeltrace.h" +#include "common/macros.h" #include #include #include diff --git a/src/lib/trace-ir/utils.h b/src/lib/trace-ir/utils.h index d68bd54b..a50fe55f 100644 --- a/src/lib/trace-ir/utils.h +++ b/src/lib/trace-ir/utils.h @@ -23,7 +23,7 @@ * SOFTWARE. */ -#include "common/babeltrace.h" +#include "common/macros.h" #include #include diff --git a/src/lib/value.h b/src/lib/value.h index aa741881..4230f44c 100644 --- a/src/lib/value.h +++ b/src/lib/value.h @@ -28,6 +28,7 @@ #include #include #include +#include "common/macros.h" struct bt_value { struct bt_object base; diff --git a/src/logging/log.c b/src/logging/log.c index d8c80402..f1e0b715 100644 --- a/src/logging/log.c +++ b/src/logging/log.c @@ -4,7 +4,7 @@ * See LICENSE. */ -#include "common/babeltrace.h" +#include "common/macros.h" #include "common/common.h" #include #include "common/assert.h" diff --git a/src/logging/log.h b/src/logging/log.h index 44f778a0..42ae118b 100644 --- a/src/logging/log.h +++ b/src/logging/log.h @@ -9,10 +9,12 @@ #ifndef BABELTRACE_LOGGING_INTERNAL_H #define BABELTRACE_LOGGING_INTERNAL_H +#include #include #include +#include #include -#include "common/babeltrace.h" +#include "common/macros.h" /* To detect incompatible changes you can define BT_LOG_VERSION_REQUIRED to be * the current value of BT_LOG_VERSION before including this file (or via diff --git a/src/plugins/ctf/common/bfcr/bfcr.h b/src/plugins/ctf/common/bfcr/bfcr.h index 9cc5aadc..7d31d2a1 100644 --- a/src/plugins/ctf/common/bfcr/bfcr.h +++ b/src/plugins/ctf/common/bfcr/bfcr.h @@ -30,7 +30,7 @@ #include #include #include -#include "common/babeltrace.h" +#include "common/macros.h" #include "../metadata/ctf-meta.h" diff --git a/src/plugins/ctf/common/metadata/ast.h b/src/plugins/ctf/common/metadata/ast.h index 6f6fbe7b..d98ff09e 100644 --- a/src/plugins/ctf/common/metadata/ast.h +++ b/src/plugins/ctf/common/metadata/ast.h @@ -22,7 +22,7 @@ #include #include "common/list.h" #include -#include "common/babeltrace.h" +#include "common/macros.h" #include "decoder.h" #include "ctf-meta.h" diff --git a/src/plugins/ctf/common/metadata/ctf-meta-resolve.c b/src/plugins/ctf/common/metadata/ctf-meta-resolve.c index 130ae61b..478166de 100644 --- a/src/plugins/ctf/common/metadata/ctf-meta-resolve.c +++ b/src/plugins/ctf/common/metadata/ctf-meta-resolve.c @@ -17,7 +17,7 @@ #include "logging.h" #include -#include "common/babeltrace.h" +#include "common/macros.h" #include "common/assert.h" #include "common/common.h" #include diff --git a/src/plugins/ctf/common/metadata/ctf-meta-translate.c b/src/plugins/ctf/common/metadata/ctf-meta-translate.c index 287cc259..6cff9921 100644 --- a/src/plugins/ctf/common/metadata/ctf-meta-translate.c +++ b/src/plugins/ctf/common/metadata/ctf-meta-translate.c @@ -16,7 +16,7 @@ #include "logging.h" #include -#include "common/babeltrace.h" +#include "common/macros.h" #include "common/assert.h" #include #include diff --git a/src/plugins/ctf/common/metadata/ctf-meta-update-default-clock-classes.c b/src/plugins/ctf/common/metadata/ctf-meta-update-default-clock-classes.c index f114d80b..41ca6b03 100644 --- a/src/plugins/ctf/common/metadata/ctf-meta-update-default-clock-classes.c +++ b/src/plugins/ctf/common/metadata/ctf-meta-update-default-clock-classes.c @@ -16,7 +16,7 @@ #include "logging.h" #include -#include "common/babeltrace.h" +#include "common/macros.h" #include "common/assert.h" #include #include diff --git a/src/plugins/ctf/common/metadata/ctf-meta-update-in-ir.c b/src/plugins/ctf/common/metadata/ctf-meta-update-in-ir.c index e6342942..1279d146 100644 --- a/src/plugins/ctf/common/metadata/ctf-meta-update-in-ir.c +++ b/src/plugins/ctf/common/metadata/ctf-meta-update-in-ir.c @@ -16,7 +16,7 @@ #include "logging.h" #include -#include "common/babeltrace.h" +#include "common/macros.h" #include "common/assert.h" #include "compat/glib.h" #include diff --git a/src/plugins/ctf/common/metadata/ctf-meta-update-meanings.c b/src/plugins/ctf/common/metadata/ctf-meta-update-meanings.c index bd801979..9aaeba83 100644 --- a/src/plugins/ctf/common/metadata/ctf-meta-update-meanings.c +++ b/src/plugins/ctf/common/metadata/ctf-meta-update-meanings.c @@ -16,7 +16,7 @@ #include "logging.h" #include -#include "common/babeltrace.h" +#include "common/macros.h" #include "common/assert.h" #include #include diff --git a/src/plugins/ctf/common/metadata/ctf-meta-update-stream-class-config.c b/src/plugins/ctf/common/metadata/ctf-meta-update-stream-class-config.c index d5dd9d93..7c28ee23 100644 --- a/src/plugins/ctf/common/metadata/ctf-meta-update-stream-class-config.c +++ b/src/plugins/ctf/common/metadata/ctf-meta-update-stream-class-config.c @@ -16,7 +16,7 @@ #include "logging.h" #include -#include "common/babeltrace.h" +#include "common/macros.h" #include "common/assert.h" #include #include diff --git a/src/plugins/ctf/common/metadata/ctf-meta-update-text-array-sequence.c b/src/plugins/ctf/common/metadata/ctf-meta-update-text-array-sequence.c index 8201954d..843069b8 100644 --- a/src/plugins/ctf/common/metadata/ctf-meta-update-text-array-sequence.c +++ b/src/plugins/ctf/common/metadata/ctf-meta-update-text-array-sequence.c @@ -16,7 +16,7 @@ #include "logging.h" #include -#include "common/babeltrace.h" +#include "common/macros.h" #include "common/assert.h" #include #include diff --git a/src/plugins/ctf/common/metadata/ctf-meta-update-value-storing-indexes.c b/src/plugins/ctf/common/metadata/ctf-meta-update-value-storing-indexes.c index 81f76382..81aa9909 100644 --- a/src/plugins/ctf/common/metadata/ctf-meta-update-value-storing-indexes.c +++ b/src/plugins/ctf/common/metadata/ctf-meta-update-value-storing-indexes.c @@ -16,7 +16,7 @@ #include "logging.h" #include -#include "common/babeltrace.h" +#include "common/macros.h" #include "common/assert.h" #include #include diff --git a/src/plugins/ctf/common/metadata/ctf-meta-validate.c b/src/plugins/ctf/common/metadata/ctf-meta-validate.c index bb1aac0c..99a73208 100644 --- a/src/plugins/ctf/common/metadata/ctf-meta-validate.c +++ b/src/plugins/ctf/common/metadata/ctf-meta-validate.c @@ -16,7 +16,7 @@ #include "logging.h" #include -#include "common/babeltrace.h" +#include "common/macros.h" #include "common/assert.h" #include #include diff --git a/src/plugins/ctf/common/metadata/ctf-meta-visitors.h b/src/plugins/ctf/common/metadata/ctf-meta-visitors.h index 9eb3cf38..cfcb043e 100644 --- a/src/plugins/ctf/common/metadata/ctf-meta-visitors.h +++ b/src/plugins/ctf/common/metadata/ctf-meta-visitors.h @@ -16,7 +16,7 @@ */ #include -#include "common/babeltrace.h" +#include "common/macros.h" #include "ctf-meta.h" diff --git a/src/plugins/ctf/common/metadata/ctf-meta-warn-meaningless-header-fields.c b/src/plugins/ctf/common/metadata/ctf-meta-warn-meaningless-header-fields.c index 73b6fe92..87245a9e 100644 --- a/src/plugins/ctf/common/metadata/ctf-meta-warn-meaningless-header-fields.c +++ b/src/plugins/ctf/common/metadata/ctf-meta-warn-meaningless-header-fields.c @@ -16,7 +16,7 @@ #include "logging.h" #include -#include "common/babeltrace.h" +#include "common/macros.h" #include "common/assert.h" #include #include diff --git a/src/plugins/ctf/common/metadata/decoder.h b/src/plugins/ctf/common/metadata/decoder.h index b0f179be..a231034f 100644 --- a/src/plugins/ctf/common/metadata/decoder.h +++ b/src/plugins/ctf/common/metadata/decoder.h @@ -20,6 +20,8 @@ #include +#include "common/macros.h" + /* A CTF metadata decoder object */ struct ctf_metadata_decoder; diff --git a/src/plugins/ctf/common/metadata/objstack.c b/src/plugins/ctf/common/metadata/objstack.c index 15b6d26a..1cb069d5 100644 --- a/src/plugins/ctf/common/metadata/objstack.c +++ b/src/plugins/ctf/common/metadata/objstack.c @@ -29,7 +29,7 @@ #include #include "common/list.h" -#include "common/babeltrace.h" +#include "common/macros.h" #include "common/align.h" #define OBJSTACK_ALIGN 8 /* Object stack alignment */ diff --git a/src/plugins/ctf/common/metadata/objstack.h b/src/plugins/ctf/common/metadata/objstack.h index c026eb54..32f7ff4b 100644 --- a/src/plugins/ctf/common/metadata/objstack.h +++ b/src/plugins/ctf/common/metadata/objstack.h @@ -27,6 +27,8 @@ * SOFTWARE. */ +#include "common/macros.h" + struct objstack; BT_HIDDEN diff --git a/src/plugins/ctf/common/metadata/scanner.h b/src/plugins/ctf/common/metadata/scanner.h index 34d6c462..801f2b16 100644 --- a/src/plugins/ctf/common/metadata/scanner.h +++ b/src/plugins/ctf/common/metadata/scanner.h @@ -18,6 +18,7 @@ */ #include +#include "common/macros.h" #include "ast.h" #ifndef YY_TYPEDEF_YY_SCANNER_T diff --git a/src/plugins/ctf/common/metadata/visitor-parent-links.c b/src/plugins/ctf/common/metadata/visitor-parent-links.c index 64098a9a..c1389ba7 100644 --- a/src/plugins/ctf/common/metadata/visitor-parent-links.c +++ b/src/plugins/ctf/common/metadata/visitor-parent-links.c @@ -35,7 +35,7 @@ #include #include #include -#include "common/babeltrace.h" +#include "common/macros.h" #include "common/list.h" #include "scanner.h" #include "parser.h" diff --git a/src/plugins/ctf/common/msg-iter/msg-iter.c b/src/plugins/ctf/common/msg-iter/msg-iter.c index 2a1c4713..377a4c5d 100644 --- a/src/plugins/ctf/common/msg-iter/msg-iter.c +++ b/src/plugins/ctf/common/msg-iter/msg-iter.c @@ -535,7 +535,7 @@ enum bt_msg_iter_status buf_ensure_available_bits( { enum bt_msg_iter_status status = BT_MSG_ITER_STATUS_OK; - if (unlikely(buf_available_bits(notit) == 0)) { + if (G_UNLIKELY(buf_available_bits(notit) == 0)) { /* * This _cannot_ return BT_MSG_ITER_STATUS_OK * _and_ no bits. @@ -1043,14 +1043,14 @@ enum bt_msg_iter_status read_event_header_begin_state(struct bt_msg_iter *notit) /* Check if we have some content left */ if (notit->cur_exp_packet_content_size >= 0) { - if (unlikely(packet_at(notit) == + if (G_UNLIKELY(packet_at(notit) == notit->cur_exp_packet_content_size)) { /* No more events! */ BT_LOGV("Reached end of packet: notit-addr=%p, " "cur=%zu", notit, packet_at(notit)); notit->state = STATE_EMIT_MSG_PACKET_END_MULTI; goto end; - } else if (unlikely(packet_at(notit) > + } else if (G_UNLIKELY(packet_at(notit) > notit->cur_exp_packet_content_size)) { /* That's not supposed to happen */ BT_LOGV("Before decoding event header field: cursor is passed the packet's content: " @@ -1898,7 +1898,7 @@ enum bt_bfcr_status bfcr_unsigned_int_cb(uint64_t value, "fc-type=%d, fc-in-ir=%d, value=%" PRIu64, notit, notit->bfcr, fc, fc->type, fc->in_ir, value); - if (likely(int_fc->meaning == CTF_FIELD_CLASS_MEANING_NONE)) { + if (G_LIKELY(int_fc->meaning == CTF_FIELD_CLASS_MEANING_NONE)) { goto update_def_clock; } @@ -1944,16 +1944,16 @@ enum bt_bfcr_status bfcr_unsigned_int_cb(uint64_t value, } update_def_clock: - if (unlikely(int_fc->mapped_clock_class)) { + if (G_UNLIKELY(int_fc->mapped_clock_class)) { update_default_clock(notit, value, int_fc->base.size); } - if (unlikely(int_fc->storing_index >= 0)) { + if (G_UNLIKELY(int_fc->storing_index >= 0)) { g_array_index(notit->stored_values, uint64_t, (uint64_t) int_fc->storing_index) = value; } - if (unlikely(!fc->in_ir)) { + if (G_UNLIKELY(!fc->in_ir)) { goto end; } @@ -1990,7 +1990,7 @@ enum bt_bfcr_status bfcr_unsigned_int_char_cb(uint64_t value, BT_ASSERT(!int_fc->mapped_clock_class); BT_ASSERT(int_fc->storing_index < 0); - if (unlikely(!fc->in_ir)) { + if (G_UNLIKELY(!fc->in_ir)) { goto end; } @@ -2037,12 +2037,12 @@ enum bt_bfcr_status bfcr_signed_int_cb(int64_t value, notit, notit->bfcr, fc, fc->type, fc->in_ir, value); BT_ASSERT(int_fc->meaning == CTF_FIELD_CLASS_MEANING_NONE); - if (unlikely(int_fc->storing_index >= 0)) { + if (G_UNLIKELY(int_fc->storing_index >= 0)) { g_array_index(notit->stored_values, uint64_t, (uint64_t) int_fc->storing_index) = (uint64_t) value; } - if (unlikely(!fc->in_ir)) { + if (G_UNLIKELY(!fc->in_ir)) { goto end; } @@ -2073,7 +2073,7 @@ enum bt_bfcr_status bfcr_floating_point_cb(double value, "fc-type=%d, fc-in-ir=%d, value=%f", notit, notit->bfcr, fc, fc->type, fc->in_ir, value); - if (unlikely(!fc->in_ir)) { + if (G_UNLIKELY(!fc->in_ir)) { goto end; } @@ -2102,7 +2102,7 @@ enum bt_bfcr_status bfcr_string_begin_cb( "fc-type=%d, fc-in-ir=%d", notit, notit->bfcr, fc, fc->type, fc->in_ir); - if (unlikely(!fc->in_ir)) { + if (G_UNLIKELY(!fc->in_ir)) { goto end; } @@ -2140,7 +2140,7 @@ enum bt_bfcr_status bfcr_string_cb(const char *value, notit, notit->bfcr, fc, fc->type, fc->in_ir, len); - if (unlikely(!fc->in_ir)) { + if (G_UNLIKELY(!fc->in_ir)) { goto end; } @@ -2172,7 +2172,7 @@ enum bt_bfcr_status bfcr_string_end_cb( "fc-type=%d, fc-in-ir=%d", notit, notit->bfcr, fc, fc->type, fc->in_ir); - if (unlikely(!fc->in_ir)) { + if (G_UNLIKELY(!fc->in_ir)) { goto end; } @@ -2788,10 +2788,10 @@ enum bt_msg_iter_status bt_msg_iter_get_next_message( while (true) { status = handle_state(notit); - if (unlikely(status == BT_MSG_ITER_STATUS_AGAIN)) { + if (G_UNLIKELY(status == BT_MSG_ITER_STATUS_AGAIN)) { BT_LOGV_STR("Medium returned BT_MSG_ITER_STATUS_AGAIN."); goto end; - } else if (unlikely(status != BT_MSG_ITER_STATUS_OK)) { + } else if (G_UNLIKELY(status != BT_MSG_ITER_STATUS_OK)) { BT_LOGW("Cannot handle state: notit-addr=%p, state=%s", notit, state_string(notit->state)); goto end; @@ -2906,10 +2906,10 @@ enum bt_msg_iter_status read_packet_header_context_fields( while (true) { status = handle_state(notit); - if (unlikely(status == BT_MSG_ITER_STATUS_AGAIN)) { + if (G_UNLIKELY(status == BT_MSG_ITER_STATUS_AGAIN)) { BT_LOGV_STR("Medium returned BT_MSG_ITER_STATUS_AGAIN."); goto end; - } else if (unlikely(status != BT_MSG_ITER_STATUS_OK)) { + } else if (G_UNLIKELY(status != BT_MSG_ITER_STATUS_OK)) { BT_LOGW("Cannot handle state: notit-addr=%p, state=%s", notit, state_string(notit->state)); goto end; diff --git a/src/plugins/ctf/common/msg-iter/msg-iter.h b/src/plugins/ctf/common/msg-iter/msg-iter.h index 65dd0ee1..77849db6 100644 --- a/src/plugins/ctf/common/msg-iter/msg-iter.h +++ b/src/plugins/ctf/common/msg-iter/msg-iter.h @@ -30,7 +30,7 @@ #include #include #include -#include "common/babeltrace.h" +#include "common/macros.h" #include "../metadata/ctf-meta.h" diff --git a/src/plugins/ctf/common/print.h b/src/plugins/ctf/common/print.h index 8825a9a7..7d98ea50 100644 --- a/src/plugins/ctf/common/print.h +++ b/src/plugins/ctf/common/print.h @@ -26,7 +26,7 @@ */ #include -#include "common/babeltrace.h" +#include "common/macros.h" #define PERR(fmt, ...) \ do { \ diff --git a/src/plugins/ctf/common/utils/utils.h b/src/plugins/ctf/common/utils/utils.h index 28f056ca..05e0a8dc 100644 --- a/src/plugins/ctf/common/utils/utils.h +++ b/src/plugins/ctf/common/utils/utils.h @@ -26,6 +26,6 @@ */ #include -#include "common/babeltrace.h" +#include "common/macros.h" #endif /* CTF_UTILS_H */ diff --git a/src/plugins/ctf/fs-sink/fs-sink-stream.c b/src/plugins/ctf/fs-sink/fs-sink-stream.c index 026251a6..d79e80e0 100644 --- a/src/plugins/ctf/fs-sink/fs-sink-stream.c +++ b/src/plugins/ctf/fs-sink/fs-sink-stream.c @@ -251,7 +251,7 @@ int write_array_field_elements(struct fs_sink_stream *stream, bt_field_array_borrow_element_field_by_index_const( field, i); ret = write_field(stream, fc->elem_fc, elem_field); - if (unlikely(ret)) { + if (G_UNLIKELY(ret)) { goto end; } } @@ -270,7 +270,7 @@ int write_sequence_field(struct fs_sink_stream *stream, if (fc->length_is_before) { ret = bt_ctfser_write_unsigned_int(&stream->ctfser, bt_field_array_get_length(field), 8, 32, BYTE_ORDER); - if (unlikely(ret)) { + if (G_UNLIKELY(ret)) { goto end; } } @@ -289,10 +289,10 @@ int write_struct_field(struct fs_sink_stream *stream, int ret = 0; uint64_t i; - if (likely(align_struct)) { + if (G_LIKELY(align_struct)) { ret = bt_ctfser_align_offset_in_current_packet(&stream->ctfser, fc->base.alignment); - if (unlikely(ret)) { + if (G_UNLIKELY(ret)) { goto end; } } @@ -306,7 +306,7 @@ int write_struct_field(struct fs_sink_stream *stream, fc, i)->fc; ret = write_field(stream, member_fc, memb_field); - if (unlikely(ret)) { + if (G_UNLIKELY(ret)) { goto end; } } @@ -327,7 +327,7 @@ int write_variant_field(struct fs_sink_stream *stream, if (fc->tag_is_before) { ret = bt_ctfser_write_unsigned_int(&stream->ctfser, opt_index, 8, 16, BYTE_ORDER); - if (unlikely(ret)) { + if (G_UNLIKELY(ret)) { goto end; } } @@ -385,7 +385,7 @@ int write_event_header(struct fs_sink_stream *stream, /* Event class ID */ ret = bt_ctfser_write_byte_aligned_unsigned_int(&stream->ctfser, bt_event_class_get_id(ec->ir_ec), 8, 64, BYTE_ORDER); - if (unlikely(ret)) { + if (G_UNLIKELY(ret)) { goto end; } @@ -394,7 +394,7 @@ int write_event_header(struct fs_sink_stream *stream, BT_ASSERT(cs); ret = bt_ctfser_write_byte_aligned_unsigned_int(&stream->ctfser, bt_clock_snapshot_get_value(cs), 8, 64, BYTE_ORDER); - if (unlikely(ret)) { + if (G_UNLIKELY(ret)) { goto end; } } @@ -413,7 +413,7 @@ int fs_sink_stream_write_event(struct fs_sink_stream *stream, /* Header */ ret = write_event_header(stream, cs, ec); - if (unlikely(ret)) { + if (G_UNLIKELY(ret)) { goto end; } @@ -424,7 +424,7 @@ int fs_sink_stream_write_event(struct fs_sink_stream *stream, ret = write_struct_field(stream, (void *) stream->sc->event_common_context_fc, field, true); - if (unlikely(ret)) { + if (G_UNLIKELY(ret)) { goto end; } } @@ -435,7 +435,7 @@ int fs_sink_stream_write_event(struct fs_sink_stream *stream, BT_ASSERT(field); ret = write_struct_field(stream, (void *) ec->spec_context_fc, field, true); - if (unlikely(ret)) { + if (G_UNLIKELY(ret)) { goto end; } } @@ -446,7 +446,7 @@ int fs_sink_stream_write_event(struct fs_sink_stream *stream, BT_ASSERT(field); ret = write_struct_field(stream, (void *) ec->payload_fc, field, true); - if (unlikely(ret)) { + if (G_UNLIKELY(ret)) { goto end; } } diff --git a/src/plugins/ctf/fs-sink/fs-sink-stream.h b/src/plugins/ctf/fs-sink/fs-sink-stream.h index c3efc9a0..adefbb20 100644 --- a/src/plugins/ctf/fs-sink/fs-sink-stream.h +++ b/src/plugins/ctf/fs-sink/fs-sink-stream.h @@ -23,7 +23,7 @@ * SOFTWARE. */ -#include "common/babeltrace.h" +#include "common/macros.h" #include #include "ctfser/ctfser.h" #include diff --git a/src/plugins/ctf/fs-sink/fs-sink-trace.h b/src/plugins/ctf/fs-sink/fs-sink-trace.h index 9a8ac525..f60cad93 100644 --- a/src/plugins/ctf/fs-sink/fs-sink-trace.h +++ b/src/plugins/ctf/fs-sink/fs-sink-trace.h @@ -23,7 +23,7 @@ * SOFTWARE. */ -#include "common/babeltrace.h" +#include "common/macros.h" #include #include "ctfser/ctfser.h" #include diff --git a/src/plugins/ctf/fs-sink/fs-sink.c b/src/plugins/ctf/fs-sink/fs-sink.c index 42d822e1..7ecc7875 100644 --- a/src/plugins/ctf/fs-sink/fs-sink.c +++ b/src/plugins/ctf/fs-sink/fs-sink.c @@ -233,7 +233,7 @@ struct fs_sink_stream *borrow_stream(struct fs_sink_comp *fs_sink, struct fs_sink_stream *stream = NULL; trace = g_hash_table_lookup(fs_sink->traces, ir_trace); - if (unlikely(!trace)) { + if (G_UNLIKELY(!trace)) { if (fs_sink->assume_single_trace && g_hash_table_size(fs_sink->traces) > 0) { BT_LOGE("Single trace mode, but getting more than one trace: " @@ -249,7 +249,7 @@ struct fs_sink_stream *borrow_stream(struct fs_sink_comp *fs_sink, } stream = g_hash_table_lookup(trace->streams, ir_stream); - if (unlikely(!stream)) { + if (G_UNLIKELY(!stream)) { stream = fs_sink_stream_create(trace, ir_stream); if (!stream) { goto end; @@ -273,7 +273,7 @@ bt_self_component_status handle_event_msg(struct fs_sink_comp *fs_sink, const bt_clock_snapshot *cs = NULL; stream = borrow_stream(fs_sink, ir_stream); - if (unlikely(!stream)) { + if (G_UNLIKELY(!stream)) { status = BT_SELF_COMPONENT_STATUS_ERROR; goto end; } @@ -293,7 +293,7 @@ bt_self_component_status handle_event_msg(struct fs_sink_comp *fs_sink, } ret = fs_sink_stream_write_event(stream, cs, ir_event, ec); - if (unlikely(ret)) { + if (G_UNLIKELY(ret)) { status = BT_SELF_COMPONENT_STATUS_ERROR; goto end; } @@ -315,7 +315,7 @@ bt_self_component_status handle_packet_beginning_msg( const bt_clock_snapshot *cs = NULL; stream = borrow_stream(fs_sink, ir_stream); - if (unlikely(!stream)) { + if (G_UNLIKELY(!stream)) { status = BT_SELF_COMPONENT_STATUS_ERROR; goto end; } @@ -502,7 +502,7 @@ bt_self_component_status handle_packet_end_msg( const bt_clock_snapshot *cs = NULL; stream = borrow_stream(fs_sink, ir_stream); - if (unlikely(!stream)) { + if (G_UNLIKELY(!stream)) { status = BT_SELF_COMPONENT_STATUS_ERROR; goto end; } diff --git a/src/plugins/ctf/fs-sink/fs-sink.h b/src/plugins/ctf/fs-sink/fs-sink.h index 7a740bc2..d4255aef 100644 --- a/src/plugins/ctf/fs-sink/fs-sink.h +++ b/src/plugins/ctf/fs-sink/fs-sink.h @@ -23,7 +23,7 @@ * SOFTWARE. */ -#include "common/babeltrace.h" +#include "common/macros.h" #include #include #include diff --git a/src/plugins/ctf/fs-sink/translate-ctf-ir-to-tsdl.c b/src/plugins/ctf/fs-sink/translate-ctf-ir-to-tsdl.c index 3b6d2bc9..c81b70f6 100644 --- a/src/plugins/ctf/fs-sink/translate-ctf-ir-to-tsdl.c +++ b/src/plugins/ctf/fs-sink/translate-ctf-ir-to-tsdl.c @@ -24,7 +24,7 @@ #include "logging.h" #include -#include "common/babeltrace.h" +#include "common/macros.h" #include #include #include diff --git a/src/plugins/ctf/fs-sink/translate-ctf-ir-to-tsdl.h b/src/plugins/ctf/fs-sink/translate-ctf-ir-to-tsdl.h index 4ed02625..8490629d 100644 --- a/src/plugins/ctf/fs-sink/translate-ctf-ir-to-tsdl.h +++ b/src/plugins/ctf/fs-sink/translate-ctf-ir-to-tsdl.h @@ -25,6 +25,7 @@ #include +#include "common/macros.h" #include "fs-sink-ctf-meta.h" BT_HIDDEN diff --git a/src/plugins/ctf/fs-sink/translate-trace-ir-to-ctf-ir.c b/src/plugins/ctf/fs-sink/translate-trace-ir-to-ctf-ir.c index 64f4d5ea..10243227 100644 --- a/src/plugins/ctf/fs-sink/translate-trace-ir-to-ctf-ir.c +++ b/src/plugins/ctf/fs-sink/translate-trace-ir-to-ctf-ir.c @@ -24,7 +24,7 @@ #include "logging.h" #include -#include "common/babeltrace.h" +#include "common/macros.h" #include "common/common.h" #include "common/assert.h" #include @@ -1095,7 +1095,7 @@ int try_translate_event_class_trace_ir_to_ctf_ir( /* Check in hash table first */ *out_ec = g_hash_table_lookup(sc->event_classes_from_ir, ir_ec); - if (likely(*out_ec)) { + if (G_LIKELY(*out_ec)) { goto end; } diff --git a/src/plugins/ctf/fs-sink/translate-trace-ir-to-ctf-ir.h b/src/plugins/ctf/fs-sink/translate-trace-ir-to-ctf-ir.h index 3a1a31e1..23a9e2b5 100644 --- a/src/plugins/ctf/fs-sink/translate-trace-ir-to-ctf-ir.h +++ b/src/plugins/ctf/fs-sink/translate-trace-ir-to-ctf-ir.h @@ -23,7 +23,7 @@ * SOFTWARE. */ -#include "common/babeltrace.h" +#include "common/macros.h" #include #include "fs-sink-ctf-meta.h" diff --git a/src/plugins/ctf/fs-src/data-stream-file.h b/src/plugins/ctf/fs-src/data-stream-file.h index c826a656..d3ad00ff 100644 --- a/src/plugins/ctf/fs-src/data-stream-file.h +++ b/src/plugins/ctf/fs-src/data-stream-file.h @@ -26,7 +26,7 @@ #include #include #include -#include "common/babeltrace.h" +#include "common/macros.h" #include #include "../common/msg-iter/msg-iter.h" diff --git a/src/plugins/ctf/fs-src/file.h b/src/plugins/ctf/fs-src/file.h index 509b1e4e..78209384 100644 --- a/src/plugins/ctf/fs-src/file.h +++ b/src/plugins/ctf/fs-src/file.h @@ -25,7 +25,7 @@ #include #include -#include "common/babeltrace.h" +#include "common/macros.h" #include "fs.h" BT_HIDDEN diff --git a/src/plugins/ctf/fs-src/fs.h b/src/plugins/ctf/fs-src/fs.h index 33e1f568..e034b416 100644 --- a/src/plugins/ctf/fs-src/fs.h +++ b/src/plugins/ctf/fs-src/fs.h @@ -29,7 +29,7 @@ */ #include -#include "common/babeltrace.h" +#include "common/macros.h" #include #include "data-stream-file.h" #include "metadata.h" diff --git a/src/plugins/ctf/fs-src/metadata.h b/src/plugins/ctf/fs-src/metadata.h index 414b875b..7af06182 100644 --- a/src/plugins/ctf/fs-src/metadata.h +++ b/src/plugins/ctf/fs-src/metadata.h @@ -25,7 +25,7 @@ #include #include -#include "common/babeltrace.h" +#include "common/macros.h" #include #define CTF_FS_METADATA_FILENAME "metadata" diff --git a/src/plugins/ctf/fs-src/query.c b/src/plugins/ctf/fs-src/query.c index 3fa28b86..b83a4353 100644 --- a/src/plugins/ctf/fs-src/query.c +++ b/src/plugins/ctf/fs-src/query.c @@ -30,7 +30,7 @@ #include "metadata.h" #include "../common/metadata/decoder.h" #include "common/common.h" -#include "common/babeltrace.h" +#include "common/macros.h" #include #include "fs.h" @@ -427,15 +427,15 @@ int populate_trace_info(const struct ctf_fs_trace *trace, bt_value *trace_info) } if (group_range.set) { - trace_range.begin_ns = min(trace_range.begin_ns, + trace_range.begin_ns = MIN(trace_range.begin_ns, group_range.begin_ns); - trace_range.end_ns = max(trace_range.end_ns, + trace_range.end_ns = MAX(trace_range.end_ns, group_range.end_ns); trace_range.set = true; - trace_intersection.begin_ns = max(trace_intersection.begin_ns, + trace_intersection.begin_ns = MAX(trace_intersection.begin_ns, group_range.begin_ns); - trace_intersection.end_ns = min(trace_intersection.end_ns, + trace_intersection.end_ns = MIN(trace_intersection.end_ns, group_range.end_ns); trace_intersection.set = true; } diff --git a/src/plugins/ctf/fs-src/query.h b/src/plugins/ctf/fs-src/query.h index 4125e4a9..35ee4b6c 100644 --- a/src/plugins/ctf/fs-src/query.h +++ b/src/plugins/ctf/fs-src/query.h @@ -25,7 +25,7 @@ * SOFTWARE. */ -#include "common/babeltrace.h" +#include "common/macros.h" #include BT_HIDDEN diff --git a/src/plugins/ctf/lttng-live/data-stream.h b/src/plugins/ctf/lttng-live/data-stream.h index d9e273a8..94943e2a 100644 --- a/src/plugins/ctf/lttng-live/data-stream.h +++ b/src/plugins/ctf/lttng-live/data-stream.h @@ -25,7 +25,7 @@ #include #include -#include "common/babeltrace.h" +#include "common/macros.h" #include #include "lttng-live.h" diff --git a/src/plugins/ctf/lttng-live/lttng-live.h b/src/plugins/ctf/lttng-live/lttng-live.h index 5c8dc41b..1ae7e0f3 100644 --- a/src/plugins/ctf/lttng-live/lttng-live.h +++ b/src/plugins/ctf/lttng-live/lttng-live.h @@ -31,7 +31,7 @@ #include -#include "common/babeltrace.h" +#include "common/macros.h" #include #include "../common/metadata/decoder.h" diff --git a/src/plugins/ctf/lttng-live/metadata.h b/src/plugins/ctf/lttng-live/metadata.h index 2cf8ae19..0731c33d 100644 --- a/src/plugins/ctf/lttng-live/metadata.h +++ b/src/plugins/ctf/lttng-live/metadata.h @@ -25,7 +25,7 @@ #include #include -#include "common/babeltrace.h" +#include "common/macros.h" #include #include "lttng-live.h" diff --git a/src/plugins/ctf/lttng-live/viewer-connection.c b/src/plugins/ctf/lttng-live/viewer-connection.c index 4a74ff9f..420f732b 100644 --- a/src/plugins/ctf/lttng-live/viewer-connection.c +++ b/src/plugins/ctf/lttng-live/viewer-connection.c @@ -373,7 +373,7 @@ int list_update_session(bt_value *results, } val = bt_value_signed_integer_get(btval); /* max */ - val = max_t(int64_t, clients, val); + val = bt_max_t(int64_t, clients, val); bt_value_signed_integer_set(btval, val); } @@ -1050,9 +1050,9 @@ ssize_t lttng_live_get_one_metadata_packet(struct lttng_live_trace *trace, goto error; } - data = zmalloc(len); + data = calloc(1, len); if (!data) { - BT_LOGE("relay data zmalloc: %s", strerror(errno)); + BT_LOGE("relay data calloc: %s", strerror(errno)); goto error; } ret_len = lttng_live_recv(viewer_connection, data, len); diff --git a/src/plugins/ctf/lttng-live/viewer-connection.h b/src/plugins/ctf/lttng-live/viewer-connection.h index 09adc6cf..761660f6 100644 --- a/src/plugins/ctf/lttng-live/viewer-connection.h +++ b/src/plugins/ctf/lttng-live/viewer-connection.h @@ -26,7 +26,7 @@ #include #include -#include "common/babeltrace.h" +#include "common/macros.h" #include "compat/socket.h" //TODO: this should not be used by plugins. Should copy code into plugin diff --git a/src/plugins/lttng-utils/debug-info/bin-info.h b/src/plugins/lttng-utils/debug-info/bin-info.h index bf473690..00a6e4e0 100644 --- a/src/plugins/lttng-utils/debug-info/bin-info.h +++ b/src/plugins/lttng-utils/debug-info/bin-info.h @@ -31,7 +31,7 @@ #include #include #include -#include "common/babeltrace.h" +#include "common/macros.h" #include "fd-cache/fd-cache.h" #define DEFAULT_DEBUG_DIR "/usr/lib/debug" diff --git a/src/plugins/lttng-utils/debug-info/crc32.h b/src/plugins/lttng-utils/debug-info/crc32.h index 73438192..5d3c07a1 100644 --- a/src/plugins/lttng-utils/debug-info/crc32.h +++ b/src/plugins/lttng-utils/debug-info/crc32.h @@ -37,7 +37,7 @@ #include #include #include -#include "common/babeltrace.h" +#include "common/macros.h" /** * Compute a 32-bit cyclic redundancy checksum for a given file. diff --git a/src/plugins/lttng-utils/debug-info/debug-info.h b/src/plugins/lttng-utils/debug-info/debug-info.h index ef99f718..c5237924 100644 --- a/src/plugins/lttng-utils/debug-info/debug-info.h +++ b/src/plugins/lttng-utils/debug-info/debug-info.h @@ -29,7 +29,7 @@ #include #include -#include "common/babeltrace.h" +#include "common/macros.h" #define VPID_FIELD_NAME "vpid" #define IP_FIELD_NAME "ip" diff --git a/src/plugins/lttng-utils/debug-info/dwarf.h b/src/plugins/lttng-utils/debug-info/dwarf.h index 4ab527b0..90d66e4d 100644 --- a/src/plugins/lttng-utils/debug-info/dwarf.h +++ b/src/plugins/lttng-utils/debug-info/dwarf.h @@ -32,7 +32,7 @@ #include #include #include -#include "common/babeltrace.h" +#include "common/macros.h" /* * bt_dwarf is a wrapper over libdw providing a nicer, higher-level diff --git a/src/plugins/lttng-utils/debug-info/trace-ir-data-copy.h b/src/plugins/lttng-utils/debug-info/trace-ir-data-copy.h index b9259769..ddb1b89d 100644 --- a/src/plugins/lttng-utils/debug-info/trace-ir-data-copy.h +++ b/src/plugins/lttng-utils/debug-info/trace-ir-data-copy.h @@ -28,6 +28,7 @@ #include +#include "common/macros.h" #include "trace-ir-mapping.h" BT_HIDDEN diff --git a/src/plugins/lttng-utils/debug-info/trace-ir-mapping.h b/src/plugins/lttng-utils/debug-info/trace-ir-mapping.h index 9691785b..fda6a729 100644 --- a/src/plugins/lttng-utils/debug-info/trace-ir-mapping.h +++ b/src/plugins/lttng-utils/debug-info/trace-ir-mapping.h @@ -25,6 +25,7 @@ #include #include "common/assert.h" +#include "common/macros.h" #include #include "debug-info.h" diff --git a/src/plugins/lttng-utils/debug-info/trace-ir-metadata-copy.h b/src/plugins/lttng-utils/debug-info/trace-ir-metadata-copy.h index 9330546d..f9f80644 100644 --- a/src/plugins/lttng-utils/debug-info/trace-ir-metadata-copy.h +++ b/src/plugins/lttng-utils/debug-info/trace-ir-metadata-copy.h @@ -28,6 +28,7 @@ */ #include +#include "common/macros.h" #include "trace-ir-mapping.h" BT_HIDDEN diff --git a/src/plugins/lttng-utils/debug-info/trace-ir-metadata-field-class-copy.h b/src/plugins/lttng-utils/debug-info/trace-ir-metadata-field-class-copy.h index 3bd5b80f..7df3fb2c 100644 --- a/src/plugins/lttng-utils/debug-info/trace-ir-metadata-field-class-copy.h +++ b/src/plugins/lttng-utils/debug-info/trace-ir-metadata-field-class-copy.h @@ -27,6 +27,7 @@ */ #include +#include "common/macros.h" #include "trace-ir-mapping.h" BT_HIDDEN diff --git a/src/plugins/lttng-utils/debug-info/utils.c b/src/plugins/lttng-utils/debug-info/utils.c index 8f1bddea..3dfdf793 100644 --- a/src/plugins/lttng-utils/debug-info/utils.c +++ b/src/plugins/lttng-utils/debug-info/utils.c @@ -22,6 +22,7 @@ * SOFTWARE. */ +#include #include "utils.h" BT_HIDDEN diff --git a/src/plugins/lttng-utils/debug-info/utils.h b/src/plugins/lttng-utils/debug-info/utils.h index 393f34eb..79b02a03 100644 --- a/src/plugins/lttng-utils/debug-info/utils.h +++ b/src/plugins/lttng-utils/debug-info/utils.h @@ -26,7 +26,7 @@ * SOFTWARE. */ -#include "common/babeltrace.h" +#include "common/macros.h" #include "trace-ir-mapping.h" /* diff --git a/src/plugins/text/dmesg/dmesg.h b/src/plugins/text/dmesg/dmesg.h index 6fc5ddef..fd29d7a5 100644 --- a/src/plugins/text/dmesg/dmesg.h +++ b/src/plugins/text/dmesg/dmesg.h @@ -24,7 +24,7 @@ */ #include -#include "common/babeltrace.h" +#include "common/macros.h" #include BT_HIDDEN diff --git a/src/plugins/text/pretty/pretty.h b/src/plugins/text/pretty/pretty.h index e3a24106..72203df2 100644 --- a/src/plugins/text/pretty/pretty.h +++ b/src/plugins/text/pretty/pretty.h @@ -25,8 +25,10 @@ * SOFTWARE. */ +#include +#include #include -#include "common/babeltrace.h" +#include "common/macros.h" #include enum pretty_default { diff --git a/src/plugins/text/pretty/print.c b/src/plugins/text/pretty/print.c index 388a0915..7ba5b3b4 100644 --- a/src/plugins/text/pretty/print.c +++ b/src/plugins/text/pretty/print.c @@ -30,6 +30,7 @@ #include "common/assert.h" #include #include +#include #include "pretty.h" #define NSEC_PER_SEC 1000000000LL diff --git a/src/plugins/utils/counter/counter.c b/src/plugins/utils/counter/counter.c index 37ddd030..200b9aa7 100644 --- a/src/plugins/utils/counter/counter.c +++ b/src/plugins/utils/counter/counter.c @@ -24,7 +24,7 @@ #include "logging.h" #include -#include "common/babeltrace.h" +#include "common/macros.h" #include "common/common.h" #include "plugins/plugins-common.h" #include "common/assert.h" @@ -236,7 +236,7 @@ bt_self_component_status counter_consume( bt_self_component_sink_as_self_component(comp)); BT_ASSERT(counter); - if (unlikely(!counter->msg_iter)) { + if (G_UNLIKELY(!counter->msg_iter)) { try_print_last(counter); ret = BT_SELF_COMPONENT_STATUS_END; goto end; diff --git a/src/plugins/utils/counter/counter.h b/src/plugins/utils/counter/counter.h index c29f0fd5..4052736e 100644 --- a/src/plugins/utils/counter/counter.h +++ b/src/plugins/utils/counter/counter.h @@ -27,6 +27,7 @@ #include #include #include +#include "common/macros.h" struct counter { bt_self_component_port_input_message_iterator *msg_iter; diff --git a/src/plugins/utils/dummy/dummy.c b/src/plugins/utils/dummy/dummy.c index 5da07ea2..d21f26a3 100644 --- a/src/plugins/utils/dummy/dummy.c +++ b/src/plugins/utils/dummy/dummy.c @@ -21,7 +21,7 @@ */ #include -#include "common/babeltrace.h" +#include "common/macros.h" #include "plugins/plugins-common.h" #include "common/assert.h" #include "dummy.h" @@ -120,7 +120,7 @@ bt_self_component_status dummy_consume( bt_self_component_sink_as_self_component(component)); BT_ASSERT(dummy); - if (unlikely(!dummy->msg_iter)) { + if (G_UNLIKELY(!dummy->msg_iter)) { ret = BT_SELF_COMPONENT_STATUS_END; goto end; } diff --git a/src/plugins/utils/dummy/dummy.h b/src/plugins/utils/dummy/dummy.h index ea44ecb9..2b05f6cf 100644 --- a/src/plugins/utils/dummy/dummy.h +++ b/src/plugins/utils/dummy/dummy.h @@ -25,7 +25,7 @@ #include #include -#include "common/babeltrace.h" +#include "common/macros.h" #include struct dummy { diff --git a/src/plugins/utils/muxer/muxer.c b/src/plugins/utils/muxer/muxer.c index b575f967..827532d9 100644 --- a/src/plugins/utils/muxer/muxer.c +++ b/src/plugins/utils/muxer/muxer.c @@ -23,7 +23,7 @@ #define BT_LOG_TAG "PLUGIN-UTILS-MUXER-FLT" #include "logging.h" -#include "common/babeltrace.h" +#include "common/macros.h" #include "compat/uuid.h" #include #include "lib/value.h" @@ -516,7 +516,7 @@ int get_msg_ts_ns(struct muxer_comp *muxer_comp, "last-returned-ts=%" PRId64, muxer_msg_iter, msg, last_returned_ts_ns); - if (unlikely(muxer_msg_iter->clock_class_expectation == + if (G_UNLIKELY(muxer_msg_iter->clock_class_expectation == MUXER_MSG_ITER_CLOCK_CLASS_EXPECTATION_NONE)) { *ts_ns = last_returned_ts_ns; goto end; @@ -524,20 +524,20 @@ int get_msg_ts_ns(struct muxer_comp *muxer_comp, msg_type = bt_message_get_type(msg); - if (unlikely(msg_type == BT_MESSAGE_TYPE_PACKET_BEGINNING)) { + if (G_UNLIKELY(msg_type == BT_MESSAGE_TYPE_PACKET_BEGINNING)) { stream_class = bt_stream_borrow_class_const( bt_packet_borrow_stream_const( bt_message_packet_beginning_borrow_packet_const( msg))); - } else if (unlikely(msg_type == BT_MESSAGE_TYPE_PACKET_END)) { + } else if (G_UNLIKELY(msg_type == BT_MESSAGE_TYPE_PACKET_END)) { stream_class = bt_stream_borrow_class_const( bt_packet_borrow_stream_const( bt_message_packet_end_borrow_packet_const( msg))); - } else if (unlikely(msg_type == BT_MESSAGE_TYPE_DISCARDED_EVENTS)) { + } else if (G_UNLIKELY(msg_type == BT_MESSAGE_TYPE_DISCARDED_EVENTS)) { stream_class = bt_stream_borrow_class_const( bt_message_discarded_events_borrow_stream_const(msg)); - } else if (unlikely(msg_type == BT_MESSAGE_TYPE_DISCARDED_PACKETS)) { + } else if (G_UNLIKELY(msg_type == BT_MESSAGE_TYPE_DISCARDED_PACKETS)) { stream_class = bt_stream_borrow_class_const( bt_message_discarded_packets_borrow_stream_const(msg)); } @@ -915,7 +915,7 @@ muxer_msg_iter_youngest_upstream_msg_iter( msg = g_queue_peek_head(cur_muxer_upstream_msg_iter->msgs); BT_ASSERT(msg); - if (unlikely(bt_message_get_type(msg) == + if (G_UNLIKELY(bt_message_get_type(msg) == BT_MESSAGE_TYPE_STREAM_BEGINNING)) { ret = validate_new_stream_clock_class( muxer_msg_iter, muxer_comp, @@ -929,7 +929,7 @@ muxer_msg_iter_youngest_upstream_msg_iter( status = BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR; goto end; } - } else if (unlikely(bt_message_get_type(msg) == + } else if (G_UNLIKELY(bt_message_get_type(msg) == BT_MESSAGE_TYPE_MESSAGE_ITERATOR_INACTIVITY)) { const bt_clock_snapshot *cs; @@ -1042,7 +1042,7 @@ bt_self_message_iterator_status validate_muxer_upstream_msg_iters( * Move this muxer upstream message iterator to the * array of ended iterators if it's ended. */ - if (unlikely(is_ended)) { + if (G_UNLIKELY(is_ended)) { BT_LOGV("Muxer's upstream message iterator wrapper: ended or canceled: " "muxer-msg-iter-addr=%p, " "muxer-upstream-msg-iter-wrap-addr=%p", diff --git a/src/plugins/utils/muxer/muxer.h b/src/plugins/utils/muxer/muxer.h index a383e4c2..43b4d52b 100644 --- a/src/plugins/utils/muxer/muxer.h +++ b/src/plugins/utils/muxer/muxer.h @@ -26,7 +26,7 @@ #include #include -#include "common/babeltrace.h" +#include "common/macros.h" BT_HIDDEN bt_self_component_status muxer_init( diff --git a/src/plugins/utils/trimmer/trimmer.c b/src/plugins/utils/trimmer/trimmer.c index f2d2c434..b8cc481a 100644 --- a/src/plugins/utils/trimmer/trimmer.c +++ b/src/plugins/utils/trimmer/trimmer.c @@ -632,7 +632,7 @@ int get_msg_ns_from_origin(const bt_message *msg, int64_t *ns_from_origin, clock_class = bt_message_event_borrow_stream_class_default_clock_class_const( msg); - if (unlikely(!clock_class)) { + if (G_UNLIKELY(!clock_class)) { goto error; } @@ -643,7 +643,7 @@ int get_msg_ns_from_origin(const bt_message *msg, int64_t *ns_from_origin, clock_class = bt_message_packet_beginning_borrow_stream_class_default_clock_class_const( msg); - if (unlikely(!clock_class)) { + if (G_UNLIKELY(!clock_class)) { goto error; } @@ -654,7 +654,7 @@ int get_msg_ns_from_origin(const bt_message *msg, int64_t *ns_from_origin, clock_class = bt_message_packet_end_borrow_stream_class_default_clock_class_const( msg); - if (unlikely(!clock_class)) { + if (G_UNLIKELY(!clock_class)) { goto error; } @@ -665,7 +665,7 @@ int get_msg_ns_from_origin(const bt_message *msg, int64_t *ns_from_origin, clock_class = bt_message_discarded_events_borrow_stream_class_default_clock_class_const( msg); - if (unlikely(!clock_class)) { + if (G_UNLIKELY(!clock_class)) { goto error; } @@ -676,7 +676,7 @@ int get_msg_ns_from_origin(const bt_message *msg, int64_t *ns_from_origin, clock_class = bt_message_discarded_packets_borrow_stream_class_default_clock_class_const( msg); - if (unlikely(!clock_class)) { + if (G_UNLIKELY(!clock_class)) { goto error; } @@ -687,7 +687,7 @@ int get_msg_ns_from_origin(const bt_message *msg, int64_t *ns_from_origin, clock_class = bt_message_stream_activity_beginning_borrow_stream_class_default_clock_class_const( msg); - if (unlikely(!clock_class)) { + if (G_UNLIKELY(!clock_class)) { goto error; } @@ -705,7 +705,7 @@ int get_msg_ns_from_origin(const bt_message *msg, int64_t *ns_from_origin, clock_class = bt_message_stream_activity_end_borrow_stream_class_default_clock_class_const( msg); - if (unlikely(!clock_class)) { + if (G_UNLIKELY(!clock_class)) { goto error; } @@ -733,7 +733,7 @@ int get_msg_ns_from_origin(const bt_message *msg, int64_t *ns_from_origin, ret = bt_clock_snapshot_get_ns_from_origin(clock_snapshot, ns_from_origin); - if (unlikely(ret)) { + if (G_UNLIKELY(ret)) { goto error; } @@ -1318,14 +1318,14 @@ bt_self_message_iterator_status handle_message_with_stream_state( switch (msg_type) { case BT_MESSAGE_TYPE_EVENT: - if (unlikely(!trimmer_it->end.is_infinite && + if (G_UNLIKELY(!trimmer_it->end.is_infinite && ns_from_origin > trimmer_it->end.ns_from_origin)) { status = end_iterator_streams(trimmer_it); *reached_end = true; break; } - if (unlikely(!sstate->inited)) { + if (G_UNLIKELY(!sstate->inited)) { status = ensure_stream_state_is_inited(trimmer_it, sstate, NULL); if (status != BT_SELF_MESSAGE_ITERATOR_STATUS_OK) { @@ -1333,7 +1333,7 @@ bt_self_message_iterator_status handle_message_with_stream_state( } } - if (unlikely(!sstate->cur_packet)) { + if (G_UNLIKELY(!sstate->cur_packet)) { const bt_event *event = bt_message_event_borrow_event_const(msg); const bt_packet *packet = bt_event_borrow_packet_const( @@ -1351,14 +1351,14 @@ bt_self_message_iterator_status handle_message_with_stream_state( msg = NULL; break; case BT_MESSAGE_TYPE_PACKET_BEGINNING: - if (unlikely(!trimmer_it->end.is_infinite && + if (G_UNLIKELY(!trimmer_it->end.is_infinite && ns_from_origin > trimmer_it->end.ns_from_origin)) { status = end_iterator_streams(trimmer_it); *reached_end = true; break; } - if (unlikely(!sstate->inited)) { + if (G_UNLIKELY(!sstate->inited)) { status = ensure_stream_state_is_inited(trimmer_it, sstate, NULL); if (status != BT_SELF_MESSAGE_ITERATOR_STATUS_OK) { @@ -1376,14 +1376,14 @@ bt_self_message_iterator_status handle_message_with_stream_state( case BT_MESSAGE_TYPE_PACKET_END: sstate->stream_act_end_ns_from_origin = ns_from_origin; - if (unlikely(!trimmer_it->end.is_infinite && + if (G_UNLIKELY(!trimmer_it->end.is_infinite && ns_from_origin > trimmer_it->end.ns_from_origin)) { status = end_iterator_streams(trimmer_it); *reached_end = true; break; } - if (unlikely(!sstate->inited)) { + if (G_UNLIKELY(!sstate->inited)) { status = ensure_stream_state_is_inited(trimmer_it, sstate, NULL); if (status != BT_SELF_MESSAGE_ITERATOR_STATUS_OK) { @@ -1391,7 +1391,7 @@ bt_self_message_iterator_status handle_message_with_stream_state( } } - if (unlikely(!sstate->cur_packet)) { + if (G_UNLIKELY(!sstate->cur_packet)) { const bt_packet *packet = bt_message_packet_end_borrow_packet_const(msg); @@ -1501,7 +1501,7 @@ bt_self_message_iterator_status handle_message_with_stream_state( BT_MESSAGE_MOVE_REF(msg, new_msg); } - if (unlikely(!sstate->inited)) { + if (G_UNLIKELY(!sstate->inited)) { status = ensure_stream_state_is_inited(trimmer_it, sstate, NULL); if (status != BT_SELF_MESSAGE_ITERATOR_STATUS_OK) { @@ -1702,11 +1702,11 @@ bt_self_message_iterator_status handle_message( break; } - if (likely(stream)) { + if (G_LIKELY(stream)) { /* Find stream state */ sstate = g_hash_table_lookup(trimmer_it->stream_states, stream); - if (unlikely(!sstate)) { + if (G_UNLIKELY(!sstate)) { /* No stream state yet: create one now */ const bt_stream_class *sc; @@ -1808,12 +1808,12 @@ bt_self_message_iterator_status handle_message( /* Retrieve the message's time */ ret = get_msg_ns_from_origin(msg, &ns_from_origin, &skip); - if (unlikely(ret)) { + if (G_UNLIKELY(ret)) { status = BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR; goto end; } - if (likely(sstate)) { + if (G_LIKELY(sstate)) { /* Message associated to a stream */ status = handle_message_with_stream_state(trimmer_it, msg, sstate, ns_from_origin, reached_end); @@ -1828,7 +1828,7 @@ bt_self_message_iterator_status handle_message( * Message not associated to a stream (message iterator * inactivity). */ - if (unlikely(ns_from_origin > trimmer_it->end.ns_from_origin)) { + if (G_UNLIKELY(ns_from_origin > trimmer_it->end.ns_from_origin)) { BT_MESSAGE_PUT_REF_AND_RESET(msg); status = end_iterator_streams(trimmer_it); *reached_end = true; @@ -1902,7 +1902,7 @@ bt_self_message_iterator_status state_trim(struct trimmer_iterator *trimmer_it, while (g_queue_is_empty(trimmer_it->output_messages)) { status = (int) bt_self_component_port_input_message_iterator_next( trimmer_it->upstream_iter, &my_msgs, &my_count); - if (unlikely(status != BT_SELF_MESSAGE_ITERATOR_STATUS_OK)) { + if (G_UNLIKELY(status != BT_SELF_MESSAGE_ITERATOR_STATUS_OK)) { if (status == BT_SELF_MESSAGE_ITERATOR_STATUS_END) { status = end_iterator_streams(trimmer_it); if (status != BT_SELF_MESSAGE_ITERATOR_STATUS_OK) { @@ -1930,13 +1930,13 @@ bt_self_message_iterator_status state_trim(struct trimmer_iterator *trimmer_it, */ my_msgs[i] = NULL; - if (unlikely(status != + if (G_UNLIKELY(status != BT_SELF_MESSAGE_ITERATOR_STATUS_OK)) { put_messages(my_msgs, my_count); goto end; } - if (unlikely(reached_end)) { + if (G_UNLIKELY(reached_end)) { /* * This message's time was passed the * trimming time range's end time: we @@ -1982,7 +1982,7 @@ bt_self_message_iterator_status trimmer_msg_iter_next( BT_ASSERT(trimmer_it); - if (likely(trimmer_it->state == TRIMMER_ITERATOR_STATE_TRIM)) { + if (G_LIKELY(trimmer_it->state == TRIMMER_ITERATOR_STATE_TRIM)) { status = state_trim(trimmer_it, msgs, capacity, count); if (status != BT_SELF_MESSAGE_ITERATOR_STATUS_OK) { goto end; diff --git a/src/plugins/utils/trimmer/trimmer.h b/src/plugins/utils/trimmer/trimmer.h index 27f23294..46ac8a38 100644 --- a/src/plugins/utils/trimmer/trimmer.h +++ b/src/plugins/utils/trimmer/trimmer.h @@ -28,7 +28,7 @@ */ #include -#include "common/babeltrace.h" +#include "common/macros.h" #include BT_HIDDEN diff --git a/src/python-plugin-provider/python-plugin-provider.c b/src/python-plugin-provider/python-plugin-provider.c index 35f87555..eb59f8ca 100644 --- a/src/python-plugin-provider/python-plugin-provider.c +++ b/src/python-plugin-provider/python-plugin-provider.c @@ -26,7 +26,7 @@ #define BT_LOG_TAG "PLUGIN-PY" -#include "common/babeltrace.h" +#include "common/macros.h" #include "compat/compiler.h" #include #include "lib/plugin/plugin.h" diff --git a/tests/lib/test_trace_ir_ref.c b/tests/lib/test_trace_ir_ref.c index 10916fba..72bbbd6b 100644 --- a/tests/lib/test_trace_ir_ref.c +++ b/tests/lib/test_trace_ir_ref.c @@ -19,6 +19,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include #include "tap/tap.h" #include #include "lib/object.h" diff --git a/tests/plugins/test_bin_info.c b/tests/plugins/test_bin_info.c index a4c95d05..d681ef56 100644 --- a/tests/plugins/test_bin_info.c +++ b/tests/plugins/test_bin_info.c @@ -27,7 +27,7 @@ #include #include -#include "common/babeltrace.h" +#include "common/macros.h" #include "common/assert.h" #include diff --git a/tests/plugins/test_dwarf.c b/tests/plugins/test_dwarf.c index fa475e10..abb72bba 100644 --- a/tests/plugins/test_dwarf.c +++ b/tests/plugins/test_dwarf.c @@ -21,6 +21,7 @@ */ #include +#include #include #include #include