From 32e6a41f33e5576716b351bd473a27939fe94fa1 Mon Sep 17 00:00:00 2001 From: Jeremy Kerr Date: Mon, 15 Dec 2008 15:22:34 +1100 Subject: Initial support for multiple UIs Move the device discovery code from separate udev helpers to a single process to listen on two sockets: one SOCK_DGRAM for incoming udev events, and one SOCK_STREAM for UIs to connect. Initial support for client/server infrastructure, still need to wire-up the udev messages. Signed-off-by: Jeremy Kerr --- lib/list/list.h | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 lib/list/list.h (limited to 'lib/list/list.h') diff --git a/lib/list/list.h b/lib/list/list.h new file mode 100644 index 0000000..3858cf6 --- /dev/null +++ b/lib/list/list.h @@ -0,0 +1,39 @@ +#ifndef _LIST_H +#define _LIST_H + +struct list_item { + struct list_item *prev, *next; +}; + +struct list { + struct list_item head; +}; + +#ifndef container_of +#define container_of(ptr, type, member) ({ \ + const typeof( ((type *)0)->member ) *__mptr = (ptr); \ + (type *)( (char *)__mptr - offsetof(type,member) );}) +#endif + +#ifndef offsetof +#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) +#endif + +#define list_for_each(list, pos) \ + for (pos = (list)->head.next; pos != ((list)->head); pos = pos->next) + +#define list_entry(ptr, type, member) \ + container_of(ptr, type, member) + +#define list_for_each_entry(list, pos, member) \ + for (pos = list_entry((list)->head.next, typeof(*pos), member); \ + &pos->member != &(list)->head; \ + pos = list_entry(pos->member.next, typeof(*pos), member)) + +void list_init(struct list *list); + +void list_add(struct list *list, struct list_item *item); + +void list_remove(struct list_item *item); + +#endif /* _LIST_H */ -- cgit v1.2.1