Port: Add bt_common_get_page_size
[babeltrace.git] / include / babeltrace / ctf-writer / serialize-internal.h
index 15ced8debe823b0f048b2cf93ff3284eb3e0a098..e029764e53b2c917b0e664bac31a16f2fd06a426 100644 (file)
@@ -26,6 +26,7 @@
  * http://www.efficios.com/ctf
  */
 
+#include <stdlib.h>
 #include <stdint.h>
 #include <limits.h>
 #include <sys/mman.h>
 #include <babeltrace/ctf-ir/fields.h>
 #include <babeltrace/ctf-ir/fields-internal.h>
 #include <babeltrace/align-internal.h>
+#include <babeltrace/common-internal.h>
 #include <babeltrace/mmap-align-internal.h>
+#include <babeltrace/types.h>
+
+#define PACKET_LEN_INCREMENT   (bt_common_get_page_size() * 8 * CHAR_BIT)
 
 struct bt_ctf_stream_pos {
        int fd;
@@ -47,7 +52,6 @@ struct bt_ctf_stream_pos {
        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 */
 };
@@ -69,12 +73,13 @@ int bt_ctf_stream_pos_access_ok(struct bt_ctf_stream_pos *pos, uint64_t bit_len)
 
        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;
@@ -110,7 +115,7 @@ char *bt_ctf_stream_pos_get_addr(struct bt_ctf_stream_pos *pos)
 {
        /* 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);
 }
 
@@ -130,7 +135,7 @@ int bt_ctf_stream_pos_init(struct bt_ctf_stream_pos *pos,
                pos->flags = MAP_SHARED;
                break;
        default:
-               assert(false);
+               abort();
        }
 
        return 0;
This page took 0.026523 seconds and 4 git commands to generate.