You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
1.3 KiB
C
66 lines
1.3 KiB
C
/* this header file comes from libowfat, http://www.fefe.de/libowfat/ */
|
|
#ifndef UINT32_H
|
|
#define UINT32_H
|
|
|
|
#include <inttypes.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
typedef uint32_t uint32;
|
|
typedef int32_t int32;
|
|
|
|
#if (defined(__i386__) || defined(__x86_64__)) && !defined(NO_UINT32_MACROS)
|
|
|
|
static inline void uint32_pack(char* out,uint32 in) {
|
|
*(uint32*)out=in;
|
|
}
|
|
|
|
static inline void uint32_unpack(const char *in,uint32* out) {
|
|
*out=*(const uint32*)in;
|
|
}
|
|
|
|
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);
|
|
void uint32_pack_big(char *out,uint32 in);
|
|
void uint32_unpack(const char *in,uint32* out);
|
|
void uint32_unpack_big(const char *in,uint32* out);
|
|
uint32 uint32_read(const char *in);
|
|
uint32 uint32_read_big(const char *in);
|
|
|
|
#endif
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif
|