00001
00009 #ifndef __UTILS_H__
00010 #define __UTILS_H__
00011
00012 #include <linux/list.h>
00013 #include "rres_config.h"
00014
00015
00016
00017
00018 #define INIT_LIST_HEAD_NULL(ptr) do { (ptr)->prev = NULL; (ptr)->next = NULL; } while (0)
00019
00035 #define list_add_ordered(head, obj_type, obj, list_field, ord_field, ret) \
00036 do { \
00037 struct list_head *h; \
00038 if (list_empty(&head)) { \
00039 list_add(&((obj)->list_field ), &(head)); \
00040 goto __ret1; \
00041 } else { \
00042 for (h = (head).next; h != &(head); h = h->next) { \
00043 if ((list_entry(h, struct obj_type, list_field)->ord_field) > (obj)->ord_field) { \
00044 break; \
00045 } \
00046 } \
00047 list_add_tail(&((obj)->list_field), h); \
00048 } \
00049 if (&((obj)->list_field) == (head).next) { \
00050 goto __ret1; \
00051 } \
00052 (ret) = 0; \
00053 break; \
00054 __ret1: \
00055 (ret) = 1; \
00056 } while (0)
00057
00059 static inline void list_del_null(struct list_head *entry)
00060 {
00061 list_del(entry);
00062 entry->next = entry->prev = 0;
00063 }
00064
00065 #endif
00066