* SOFTWARE.
*/
+#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
-#include <stdbool.h>
#include <babeltrace/ctf-ir/field-types.h>
#include <babeltrace/ctf-ir/field-types-internal.h>
#include <babeltrace/ctf-ir/fields.h>
#include <babeltrace/ctf-ir/fields-internal.h>
#include <babeltrace/ctf-writer/serialize-internal.h>
-#include <babeltrace/align.h>
-#include <babeltrace/mmap-align.h>
-#include <babeltrace/endian.h>
-#include <babeltrace/bitfield.h>
-#include <babeltrace/compat/fcntl.h>
+#include <babeltrace/align-internal.h>
+#include <babeltrace/mmap-align-internal.h>
+#include <babeltrace/endian-internal.h>
+#include <babeltrace/bitfield-internal.h>
+#include <babeltrace/compat/fcntl-internal.h>
+#include <babeltrace/types.h>
+#include <babeltrace/common-internal.h>
#include <glib.h>
-/* "Native" to CTF IR byte order */
-#if (BYTE_ORDER == LITTLE_ENDIAN)
-# define MY_BT_CTF_BYTE_ORDER BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
-#else
-# define MY_BT_CTF_BYTE_ORDER BT_CTF_BYTE_ORDER_BIG_ENDIAN
-#endif
-
#if (FLT_RADIX != 2)
# error "Unsupported floating point radix"
#endif
static
int aligned_integer_write(struct bt_ctf_stream_pos *pos,
union intval value, unsigned int alignment, unsigned int size,
- bool is_signed, enum bt_ctf_byte_order byte_order)
+ bt_bool is_signed, enum bt_ctf_byte_order byte_order)
{
- bool rbo = (byte_order != MY_BT_CTF_BYTE_ORDER); /* reverse byte order */
+ bt_bool rbo = (byte_order != BT_CTF_MY_BYTE_ORDER); /* reverse byte order */
if (!bt_ctf_stream_pos_align(pos, alignment))
return -EFAULT;
break;
}
default:
- assert(false);
+ abort();
}
} else {
switch (size) {
break;
}
default:
- assert(false);
+ abort();
}
}
static
int integer_write(struct bt_ctf_stream_pos *pos, union intval value,
- unsigned int alignment, unsigned int size, bool is_signed,
+ unsigned int alignment, unsigned int size, bt_bool is_signed,
enum bt_ctf_byte_order byte_order)
{
if (!(alignment % CHAR_BIT)
return -EINVAL;
}
- return integer_write(pos, value, type->alignment, size, false,
+ return integer_write(pos, value, type->alignment, size, BT_FALSE,
byte_order);
}
/* unmap old base */
ret = munmap_align(pos->base_mma);
if (ret) {
- assert(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->content_size = -1U; /* Unknown at this point */
- 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);
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(false);
+ // FIXME: this can legitimately fail?
+ abort();
}
}