aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjoern B. Brandenburg <bbb@cs.unc.edu>2008-02-05 19:33:14 -0500
committerBjoern B. Brandenburg <bbb@cs.unc.edu>2008-02-05 19:33:14 -0500
commit405d961616b5593cf780a1653c1fe4a386c305e3 (patch)
tree7d8bbc0da6fe72b4aa9b0388f5cc3c30dc0867a4
parentf0c2c2b2aa78e96941ded5ab03f85bf60e45d44b (diff)
move sorted list functionality into litmus.h
-rw-r--r--include/linux/list.h30
-rw-r--r--include/litmus/litmus.h28
2 files changed, 28 insertions, 30 deletions
diff --git a/include/linux/list.h b/include/linux/list.h
index 319c5eda13..611059d633 100644
--- a/include/linux/list.h
+++ b/include/linux/list.h
@@ -898,36 +898,6 @@ static inline void hlist_add_after_rcu(struct hlist_node *prev,
898 ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \ 898 ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
899 pos = pos->next) 899 pos = pos->next)
900 900
901
902typedef int (*list_cmp_t)(struct list_head*, struct list_head*);
903
904static inline unsigned int list_insert(struct list_head* new,
905 struct list_head* head,
906 list_cmp_t order_before)
907{
908 struct list_head *pos;
909 unsigned int passed = 0;
910
911 BUG_ON(!new);
912
913 /* find a spot where the new entry is less than the next */
914 list_for_each(pos, head) {
915 if (unlikely(order_before(new, pos))) {
916 /* pos is not less than new, thus insert here */
917 __list_add(new, pos->prev, pos);
918 goto out;
919 }
920 passed++;
921 }
922 /* if we get to this point either the list is empty or every entry
923 * queued element is less than new.
924 * Let's add new to the end. */
925 list_add_tail(new, head);
926 out:
927 return passed;
928}
929
930
931#else 901#else
932#warning "don't include kernel headers in userspace" 902#warning "don't include kernel headers in userspace"
933#endif /* __KERNEL__ */ 903#endif /* __KERNEL__ */
diff --git a/include/litmus/litmus.h b/include/litmus/litmus.h
index 6373a37da3..de99addbce 100644
--- a/include/litmus/litmus.h
+++ b/include/litmus/litmus.h
@@ -77,6 +77,34 @@ static inline int in_list(struct list_head* list)
77 ); 77 );
78} 78}
79 79
80typedef int (*list_cmp_t)(struct list_head*, struct list_head*);
81
82static inline unsigned int list_insert(struct list_head* new,
83 struct list_head* head,
84 list_cmp_t order_before)
85{
86 struct list_head *pos;
87 unsigned int passed = 0;
88
89 BUG_ON(!new);
90
91 /* find a spot where the new entry is less than the next */
92 list_for_each(pos, head) {
93 if (unlikely(order_before(new, pos))) {
94 /* pos is not less than new, thus insert here */
95 __list_add(new, pos->prev, pos);
96 goto out;
97 }
98 passed++;
99 }
100 /* if we get to this point either the list is empty or every entry
101 * queued element is less than new.
102 * Let's add new to the end. */
103 list_add_tail(new, head);
104 out:
105 return passed;
106}
107
80void list_qsort(struct list_head* list, list_cmp_t less_than); 108void list_qsort(struct list_head* list, list_cmp_t less_than);
81 109
82 110