To remain compatible with the first experiments of CTF writer, let's
restore this legacy behaviour in which a native byte order means the
native byte order of the CPU running the Babeltrace library.
This only applies to bt_ctf_writer_set_byte_order() when you pass
BT_CTF_BYTE_ORDER_NATIVE: bt_ctf_trace_set_native_byte_order() does
not accept BT_CTF_BYTE_ORDER_NATIVE. Thus, when you create a CTF writer
object with bt_ctf_writer_create(), it sets its trace's native byte
order to the CPU's native byte order.
perf is a CTF writer user known to not call
bt_ctf_writer_set_byte_order() manually: in this case the CTF IR trace
would be invalid because its native byte order would still be set to
BT_CTF_BYTE_ORDER_NATIVE.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
#endif /* __FLOAT_WORD_ORDER */
#endif /* FLOAT_WORD_ORDER */
#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 */
#endif /* _BABELTRACE_ENDIAN_H */
#include <babeltrace/compat/fcntl.h>
#include <glib.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
#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)
{
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;
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/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>
#include <babeltrace/compiler.h>
#include <stdio.h>
#include <stdlib.h>
struct bt_ctf_writer *bt_ctf_writer_create(const char *path)
{
struct bt_ctf_writer *bt_ctf_writer_create(const char *path)
{
struct bt_ctf_writer *writer = NULL;
if (!path) {
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);
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");
/* 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");
+ 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:
ret = bt_ctf_trace_set_native_byte_order(writer->trace,
byte_order);
end: