Unify Framework Lib 1.6.0
list.h
Go to the documentation of this file.
1
35/*
36 * Copyright (c) 2004, Swedish Institute of Computer Science.
37 * All rights reserved.
38 *
39 * Redistribution and use in source and binary forms, with or without
40 * modification, are permitted provided that the following conditions
41 * are met:
42 * 1. Redistributions of source code must retain the above copyright
43 * notice, this list of conditions and the following disclaimer.
44 * 2. Redistributions in binary form must reproduce the above copyright
45 * notice, this list of conditions and the following disclaimer in the
46 * documentation and/or other materials provided with the distribution.
47 * 3. Neither the name of the Institute nor the names of its contributors
48 * may be used to endorse or promote products derived from this software
49 * without specific prior written permission.
50 *
51 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
52 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
53 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
54 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
55 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
56 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
57 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
58 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
59 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
60 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
61 * SUCH DAMAGE.
62 *
63 * This file is part of the Contiki operating system.
64 *
65 * Author: Adam Dunkels <adam@sics.se>
66 *
67 * $Id: list.h,v 1.5 2010/09/13 13:31:00 adamdunkels Exp $
68 */
69#ifndef __LIST_H__
70#define __LIST_H__
71
72#define LIST_CONCAT2(s1, s2) s1##s2
73#define LIST_CONCAT(s1, s2) LIST_CONCAT2(s1, s2)
74
89#define LIST(name) \
90 static void *LIST_CONCAT(name,_list) = NULL; \
91 static list_t name = (list_t)&LIST_CONCAT(name,_list)
92
111#define LIST_STRUCT(name) \
112 void *LIST_CONCAT(name,_list); \
113 list_t name
114
125#define LIST_STRUCT_INIT(struct_ptr, name) \
126 do { \
127 (struct_ptr)->name = &((struct_ptr)->LIST_CONCAT(name,_list)); \
128 (struct_ptr)->LIST_CONCAT(name,_list) = NULL; \
129 list_init((struct_ptr)->name); \
130 } while(0)
131
136typedef void ** list_t;
137
138void list_init(list_t list);
139void * list_head(list_t list);
140void * list_tail(list_t list);
141void * list_pop (list_t list);
142void list_push(list_t list, void *item);
143
144void * list_chop(list_t list);
145
146void list_add(list_t list, void *item);
147void list_remove(list_t list, void *item);
148
150
151void list_copy(list_t dest, list_t src);
152
153void list_insert(list_t list, void *previtem, void *newitem);
154
155void * list_item_next(void *item);
156
157int list_contains(list_t list, void *item);
158#endif /* __LIST_H__ */
159
void list_init(list_t list)
Definition: list.c:66
void * list_chop(list_t list)
Definition: list.c:186
int list_contains(list_t list, void *item)
Definition: list.c:340
void list_remove(list_t list, void *item)
Definition: list.c:240
void * list_tail(list_t list)
Definition: list.c:118
void list_add(list_t list, void *item)
Definition: list.c:143
void * list_pop(list_t list)
Definition: list.c:218
void list_copy(list_t dest, list_t src)
Definition: list.c:101
int list_length(list_t list)
Definition: list.c:275
void ** list_t
Definition: list.h:136
void list_push(list_t list, void *item)
Definition: list.c:165
void * list_head(list_t list)
Definition: list.c:83
void list_insert(list_t list, void *previtem, void *newitem)
Insert an item after a specified item on the list.
Definition: list.c:303
void * list_item_next(void *item)
Get the next item following this item.
Definition: list.c:325
Definition: list.c:52