Xenomai 3.3.2
Loading...
Searching...
No Matches
list.h
1/*
2 * Copyright (C) 2013 Philippe Gerum <rpm@xenomai.org>.
3 *
4 * Xenomai is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published
6 * by the Free Software Foundation; either version 2 of the License,
7 * or (at your option) any later version.
8 *
9 * Xenomai is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with Xenomai; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
17 * 02111-1307, USA.
18 */
19#ifndef _COBALT_KERNEL_LIST_H
20#define _COBALT_KERNEL_LIST_H
21
22#include <linux/list.h>
23
24#define __list_add_pri(__new, __head, __member_pri, __member_next, __relop) \
25do { \
26 typeof(*__new) *__pos; \
27 if (list_empty(__head)) \
28 list_add(&(__new)->__member_next, __head); \
29 else { \
30 list_for_each_entry_reverse(__pos, __head, __member_next) { \
31 if ((__new)->__member_pri __relop __pos->__member_pri) \
32 break; \
33 } \
34 list_add(&(__new)->__member_next, &__pos->__member_next); \
35 } \
36} while (0)
37
38#define list_add_priff(__new, __head, __member_pri, __member_next) \
39 __list_add_pri(__new, __head, __member_pri, __member_next, <=)
40
41#define list_add_prilf(__new, __head, __member_pri, __member_next) \
42 __list_add_pri(__new, __head, __member_pri, __member_next, <)
43
44#define list_get_entry(__head, __type, __member) \
45 ({ \
46 __type *__item; \
47 __item = list_first_entry(__head, __type, __member); \
48 list_del(&__item->__member); \
49 __item; \
50 })
51
52#define list_get_entry_init(__head, __type, __member) \
53 ({ \
54 __type *__item; \
55 __item = list_first_entry(__head, __type, __member); \
56 list_del_init(&__item->__member); \
57 __item; \
58 })
59
60#ifndef list_next_entry
61#define list_next_entry(__item, __member) \
62 list_entry((__item)->__member.next, typeof(*(__item)), __member)
63#endif
64
65#endif /* !_COBALT_KERNEL_LIST_H_ */