meta: move endian functions from object to core
This commit is contained in:
49
core/include/blue/core/endian.h
Normal file
49
core/include/blue/core/endian.h
Normal file
@@ -0,0 +1,49 @@
|
||||
#ifndef BLUELIB_CORE_ENDIAN_H_
|
||||
#define BLUELIB_CORE_ENDIAN_H_
|
||||
|
||||
#include <blue/core/misc.h>
|
||||
#include <stdint.h>
|
||||
|
||||
typedef struct {
|
||||
union {
|
||||
unsigned char i_bytes[sizeof(uint16_t)];
|
||||
int16_t i_val;
|
||||
uint16_t i_uval;
|
||||
};
|
||||
} b_i16;
|
||||
|
||||
typedef struct {
|
||||
union {
|
||||
unsigned char i_bytes[sizeof(uint32_t)];
|
||||
int32_t i_val;
|
||||
uint32_t i_uval;
|
||||
};
|
||||
} b_i32;
|
||||
|
||||
typedef struct {
|
||||
union {
|
||||
unsigned char i_bytes[sizeof(uint64_t)];
|
||||
int64_t i_val;
|
||||
uint64_t i_uval;
|
||||
};
|
||||
} b_i64;
|
||||
|
||||
BLUE_API b_i16 b_i16_htob(uint16_t v);
|
||||
BLUE_API b_i16 b_i16_htos(uint16_t v);
|
||||
|
||||
BLUE_API uint16_t b_i16_btoh(b_i16 v);
|
||||
BLUE_API uint16_t b_i16_stoh(b_i16 v);
|
||||
|
||||
BLUE_API b_i32 b_i32_htob(uint32_t v);
|
||||
BLUE_API b_i32 b_i32_htos(uint32_t v);
|
||||
|
||||
BLUE_API uint32_t b_i32_btoh(b_i32 v);
|
||||
BLUE_API uint32_t b_i32_stoh(b_i32 v);
|
||||
|
||||
BLUE_API b_i64 b_i64_htob(uint64_t v);
|
||||
BLUE_API b_i64 b_i64_htos(uint64_t v);
|
||||
|
||||
BLUE_API uint64_t b_i64_btoh(b_i64 v);
|
||||
BLUE_API uint64_t b_i64_stoh(b_i64 v);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user