aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKristian Høgsberg2009-11-17 10:14:54 -0600
committerKristian Høgsberg2009-11-17 10:15:06 -0600
commit4f57abfe66091281c9f59c14e6ea27b524b55d5b (patch)
treef00d1022cf208b381b93aa5c96858164e6a3f602 /libdrm_lists.h
parent9dd3613073aa2491cef440725fdfa0cf1e8f1a42 (diff)
downloadexternal-libdrm-4f57abfe66091281c9f59c14e6ea27b524b55d5b.tar.gz
external-libdrm-4f57abfe66091281c9f59c14e6ea27b524b55d5b.tar.xz
external-libdrm-4f57abfe66091281c9f59c14e6ea27b524b55d5b.zip
Move libdrm/ up one level
Diffstat (limited to 'libdrm_lists.h')
-rw-r--r--libdrm_lists.h89
1 files changed, 89 insertions, 0 deletions
diff --git a/libdrm_lists.h b/libdrm_lists.h
new file mode 100644
index 00000000..6410f573
--- /dev/null
+++ b/libdrm_lists.h
@@ -0,0 +1,89 @@
1/**************************************************************************
2 *
3 * Copyright 2006 Tungsten Graphics, Inc., Bismarck, ND. USA.
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
18 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20 * USE OR OTHER DEALINGS IN THE SOFTWARE.
21 *
22 * The above copyright notice and this permission notice (including the
23 * next paragraph) shall be included in all copies or substantial portions
24 * of the Software.
25 */
26
27/*
28 * List macros heavily inspired by the Linux kernel
29 * list handling. No list looping yet.
30 */
31
32#include <stddef.h>
33
34typedef struct _drmMMListHead
35{
36 struct _drmMMListHead *prev;
37 struct _drmMMListHead *next;
38} drmMMListHead;
39
40#define DRMINITLISTHEAD(__item) \
41 do{ \
42 (__item)->prev = (__item); \
43 (__item)->next = (__item); \
44 } while (0)
45
46#define DRMLISTADD(__item, __list) \
47 do { \
48 (__item)->prev = (__list); \
49 (__item)->next = (__list)->next; \
50 (__list)->next->prev = (__item); \
51 (__list)->next = (__item); \
52 } while (0)
53
54#define DRMLISTADDTAIL(__item, __list) \
55 do { \
56 (__item)->next = (__list); \
57 (__item)->prev = (__list)->prev; \
58 (__list)->prev->next = (__item); \
59 (__list)->prev = (__item); \
60 } while(0)
61
62#define DRMLISTDEL(__item) \
63 do { \
64 (__item)->prev->next = (__item)->next; \
65 (__item)->next->prev = (__item)->prev; \
66 } while(0)
67
68#define DRMLISTDELINIT(__item) \
69 do { \
70 (__item)->prev->next = (__item)->next; \
71 (__item)->next->prev = (__item)->prev; \
72 (__item)->next = (__item); \
73 (__item)->prev = (__item); \
74 } while(0)
75
76#define DRMLISTENTRY(__type, __item, __field) \
77 ((__type *)(((char *) (__item)) - offsetof(__type, __field)))
78
79#define DRMLISTEMPTY(__item) ((__item)->next == (__item))
80
81#define DRMLISTFOREACHSAFE(__item, __temp, __list) \
82 for ((__item) = (__list)->next, (__temp) = (__item)->next; \
83 (__item) != (__list); \
84 (__item) = (__temp), (__temp) = (__item)->next)
85
86#define DRMLISTFOREACHSAFEREVERSE(__item, __temp, __list) \
87 for ((__item) = (__list)->prev, (__temp) = (__item)->prev; \
88 (__item) != (__list); \
89 (__item) = (__temp), (__temp) = (__item)->prev)