libcortex
Event loop library following a "batteries included" approach
Loading...
Searching...
No Matches
llist.h
1/*
2 * Mario Kicherer (dev@kicherer.org) 2016
3 *
4 */
5
6// no preprocessor guard as linkedlist.h will include this header twice
7
8/*
9 * user code can create a specialized linked-list implementation by including
10 * the llist.c file similar to the following code:
11 *
12 * #undef CRTX_DLL_PREFIX
13 * #define CRTX_DLL_CUSTOM_UNION_TYPE struct my_app_type *my_value
14 * #define CRTX_DLL_PREFIX my_app_ll
15 * #include <crtx/llist.c>
16 * #undef CRTX_DLL_PREFIX
17 *
18 * And then call the functions like this, for example:
19 *
20 * my_app_ll_append_new(&my_list_head, my_value);
21 */
22
23#ifndef CRTX_DLL_PREFIX
24 #ifdef CRTX_DLL
25 #define CRTX_DLL_PREFIX crtx_dll
26 #else
27 #ifndef CRTX_DLL_PREFIX
28 #define CRTX_DLL_PREFIX crtx_ll
29 #else
30 #define STOP
31 #endif
32 #endif
33#endif
34
35#ifndef STOP
36
37#define CRTX_DLL_TYPE struct CRTX_DLL_PREFIX
38
39#define CRTX_DLL_FCT_HELPER2(x,y) x ## _ ## y
40#define CRTX_DLL_FCT_HELPER(x,y) CRTX_DLL_FCT_HELPER2(x,y)
41#define CRTX_DLL_FCT(x) CRTX_DLL_FCT_HELPER(CRTX_DLL_PREFIX, x)
42
43CRTX_DLL_TYPE {
44 #ifdef CRTX_DLL
45 CRTX_DLL_TYPE *prev;
46 #endif
47 CRTX_DLL_TYPE *next;
48
49 union {
50 void *data;
51 size_t size;
52 struct crtx_event *event;
53 struct crtx_graph *graph;
54 struct crtx_inotify_listener *in_listener;
55 struct crtx_transform_dict_handler *transform_handler;
56 struct crtx_handler_category *handler_category;
57 struct crtx_handler_category_entry *handler_category_entry;
58 struct crtx_dict *dict;
59
60 #ifdef CRTX_DLL_CUSTOM_UNION_TYPE
61 CRTX_DLL_CUSTOM_UNION_TYPE;
62 #endif
63 };
64
65 int payload[0];
66};
67
68int CRTX_DLL_FCT(append)(CRTX_DLL_TYPE **head, CRTX_DLL_TYPE *item);
69CRTX_DLL_TYPE * CRTX_DLL_FCT(append_new)(CRTX_DLL_TYPE **head, void *data);
70
71int CRTX_DLL_FCT(unlink)(CRTX_DLL_TYPE **head, CRTX_DLL_TYPE *item);
72CRTX_DLL_TYPE *CRTX_DLL_FCT(unlink_data)(CRTX_DLL_TYPE **head, void *data);
73int CRTX_DLL_FCT(unlink_data2)(CRTX_DLL_TYPE **head, void *data);
74
75int CRTX_DLL_FCT(insert)(CRTX_DLL_TYPE **head, CRTX_DLL_TYPE *item, CRTX_DLL_TYPE *before);
76CRTX_DLL_TYPE * CRTX_DLL_FCT(insert_new)(CRTX_DLL_TYPE **head, void *data, CRTX_DLL_TYPE *before);
77
78// #undef CRTX_DLL_PREFIX
79#endif
Definition dict.h:61
an event that is emitted by a listener crtx_listener_base
Definition core.h:59
structure that represents a graph of tasks (crtx_task) that will be traversed with every crtx_event
Definition core.h:115
Definition core.h:265
a list of crtx_handler_category_entry for a certain event type
Definition core.h:272
Definition inotify.h:15
Definition dict.h:83