[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Minios-devel] [UNIKRAFT/LIBELF PATCH 3/7] Add SLIST macro operation
Adds missing `SLIST` macros so that libelf can be built without `<sys/queues.h>`. Signed-off-by: Simon Kuenzer <simon.kuenzer@xxxxxxxxx> --- _elftc.h | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ _libelf.h | 2 ++ elf_scn.c | 2 ++ 3 files changed, 59 insertions(+) diff --git a/_elftc.h b/_elftc.h index 94272ef..f0fa046 100644 --- a/_elftc.h +++ b/_elftc.h @@ -83,6 +83,35 @@ (var) = (tvar)) #endif +#ifndef SLIST_HEAD +#define SLIST_HEAD(name, type) \ +struct name { \ + struct type *slh_first; /* first element */ \ +} +#endif + +#ifndef SLIST_ENTRY +#define SLIST_ENTRY(type) \ +struct { \ + struct type *sle_next; /* next element */ \ +} +#endif + +#ifndef SLIST_FIRST +#define SLIST_FIRST(head) ((head)->slh_first) +#endif + +#ifndef SLIST_NEXT +#define SLIST_NEXT(elm, field) ((elm)->field.sle_next) +#endif + +#ifndef SLIST_FOREACH +#define SLIST_FOREACH(var, head, field) \ + for ((var) = SLIST_FIRST((head)); \ + (var); \ + (var) = SLIST_NEXT((var), field)) +#endif + #ifndef SLIST_FOREACH_SAFE #define SLIST_FOREACH_SAFE(var, head, field, tvar) \ for ((var) = SLIST_FIRST((head)); \ @@ -90,6 +119,32 @@ (var) = (tvar)) #endif +#ifndef SLIST_INIT +#define SLIST_INIT(head) do { \ + SLIST_FIRST((head)) = 0; \ +} while (0) +#endif + +#ifndef SLIST_INSERT_AFTER +#define SLIST_INSERT_AFTER(slistelm, elm, field) do { \ + SLIST_NEXT((elm), field) = SLIST_NEXT((slistelm), field); \ + SLIST_NEXT((slistelm), field) = (elm); \ +} while (0) +#endif + +#ifndef SLIST_INSERT_HEAD +#define SLIST_INSERT_HEAD(head, elm, field) do { \ + SLIST_NEXT((elm), field) = SLIST_FIRST((head)); \ + SLIST_FIRST((head)) = (elm); \ +} while (0) +#endif + +#ifndef SLIST_REMOVE_HEAD +#define SLIST_REMOVE_HEAD(head, field) do { \ + SLIST_FIRST((head)) = SLIST_NEXT(SLIST_FIRST((head)), field); \ +} while (0) +#endif + #ifndef STAILQ_CONCAT #define STAILQ_CONCAT(head1, head2) do { \ if (!STAILQ_EMPTY((head2))) { \ diff --git a/_libelf.h b/_libelf.h index be45335..734cbe7 100644 --- a/_libelf.h +++ b/_libelf.h @@ -29,7 +29,9 @@ #ifndef __LIBELF_H_ #define __LIBELF_H_ +#if !defined(__Unikraft__) #include <sys/queue.h> +#endif #include "_libelf_config.h" diff --git a/elf_scn.c b/elf_scn.c index d3e2747..4bc4035 100644 --- a/elf_scn.c +++ b/elf_scn.c @@ -24,7 +24,9 @@ * SUCH DAMAGE. */ +#if !defined(__Unikraft__) #include <sys/queue.h> +#endif #include <assert.h> #include <errno.h> -- 2.20.1 _______________________________________________ Minios-devel mailing list Minios-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/minios-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |