Re: [PATCH 2/3] Write CTF in host byte order

Joel Brobecker
2013-03-19T21:23:15Z

> Because data has been converted to the host byte order when they are
> received from the target. We use them in host side, store them
> to trace file in host side, and read the data back in host side as
> well.
>
> gdb:
>
> 2013-03-16 Yao Qi <yao@codesourcery.com>
>
> * ctf.c (ctf_save_metadata_header): Define macro HOST_ENDIANNESS
> and write it to CTF metadata.

This patch looks independent of the rest, and I think would fix
one of the build issues that have been reported.

> +#if WORDS_BIGENDIAN
> +#define HOST_ENDIANNESS "be"
> +#else
> +#define HOST_ENDIANNESS "le"
> +#endif

A comment would have been nice, although I am thinking it would
have been just as simple if you did not define HOST_ENDIANNESS
and used WORDS_BIGENDIAN directly in the code below:

> ctf_save_write_metadata (handler, metadata_fmt,
> CTF_SAVE_MAJOR, CTF_SAVE_MINOR,
> - BYTE_ORDER == LITTLE_ENDIAN ? "le" : "be");
> + HOST_ENDIANNESS);

+ WORDS_BIGENDIAN ? "be" : "le");

Either way really works for me, especially if you think you might
be using HOST_ENDIANNESS elsewhere again sometime.

You can commit with a comment or the change I suggested. If someone
objects, it's easy to revert or adjust.

--
Joel