Port: Add bt_common_get_page_size
[babeltrace.git] / lib / ctf-writer / serialize.c
index 427c2c5a96fd5c8a03c6c46bcd6b33ad26129911..11ce8b443531a5783dc6d8a80bff101ba0b4ff8f 100644 (file)
@@ -28,6 +28,7 @@
  * SOFTWARE.
  */
 
+#include <stdlib.h>
 #include <stdio.h>
 #include <stdint.h>
 #include <babeltrace/ctf-ir/field-types.h>
@@ -41,6 +42,7 @@
 #include <babeltrace/bitfield-internal.h>
 #include <babeltrace/compat/fcntl-internal.h>
 #include <babeltrace/types.h>
+#include <babeltrace/common-internal.h>
 #include <glib.h>
 
 #if (FLT_RADIX != 2)
@@ -108,7 +110,7 @@ int aligned_integer_write(struct bt_ctf_stream_pos *pos,
                        break;
                }
                default:
-                       assert(BT_FALSE);
+                       abort();
                }
        } else {
                switch (size) {
@@ -147,7 +149,7 @@ int aligned_integer_write(struct bt_ctf_stream_pos *pos,
                        break;
                }
                default:
-                       assert(BT_FALSE);
+                       abort();
                }
        }
 
@@ -275,14 +277,15 @@ void bt_ctf_stream_pos_packet_seek(struct bt_ctf_stream_pos *pos, size_t index,
                /* unmap old base */
                ret = munmap_align(pos->base_mma);
                if (ret) {
-                       assert(BT_FALSE);
+                       // FIXME: this can legitimately fail?
+                       abort();
                }
                pos->base_mma = NULL;
        }
 
        /* The writer will add padding */
        pos->mmap_offset += pos->packet_size / CHAR_BIT;
-       pos->packet_size = getpagesize() * 8 * CHAR_BIT;
+       pos->packet_size = PACKET_LEN_INCREMENT;
        do {
                ret = bt_posix_fallocate(pos->fd, pos->mmap_offset,
                        pos->packet_size / CHAR_BIT);
@@ -294,6 +297,7 @@ void bt_ctf_stream_pos_packet_seek(struct bt_ctf_stream_pos *pos, size_t index,
        pos->base_mma = mmap_align(pos->packet_size / CHAR_BIT, pos->prot,
                pos->flags, pos->fd, pos->mmap_offset);
        if (pos->base_mma == MAP_FAILED) {
-               assert(BT_FALSE);
+               // FIXME: this can legitimately fail?
+               abort();
        }
 }
This page took 0.025208 seconds and 4 git commands to generate.