summaryrefslogtreecommitdiffstats
path: root/src/fastd.h
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2012-09-15 19:57:18 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2012-09-15 19:57:18 +0200
commitf33d7756b8361ca38991bfe9d39ea5de13f86dfc (patch)
treef43a86dfebaff297ddc18778c2765a8f6c9f58d8 /src/fastd.h
parentb2d02587fcd86f0c3910441d58c94dd0c9fea5b5 (diff)
downloadfastd-f33d7756b8361ca38991bfe9d39ea5de13f86dfc.tar
fastd-f33d7756b8361ca38991bfe9d39ea5de13f86dfc.zip
Use inline function for alignment
Diffstat (limited to 'src/fastd.h')
-rw-r--r--src/fastd.h6
1 files changed, 4 insertions, 2 deletions
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));