Added fallback for betoh/htobe if they do not exist
PATCH v3 1/1 Added fallback for betoh/htobe if they do not exist
In reply to a message not in the archiveFor older systems endian.h may not contain the betoh/htobe macros. If they are missing, add them and make sure that any user of htobe/betoh uses the compat/endian.h
---
Compared to v2 this fixes the coding style for comments. I just want to mention that I did run checkpatch for v2 and that it passed. But fixed according to Mr. Desnoyers comments anyway.
formats/lttng-live/lttng-live-comm.c | 1 + include/babeltrace/endian.h | 93 +++++++++++++++++++++++++++++++++++- 2 files changed, 93 insertions(+), 1 deletion(-)
formats/lttng-live/lttng-live-comm.c +1 -0
@@ -50,6 +50,7 @@#include <babeltrace/ctf/events-internal.h> #include <formats/ctf/events-private.h> +#include <babeltrace/endian.h> #include <babeltrace/compat/memstream.h> #include "lttng-live.h"
include/babeltrace/endian.h +92 -1
99 lines not on this page · raw message
Signature · 1 line
1.8.4.1
Merged. I added the missing space between "." and "*" in one comment. I also changed the patch title to present tense "Add fallback...".
Thanks!
Mathieu
----- Original Message -----
Quoted 144 lines
From: "Jesper Derehag" <[email protected]>
To: "mathieu desnoyers" <[email protected]>
Cc: [email protected], "Jesper Derehag" <[email protected]>
Sent: Wednesday, April 23, 2014 5:45:26 PM
Subject: [PATCH v3 babeltrace] Added fallback for betoh/htobe if they do not existFor older systems
endian.hmay not contain the betoh/htobe macros. If they are missing, add them and make sure that any user of htobe/betoh uses thecompat/endian.hSigned-off-by Jesper Derehag <[email protected]>Tested-by Jesper Derehag <[email protected]>---
Compared to v2 this fixes the coding style for comments. I just want to mention that I did run checkpatch for v2 and that it passed. But fixed according to Mr. Desnoyers comments anyway.formats/lttng-live/lttng-live-comm.c | 1 + include/babeltrace/endian.h | 93 +++++++++++++++++++++++++++++++++++- 2 files changed, 93 insertions(+), 1 deletion(-)formats/lttng-live/lttng-live-comm.c +1
-0@@ -50,6 +50,7 @@#include <babeltrace/ctf/events-internal.h> #include <formats/ctf/events-private.h> +#include <babeltrace/endian.h> #include <babeltrace/compat/memstream.h> #include "lttng-live.h" include/babeltrace/endian.h +92
-2@@ -47,7 +47,98 @@#define BYTE_ORDER __BYTE_ORDER#else #include <endian.h> -#endif + +/* +* htobe/betoh are not defined for glibc <2.9, so add them +* explicitly if they are missing. +*/ +# ifdef __USE_BSD +/* Conversion interfaces.*/ +# include <byteswap.h> + +# if __BYTE_ORDER == __LITTLE_ENDIAN +# ifndef htobe16 +# define htobe16 (x) __bswap_16(x) +# endif +# ifndef htole16 +# define htole16 (x) (x) +# endif +# ifndef be16toh +# define be16toh (x) __bswap_16(x) +# endif +# ifndef le16toh +# define le16toh (x) (x) +# endif + +# ifndef htobe32 +# define htobe32 (x) __bswap_32(x) +# endif +# ifndef htole32 +# define htole32 (x) (x) +# endif +# ifndef be32toh +# define be32toh (x) __bswap_32(x) +# endif +# ifndef le32toh +# define le32toh (x) (x) +# endif + +# ifndef htobe64 +# define htobe64 (x) __bswap_64(x) +# endif +# ifndef htole64 +# define htole64 (x) (x) +# endif +# ifndef be64toh +# define be64toh (x) __bswap_64(x) +# endif +# ifndef le64toh +# define le64toh (x) (x) +# endif + +# else /* __BYTE_ORDER == __LITTLE_ENDIAN */ +# ifndef htobe16 +# define htobe16 (x) (x) +# endif +# ifndef htole16 +# define htole16 (x) __bswap_16(x) +# endif +# ifndef be16toh +# define be16toh (x) (x) +# endif +# ifndef le16toh +# define le16toh (x) __bswap_16(x) +# endif + +# ifndef htobe32 +# define htobe32 (x) (x) +# endif +# ifndef htole32 +# define htole32 (x) __bswap_32(x) +# endif +# ifndef be32toh +# define be32toh (x) (x) +# endif +# ifndef le32toh +# define le32toh (x) __bswap_32(x) +# endif + +# ifndef htobe64 +# define htobe64 (x) (x) +# endif +# ifndef htole64 +# define htole64 (x) __bswap_64(x) +# endif +# ifndef be64toh +# define be64toh (x) (x) +# endif +# ifndef le64toh +# define le64toh (x) __bswap_64(x) +# endif + +# endif /* __BYTE_ORDER == __LITTLE_ENDIAN */ +# endif /* __USE_BSD */ +#endif /* else -- __FreeBSD__ */ #ifndef FLOAT_WORD_ORDER #ifdef __FLOAT_WORD_ORDER --1.8.4.1
Signature · 3 lines
Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com
Thanks!
----------------------------------------
Quoted 164 lines
Date: Thu, 24 Apr 2014 06:14:42 +0000
From: [email protected]
To: [email protected]
CC: [email protected]
Subject: Re: [PATCH v3 babeltrace] Added fallback for betoh/htobe if they do not existMerged. I added the missing space between "." and "*" in one comment. I also changed the patch title to present tense "Add fallback...".
Thanks!
Mathieu
----- Original Message -----
Quoted 141 lines
From: "Jesper Derehag" <[email protected]>
To: "mathieu desnoyers" <[email protected]>
Cc: [email protected], "Jesper Derehag" <[email protected]>
Sent: Wednesday, April 23, 2014 5:45:26 PM
Subject: [PATCH v3 babeltrace] Added fallback for betoh/htobe if they do not existFor older systems
endian.hmay not contain the betoh/htobe macros. If they are missing, add them and make sure that any user of htobe/betoh uses thecompat/endian.hSigned-off-by Jesper Derehag <[email protected]>Tested-by Jesper Derehag <[email protected]>---
Compared to v2 this fixes the coding style for comments. I just want to mention that I did run checkpatch for v2 and that it passed. But fixed according to Mr. Desnoyers comments anyway.
formats/lttng-live/lttng-live-comm.c| 1 +include/babeltrace/endian.h| 93
+++++++++++++++++++++++++++++++++++-2 files changed, 93 insertions(+), 1 deletion(-)formats/lttng-live/lttng-live-comm.c +1
-0@@ -50,6 +50,7 @@#include <babeltrace/ctf/events-internal.h> #include <formats/ctf/events-private.h> +#include <babeltrace/endian.h> #include <babeltrace/compat/memstream.h> #include "lttng-live.h" include/babeltrace/endian.h +92
-2@@ -47,7 +47,98 @@#define BYTE_ORDER __BYTE_ORDER#else #include <endian.h> -#endif + +/* +* htobe/betoh are not defined for glibc <2.9, so add them +* explicitly if they are missing. +*/ +# ifdef __USE_BSD +/* Conversion interfaces.*/ +# include <byteswap.h> + +# if __BYTE_ORDER == __LITTLE_ENDIAN +# ifndef htobe16 +# define htobe16 (x) __bswap_16(x) +# endif +# ifndef htole16 +# define htole16 (x) (x) +# endif +# ifndef be16toh +# define be16toh (x) __bswap_16(x) +# endif +# ifndef le16toh +# define le16toh (x) (x) +# endif + +# ifndef htobe32 +# define htobe32 (x) __bswap_32(x) +# endif +# ifndef htole32 +# define htole32 (x) (x) +# endif +# ifndef be32toh +# define be32toh (x) __bswap_32(x) +# endif +# ifndef le32toh +# define le32toh (x) (x) +# endif + +# ifndef htobe64 +# define htobe64 (x) __bswap_64(x) +# endif +# ifndef htole64 +# define htole64 (x) (x) +# endif +# ifndef be64toh +# define be64toh (x) __bswap_64(x) +# endif +# ifndef le64toh +# define le64toh (x) (x) +# endif + +# else /* __BYTE_ORDER == __LITTLE_ENDIAN */ +# ifndef htobe16 +# define htobe16 (x) (x) +# endif +# ifndef htole16 +# define htole16 (x) __bswap_16(x) +# endif +# ifndef be16toh +# define be16toh (x) (x) +# endif +# ifndef le16toh +# define le16toh (x) __bswap_16(x) +# endif + +# ifndef htobe32 +# define htobe32 (x) (x) +# endif +# ifndef htole32 +# define htole32 (x) __bswap_32(x) +# endif +# ifndef be32toh +# define be32toh (x) (x) +# endif +# ifndef le32toh +# define le32toh (x) __bswap_32(x) +# endif + +# ifndef htobe64 +# define htobe64 (x) (x) +# endif +# ifndef htole64 +# define htole64 (x) __bswap_64(x) +# endif +# ifndef be64toh +# define be64toh (x) (x) +# endif +# ifndef le64toh +# define le64toh (x) __bswap_64(x) +# endif + +# endif /* __BYTE_ORDER == __LITTLE_ENDIAN */ +# endif /* __USE_BSD */ +#endif /* else -- __FreeBSD__ */ #ifndef FLOAT_WORD_ORDER #ifdef __FLOAT_WORD_ORDER --Quoted 3 lines
1.8.4.1
--
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com