From: Lucian Petrut Date: Wed, 20 Jan 2021 11:40:35 +0000 (+0000) Subject: compat: add win32 endianness helpers X-Git-Tag: v16.2.0~239^2~5 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=513f7b50a0206f4d0ac712def571810c01de5696;p=ceph.git compat: add win32 endianness helpers 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 (cherry picked from commit 057660aec9f7435f92ac32e3ee902d601b09b540) --- diff --git a/src/include/compat.h b/src/include/compat.h index 0534c15e3bfc..753741295667 100644 --- a/src/include/compat.h +++ b/src/include/compat.h @@ -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 }