* [PATCH RFC] libxl: fix build with glibc < 2.9
@ 2015-07-20 14:30 Jan Beulich
2015-07-21 14:06 ` Ian Campbell
0 siblings, 1 reply; 3+ messages in thread
From: Jan Beulich @ 2015-07-20 14:30 UTC (permalink / raw)
To: xen-devel
Cc: Ian Campbell, Andrew Cooper, Wei Liu, Ian Jackson, Stefano Stabellini
[-- 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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH RFC] libxl: fix build with glibc < 2.9
2015-07-20 14:30 [PATCH RFC] libxl: fix build with glibc < 2.9 Jan Beulich
@ 2015-07-21 14:06 ` Ian Campbell
2015-07-22 12:24 ` Wei Liu
0 siblings, 1 reply; 3+ messages in thread
From: Ian Campbell @ 2015-07-21 14:06 UTC (permalink / raw)
To: Jan Beulich, xen-devel
Cc: Andrew Cooper, Wei Liu, Ian Jackson, Stefano Stabellini
On Mon, 2015-07-20 at 15:30 +0100, Jan Beulich wrote:
> 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.
I think they will do.
I was a bit confused by xl.c including libxl_osdeps.h, but I think that
is an aberration and we don't install the header so it is not really
"public".
Acked-by: Ian Campbell <ian.campbell@citrix.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH RFC] libxl: fix build with glibc < 2.9
2015-07-21 14:06 ` Ian Campbell
@ 2015-07-22 12:24 ` Wei Liu
0 siblings, 0 replies; 3+ messages in thread
From: Wei Liu @ 2015-07-22 12:24 UTC (permalink / raw)
To: Ian Campbell
Cc: Wei Liu, Stefano Stabellini, Andrew Cooper, Ian Jackson,
Jan Beulich, xen-devel
On Tue, Jul 21, 2015 at 03:06:29PM +0100, Ian Campbell wrote:
> On Mon, 2015-07-20 at 15:30 +0100, Jan Beulich wrote:
> > 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.
>
> I think they will do.
>
> I was a bit confused by xl.c including libxl_osdeps.h, but I think that
> is an aberration and we don't install the header so it is not really
> "public".
>
> Acked-by: Ian Campbell <ian.campbell@citrix.com>
I was about to object putting them in libxl_osdep.h because they are not
really OS-dependent. However we've dumped something similar there before
so I withdraw my objection.
FWIW
Acked-by: Wei Liu <wei.liu2@citrix.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-07-22 12:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-20 14:30 [PATCH RFC] libxl: fix build with glibc < 2.9 Jan Beulich
2015-07-21 14:06 ` Ian Campbell
2015-07-22 12:24 ` Wei Liu
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).