X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=src%2Fctfser%2Fctfser.h;h=caffaec8256cc89fdfc9d29a4a0c4e3e4b40dd11;hb=0235b0db7de5bcacdb3650c92461f2ce5eb2143d;hp=c59af924152bd5e704c66b9ebe6cc80f09ce773d;hpb=91d8147391efdc4d42cc4e1c171a65c0372a008f;p=babeltrace.git diff --git a/src/ctfser/ctfser.h b/src/ctfser/ctfser.h index c59af924..caffaec8 100644 --- a/src/ctfser/ctfser.h +++ b/src/ctfser/ctfser.h @@ -1,33 +1,18 @@ -#ifndef BABELTRACE_CTFSER_INTERNAL_H -#define BABELTRACE_CTFSER_INTERNAL_H - /* + * SPDX-License-Identifier: MIT + * * Copyright 2010-2011 EfficiOS Inc. and Linux Foundation * Copyright 2013, 2014 Jérémie Galarneau * Copyright 2017-2019 Philippe Proulx * - * 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. - * * The Common Trace Format (CTF) Specification is available at * http://www.efficios.com/ctf */ +#ifndef BABELTRACE_CTFSER_INTERNAL_H +#define BABELTRACE_CTFSER_INTERNAL_H + +#include #include #include #include @@ -72,6 +57,9 @@ struct bt_ctfser { /* Stream file's path (for debugging) */ GString *path; + + /* Serializer's log level */ + int log_level; }; /* @@ -80,7 +68,8 @@ struct bt_ctfser { * This function opens the file `path` for writing. */ BT_HIDDEN -int bt_ctfser_init(struct bt_ctfser *ctfser, const char *path); +int bt_ctfser_init(struct bt_ctfser *ctfser, const char *path, + int log_level); /* * Finalizes a CTF serializer. @@ -131,7 +120,7 @@ static inline uint8_t *_bt_ctfser_get_addr(struct bt_ctfser *ctfser) { /* Only makes sense to get the address after aligning on byte */ - BT_ASSERT(ctfser->offset_in_cur_packet_bits % 8 == 0); + BT_ASSERT_DBG(ctfser->offset_in_cur_packet_bits % 8 == 0); return ((uint8_t *) mmap_align_addr(ctfser->base_mma)) + ctfser->mmap_base_offset + _bt_ctfser_offset_bytes(ctfser); } @@ -159,7 +148,7 @@ end: static inline void _bt_ctfser_incr_offset(struct bt_ctfser *ctfser, uint64_t size_bits) { - BT_ASSERT(_bt_ctfser_has_space_left(ctfser, size_bits)); + BT_ASSERT_DBG(_bt_ctfser_has_space_left(ctfser, size_bits)); ctfser->offset_in_cur_packet_bits += size_bits; } @@ -174,7 +163,7 @@ int bt_ctfser_align_offset_in_current_packet(struct bt_ctfser *ctfser, int ret = 0; uint64_t align_size_bits; - BT_ASSERT(alignment_bits > 0); + BT_ASSERT_DBG(alignment_bits > 0); align_size_bits = ALIGN(ctfser->offset_in_cur_packet_bits, alignment_bits) - ctfser->offset_in_cur_packet_bits; @@ -201,8 +190,8 @@ int _bt_ctfser_write_byte_aligned_unsigned_int_no_align( /* Reverse byte order? */ bool rbo = byte_order != BYTE_ORDER; - BT_ASSERT(size_bits % 8 == 0); - BT_ASSERT(_bt_ctfser_has_space_left(ctfser, size_bits)); + BT_ASSERT_DBG(size_bits % 8 == 0); + BT_ASSERT_DBG(_bt_ctfser_has_space_left(ctfser, size_bits)); switch (size_bits) { case 8: @@ -246,7 +235,7 @@ int _bt_ctfser_write_byte_aligned_unsigned_int_no_align( break; } default: - abort(); + bt_common_abort(); } _bt_ctfser_incr_offset(ctfser, size_bits); @@ -263,8 +252,8 @@ int _bt_ctfser_write_byte_aligned_signed_int_no_align( /* Reverse byte order? */ bool rbo = byte_order != BYTE_ORDER; - BT_ASSERT(size_bits % 8 == 0); - BT_ASSERT(_bt_ctfser_has_space_left(ctfser, size_bits)); + BT_ASSERT_DBG(size_bits % 8 == 0); + BT_ASSERT_DBG(_bt_ctfser_has_space_left(ctfser, size_bits)); switch (size_bits) { case 8: @@ -308,7 +297,7 @@ int _bt_ctfser_write_byte_aligned_signed_int_no_align( break; } default: - abort(); + bt_common_abort(); } _bt_ctfser_incr_offset(ctfser, size_bits); @@ -327,7 +316,7 @@ int bt_ctfser_write_byte_aligned_unsigned_int(struct bt_ctfser *ctfser, { int ret; - BT_ASSERT(alignment_bits % 8 == 0); + BT_ASSERT_DBG(alignment_bits % 8 == 0); ret = bt_ctfser_align_offset_in_current_packet(ctfser, alignment_bits); if (G_UNLIKELY(ret)) { goto end; @@ -362,7 +351,7 @@ int bt_ctfser_write_byte_aligned_signed_int(struct bt_ctfser *ctfser, { int ret; - BT_ASSERT(alignment_bits % 8 == 0); + BT_ASSERT_DBG(alignment_bits % 8 == 0); ret = bt_ctfser_align_offset_in_current_packet(ctfser, alignment_bits); if (G_UNLIKELY(ret)) { goto end; @@ -503,10 +492,10 @@ int bt_ctfser_write_float64(struct bt_ctfser *ctfser, double value, { union u64f { uint64_t u; - float f; + double d; } u64f; - u64f.f = value; + u64f.d = value; return bt_ctfser_write_unsigned_int(ctfser, u64f.u, alignment_bits, 64, byte_order); } @@ -564,7 +553,7 @@ static inline void bt_ctfser_set_offset_in_current_packet_bits(struct bt_ctfser *ctfser, uint64_t offset_bits) { - BT_ASSERT(offset_bits <= _bt_ctfser_cur_packet_size_bits(ctfser)); + BT_ASSERT_DBG(offset_bits <= _bt_ctfser_cur_packet_size_bits(ctfser)); ctfser->offset_in_cur_packet_bits = offset_bits; }