-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix compile issues under Developer Studio 12.6
- Loading branch information
Showing
16 changed files
with
257 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,17 +86,123 @@ | |
#include <sys/endian.h> | ||
#endif | ||
|
||
#if !defined BYTE_ORDER | ||
#error "missing definition of BYTE_ORDER" | ||
#if !defined(LITTLE_ENDIAN) | ||
# if defined(__ORDER_LITTLE_ENDIAN__) | ||
# define LITTLE_ENDIAN __ORDER_LITTLE_ENDIAN__ | ||
# else | ||
# define LITTLE_ENDIAN 1234 | ||
# endif | ||
#endif | ||
|
||
#if !defined LITTLE_ENDIAN | ||
#error "missing definition of LITTLE_ENDIAN" | ||
#if !defined(BIG_ENDIAN) | ||
# if defined(__ORDER_BIG_ENDIAN__) | ||
# define BIG_ENDIAN __ORDER_BIG_ENDIAN__ | ||
# else | ||
# define BIG_ENDIAN 4321 | ||
# endif | ||
#endif | ||
|
||
#if !defined BIG_ENDIAN | ||
#error "missing definition of BIG_ENDIAN" | ||
#if !defined(BYTE_ORDER) | ||
# if defined(__BYTE_ORDER__) | ||
# define BYTE_ORDER __BYTE_ORDER__ | ||
# elif defined(__BYTE_ORDER) | ||
# define BYTE_ORDER __BYTE_ORDER | ||
# elif defined(i386) || defined(__i386__) || defined(__i486__) || \ | ||
defined(__i586__) || defined(__i686__) || \ | ||
defined(__x86) || defined(__x86_64) || defined(__x86_64__) || \ | ||
defined(__amd64) || defined(__amd64__) | ||
# define BYTE_ORDER LITTLE_ENDIAN | ||
# elif defined(sparc) || defined(__sparc) || defined(__sparc__) || \ | ||
defined(POWERPC) || defined(mc68000) || defined(sel) | ||
# define BYTE_ORDER BIG_ENDIAN | ||
# else | ||
# error "missing definition of BYTE_ORDER" | ||
# endif | ||
#endif | ||
|
||
static really_inline uint16_t bswap16(uint16_t x) | ||
{ | ||
// Copied from src/common/lib/libc/gen/bswap16.c in NetBSD | ||
// Written by Manuel Bouyer <[email protected]>. | ||
// Public domain. | ||
return ((x << 8) & 0xff00) | ((x >> 8) & 0x00ff); | ||
} | ||
|
||
static really_inline uint32_t bswap32(uint32_t x) | ||
{ | ||
// Copied from src/common/lib/libc/gen/bswap32.c in NetBSD | ||
// Written by Manuel Bouyer <[email protected]>. | ||
// Public domain. | ||
return ( (x << 24) & 0xff000000 ) | | ||
( (x << 8) & 0x00ff0000 ) | | ||
( (x >> 8) & 0x0000ff00 ) | | ||
( (x >> 24) & 0x000000ff ); | ||
} | ||
|
||
static really_inline uint64_t bswap64(uint64_t x) | ||
{ | ||
// Copied from src/common/lib/libc/gen/bswap64.c in NetBSD | ||
// Written by Manuel Bouyer <[email protected]>. | ||
// Public domain. | ||
return ( (x << 56) & 0xff00000000000000ull ) | | ||
( (x << 40) & 0x00ff000000000000ull ) | | ||
( (x << 24) & 0x0000ff0000000000ull ) | | ||
( (x << 8) & 0x000000ff00000000ull ) | | ||
( (x >> 8) & 0x00000000ff000000ull ) | | ||
( (x >> 24) & 0x0000000000ff0000ull ) | | ||
( (x >> 40) & 0x000000000000ff00ull ) | | ||
( (x >> 56) & 0x00000000000000ffull ); | ||
} | ||
|
||
# if BYTE_ORDER == LITTLE_ENDIAN | ||
# define htobe(bits, x) bswap ## bits((x)) | ||
# define htole(bits, x) (x) | ||
# define betoh(bits, x) bswap ## bits((x)) | ||
# define letoh(bits, x) (x) | ||
# else | ||
# define htobe(bits, x) (x) | ||
# define htole(bits, x) bswap ## bits((x)) | ||
# define betoh(bits, x) (x) | ||
# define letoh(bits, x) bswap ## bits((x)) | ||
# endif | ||
|
||
# if !defined htobe16 | ||
# define htobe16(x) htobe(16,(x)) | ||
# endif | ||
# if !defined htobe32 | ||
# define htobe32(x) htobe(32,(x)) | ||
# endif | ||
# if !defined htobe64 | ||
# define htobe64(x) htobe(64,(x)) | ||
# endif | ||
# if !defined htole16 | ||
# define htole16(x) htole(16,(x)) | ||
# endif | ||
# if !defined htole32 | ||
# define htole32(x) htole(32,(x)) | ||
# endif | ||
# if !defined htole64 | ||
# define htole64(x) htole(64,(x)) | ||
# endif | ||
|
||
# if !defined be16toh | ||
# define be16toh(x) betoh(16,(x)) | ||
# endif | ||
# if !defined be32toh | ||
# define be32toh(x) betoh(32,(x)) | ||
# endif | ||
# if !defined be64toh | ||
# define be64toh(x) betoh(64,(x)) | ||
# endif | ||
# if !defined le16toh | ||
# define le16toh(x) letoh(16,(x)) | ||
# endif | ||
# if !defined le32toh | ||
# define le32toh(x) letoh(32,(x)) | ||
# endif | ||
# if !defined le64toh | ||
# define le64toh(x) letoh(64,(x)) | ||
# endif | ||
#endif | ||
|
||
#endif // ENDIAN_H |
Oops, something went wrong.