Skip to contentSkip to conversation

blktap2: use HAVE_BYTESWAP_H and _BYTESWAP_H for uclibc compatibility

PATCH In review Roger Pau Monne 2 participants 4 messages Dec 15, 2011 – Dec 16, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 blktap2: use HAVE_BYTESWAP_H and _BYTESWAP_H for uclibc compatibility

# HG changeset patch
# User Roger Pau Monne <[email protected]>
# Date 1323969492 -3600
# Node ID a01f1e2f654ea54bbf5d0a77b315b676cc494aa8
# Parent 0051e09f73efea06f2f28c0ece57194e286daedc
blktap2: use HAVE_BYTESWAP_H and _BYTESWAP_H for uclibc compatibility

uclibc defines _BYTESWAP_H instead of HAVE_BYTESWAP_H in byteswap.h:

http://git.uclibc.org/uClibc/tree/include/byteswap.h

Without this fix, blktap2 doesn't compile under uclibc and throws the following error:

gcc -O1 -fno-omit-frame-pointer -m64 -g -fno-strict-aliasing -std=gnu99 -Wall -Wstrict-prototypes -Wdeclaration-after-statement
-Wno-unused-but-set-variable -D__XEN_TOOLS__ -MMD -MF
.block-qcow.o.d -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -fno-optimize-sibling-calls -Werror -g -O0 -Wno-unused -fno-strict-aliasing -I../include -I../drivers -I/root/xen-unstable/tools/blktap2/drivers/../../../tools/libxc -I/root/xen-unstable/tools/blktap2/drivers/../../../tools/include -I /root/xen-unstable/tools/blktap2/drivers/../../../tools/memshr -D_GNU_SOURCE -DUSE_NFS_LOCKS -fPIC -I /root/xen-unstable/tools/blktap2/drivers/../../../tools/libaio/src -c -o block-qcow.o block-qcow.c -I/usr/local/include
In file included from block-qcow.c:37:0:
bswap.h:23:0: error: "bswap_16" redefined [-Werror] /usr/include/byteswap.h:30:0: note: this is the location of the previous definition
bswap.h:31:0: error: "bswap_32" redefined [-Werror] /usr/include/byteswap.h:33:0: note: this is the location of the previous definition
bswap.h:41:0: error: "bswap_64" redefined [-Werror] /usr/include/byteswap.h:37:0: note: this is the location of the previous definition
cc1: all warnings being treated as errors

tools/blktap2/drivers/bswap.h +1 -1
diff -r 0051e09f73ef -r a01f1e2f654e tools/blktap2/drivers/bswap.h
@@ -15,7 +15,7 @@
 #define bswap_64(x) swap64(x)
 #else
 
-#ifdef HAVE_BYTESWAP_H
+#if defined(HAVE_BYTESWAP_H) || defined(_BYTESWAP_H)
 #include <byteswap.h>
 #else
#1 lore raw

I'm having second thoughts about this patch, although it works, I'm not sure it's the right way to do it. I don't know why configure fails to set HAVE_BYTESWAP_H when using uclibc. Any thoughts?

#2 lore raw

This patch is wrong, but I think blktap bswap.h is also wrong, because HAVE_BYTESWAP_H is defined by qemu, but blktap doesn't include qemu config file, so HAVE_BYTESWAP_H is not defined in this header file (which doesn't mean that byteswap.h is not present on the system). How should we fix this? Forget about including byteswap.h and always define the functions ourselves?

Thanks, Roger.

#3 lore raw
Quoted 6 lines · Roger Pau Monné

This patch is wrong, but I think blktap bswap.h is also wrong, because HAVE_BYTESWAP_H is defined by qemu, but blktap doesn't include qemu config file, so HAVE_BYTESWAP_H is not defined in this header file (which doesn't mean that byteswap.h is not present on the system). How should we fix this? Forget about including byteswap.h and always define the functions ourselves?

If HAVE_BYTESWAP_H has never been defined up until now can't we just delete the include?

Quoted 7 lines

Thanks, Roger.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel