switch (bo) {
case BT_CTF_BYTE_ORDER_UNKNOWN:
return "BT_CTF_BYTE_ORDER_UNKNOWN";
+ case BT_CTF_BYTE_ORDER_NONE:
+ return "BT_CTF_BYTE_ORDER_NONE";
case BT_CTF_BYTE_ORDER_NATIVE:
return "BT_CTF_BYTE_ORDER_NATIVE";
case BT_CTF_BYTE_ORDER_LITTLE_ENDIAN:
/// Native (default) byte order.
BT_CTF_BYTE_ORDER_NATIVE = 0,
+ /**
+ No byte order; the initial native byte order of a
+ \link ctfirtraceclass CTF IR trace class\endlink.
+ */
+ BT_CTF_BYTE_ORDER_NONE,
+
/// Little-endian.
BT_CTF_BYTE_ORDER_LITTLE_ENDIAN,
with bt_ctf_trace_set_name().
- <strong>UUID</strong>: none. You can set a UUID with
bt_ctf_trace_set_uuid().
-- <strong>Native byte order</strong>: #BT_CTF_BYTE_ORDER_NATIVE. You
+- <strong>Native byte order</strong>: #BT_CTF_BYTE_ORDER_NONE. You
can set a native byte order with bt_ctf_trace_set_native_byte_order().
-
- Note that you \em must set the native byte order if any field type
- contained in the created trace class, in its stream classes, or in
- its event classes, has a byte order set to #BT_CTF_BYTE_ORDER_NATIVE.
- <strong>Environment</strong>: empty. You can add environment entries
with bt_ctf_trace_set_environment_field(),
bt_ctf_trace_set_environment_field_integer(), and
- #BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
- #BT_CTF_BYTE_ORDER_BIG_ENDIAN
- #BT_CTF_BYTE_ORDER_NETWORK
+- <strong>If the trace is not in CTF writer mode<strong>,
+ #BT_CTF_BYTE_ORDER_NONE.
@param[in] trace_class Trace class of which to set the native byte
order.
@prenotnull{trace_class}
@prehot{trace_class}
-@pre \p native_byte_order is either #BT_CTF_BYTE_ORDER_LITTLE_ENDIAN,
- #BT_CTF_BYTE_ORDER_BIG_ENDIAN, or
+@pre \p native_byte_order is either #BT_CTF_BYTE_ORDER_NONE (if the
+ trace is not in CTF writer mode),
+ #BT_CTF_BYTE_ORDER_LITTLE_ENDIAN, #BT_CTF_BYTE_ORDER_BIG_ENDIAN, or
#BT_CTF_BYTE_ORDER_NETWORK.
@postrefcountsame{trace_class}
byte_order != BT_CTF_BYTE_ORDER_LITTLE_ENDIAN &&
byte_order != BT_CTF_BYTE_ORDER_BIG_ENDIAN &&
byte_order != BT_CTF_BYTE_ORDER_NETWORK) {
- BT_LOGW("Invalid parameter: unknown byte order: "
+ BT_LOGW("Invalid parameter: invalid byte order: "
"addr=%p, bo=%s", type,
bt_ctf_byte_order_string(byte_order));
ret = -1;
}
BT_LOGD_STR("Creating trace object.");
- trace->native_byte_order = BT_CTF_BYTE_ORDER_NATIVE;
+ trace->native_byte_order = BT_CTF_BYTE_ORDER_NONE;
bt_object_init(trace, bt_ctf_trace_destroy);
trace->clocks = g_ptr_array_new_with_free_func(
(GDestroyNotify) bt_put);
stream_class, bt_ctf_stream_class_get_name(stream_class),
bt_ctf_stream_class_get_id(stream_class));
- /*
- * At the end of this function we freeze the trace, so its
- * native byte order must NOT be BT_CTF_BYTE_ORDER_NATIVE.
- */
- if (trace->native_byte_order == BT_CTF_BYTE_ORDER_NATIVE) {
- BT_LOGW_STR("Invalid parameter: trace's byte order cannot be BT_CTF_BYTE_ORDER_NATIVE at this point; "
- "set it with bt_ctf_trace_set_native_byte_order().");
- ret = -1;
- goto end;
- }
-
current_parent_trace = bt_ctf_stream_class_get_trace(stream_class);
if (current_parent_trace) {
/* Stream class is already associated to a trace, abort. */
unsigned char *uuid = trace->uuid;
int ret = 0;
- if (trace->native_byte_order == BT_CTF_BYTE_ORDER_NATIVE) {
- BT_LOGW("Invalid parameter: trace's byte order cannot be BT_CTF_BYTE_ORDER_NATIVE at this point; "
+ if (trace->native_byte_order == BT_CTF_BYTE_ORDER_NATIVE ||
+ trace->native_byte_order == BT_CTF_BYTE_ORDER_NONE) {
+ BT_LOGW("Invalid parameter: trace's byte order cannot be BT_CTF_BYTE_ORDER_NATIVE or BT_CTF_BYTE_ORDER_NONE at this point; "
"set it with bt_ctf_trace_set_native_byte_order(): "
"addr=%p, name=\"%s\"",
trace, bt_ctf_trace_get_name(trace));
goto end;
}
+ if (trace->is_created_by_writer &&
+ byte_order == BT_CTF_BYTE_ORDER_NONE) {
+ BT_LOGW("Invalid parameter: BT_CTF_BYTE_ORDER_NONE byte order is not allowed for a CTF writer trace: "
+ "addr=%p, name=\"%s\"",
+ trace, bt_ctf_trace_get_name(trace));
+ ret = -1;
+ goto end;
+ }
+
if (byte_order != BT_CTF_BYTE_ORDER_LITTLE_ENDIAN &&
byte_order != BT_CTF_BYTE_ORDER_BIG_ENDIAN &&
byte_order != BT_CTF_BYTE_ORDER_NETWORK) {
goto end;
}
- ret = bt_ctf_trace_set_native_byte_order(writer_trace, order);
- if (ret) {
- fprintf(err, "[error] %s in %s:%d\n", __func__, __FILE__, __LINE__);
- ret = BT_COMPONENT_STATUS_ERROR;
- goto end;
+ /*
+ * Only explicitly set the writer trace's native byte order if
+ * the original trace has a specific one. Otherwise leave what
+ * the CTF writer object chooses, which is the machine's native
+ * byte order.
+ */
+ if (order != BT_CTF_BYTE_ORDER_NONE) {
+ ret = bt_ctf_trace_set_native_byte_order(writer_trace, order);
+ if (ret) {
+ fprintf(err, "[error] %s in %s:%d\n", __func__, __FILE__, __LINE__);
+ ret = BT_COMPONENT_STATUS_ERROR;
+ goto end;
+ }
}
header_type = bt_ctf_trace_get_packet_header_type(writer_trace);