From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Jan Beulich" Subject: [PATCH RFC] libxl: fix build with glibc < 2.9 Date: Mon, 20 Jul 2015 15:30:52 +0100 Message-ID: <55AD223C02000078000932DC@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part9AAE6F0C.2__=" Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1ZHH7u-0000XI-Ga for xen-devel@lists.xenproject.org; Mon, 20 Jul 2015 19:53:26 +0000 List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel Cc: Ian Campbell , Andrew Cooper , Wei Liu , Ian Jackson , Stefano Stabellini List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__Part9AAE6F0C.2__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline htobe*() and be*toh() don't exist there. While replacing the 32-bit ones with hton() and ntoh() would be possible, there wouldn't be an obvious replacement for the 64-bit ones. Hence just take what current glibc (2.21) has (assuming __bswap_*() exists, which it does back to at least 2.4 according to my checking). Signed-off-by: Jan Beulich --- Not sure whether I picked an appropriate header to place this in, or an appropriate #ifdef to hook this onto. Hence the RFC. --- a/tools/libxl/libxl_osdeps.h +++ b/tools/libxl/libxl_osdeps.h @@ -59,6 +59,42 @@ int asprintf(char **buffer, char *fmt, . int vasprintf(char **buffer, const char *fmt, va_list ap); #endif /*NEED_OWN_ASPRINTF*/ =20 +#ifndef htobe32 /* glibc < 2.9 */ +# include + +# if __BYTE_ORDER =3D=3D __LITTLE_ENDIAN +# define htobe16(x) __bswap_16(x) +# define htole16(x) (x) +# define be16toh(x) __bswap_16(x) +# define le16toh(x) (x) + +# define htobe32(x) __bswap_32(x) +# define htole32(x) (x) +# define be32toh(x) __bswap_32(x) +# define le32toh(x) (x) + +# define htobe64(x) __bswap_64(x) +# define htole64(x) (x) +# define be64toh(x) __bswap_64(x) +# define le64toh(x) (x) +# else +# define htobe16(x) (x) +# define htole16(x) __bswap_16(x) +# define be16toh(x) (x) +# define le16toh(x) __bswap_16(x) + +# define htobe32(x) (x) +# define htole32(x) __bswap_32(x) +# define be32toh(x) (x) +# define le32toh(x) __bswap_32(x) + +# define htobe64(x) (x) +# define htole64(x) __bswap_64(x) +# define be64toh(x) (x) +# define le64toh(x) __bswap_64(x) +# endif +#endif + #endif =20 /* --=__Part9AAE6F0C.2__= Content-Type: text/plain; name="libxl-glibc-2-8.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="libxl-glibc-2-8.patch" libxl: fix build with glibc < 2.9=0A=0Ahtobe*() and be*toh() don't exist = there. While replacing the 32-bit=0Aones with hton() and ntoh() would be = possible, there wouldn't be an=0Aobvious replacement for the 64-bit ones. = Hence just take what current=0Aglibc (2.21) has (assuming __bswap_*() = exists, which it does back to=0Aat least 2.4 according to my checking).=0A= =0ASigned-off-by: Jan Beulich =0A---=0ANot sure whether = I picked an appropriate header to place this in, or=0Aan appropriate = #ifdef to hook this onto. Hence the RFC.=0A=0A--- a/tools/libxl/libxl_osdep= s.h=0A+++ b/tools/libxl/libxl_osdeps.h=0A@@ -59,6 +59,42 @@ int asprintf(ch= ar **buffer, char *fmt, .=0A int vasprintf(char **buffer, const char *fmt, = va_list ap);=0A #endif /*NEED_OWN_ASPRINTF*/=0A =0A+#ifndef htobe32 /* = glibc < 2.9 */=0A+# include =0A+=0A+# if __BYTE_ORDER =3D=3D = __LITTLE_ENDIAN=0A+# define htobe16(x) __bswap_16(x)=0A+# define = htole16(x) (x)=0A+# define be16toh(x) __bswap_16(x)=0A+# define = le16toh(x) (x)=0A+=0A+# define htobe32(x) __bswap_32(x)=0A+# define = htole32(x) (x)=0A+# define be32toh(x) __bswap_32(x)=0A+# define = le32toh(x) (x)=0A+=0A+# define htobe64(x) __bswap_64(x)=0A+# define = htole64(x) (x)=0A+# define be64toh(x) __bswap_64(x)=0A+# define = le64toh(x) (x)=0A+# else=0A+# define htobe16(x) (x)=0A+# define = htole16(x) __bswap_16(x)=0A+# define be16toh(x) (x)=0A+# define = le16toh(x) __bswap_16(x)=0A+=0A+# define htobe32(x) (x)=0A+# define = htole32(x) __bswap_32(x)=0A+# define be32toh(x) (x)=0A+# define = le32toh(x) __bswap_32(x)=0A+=0A+# define htobe64(x) (x)=0A+# define = htole64(x) __bswap_64(x)=0A+# define be64toh(x) (x)=0A+# define = le64toh(x) __bswap_64(x)=0A+# endif=0A+#endif=0A+=0A #endif=0A =0A /*=0A --=__Part9AAE6F0C.2__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --=__Part9AAE6F0C.2__=--