support __builtin_swap16 and __builtin_swap32

master
leitner 7 years ago
parent e0ee49ba2e
commit 2bb35a6106

@ -25,9 +25,28 @@ static inline uint16 uint16_read(const char* in) {
return *(const uint16*)in;
}
#if defined(__x86_64__) && defined(__GNUC__)
static inline void uint16_pack_big(char* out,uint16 in) {
*(uint16*)out=__builtin_bswap16(in);
}
static inline void uint16_unpack_big(const char *in,uint16* out) {
*out=__builtin_bswap16(*(const uint16*)in);
}
static inline uint16 uint16_read_big(const char* in) {
return __builtin_bswap16(*(const uint16*)in);
}
#else
void uint16_pack_big(char *out,uint16 in);
void uint16_unpack_big(const char *in,uint16* out);
uint16 uint16_read_big(const char *in);
#endif
#else
void uint16_pack(char *out,uint16 in);

@ -25,9 +25,28 @@ static inline uint32 uint32_read(const char* in) {
return *(const uint32*)in;
}
#if defined(__x86_64__) && defined(__GNUC__)
static inline void uint32_pack_big(char *out,uint32 in) {
*(uint32*)out=__builtin_bswap32(in);
}
static inline void uint32_unpack_big(const char *in,uint32* out) {
*out=__builtin_bswap32(*(const uint32*)in);
}
static inline uint32 uint32_read_big(const char *in) {
return __builtin_bswap32(*(const uint32*)in);
}
#else
void uint32_pack_big(char *out,uint32 in);
void uint32_unpack_big(const char *in,uint32* out);
uint32 uint32_read_big(const char *in);
#endif
#else
void uint32_pack(char *out,uint32 in);

Loading…
Cancel
Save