xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: "Jan Beulich" <JBeulich@suse.com>
To: xen-devel <xen-devel@lists.xenproject.org>
Cc: Ian Campbell <Ian.Campbell@eu.citrix.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Wei Liu <wei.liu2@citrix.com>,
	Ian Jackson <Ian.Jackson@eu.citrix.com>,
	Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Subject: [PATCH RFC] libxl: fix build with glibc < 2.9
Date: Mon, 20 Jul 2015 15:30:52 +0100	[thread overview]
Message-ID: <55AD223C02000078000932DC@mail.emea.novell.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1665 bytes --]

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 <jbeulich@suse.com>
---
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*/
 
+#ifndef htobe32 /* glibc < 2.9 */
+# include <byteswap.h>
+
+# if __BYTE_ORDER == __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
 
 /*




[-- Attachment #2: libxl-glibc-2-8.patch --]
[-- Type: text/plain, Size: 1696 bytes --]

libxl: fix build with glibc < 2.9

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 <jbeulich@suse.com>
---
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*/
 
+#ifndef htobe32 /* glibc < 2.9 */
+# include <byteswap.h>
+
+# if __BYTE_ORDER == __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
 
 /*

[-- Attachment #3: Type: text/plain, Size: 126 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

             reply	other threads:[~2015-07-20 19:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-20 14:30 Jan Beulich [this message]
2015-07-21 14:06 ` [PATCH RFC] libxl: fix build with glibc < 2.9 Ian Campbell
2015-07-22 12:24   ` Wei Liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55AD223C02000078000932DC@mail.emea.novell.com \
    --to=jbeulich@suse.com \
    --cc=Ian.Campbell@eu.citrix.com \
    --cc=Ian.Jackson@eu.citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).