#include <unistd.h>
#include <errno.h>
#include <string.h>
+#include <inttypes.h>
#include <babeltrace/babeltrace-internal.h>
#include <babeltrace/ctf/types.h>
"/* CTF 1.8 */\n"
"typealias integer { size = 8; align = 8; signed = false; } := uint8_t;\n"
"typealias integer { size = 32; align = 32; signed = false; } := uint32_t;\n"
+"typealias integer { size = 64; align = 64; signed = false; } := uint64_t;\n"
"\n"
"trace {\n"
" major = %u;\n" /* major (e.g. 0) */
"\n"
"stream {\n"
" packet.context := struct {\n"
-" uint32_t content_size;\n"
-" uint32_t packet_size;\n"
+" uint64_t content_size;\n"
+" uint64_t packet_size;\n"
" };\n"
"%s" /* Stream event header (opt.) */
"};\n"
/* content_size */
ctf_dummy_pos(pos, &dummy);
- ctf_align_pos(&dummy, sizeof(uint32_t) * CHAR_BIT);
- ctf_move_pos(&dummy, sizeof(uint32_t) * CHAR_BIT);
+ ctf_align_pos(&dummy, sizeof(uint64_t) * CHAR_BIT);
+ ctf_move_pos(&dummy, sizeof(uint64_t) * CHAR_BIT);
assert(!ctf_pos_packet(&dummy));
- ctf_align_pos(pos, sizeof(uint32_t) * CHAR_BIT);
- *(uint32_t *) ctf_get_pos_addr(pos) = -1U; /* Not known yet */
- pos->content_size_loc = (uint32_t *) ctf_get_pos_addr(pos);
- ctf_move_pos(pos, sizeof(uint32_t) * CHAR_BIT);
+ ctf_align_pos(pos, sizeof(uint64_t) * CHAR_BIT);
+ *(uint64_t *) ctf_get_pos_addr(pos) = ~0ULL; /* Not known yet */
+ pos->content_size_loc = (uint64_t *) ctf_get_pos_addr(pos);
+ ctf_move_pos(pos, sizeof(uint64_t) * CHAR_BIT);
/* packet_size */
ctf_dummy_pos(pos, &dummy);
- ctf_align_pos(&dummy, sizeof(uint32_t) * CHAR_BIT);
- ctf_move_pos(&dummy, sizeof(uint32_t) * CHAR_BIT);
+ ctf_align_pos(&dummy, sizeof(uint64_t) * CHAR_BIT);
+ ctf_move_pos(&dummy, sizeof(uint64_t) * CHAR_BIT);
assert(!ctf_pos_packet(&dummy));
- ctf_align_pos(pos, sizeof(uint32_t) * CHAR_BIT);
- *(uint32_t *) ctf_get_pos_addr(pos) = pos->packet_size;
- ctf_move_pos(pos, sizeof(uint32_t) * CHAR_BIT);
+ ctf_align_pos(pos, sizeof(uint64_t) * CHAR_BIT);
+ *(uint64_t *) ctf_get_pos_addr(pos) = pos->packet_size;
+ ctf_move_pos(pos, sizeof(uint64_t) * CHAR_BIT);
}
static
write_packet_header(pos, s_uuid);
write_packet_context(pos);
if (attempt++ == 1) {
- fprintf(stderr, "[Error] Line too large for packet size (%zukB) (discarded)\n",
+ fprintf(stderr, "[Error] Line too large for packet size (%" PRIu64 "kB) (discarded)\n",
pos->packet_size / CHAR_BIT / 1024);
return;
}
#include <unistd.h>
#include <glib.h>
#include <stdio.h>
+#include <inttypes.h>
#include <babeltrace/mmap-align.h>
-#define LAST_OFFSET_POISON ((ssize_t) -1L)
+#define LAST_OFFSET_POISON ((int64_t) ~0ULL)
struct bt_stream_callbacks;
struct packet_index {
off_t offset; /* offset of the packet in the file, in bytes */
- off_t data_offset; /* offset of data within the packet, in bits */
+ int64_t data_offset; /* offset of data within the packet, in bits */
uint64_t packet_size; /* packet size, in bits */
uint64_t content_size; /* content size, in bits */
uint64_t timestamp_begin;
uint64_t timestamp_end;
uint64_t events_discarded;
- size_t events_discarded_len; /* length of the field, in bits */
+ uint64_t events_discarded_len; /* length of the field, in bits */
};
/*
/* Current position */
off_t mmap_offset; /* mmap offset in the file, in bytes */
off_t mmap_base_offset; /* offset of start of packet in mmap, in bytes */
- size_t packet_size; /* current packet size, in bits */
- size_t content_size; /* current content size, in bits */
- uint32_t *content_size_loc; /* pointer to current content size */
+ uint64_t packet_size; /* current packet size, in bits */
+ uint64_t content_size; /* current content size, in bits */
+ uint64_t *content_size_loc; /* pointer to current content size */
struct mmap_align *base_mma;/* mmap base address */
- ssize_t offset; /* offset from base, in bits. EOF for end of file. */
- ssize_t last_offset; /* offset before the last read_event */
- size_t cur_index; /* current index in packet index */
+ int64_t offset; /* offset from base, in bits. EOF for end of file. */
+ int64_t last_offset; /* offset before the last read_event */
+ uint64_t cur_index; /* current index in packet index */
uint64_t last_events_discarded; /* last known amount of event discarded */
void (*packet_seek)(struct stream_pos *pos, size_t index,
int whence); /* function called to switch packet */
* TODO: allow larger files by updating base too.
*/
static inline
-void ctf_move_pos(struct ctf_stream_pos *pos, size_t bit_offset)
+void ctf_move_pos(struct ctf_stream_pos *pos, uint64_t bit_offset)
{
- printf_debug("ctf_move_pos test EOF: %zd\n", pos->offset);
+ printf_debug("ctf_move_pos test EOF: %" PRId64 "\n", pos->offset);
if (unlikely(pos->offset == EOF))
return;
*/
if ((pos->prot == PROT_WRITE)
&& (unlikely(pos->offset + bit_offset >= pos->packet_size))) {
- printf_debug("ctf_packet_seek (before call): %zd\n",
+ printf_debug("ctf_packet_seek (before call): %" PRId64 "\n",
pos->offset);
ctf_packet_seek(&pos->parent, 0, SEEK_CUR);
- printf_debug("ctf_packet_seek (after call): %zd\n",
+ printf_debug("ctf_packet_seek (after call): %" PRId64 "\n",
pos->offset);
return;
}
}
pos->offset += bit_offset;
- printf_debug("ctf_move_pos after increment: %zd\n", pos->offset);
+ printf_debug("ctf_move_pos after increment: %" PRId64 "\n", pos->offset);
}
/*
* TODO: allow larger files by updating base too.
*/
static inline
-void ctf_align_pos(struct ctf_stream_pos *pos, size_t bit_offset)
+void ctf_align_pos(struct ctf_stream_pos *pos, uint64_t bit_offset)
{
ctf_move_pos(pos, offset_align(pos->offset, bit_offset));
}
}
static inline
-int ctf_pos_access_ok(struct ctf_stream_pos *pos, size_t bit_len)
+int ctf_pos_access_ok(struct ctf_stream_pos *pos, uint64_t bit_len)
{
if (unlikely(pos->offset == EOF))
return 0;
{
assert(pos->offset <= pos->content_size);
if (pos->offset == pos->content_size) {
- printf_debug("ctf_packet_seek (before call): %zd\n",
+ printf_debug("ctf_packet_seek (before call): %" PRId64 "\n",
pos->offset);
pos->packet_seek(&pos->parent, 0, SEEK_CUR);
- printf_debug("ctf_packet_seek (after call): %zd\n",
+ printf_debug("ctf_packet_seek (after call): %" PRId64 "\n",
pos->offset);
}
}