From bc6735c61c81193ca69aa7455e52a0dbee2ba7cc Mon Sep 17 00:00:00 2001 From: leitner Date: Thu, 28 Apr 2011 14:28:53 +0000 Subject: [PATCH] change macros to inline functions to get rid of strict aliasing gcc warnings in code using them --- uint32.h | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/uint32.h b/uint32.h index 7ff87c1..57aff72 100644 --- a/uint32.h +++ b/uint32.h @@ -8,9 +8,19 @@ typedef uint32_t uint32; typedef int32_t int32; #if (defined(__i386__) || defined(__x86_64__)) && !defined(NO_UINT32_MACROS) -#define uint32_pack(out,in) (*(uint32*)(out)=(in)) -#define uint32_unpack(in,out) (*(out)=*(uint32*)(in)) -#define uint32_read(in) (*(uint32*)(in)) + +static inline void uint32_pack(char* out,uint32 in) { + *(uint32*)out=in; +} + +static inline void uint32_unpack(const char *in,uint32* out) { + *out=*(uint32*)in; +} + +static inline uint32 uint32_read(const char* in) { + return *(uint32*)in; +} + void uint32_pack_big(char *out,uint32 in); void uint32_unpack_big(const char *in,uint32* out); uint32 uint32_read_big(const char *in);