Fix some broken strict-aliasing rules

This commit is contained in:
jsteube
2019-03-17 11:09:32 +01:00
parent b48056fa42
commit 42e440611a
6 changed files with 158 additions and 46 deletions

View File

@@ -58,4 +58,12 @@ size_t base64_encode (u8 (*f) (const u8), const u8 *in_buf, const size_t in_len,
void lowercase (u8 *buf, const size_t len);
void uppercase (u8 *buf, const size_t len);
u16 v16a_from_v32 (const u32 v32);
u16 v16b_from_v32 (const u32 v32);
u32 v32_from_v16ab (const u16 v16a, const u16 v16b);
u32 v32a_from_v64 (const u64 v64);
u32 v32b_from_v64 (const u64 v64);
u64 v64_from_v32ab (const u32 v32a, const u32 v32b);
#endif // _CONVERT_H

View File

@@ -75,6 +75,60 @@ typedef pthread_mutex_t hc_thread_mutex_t;
typedef sem_t hc_thread_semaphore_t;
#endif
// unions
typedef union vconv32
{
u64 v32;
struct
{
u16 v16a;
u16 v16b;
};
struct
{
u8 v8a;
u8 v8b;
u8 v8c;
u8 v8d;
};
} vconv32_t;
typedef union vconv64
{
u64 v64;
struct
{
u32 v32a;
u32 v32b;
};
struct
{
u16 v16a;
u16 v16b;
u16 v16c;
u16 v16d;
};
struct
{
u8 v8a;
u8 v8b;
u8 v8c;
u8 v8d;
u8 v8e;
u8 v8f;
u8 v8g;
u8 v8h;
};
} vconv64_t;
// enums
typedef enum loglevel