]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
compat: add win32 endianness helpers
authorLucian Petrut <lpetrut@cloudbasesolutions.com>
Wed, 20 Jan 2021 11:40:35 +0000 (11:40 +0000)
committerLucian Petrut <lpetrut@cloudbasesolutions.com>
Fri, 22 Jan 2021 11:49:53 +0000 (11:49 +0000)
The new QCOW migration helpers are using functions such as "be64toh",
which aren't provided by MINGW, breaking the "rbd" tool on Windows.

We'll define those endianness related helpers in compat.h

Signed-off-by: Lucian Petrut <lpetrut@cloudbasesolutions.com>
src/include/compat.h

index 0534c15e3bfc31eea41d0915cf2bf98bd3aab406..7537412956673f9be5729da9e2540dbaab43a415 100644 (file)
@@ -313,7 +313,25 @@ int win_socketpair(int socks[2]);
 
 #ifdef __MINGW32__
 extern _CRTIMP errno_t __cdecl _putenv_s(const char *_Name,const char *_Value);
-#endif
+
+#if defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
+#define htobe16(x) __builtin_bswap16(x)
+#define htole16(x) (x)
+#define be16toh(x) __builtin_bswap16(x)
+#define le16toh(x) (x)
+
+#define htobe32(x) __builtin_bswap32(x)
+#define htole32(x) (x)
+#define be32toh(x) __builtin_bswap32(x)
+#define le32toh(x) (x)
+
+#define htobe64(x) __builtin_bswap64(x)
+#define htole64(x) (x)
+#define be64toh(x) __builtin_bswap64(x)
+#define le64toh(x) (x)
+#endif // defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
+
+#endif // __MINGW32__
 
 #ifdef __cplusplus
 }