* http://www.efficios.com/ctf
*/
+#include <stdlib.h>
#include <stdint.h>
#include <limits.h>
#include <sys/mman.h>
#include <babeltrace/ctf-ir/fields-internal.h>
#include <babeltrace/align-internal.h>
#include <babeltrace/mmap-align-internal.h>
+#include <babeltrace/types.h>
struct bt_ctf_stream_pos {
int fd;
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 */
uint64_t packet_size; /* current packet size, in bits */
- uint64_t content_size; /* current content size, in bits */
int64_t offset; /* offset from base, in bits. EOF for end of file. */
struct mmap_align *base_mma;/* mmap base address */
};
if (unlikely(pos->offset == EOF))
return 0;
+
if (pos->prot == PROT_READ) {
/*
* Reads may only reach up to the "content_size",
* regardless of the packet_size.
*/
- max_len = pos->content_size;
+ max_len = pos->offset;
} else {
/* Writes may take place up to the end of the packet. */
max_len = pos->packet_size;
{
/* Only makes sense to get the address after aligning on CHAR_BIT */
assert(!(pos->offset % CHAR_BIT));
- return mmap_align_addr(pos->base_mma) +
+ return ((char *) mmap_align_addr(pos->base_mma)) +
pos->mmap_base_offset + (pos->offset / CHAR_BIT);
}
pos->flags = MAP_SHARED;
break;
default:
- assert(false);
+ abort();
}
return 0;