[Drbd-dev] [PATCH 1/2] drbd_endian: fix compilation error with the musl C library

Christophe Vu-Brugier cvubrugier at fastmail.fm
Wed Sep 9 15:16:06 CEST 2015


drbd-utils does not build with the musl C library due to the following
define directive:

  #define BITS_PER_LONG __WORDSIZE

The musl C library does not define __WORDSIZE unless <sys/reg.h> is
included. However, including <sys/reg.h> looks weird and does not work
with old compilers.

This patch defines BITS_PER_LONG in a more portable way:

  #define BITS_PER_LONG (__SIZEOF_LONG__ * 8)

Signed-off-by: Christophe Vu-Brugier <cvubrugier at fastmail.fm>
---
 user/shared/drbd_endian.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/user/shared/drbd_endian.h b/user/shared/drbd_endian.h
index 014516f..8d8d43e 100644
--- a/user/shared/drbd_endian.h
+++ b/user/shared/drbd_endian.h
@@ -15,7 +15,7 @@
 #include <endian.h>
 
 #ifndef BITS_PER_LONG
-# define BITS_PER_LONG __WORDSIZE
+# define BITS_PER_LONG (__SIZEOF_LONG__ * 8)
 #endif
 
 /* linux/byteorder/swab.h */
-- 
2.5.0



More information about the drbd-dev mailing list