Skip to content

Commit 3d6fb00

Browse files
committed
portable byteswap.h
byteswap.h comes from glibc, doesn't work on mac
1 parent c2bfd1e commit 3d6fb00

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

arcompact/arcompact.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1+
#if HAVE_BYTESWAP_H
12
#include <byteswap.h>
3+
#else
4+
#define bswap_16(value) ((((value) & 0xff) << 8) | ((value) >> 8))
5+
#define bswap_32(value) (((uint32_t)bswap_16((uint16_t)((value) & 0xffff)) << 16) | (uint32_t)bswap_16((uint16_t)((value) >> 16)))
6+
#define bswap_64(value) (((uint64_t)bswap_32((uint32_t)((value) & 0xffffffff)) << 32) | (uint64_t)bswap_32((uint32_t)((value) >> 32)))
7+
#endif
8+
29
#include <cstdint>
310
#include <stdlib.h>
411
#include <stdio.h>
@@ -1995,4 +2002,4 @@ namespace ArCompact {
19952002

19962003
return result;
19972004
}
1998-
}
2005+
}

0 commit comments

Comments
 (0)