diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2012-03-06 23:06:18 +0100 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2012-03-06 23:06:18 +0100 |
commit | f8a2fec8f399229d15d3481be0ce8567b2ed6851 (patch) | |
tree | c214fcb30a99791dabe3076ea8c449b3d6538c89 /src/fastd.h | |
parent | 1d18f972554c8bad0f08b3ff6727c87586e97094 (diff) | |
download | fastd-f8a2fec8f399229d15d3481be0ce8567b2ed6851.tar fastd-f8a2fec8f399229d15d3481be0ce8567b2ed6851.zip |
Simplify queue functions
Diffstat (limited to 'src/fastd.h')
-rw-r--r-- | src/fastd.h | 5 |
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); |