0

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:
Wunkolo
2019-06-25 10:20:38 -07:00
parent b6a3c18b65
commit d738c21852
31 changed files with 399 additions and 394 deletions

View File

@@ -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;
}