summaryrefslogtreecommitdiffstats
path: root/lib/list
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2008-12-15 15:22:34 +1100
committerJeremy Kerr <jk@ozlabs.org>2008-12-15 15:22:34 +1100
commit32e6a41f33e5576716b351bd473a27939fe94fa1 (patch)
tree0d6b75ac0a02d2496416095405cb9498777c3beb /lib/list
parent000a92b4fa909c432732ac3ed8f28eeeaeac70ee (diff)
downloadtalos-petitboot-32e6a41f33e5576716b351bd473a27939fe94fa1.tar.gz
talos-petitboot-32e6a41f33e5576716b351bd473a27939fe94fa1.zip
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 <jk@ozlabs.org>
Diffstat (limited to 'lib/list')
-rw-r--r--lib/list/list.c24
-rw-r--r--lib/list/list.h39
2 files changed, 63 insertions, 0 deletions
diff --git a/lib/list/list.c b/lib/list/list.c
new file mode 100644
index 0000000..d9bc532
--- /dev/null
+++ b/lib/list/list.c
@@ -0,0 +1,24 @@
+
+#include "list/list.h"
+
+void list_init(struct list *list)
+{
+ list->head.next = &list->head;
+ list->head.prev = &list->head;
+}
+
+void list_add(struct list *list, struct list_item *new)
+{
+ new->next = list->head.next;
+ new->prev = &list->head;
+
+ list->head.next->prev = new;
+ list->head.next = new;
+}
+
+void list_remove(struct list_item *item)
+{
+ item->next->prev = item->prev;
+ item->prev->next = item->next;
+}
+
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 */
OpenPOWER on IntegriCloud