summaryrefslogtreecommitdiffstats
path: root/src/fastd.h
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2012-03-06 23:06:18 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2012-03-06 23:06:18 +0100
commitf8a2fec8f399229d15d3481be0ce8567b2ed6851 (patch)
treec214fcb30a99791dabe3076ea8c449b3d6538c89 /src/fastd.h
parent1d18f972554c8bad0f08b3ff6727c87586e97094 (diff)
downloadfastd-f8a2fec8f399229d15d3481be0ce8567b2ed6851.tar
fastd-f8a2fec8f399229d15d3481be0ce8567b2ed6851.zip
Simplify queue functions
Diffstat (limited to 'src/fastd.h')
-rw-r--r--src/fastd.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/fastd.h b/src/fastd.h
index c8cad39..e4bef44 100644
--- a/src/fastd.h
+++ b/src/fastd.h
@@ -121,6 +121,11 @@ struct _fastd_context {
#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) );})
+
+
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(head_space+len);