From f33d7756b8361ca38991bfe9d39ea5de13f86dfc Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sat, 15 Sep 2012 19:57:18 +0200 Subject: Use inline function for alignment --- src/fastd.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/fastd.h') diff --git a/src/fastd.h b/src/fastd.h index 3981f46..d7946ea 100644 --- a/src/fastd.h +++ b/src/fastd.h @@ -283,6 +283,10 @@ static inline int fastd_rand(fastd_context *ctx, int min, int max) { (type *)( (char *)__mptr - offsetof(type,member) );}) +static inline size_t alignto(size_t l, size_t a) { + return ((l+a-1)/a)*a; +} + static inline fastd_buffer fastd_buffer_alloc(size_t len, size_t head_space, size_t tail_space) { size_t base_len = head_space+len+tail_space; uint8_t *ptr = malloc(base_len); @@ -354,8 +358,6 @@ static inline void fastd_string_stack_free(fastd_string_stack *str) { } } -#define ALIGN(l, a) (((l+a-1)/a)*a) - static inline bool timespec_after(const struct timespec *tp1, const struct timespec *tp2) { return (tp1->tv_sec > tp2->tv_sec || (tp1->tv_sec == tp2->tv_sec && tp1->tv_nsec > tp2->tv_nsec)); -- cgit v1.2.3