#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);
}
}