diff options
author | dimitri staessens <dimitri.staessens@ugent.be> | 2017-07-10 19:22:44 +0000 |
---|---|---|
committer | Sander Vrijders <sander.vrijders@ugent.be> | 2017-07-10 19:22:44 +0000 |
commit | c9c788e4c8d3e16bb5b3a8fdbbfc234eaec93d04 (patch) | |
tree | 4bdf7b4d37bd33137b59f5cb4ef81b7b4225e8d0 /include | |
parent | bebcbf797d1b8703dc5eb67123ccc8a39ee631ed (diff) | |
parent | 662eaf1b0be528020b10311fc9c130f4039d4f81 (diff) | |
download | ouroboros-c9c788e4c8d3e16bb5b3a8fdbbfc234eaec93d04.tar.gz ouroboros-c9c788e4c8d3e16bb5b3a8fdbbfc234eaec93d04.zip |
Merged in dstaesse/ouroboros/be-fmt (pull request #524)
include: Fix formatting in list.h
Diffstat (limited to 'include')
-rw-r--r-- | include/ouroboros/hash.h | 1 | ||||
-rw-r--r-- | include/ouroboros/list.h | 24 |
2 files changed, 14 insertions, 11 deletions
diff --git a/include/ouroboros/hash.h b/include/ouroboros/hash.h index eeca8a28..456a93f3 100644 --- a/include/ouroboros/hash.h +++ b/include/ouroboros/hash.h @@ -31,7 +31,6 @@ #include <ouroboros/md5.h> #include <ouroboros/sha3.h> - #define HASH_FMT "%02x%02x%02x%02x" #define HASH_VAL(hash) \ (betoh32(*(uint32_t *) hash) & 0xFF000000) >> 24, \ diff --git a/include/ouroboros/list.h b/include/ouroboros/list.h index 5da93b9a..8811e291 100644 --- a/include/ouroboros/list.h +++ b/include/ouroboros/list.h @@ -21,28 +21,32 @@ * 02110-1301 USA */ -#ifndef OUROBOROS_LIST_H -#define OUROBOROS_LIST_H +#ifndef OUROBOROS_LIB_LIST_H +#define OUROBOROS_LIB_LIST_H #include <stdbool.h> +#include <stdint.h> #include <sys/types.h> struct list_head { - struct list_head * nxt, * prv; + struct list_head * nxt; + struct list_head * prv; }; #define list_entry(ptr, type, mbr) \ - ((type *)((char *)(ptr)-(size_t)(&((type *)0)->mbr))) + ((type *)((uint8_t *)(ptr)-(size_t)(&((type *)0)->mbr))) -#define list_first_entry(ptr, type, mbr) \ +#define list_first_entry(ptr, type, mbr) \ list_entry((ptr)->nxt, type, mbr) -#define list_for_each(p, h) \ +#define list_last_entry(ptr, type, mbr) \ + list_entry((ptr)->prv, type, mbr) + +#define list_for_each(p, h) \ for (p = (h)->nxt; p != (h); p = p->nxt) -#define list_for_each_safe(p, t, h) \ - for (p = (h)->nxt, t = p->nxt; p != (h); \ - p = t, t = p->nxt) +#define list_for_each_safe(p, t, h) \ + for (p = (h)->nxt, t = p->nxt; p != (h); p = t, t = p->nxt) void list_head_init(struct list_head * h); @@ -59,4 +63,4 @@ void list_move(struct list_head * dst, bool list_is_empty(struct list_head * h); -#endif +#endif /* OUROBOROS_LIB_LIST_H */ |