aboutsummaryrefslogtreecommitdiffstats
path: root/extras/mini-os/include/wait.h
diff options
context:
space:
mode:
authorIan Campbell <Ian.Campbell@citrix.com>2012-01-31 16:06:14 +0000
committerIan Campbell <Ian.Campbell@citrix.com>2012-01-31 16:06:14 +0000
commit1a4af67d32b1c39b73e09346203f3e12c00b9e41 (patch)
treeee7058fc62cdec6fe3f3582a63f99f90bd05bb24 /extras/mini-os/include/wait.h
parentf17888fc962b5249f9b6b34f28a61998c3092018 (diff)
downloadxen-1a4af67d32b1c39b73e09346203f3e12c00b9e41.tar.gz
xen-1a4af67d32b1c39b73e09346203f3e12c00b9e41.tar.bz2
xen-1a4af67d32b1c39b73e09346203f3e12c00b9e41.zip
mini-os: use BSD sys/queue.h instead of Linux list.h
The latter is GPL which makes the whole of mini-os GPL rather than BSD as intended. In tree users are all GPL or GPL-compatible but we should fix this so that mini-os is BSD. Do so by using the same BSD sys/queue.h as we use in libxl. Tested with the builtin mini-os test app and qemu stubdomain, both of which appear to still function as expected. Move tools/libxl/external and the associated sed script to tools/include/xen-external to allow more sensible access from mini-os. Also add s/NULL/0/ in the sed script due to NULL not always being defined in stubdom code when mini-os/wait.h is included. As well as the obvious ABI changes there are a few API updates associated with the change: - struct rw_semaphore.wait_list is unused - remove_waiter needs to take the wait_queue_head The latter requires a qemu update, so there is also a QEMU_TAG update in this changeset. I sprinkled some extra-emacs local variables around the files I edited which didn't have them. I think this should be backported to the stable branches since external users of mini-os may have been mislead into thinking they could safely link mini-os against GPL-incompatible code. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Diffstat (limited to 'extras/mini-os/include/wait.h')
-rw-r--r--extras/mini-os/include/wait.h56
1 files changed, 33 insertions, 23 deletions
diff --git a/extras/mini-os/include/wait.h b/extras/mini-os/include/wait.h
index 10b9f29b07..bffa3c444c 100644
--- a/extras/mini-os/include/wait.h
+++ b/extras/mini-os/include/wait.h
@@ -5,47 +5,47 @@
#include <mini-os/os.h>
#include <mini-os/waittypes.h>
-#define DEFINE_WAIT(name) \
-struct wait_queue name = { \
- .thread = get_current(), \
- .thread_list = MINIOS_LIST_HEAD_INIT((name).thread_list), \
+#define DEFINE_WAIT(name) \
+struct wait_queue name = { \
+ .thread = get_current(), \
+ .waiting = 0, \
}
static inline void init_waitqueue_head(struct wait_queue_head *h)
{
- MINIOS_INIT_LIST_HEAD(&h->thread_list);
+ MINIOS_STAILQ_INIT(h);
}
static inline void init_waitqueue_entry(struct wait_queue *q, struct thread *thread)
{
q->thread = thread;
- MINIOS_INIT_LIST_HEAD(&q->thread_list);
+ q->waiting = 0;
}
-
static inline void add_wait_queue(struct wait_queue_head *h, struct wait_queue *q)
{
- if (minios_list_empty(&q->thread_list))
- minios_list_add(&q->thread_list, &h->thread_list);
+ if (!q->waiting) {
+ MINIOS_STAILQ_INSERT_HEAD(h, q, thread_list);
+ q->waiting = 1;
+ }
}
-static inline void remove_wait_queue(struct wait_queue *q)
+static inline void remove_wait_queue(struct wait_queue_head *h, struct wait_queue *q)
{
- minios_list_del(&q->thread_list);
+ if (q->waiting) {
+ MINIOS_STAILQ_REMOVE(h, q, struct wait_queue, thread_list);
+ q->waiting = 0;
+ }
}
static inline void wake_up(struct wait_queue_head *head)
{
unsigned long flags;
- struct minios_list_head *tmp, *next;
+ struct wait_queue *curr, *tmp;
local_irq_save(flags);
- minios_list_for_each_safe(tmp, next, &head->thread_list)
- {
- struct wait_queue *curr;
- curr = minios_list_entry(tmp, struct wait_queue, thread_list);
+ MINIOS_STAILQ_FOREACH_SAFE(curr, head, thread_list, tmp)
wake(curr->thread);
- }
local_irq_restore(flags);
}
@@ -57,11 +57,11 @@ static inline void wake_up(struct wait_queue_head *head)
local_irq_restore(flags); \
} while (0)
-#define remove_waiter(w) do { \
- unsigned long flags; \
- local_irq_save(flags); \
- remove_wait_queue(&w); \
- local_irq_restore(flags); \
+#define remove_waiter(w, wq) do { \
+ unsigned long flags; \
+ local_irq_save(flags); \
+ remove_wait_queue(&wq, &w); \
+ local_irq_restore(flags); \
} while (0)
#define wait_event_deadline(wq, condition, deadline) do { \
@@ -84,7 +84,7 @@ static inline void wake_up(struct wait_queue_head *head)
local_irq_save(flags); \
/* need to wake up */ \
wake(get_current()); \
- remove_wait_queue(&__wait); \
+ remove_wait_queue(&wq, &__wait); \
local_irq_restore(flags); \
} while(0)
@@ -93,3 +93,13 @@ static inline void wake_up(struct wait_queue_head *head)
#endif /* __WAIT_H__ */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-set-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */