#endif /* __FLOAT_WORD_ORDER */
#endif /* FLOAT_WORD_ORDER */
+#if (BYTE_ORDER == BIG_ENDIAN)
+# define BT_CTF_MY_BYTE_ORDER BT_CTF_BYTE_ORDER_BIG_ENDIAN
+#else
+# define BT_CTF_MY_BYTE_ORDER BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
+#endif
+
#endif /* _BABELTRACE_ENDIAN_H */
#include <babeltrace/compat/fcntl.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
union intval value, unsigned int alignment, unsigned int size,
bool is_signed, enum bt_ctf_byte_order byte_order)
{
- bool rbo = (byte_order != MY_BT_CTF_BYTE_ORDER); /* reverse byte order */
+ bool rbo = (byte_order != BT_CTF_MY_BYTE_ORDER); /* reverse byte order */
if (!bt_ctf_stream_pos_align(pos, alignment))
return -EFAULT;
#include <babeltrace/ctf-ir/stream-internal.h>
#include <babeltrace/ctf-ir/trace-internal.h>
#include <babeltrace/ref.h>
+#include <babeltrace/endian.h>
#include <babeltrace/compiler.h>
#include <stdio.h>
#include <stdlib.h>
struct bt_ctf_writer *bt_ctf_writer_create(const char *path)
{
+ int ret;
struct bt_ctf_writer *writer = NULL;
if (!path) {
writer->trace->is_created_by_writer = 1;
bt_object_set_parent(writer->trace, writer);
bt_put(writer->trace);
+
+ /* Default to little-endian */
+ ret = bt_ctf_writer_set_byte_order(writer, BT_CTF_BYTE_ORDER_NATIVE);
+ assert(ret == 0);
+
/* Create trace directory if necessary and open a metadata file */
if (g_mkdir_with_parents(path, S_IRWXU | S_IRWXG)) {
perror("g_mkdir_with_parents");
goto end;
}
+ if (byte_order == BT_CTF_BYTE_ORDER_NATIVE) {
+ byte_order = BT_CTF_MY_BYTE_ORDER;
+ }
+
ret = bt_ctf_trace_set_native_byte_order(writer->trace,
byte_order);
end: