Propagate block, bool, standard integer types across codebase
Posix type integer pass Propagate block, bool, integer types across codebase Add standard integer types to prototypes
This commit is contained in:
@@ -17,23 +17,25 @@
|
||||
|
||||
/* simple routines for dealing with endian conversion */
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define UNKNOWN_ENDIAN 0
|
||||
#define BIG_ENDIAN 1
|
||||
#define LITTLE_ENDIAN 2
|
||||
|
||||
static int endianness = UNKNOWN_ENDIAN;
|
||||
static int32_t endianness = UNKNOWN_ENDIAN;
|
||||
|
||||
void init_endian(void) {
|
||||
/* figure out what our endianness is! */
|
||||
short word = 0x0001;
|
||||
int16_t word = 0x0001;
|
||||
char* byte = (char*)(&word);
|
||||
endianness = byte[0] ? LITTLE_ENDIAN : BIG_ENDIAN;
|
||||
}
|
||||
|
||||
unsigned short big_endian_ushort(unsigned short in) {
|
||||
uint16_t big_endian_ushort(uint16_t in) {
|
||||
return (endianness == LITTLE_ENDIAN) ? ((in >> 8) | (in << 8)) : in;
|
||||
}
|
||||
|
||||
unsigned int big_endian_uint(unsigned int in) {
|
||||
uint32_t big_endian_uint(uint32_t in) {
|
||||
return (endianness == LITTLE_ENDIAN) ? (((in & 0x000000FF) << 24) + ((in & 0x0000FF00) << 8) + ((in & 0x00FF0000) >> 8) + ((in & 0xFF000000) >> 24)) : in;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user