diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2013-11-29 05:33:12 +0100 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2013-11-29 05:35:49 +0100 |
commit | 61349d3d273aa23935b0c413c5885005db2669db (patch) | |
tree | 9cbc05acb31476d45b48d4a51e9edca19328b8e8 /src/fastd.h | |
parent | c13fe36e4c0730037ae75d51f7f052d916486aac (diff) | |
download | fastd-61349d3d273aa23935b0c413c5885005db2669db.tar fastd-61349d3d273aa23935b0c413c5885005db2669db.zip |
Compile with -std=c99 and restructure some code to ensure there is no invalid aliasing (hopefully)
Diffstat (limited to 'src/fastd.h')
-rw-r--r-- | src/fastd.h | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/fastd.h b/src/fastd.h index 237af4b..8ea5027 100644 --- a/src/fastd.h +++ b/src/fastd.h @@ -380,9 +380,10 @@ static inline int fastd_rand(fastd_context_t *ctx, int min, int max) { #define exit_errno(ctx, message) exit_error(ctx, "%s: %s", message, strerror(errno)) -#define container_of(ptr, type, member) ({ \ - const typeof( ((type *)0)->member ) *__mptr = (ptr); \ - (type *)( (char *)__mptr - offsetof(type,member) );}) +#define container_of(ptr, type, member) ({ \ + const __typeof__(((type *)0)->member) *_mptr = (ptr); \ + (type*)((char*)_mptr - offsetof(type, member)); \ + }) #define array_size(array) (sizeof(array)/sizeof((array)[0])) @@ -506,16 +507,16 @@ static inline size_t min_size_t(size_t a, size_t b) { static inline void secure_memzero(void *s, size_t n) { memset(s, 0, n); - asm volatile("" : : "m"(s)); + __asm__ volatile("" : : "m"(s)); } -static inline void xor(fastd_block128_t *x, const fastd_block128_t *a, const fastd_block128_t *b) { - x->qw[0] = a->qw[0] ^ b->qw[0]; - x->qw[1] = a->qw[1] ^ b->qw[1]; +static inline void xor(fastd_block128_t *x, fastd_block128_t a, fastd_block128_t b) { + x->qw[0] = a.qw[0] ^ b.qw[0]; + x->qw[1] = a.qw[1] ^ b.qw[1]; } -static inline void xor_a(fastd_block128_t *x, const fastd_block128_t *a) { - xor(x, x, a); +static inline void xor_a(fastd_block128_t *x, fastd_block128_t a) { + xor(x, *x, a); } static inline bool fastd_true(void) { |