+++ /dev/null
-#ifndef _BARECTF_BITFIELD_H
-#define _BARECTF_BITFIELD_H
-
-/*
- * BabelTrace
- *
- * Bitfields read/write functions.
- *
- * Copyright 2010 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * 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 <stdint.h> /* C99 5.2.4.2 Numerical limits */
-#include <limits.h>
-
-#define BARECTF_BYTE_ORDER LITTLE_ENDIAN
-
-/* We can't shift a int from 32 bit, >> 32 and << 32 on int is undefined */
-#define _barectf_bt_piecewise_rshift(_v, _shift) \
-__extension__ ({ \
- __typeof__(_v) ___v = (_v); \
- __typeof__(_shift) ___shift = (_shift); \
- unsigned long sb = (___shift) / (sizeof(___v) * CHAR_BIT - 1); \
- unsigned long final = (___shift) % (sizeof(___v) * CHAR_BIT - 1); \
- \
- for (; sb; sb--) \
- ___v >>= sizeof(___v) * CHAR_BIT - 1; \
- ___v >>= final; \
-})
-
-#define _barectf_bt_piecewise_lshift(_v, _shift) \
-__extension__ ({ \
- __typeof__(_v) ___v = (_v); \
- __typeof__(_shift) ___shift = (_shift); \
- unsigned long sb = (___shift) / (sizeof(___v) * CHAR_BIT - 1); \
- unsigned long final = (___shift) % (sizeof(___v) * CHAR_BIT - 1); \
- \
- for (; sb; sb--) \
- ___v <<= sizeof(___v) * CHAR_BIT - 1; \
- ___v <<= final; \
-})
-
-#define _barectf_bt_is_signed_type(type) ((type) -1 < (type) 0)
-
-#define _barectf_bt_unsigned_cast(type, v) \
-__extension__ ({ \
- (sizeof(v) < sizeof(type)) ? \
- ((type) (v)) & (~(~(type) 0 << (sizeof(v) * CHAR_BIT))) : \
- (type) (v); \
-})
-
-/*
- * barectf_bt_bitfield_write - write integer to a bitfield in native endianness
- *
- * Save integer to the bitfield, which starts at the "start" bit, has "len"
- * bits.
- * The inside of a bitfield is from high bits to low bits.
- * Uses native endianness.
- * For unsigned "v", pad MSB with 0 if bitfield is larger than v.
- * For signed "v", sign-extend v if bitfield is larger than v.
- *
- * On little endian, bytes are placed from the less significant to the most
- * significant. Also, consecutive bitfields are placed from lower bits to higher
- * bits.
- *
- * On big endian, bytes are places from most significant to less significant.
- * Also, consecutive bitfields are placed from higher to lower bits.
- */
-
-#define _barectf_bt_bitfield_write_le(_ptr, type, _start, _length, _v) \
-do { \
- __typeof__(_v) __v = (_v); \
- type *__ptr = (void *) (_ptr); \
- unsigned long __start = (_start), __length = (_length); \
- type mask, cmask; \
- unsigned long ts = sizeof(type) * CHAR_BIT; /* type size */ \
- unsigned long start_unit, end_unit, this_unit; \
- unsigned long end, cshift; /* cshift is "complement shift" */ \
- \
- if (!__length) \
- break; \
- \
- end = __start + __length; \
- start_unit = __start / ts; \
- end_unit = (end + (ts - 1)) / ts; \
- \
- /* Trim v high bits */ \
- if (__length < sizeof(__v) * CHAR_BIT) \
- __v &= ~((~(__typeof__(__v)) 0) << __length); \
- \
- /* We can now append v with a simple "or", shift it piece-wise */ \
- this_unit = start_unit; \
- if (start_unit == end_unit - 1) { \
- mask = ~((~(type) 0) << (__start % ts)); \
- if (end % ts) \
- mask |= (~(type) 0) << (end % ts); \
- cmask = (type) __v << (__start % ts); \
- cmask &= ~mask; \
- __ptr[this_unit] &= mask; \
- __ptr[this_unit] |= cmask; \
- break; \
- } \
- if (__start % ts) { \
- cshift = __start % ts; \
- mask = ~((~(type) 0) << cshift); \
- cmask = (type) __v << cshift; \
- cmask &= ~mask; \
- __ptr[this_unit] &= mask; \
- __ptr[this_unit] |= cmask; \
- __v = _barectf_bt_piecewise_rshift(__v, ts - cshift); \
- __start += ts - cshift; \
- this_unit++; \
- } \
- for (; this_unit < end_unit - 1; this_unit++) { \
- __ptr[this_unit] = (type) __v; \
- __v = _barectf_bt_piecewise_rshift(__v, ts); \
- __start += ts; \
- } \
- if (end % ts) { \
- mask = (~(type) 0) << (end % ts); \
- cmask = (type) __v; \
- cmask &= ~mask; \
- __ptr[this_unit] &= mask; \
- __ptr[this_unit] |= cmask; \
- } else \
- __ptr[this_unit] = (type) __v; \
-} while (0)
-
-#define _barectf_bt_bitfield_write_be(_ptr, type, _start, _length, _v) \
-do { \
- __typeof__(_v) __v = (_v); \
- type *__ptr = (void *) (_ptr); \
- unsigned long __start = (_start), __length = (_length); \
- type mask, cmask; \
- unsigned long ts = sizeof(type) * CHAR_BIT; /* type size */ \
- unsigned long start_unit, end_unit, this_unit; \
- unsigned long end, cshift; /* cshift is "complement shift" */ \
- \
- if (!__length) \
- break; \
- \
- end = __start + __length; \
- start_unit = __start / ts; \
- end_unit = (end + (ts - 1)) / ts; \
- \
- /* Trim v high bits */ \
- if (__length < sizeof(__v) * CHAR_BIT) \
- __v &= ~((~(__typeof__(__v)) 0) << __length); \
- \
- /* We can now append v with a simple "or", shift it piece-wise */ \
- this_unit = end_unit - 1; \
- if (start_unit == end_unit - 1) { \
- mask = ~((~(type) 0) << ((ts - (end % ts)) % ts)); \
- if (__start % ts) \
- mask |= (~((type) 0)) << (ts - (__start % ts)); \
- cmask = (type) __v << ((ts - (end % ts)) % ts); \
- cmask &= ~mask; \
- __ptr[this_unit] &= mask; \
- __ptr[this_unit] |= cmask; \
- break; \
- } \
- if (end % ts) { \
- cshift = end % ts; \
- mask = ~((~(type) 0) << (ts - cshift)); \
- cmask = (type) __v << (ts - cshift); \
- cmask &= ~mask; \
- __ptr[this_unit] &= mask; \
- __ptr[this_unit] |= cmask; \
- __v = _barectf_bt_piecewise_rshift(__v, cshift); \
- end -= cshift; \
- this_unit--; \
- } \
- for (; (long) this_unit >= (long) start_unit + 1; this_unit--) { \
- __ptr[this_unit] = (type) __v; \
- __v = _barectf_bt_piecewise_rshift(__v, ts); \
- end -= ts; \
- } \
- if (__start % ts) { \
- mask = (~(type) 0) << (ts - (__start % ts)); \
- cmask = (type) __v; \
- cmask &= ~mask; \
- __ptr[this_unit] &= mask; \
- __ptr[this_unit] |= cmask; \
- } else \
- __ptr[this_unit] = (type) __v; \
-} while (0)
-
-/*
- * barectf_bt_bitfield_write_le - write integer to a bitfield in little endian
- * barectf_bt_bitfield_write_be - write integer to a bitfield in big endian
- */
-
-#if (BARECTF_BYTE_ORDER == LITTLE_ENDIAN)
-
-#define barectf_bt_bitfield_write_le(ptr, type, _start, _length, _v) \
- _barectf_bt_bitfield_write_le(ptr, type, _start, _length, _v)
-
-#define barectf_bt_bitfield_write_be(ptr, type, _start, _length, _v) \
- _barectf_bt_bitfield_write_be(ptr, unsigned char, _start, _length, _v)
-
-#elif (BARECTF_BYTE_ORDER == BIG_ENDIAN)
-
-#define barectf_bt_bitfield_write_le(ptr, type, _start, _length, _v) \
- _barectf_bt_bitfield_write_le(ptr, unsigned char, _start, _length, _v)
-
-#define barectf_bt_bitfield_write_be(ptr, type, _start, _length, _v) \
- _barectf_bt_bitfield_write_be(ptr, type, _start, _length, _v)
-
-#else /* (BARECTF_BYTE_ORDER == PDP_ENDIAN) */
-
-#error "Byte order not supported"
-
-#endif
-
-#endif /* _BARECTF_BITFIELD_H */
+++ /dev/null
-/*
- * The following C code was generated by barectf 2.1.0-dev
- * on 2016-03-15T21:29:16.070651.
- *
- * For more details, see <https://github.com/efficios/barectf>.
- */
-
-#include <stdint.h>
-#include <string.h>
-#include <assert.h>
-
-#include "barectf.h"
-
-#define _ALIGN(_at, _align) \
- do { \
- (_at) = ((_at) + ((_align) - 1)) & -(_align); \
- } while (0)
-
-#define _BITS_TO_BYTES(_x) ((_x) >> 3)
-#define _BYTES_TO_BITS(_x) ((_x) << 3)
-
-union f2u {
- float f;
- uint32_t u;
-};
-
-union d2u {
- double f;
- uint64_t u;
-};
-
-uint32_t barectf_packet_size(void *ctx)
-{
- return ((struct barectf_ctx *) ctx)->packet_size;
-}
-
-int barectf_packet_is_full(void *ctx)
-{
- struct barectf_ctx *cctx = ctx;
-
- return cctx->at == cctx->packet_size;
-}
-
-int barectf_packet_is_empty(void *ctx)
-{
- struct barectf_ctx *cctx = ctx;
-
- return cctx->at <= cctx->off_content;
-}
-
-uint32_t barectf_packet_events_discarded(void *ctx)
-{
- return ((struct barectf_ctx *) ctx)->events_discarded;
-}
-
-uint8_t *barectf_packet_buf(void *ctx)
-{
- return ((struct barectf_ctx *) ctx)->buf;
-}
-
-uint32_t barectf_packet_buf_size(void *ctx)
-{
- return _BITS_TO_BYTES(((struct barectf_ctx *) ctx)->packet_size);
-}
-
-void barectf_packet_set_buf(void *ctx, uint8_t *buf, uint32_t buf_size)
-{
- struct barectf_ctx *barectf_ctx = ctx;
-
- barectf_ctx->buf = buf;
- barectf_ctx->packet_size = _BYTES_TO_BITS(buf_size);
-}
-
-int barectf_packet_is_open(void *ctx)
-{
- return ((struct barectf_ctx *) ctx)->packet_is_open;
-}
-
-static
-void _write_cstring(struct barectf_ctx *ctx, const char *src)
-{
- uint32_t sz = strlen(src) + 1;
-
- memcpy(&ctx->buf[_BITS_TO_BYTES(ctx->at)], src, sz);
- ctx->at += _BYTES_TO_BITS(sz);
-}
-
-static inline
-int _packet_is_full(struct barectf_ctx *ctx)
-{
- return barectf_packet_is_full(ctx);
-}
-
-static
-int _reserve_event_space(struct barectf_ctx *ctx, uint32_t ev_size)
-{
- /* event _cannot_ fit? */
- if (ev_size > (ctx->packet_size - ctx->off_content)) {
- ctx->events_discarded++;
-
- return 0;
- }
-
- /* packet is full? */
- if (barectf_packet_is_full(ctx)) {
- /* yes: is back-end full? */
- if (ctx->cbs.is_backend_full(ctx->data)) {
- /* yes: discard event */
- ctx->events_discarded++;
-
- return 0;
- }
-
- /* back-end is not full: open new packet */
- ctx->cbs.open_packet(ctx->data);
- }
-
- /* event fits the current packet? */
- if (ev_size > (ctx->packet_size - ctx->at)) {
- /* no: close packet now */
- ctx->cbs.close_packet(ctx->data);
-
- /* is back-end full? */
- if (ctx->cbs.is_backend_full(ctx->data)) {
- /* yes: discard event */
- ctx->events_discarded++;
-
- return 0;
- }
-
- /* back-end is not full: open new packet */
- ctx->cbs.open_packet(ctx->data);
- assert(ev_size <= (ctx->packet_size - ctx->at));
- }
-
- return 1;
-}
-
-static
-void _commit_event(struct barectf_ctx *ctx)
-{
- /* is packet full? */
- if (barectf_packet_is_full(ctx)) {
- /* yes: close it now */
- ctx->cbs.close_packet(ctx->data);
- }
-}
-
-/* initialize context */
-void barectf_init(
- void *ctx,
- uint8_t *buf,
- uint32_t buf_size,
- struct barectf_platform_callbacks cbs,
- void *data
-)
-{
- struct barectf_ctx *barectf_ctx = ctx;
- barectf_ctx->cbs = cbs;
- barectf_ctx->data = data;
- barectf_ctx->buf = buf;
- barectf_ctx->packet_size = _BYTES_TO_BITS(buf_size);
- barectf_ctx->at = 0;
- barectf_ctx->events_discarded = 0;
- barectf_ctx->packet_is_open = 0;
-}
-
-/* open packet for stream "default" */
-void barectf_default_open_packet(
- struct barectf_default_ctx *ctx
-)
-{
- uint64_t ts = ctx->parent.cbs.default_clock_get_value(ctx->parent.data);
-
- /* do not open a packet that is already open */
- if (ctx->parent.packet_is_open) {
- return;
- }
-
- ctx->parent.at = 0;
-
- /* trace packet header */
- {
- /* align structure */
- _ALIGN(ctx->parent.at, 8);
-
- /* "magic" field */
- _ALIGN(ctx->parent.at, 8);
- barectf_bt_bitfield_write_le(&(&ctx->parent)->buf[_BITS_TO_BYTES((&ctx->parent)->at)], uint8_t, 0, 32, 0xc1fc1fc1UL);
- (&ctx->parent)->at += 32;
-
- /* "uuid" field */
- {
- static uint8_t uuid[] = {
- 127,
- 53,
- 26,
- 32,
- 235,
- 22,
- 17,
- 229,
- 140,
- 48,
- 36,
- 119,
- 3,
- 138,
- 62,
- 196,
- };
-
- _ALIGN(ctx->parent.at, 8);
- memcpy(&ctx->parent.buf[_BITS_TO_BYTES(ctx->parent.at)], uuid, 16);
- ctx->parent.at += _BYTES_TO_BITS(16);
- }
-
- /* "stream_id" field */
- _ALIGN(ctx->parent.at, 8);
- barectf_bt_bitfield_write_le(&(&ctx->parent)->buf[_BITS_TO_BYTES((&ctx->parent)->at)], uint8_t, 0, 8, (uint8_t) 0);
- (&ctx->parent)->at += 8;
- }
-
- /* stream packet context */
- {
- /* align structure */
- _ALIGN(ctx->parent.at, 8);
-
- /* "timestamp_begin" field */
- _ALIGN(ctx->parent.at, 8);
- barectf_bt_bitfield_write_le(&(&ctx->parent)->buf[_BITS_TO_BYTES((&ctx->parent)->at)], uint8_t, 0, 64, (uint64_t) ts);
- (&ctx->parent)->at += 64;
-
- /* "timestamp_end" field */
- _ALIGN(ctx->parent.at, 8);
- ctx->off_spc_timestamp_end = ctx->parent.at;
- ctx->parent.at += 64;
-
- /* "packet_size" field */
- _ALIGN(ctx->parent.at, 8);
- barectf_bt_bitfield_write_le(&(&ctx->parent)->buf[_BITS_TO_BYTES((&ctx->parent)->at)], uint8_t, 0, 32, (uint32_t) ctx->parent.packet_size);
- (&ctx->parent)->at += 32;
-
- /* "content_size" field */
- _ALIGN(ctx->parent.at, 8);
- ctx->off_spc_content_size = ctx->parent.at;
- ctx->parent.at += 32;
-
- /* "events_discarded" field */
- _ALIGN(ctx->parent.at, 8);
- ctx->off_spc_events_discarded = ctx->parent.at;
- ctx->parent.at += 32;
- }
-
- ctx->parent.off_content = ctx->parent.at;
-
- /* mark current packet as open */
- ctx->parent.packet_is_open = 1;
-}
-
-/* close packet for stream "default" */
-void barectf_default_close_packet(struct barectf_default_ctx *ctx)
-{
- uint64_t ts = ctx->parent.cbs.default_clock_get_value(ctx->parent.data);
-
- /* do not close a packet that is not open */
- if (!ctx->parent.packet_is_open) {
- return;
- }
-
- /* save content size */
- ctx->parent.content_size = ctx->parent.at;
-
- /* "timestamp_end" field */
- ctx->parent.at = ctx->off_spc_timestamp_end;
- barectf_bt_bitfield_write_le(&(&ctx->parent)->buf[_BITS_TO_BYTES((&ctx->parent)->at)], uint8_t, 0, 64, (uint64_t) ts);
- (&ctx->parent)->at += 64;
-
- /* "content_size" field */
- ctx->parent.at = ctx->off_spc_content_size;
- barectf_bt_bitfield_write_le(&(&ctx->parent)->buf[_BITS_TO_BYTES((&ctx->parent)->at)], uint8_t, 0, 32, (uint32_t) ctx->parent.content_size);
- (&ctx->parent)->at += 32;
-
- /* "events_discarded" field */
- ctx->parent.at = ctx->off_spc_events_discarded;
- barectf_bt_bitfield_write_le(&(&ctx->parent)->buf[_BITS_TO_BYTES((&ctx->parent)->at)], uint8_t, 0, 32, (uint32_t) ctx->parent.events_discarded);
- (&ctx->parent)->at += 32;
-
- /* go back to end of packet */
- ctx->parent.at = ctx->parent.packet_size;
-
- /* mark packet as closed */
- ctx->parent.packet_is_open = 0;
-}
-
-static void _serialize_stream_event_header_default(
- struct barectf_ctx *ctx,
- uint32_t event_id
-)
-{
- uint64_t ts = ctx->cbs.default_clock_get_value(ctx->data);
-
- {
- /* align structure */
- _ALIGN(ctx->at, 8);
-
- /* "timestamp" field */
- _ALIGN(ctx->at, 8);
- barectf_bt_bitfield_write_le(&ctx->buf[_BITS_TO_BYTES(ctx->at)], uint8_t, 0, 64, (uint64_t) ts);
- ctx->at += 64;
-
- /* "id" field */
- _ALIGN(ctx->at, 8);
- barectf_bt_bitfield_write_le(&ctx->buf[_BITS_TO_BYTES(ctx->at)], uint8_t, 0, 16, (uint16_t) event_id);
- ctx->at += 16;
- }
-
-}
-
-static uint32_t _get_event_size_default_simple_uint32(
- struct barectf_ctx *ctx,
- uint32_t ep_value
-)
-{
- uint32_t at = ctx->at;
-
- /* stream event header */
- {
- /* align structure */
- _ALIGN(at, 8);
-
- /* "timestamp" field */
- _ALIGN(at, 8);
- at += 64;
-
- /* "id" field */
- _ALIGN(at, 8);
- at += 16;
- }
-
- /* event payload */
- {
- /* align structure */
- _ALIGN(at, 8);
-
- /* "value" field */
- _ALIGN(at, 8);
- at += 32;
- }
-
- return at - ctx->at;
-}
-
-static void _serialize_event_default_simple_uint32(
- struct barectf_ctx *ctx,
- uint32_t ep_value
-)
-{
- /* stream event header */
- _serialize_stream_event_header_default(ctx, 0);
-
- /* event payload */
- {
- /* align structure */
- _ALIGN(ctx->at, 8);
-
- /* "value" field */
- _ALIGN(ctx->at, 8);
- barectf_bt_bitfield_write_le(&ctx->buf[_BITS_TO_BYTES(ctx->at)], uint8_t, 0, 32, ep_value);
- ctx->at += 32;
- }
-
-}
-
-/* trace (stream "default", event "simple_uint32") */
-void barectf_default_trace_simple_uint32(
- struct barectf_default_ctx *ctx,
- uint32_t ep_value
-)
-{
- uint32_t ev_size;
-
- /* get event size */
- ev_size = _get_event_size_default_simple_uint32((void *) ctx, ep_value);
-
- /* do we have enough space to serialize? */
- if (!_reserve_event_space((void *) ctx, ev_size)) {
- /* no: forget this */
- return;
- }
-
- /* serialize event */
- _serialize_event_default_simple_uint32((void *) ctx, ep_value);
-
- /* commit event */
- _commit_event((void *) ctx);
-}
-
-static uint32_t _get_event_size_default_simple_int16(
- struct barectf_ctx *ctx,
- int16_t ep_value
-)
-{
- uint32_t at = ctx->at;
-
- /* stream event header */
- {
- /* align structure */
- _ALIGN(at, 8);
-
- /* "timestamp" field */
- _ALIGN(at, 8);
- at += 64;
-
- /* "id" field */
- _ALIGN(at, 8);
- at += 16;
- }
-
- /* event payload */
- {
- /* align structure */
- _ALIGN(at, 8);
-
- /* "value" field */
- _ALIGN(at, 8);
- at += 16;
- }
-
- return at - ctx->at;
-}
-
-static void _serialize_event_default_simple_int16(
- struct barectf_ctx *ctx,
- int16_t ep_value
-)
-{
- /* stream event header */
- _serialize_stream_event_header_default(ctx, 1);
-
- /* event payload */
- {
- /* align structure */
- _ALIGN(ctx->at, 8);
-
- /* "value" field */
- _ALIGN(ctx->at, 8);
- barectf_bt_bitfield_write_le(&ctx->buf[_BITS_TO_BYTES(ctx->at)], uint8_t, 0, 16, ep_value);
- ctx->at += 16;
- }
-
-}
-
-/* trace (stream "default", event "simple_int16") */
-void barectf_default_trace_simple_int16(
- struct barectf_default_ctx *ctx,
- int16_t ep_value
-)
-{
- uint32_t ev_size;
-
- /* get event size */
- ev_size = _get_event_size_default_simple_int16((void *) ctx, ep_value);
-
- /* do we have enough space to serialize? */
- if (!_reserve_event_space((void *) ctx, ev_size)) {
- /* no: forget this */
- return;
- }
-
- /* serialize event */
- _serialize_event_default_simple_int16((void *) ctx, ep_value);
-
- /* commit event */
- _commit_event((void *) ctx);
-}
-
-static uint32_t _get_event_size_default_simple_float(
- struct barectf_ctx *ctx,
- float ep_value
-)
-{
- uint32_t at = ctx->at;
-
- /* stream event header */
- {
- /* align structure */
- _ALIGN(at, 8);
-
- /* "timestamp" field */
- _ALIGN(at, 8);
- at += 64;
-
- /* "id" field */
- _ALIGN(at, 8);
- at += 16;
- }
-
- /* event payload */
- {
- /* align structure */
- _ALIGN(at, 32);
-
- /* "value" field */
- _ALIGN(at, 32);
- at += 32;
- }
-
- return at - ctx->at;
-}
-
-static void _serialize_event_default_simple_float(
- struct barectf_ctx *ctx,
- float ep_value
-)
-{
- /* stream event header */
- _serialize_stream_event_header_default(ctx, 2);
-
- /* event payload */
- {
- /* align structure */
- _ALIGN(ctx->at, 32);
-
- /* "value" field */
- _ALIGN(ctx->at, 32);
- union f2u f2u;
-
- f2u.f = ep_value;
- barectf_bt_bitfield_write_le(&ctx->buf[_BITS_TO_BYTES(ctx->at)], uint8_t, 0, 32, f2u.u);
- ctx->at += 32;
- }
-
-}
-
-/* trace (stream "default", event "simple_float") */
-void barectf_default_trace_simple_float(
- struct barectf_default_ctx *ctx,
- float ep_value
-)
-{
- uint32_t ev_size;
-
- /* get event size */
- ev_size = _get_event_size_default_simple_float((void *) ctx, ep_value);
-
- /* do we have enough space to serialize? */
- if (!_reserve_event_space((void *) ctx, ev_size)) {
- /* no: forget this */
- return;
- }
-
- /* serialize event */
- _serialize_event_default_simple_float((void *) ctx, ep_value);
-
- /* commit event */
- _commit_event((void *) ctx);
-}
-
-static uint32_t _get_event_size_default_simple_string(
- struct barectf_ctx *ctx,
- const char * ep_value
-)
-{
- uint32_t at = ctx->at;
-
- /* stream event header */
- {
- /* align structure */
- _ALIGN(at, 8);
-
- /* "timestamp" field */
- _ALIGN(at, 8);
- at += 64;
-
- /* "id" field */
- _ALIGN(at, 8);
- at += 16;
- }
-
- /* event payload */
- {
- /* align structure */
- _ALIGN(at, 8);
-
- /* "value" field */
- _ALIGN(at, 8);
- at += _BYTES_TO_BITS(strlen(ep_value) + 1);
- }
-
- return at - ctx->at;
-}
-
-static void _serialize_event_default_simple_string(
- struct barectf_ctx *ctx,
- const char * ep_value
-)
-{
- /* stream event header */
- _serialize_stream_event_header_default(ctx, 3);
-
- /* event payload */
- {
- /* align structure */
- _ALIGN(ctx->at, 8);
-
- /* "value" field */
- _ALIGN(ctx->at, 8);
- _write_cstring(ctx, ep_value);
- }
-
-}
-
-/* trace (stream "default", event "simple_string") */
-void barectf_default_trace_simple_string(
- struct barectf_default_ctx *ctx,
- const char * ep_value
-)
-{
- uint32_t ev_size;
-
- /* get event size */
- ev_size = _get_event_size_default_simple_string((void *) ctx, ep_value);
-
- /* do we have enough space to serialize? */
- if (!_reserve_event_space((void *) ctx, ev_size)) {
- /* no: forget this */
- return;
- }
-
- /* serialize event */
- _serialize_event_default_simple_string((void *) ctx, ep_value);
-
- /* commit event */
- _commit_event((void *) ctx);
-}
-
-static uint32_t _get_event_size_default_simple_enum(
- struct barectf_ctx *ctx,
- uint8_t ep_value
-)
-{
- uint32_t at = ctx->at;
-
- /* stream event header */
- {
- /* align structure */
- _ALIGN(at, 8);
-
- /* "timestamp" field */
- _ALIGN(at, 8);
- at += 64;
-
- /* "id" field */
- _ALIGN(at, 8);
- at += 16;
- }
-
- /* event payload */
- {
- /* align structure */
- _ALIGN(at, 8);
-
- /* "value" field */
- _ALIGN(at, 8);
- at += 8;
- }
-
- return at - ctx->at;
-}
-
-static void _serialize_event_default_simple_enum(
- struct barectf_ctx *ctx,
- uint8_t ep_value
-)
-{
- /* stream event header */
- _serialize_stream_event_header_default(ctx, 4);
-
- /* event payload */
- {
- /* align structure */
- _ALIGN(ctx->at, 8);
-
- /* "value" field */
- _ALIGN(ctx->at, 8);
- barectf_bt_bitfield_write_le(&ctx->buf[_BITS_TO_BYTES(ctx->at)], uint8_t, 0, 8, ep_value);
- ctx->at += 8;
- }
-
-}
-
-/* trace (stream "default", event "simple_enum") */
-void barectf_default_trace_simple_enum(
- struct barectf_default_ctx *ctx,
- uint8_t ep_value
-)
-{
- uint32_t ev_size;
-
- /* get event size */
- ev_size = _get_event_size_default_simple_enum((void *) ctx, ep_value);
-
- /* do we have enough space to serialize? */
- if (!_reserve_event_space((void *) ctx, ev_size)) {
- /* no: forget this */
- return;
- }
-
- /* serialize event */
- _serialize_event_default_simple_enum((void *) ctx, ep_value);
-
- /* commit event */
- _commit_event((void *) ctx);
-}
-
-static uint32_t _get_event_size_default_a_few_fields(
- struct barectf_ctx *ctx,
- int32_t ep_int32,
- uint16_t ep_uint16,
- double ep_dbl,
- const char * ep_str,
- uint8_t ep_state
-)
-{
- uint32_t at = ctx->at;
-
- /* stream event header */
- {
- /* align structure */
- _ALIGN(at, 8);
-
- /* "timestamp" field */
- _ALIGN(at, 8);
- at += 64;
-
- /* "id" field */
- _ALIGN(at, 8);
- at += 16;
- }
-
- /* event payload */
- {
- /* align structure */
- _ALIGN(at, 64);
-
- /* "int32" field */
- _ALIGN(at, 8);
- at += 32;
-
- /* "uint16" field */
- _ALIGN(at, 8);
- at += 16;
-
- /* "dbl" field */
- _ALIGN(at, 64);
- at += 64;
-
- /* "str" field */
- _ALIGN(at, 8);
- at += _BYTES_TO_BITS(strlen(ep_str) + 1);
-
- /* "state" field */
- _ALIGN(at, 8);
- at += 8;
- }
-
- return at - ctx->at;
-}
-
-static void _serialize_event_default_a_few_fields(
- struct barectf_ctx *ctx,
- int32_t ep_int32,
- uint16_t ep_uint16,
- double ep_dbl,
- const char * ep_str,
- uint8_t ep_state
-)
-{
- /* stream event header */
- _serialize_stream_event_header_default(ctx, 5);
-
- /* event payload */
- {
- /* align structure */
- _ALIGN(ctx->at, 64);
-
- /* "int32" field */
- _ALIGN(ctx->at, 8);
- barectf_bt_bitfield_write_le(&ctx->buf[_BITS_TO_BYTES(ctx->at)], uint8_t, 0, 32, ep_int32);
- ctx->at += 32;
-
- /* "uint16" field */
- _ALIGN(ctx->at, 8);
- barectf_bt_bitfield_write_le(&ctx->buf[_BITS_TO_BYTES(ctx->at)], uint8_t, 0, 16, ep_uint16);
- ctx->at += 16;
-
- /* "dbl" field */
- _ALIGN(ctx->at, 64);
- union d2u d2u;
-
- d2u.f = ep_dbl;
- barectf_bt_bitfield_write_le(&ctx->buf[_BITS_TO_BYTES(ctx->at)], uint8_t, 0, 64, d2u.u);
- ctx->at += 64;
-
- /* "str" field */
- _ALIGN(ctx->at, 8);
- _write_cstring(ctx, ep_str);
-
- /* "state" field */
- _ALIGN(ctx->at, 8);
- barectf_bt_bitfield_write_le(&ctx->buf[_BITS_TO_BYTES(ctx->at)], uint8_t, 0, 8, ep_state);
- ctx->at += 8;
- }
-
-}
-
-/* trace (stream "default", event "a_few_fields") */
-void barectf_default_trace_a_few_fields(
- struct barectf_default_ctx *ctx,
- int32_t ep_int32,
- uint16_t ep_uint16,
- double ep_dbl,
- const char * ep_str,
- uint8_t ep_state
-)
-{
- uint32_t ev_size;
-
- /* get event size */
- ev_size = _get_event_size_default_a_few_fields((void *) ctx, ep_int32, ep_uint16, ep_dbl, ep_str, ep_state);
-
- /* do we have enough space to serialize? */
- if (!_reserve_event_space((void *) ctx, ev_size)) {
- /* no: forget this */
- return;
- }
-
- /* serialize event */
- _serialize_event_default_a_few_fields((void *) ctx, ep_int32, ep_uint16, ep_dbl, ep_str, ep_state);
-
- /* commit event */
- _commit_event((void *) ctx);
-}
-
-static uint32_t _get_event_size_default_bit_packed_integers(
- struct barectf_ctx *ctx,
- uint8_t ep_uint1,
- int8_t ep_int1,
- uint8_t ep_uint2,
- int8_t ep_int3,
- uint8_t ep_uint4,
- int8_t ep_int5,
- uint8_t ep_uint6,
- int8_t ep_int7,
- uint8_t ep_uint8
-)
-{
- uint32_t at = ctx->at;
-
- /* stream event header */
- {
- /* align structure */
- _ALIGN(at, 8);
-
- /* "timestamp" field */
- _ALIGN(at, 8);
- at += 64;
-
- /* "id" field */
- _ALIGN(at, 8);
- at += 16;
- }
-
- /* event payload */
- {
- /* align structure */
- _ALIGN(at, 8);
-
- /* "uint1" field */
- at += 1;
-
- /* "int1" field */
- at += 1;
-
- /* "uint2" field */
- at += 2;
-
- /* "int3" field */
- at += 3;
-
- /* "uint4" field */
- at += 4;
-
- /* "int5" field */
- at += 5;
-
- /* "uint6" field */
- at += 6;
-
- /* "int7" field */
- at += 7;
-
- /* "uint8" field */
- at += 8;
- }
-
- return at - ctx->at;
-}
-
-static void _serialize_event_default_bit_packed_integers(
- struct barectf_ctx *ctx,
- uint8_t ep_uint1,
- int8_t ep_int1,
- uint8_t ep_uint2,
- int8_t ep_int3,
- uint8_t ep_uint4,
- int8_t ep_int5,
- uint8_t ep_uint6,
- int8_t ep_int7,
- uint8_t ep_uint8
-)
-{
- /* stream event header */
- _serialize_stream_event_header_default(ctx, 6);
-
- /* event payload */
- {
- /* align structure */
- _ALIGN(ctx->at, 8);
-
- /* "uint1" field */
- barectf_bt_bitfield_write_le(&ctx->buf[_BITS_TO_BYTES(ctx->at)], uint8_t, 0, 1, ep_uint1);
- ctx->at += 1;
-
- /* "int1" field */
- barectf_bt_bitfield_write_le(&ctx->buf[_BITS_TO_BYTES(ctx->at)], uint8_t, 1, 1, ep_int1);
- ctx->at += 1;
-
- /* "uint2" field */
- barectf_bt_bitfield_write_le(&ctx->buf[_BITS_TO_BYTES(ctx->at)], uint8_t, 2, 2, ep_uint2);
- ctx->at += 2;
-
- /* "int3" field */
- barectf_bt_bitfield_write_le(&ctx->buf[_BITS_TO_BYTES(ctx->at)], uint8_t, 4, 3, ep_int3);
- ctx->at += 3;
-
- /* "uint4" field */
- barectf_bt_bitfield_write_le(&ctx->buf[_BITS_TO_BYTES(ctx->at)], uint8_t, 7, 4, ep_uint4);
- ctx->at += 4;
-
- /* "int5" field */
- barectf_bt_bitfield_write_le(&ctx->buf[_BITS_TO_BYTES(ctx->at)], uint8_t, 3, 5, ep_int5);
- ctx->at += 5;
-
- /* "uint6" field */
- barectf_bt_bitfield_write_le(&ctx->buf[_BITS_TO_BYTES(ctx->at)], uint8_t, 0, 6, ep_uint6);
- ctx->at += 6;
-
- /* "int7" field */
- barectf_bt_bitfield_write_le(&ctx->buf[_BITS_TO_BYTES(ctx->at)], uint8_t, 6, 7, ep_int7);
- ctx->at += 7;
-
- /* "uint8" field */
- barectf_bt_bitfield_write_le(&ctx->buf[_BITS_TO_BYTES(ctx->at)], uint8_t, 5, 8, ep_uint8);
- ctx->at += 8;
- }
-
-}
-
-/* trace (stream "default", event "bit_packed_integers") */
-void barectf_default_trace_bit_packed_integers(
- struct barectf_default_ctx *ctx,
- uint8_t ep_uint1,
- int8_t ep_int1,
- uint8_t ep_uint2,
- int8_t ep_int3,
- uint8_t ep_uint4,
- int8_t ep_int5,
- uint8_t ep_uint6,
- int8_t ep_int7,
- uint8_t ep_uint8
-)
-{
- uint32_t ev_size;
-
- /* get event size */
- ev_size = _get_event_size_default_bit_packed_integers((void *) ctx, ep_uint1, ep_int1, ep_uint2, ep_int3, ep_uint4, ep_int5, ep_uint6, ep_int7, ep_uint8);
-
- /* do we have enough space to serialize? */
- if (!_reserve_event_space((void *) ctx, ev_size)) {
- /* no: forget this */
- return;
- }
-
- /* serialize event */
- _serialize_event_default_bit_packed_integers((void *) ctx, ep_uint1, ep_int1, ep_uint2, ep_int3, ep_uint4, ep_int5, ep_uint6, ep_int7, ep_uint8);
-
- /* commit event */
- _commit_event((void *) ctx);
-}
+++ /dev/null
-#ifndef _BARECTF_H
-#define _BARECTF_H
-
-/*
- * The following C code was generated by barectf 2.1.0-dev
- * on 2016-03-15T21:29:16.069818.
- *
- * For more details, see <https://github.com/efficios/barectf>.
- */
-
-#include <stdint.h>
-
-#include "barectf-bitfield.h"
-
-struct barectf_ctx;
-
-uint32_t barectf_packet_size(void *ctx);
-int barectf_packet_is_full(void *ctx);
-int barectf_packet_is_empty(void *ctx);
-uint32_t barectf_packet_events_discarded(void *ctx);
-uint8_t *barectf_packet_buf(void *ctx);
-void barectf_packet_set_buf(void *ctx, uint8_t *buf, uint32_t buf_size);
-uint32_t barectf_packet_buf_size(void *ctx);
-int barectf_packet_is_open(void *ctx);
-
-/* barectf platform callbacks */
-struct barectf_platform_callbacks {
- /* clock callbacks */
- uint64_t (*default_clock_get_value)(void *);
-
- /* is back-end full? */
- int (*is_backend_full)(void *);
-
- /* open packet */
- void (*open_packet)(void *);
-
- /* close packet */
- void (*close_packet)(void *);
-};
-
-/* common barectf context */
-struct barectf_ctx {
- /* platform callbacks */
- struct barectf_platform_callbacks cbs;
-
- /* platform data (passed to callbacks) */
- void *data;
-
- /* output buffer (will contain a CTF binary packet) */
- uint8_t *buf;
-
- /* packet size in bits */
- uint32_t packet_size;
-
- /* content size in bits */
- uint32_t content_size;
-
- /* current position from beginning of packet in bits */
- uint32_t at;
-
- /* packet header + context size (content offset) */
- uint32_t off_content;
-
- /* events discarded */
- uint32_t events_discarded;
-
- /* current packet is opened */
- int packet_is_open;
-};
-
-/* context for stream "default" */
-struct barectf_default_ctx {
- /* parent */
- struct barectf_ctx parent;
-
- /* config-specific members follow */
- uint32_t off_tph_magic;
- uint32_t off_tph_uuid;
- uint32_t off_tph_stream_id;
- uint32_t off_spc_timestamp_begin;
- uint32_t off_spc_timestamp_end;
- uint32_t off_spc_packet_size;
- uint32_t off_spc_content_size;
- uint32_t off_spc_events_discarded;
-};
-
-/* initialize context */
-void barectf_init(
- void *ctx,
- uint8_t *buf,
- uint32_t buf_size,
- struct barectf_platform_callbacks cbs,
- void *data
-);
-
-/* open packet for stream "default" */
-void barectf_default_open_packet(
- struct barectf_default_ctx *ctx
-);
-
-/* close packet for stream "default" */
-void barectf_default_close_packet(struct barectf_default_ctx *ctx);
-
-/* trace (stream "default", event "simple_uint32") */
-void barectf_default_trace_simple_uint32(
- struct barectf_default_ctx *ctx,
- uint32_t ep_value
-);
-
-/* trace (stream "default", event "simple_int16") */
-void barectf_default_trace_simple_int16(
- struct barectf_default_ctx *ctx,
- int16_t ep_value
-);
-
-/* trace (stream "default", event "simple_float") */
-void barectf_default_trace_simple_float(
- struct barectf_default_ctx *ctx,
- float ep_value
-);
-
-/* trace (stream "default", event "simple_string") */
-void barectf_default_trace_simple_string(
- struct barectf_default_ctx *ctx,
- const char * ep_value
-);
-
-/* trace (stream "default", event "simple_enum") */
-void barectf_default_trace_simple_enum(
- struct barectf_default_ctx *ctx,
- uint8_t ep_value
-);
-
-/* trace (stream "default", event "a_few_fields") */
-void barectf_default_trace_a_few_fields(
- struct barectf_default_ctx *ctx,
- int32_t ep_int32,
- uint16_t ep_uint16,
- double ep_dbl,
- const char * ep_str,
- uint8_t ep_state
-);
-
-/* trace (stream "default", event "bit_packed_integers") */
-void barectf_default_trace_bit_packed_integers(
- struct barectf_default_ctx *ctx,
- uint8_t ep_uint1,
- int8_t ep_int1,
- uint8_t ep_uint2,
- int8_t ep_int3,
- uint8_t ep_uint4,
- int8_t ep_int5,
- uint8_t ep_uint6,
- int8_t ep_int7,
- uint8_t ep_uint8
-);
-
-#endif /* _BARECTF_H */
\ No newline at end of file