blob: 035a4f53c9b1bc6b0e818c13c80068516e883d67 [file] [log] [blame]
Kristian Høgsberg1e4b86a2008-11-23 23:41:08 -05001#ifndef WAYLAND_UTIL_H
2#define WAYLAND_UTIL_H
3
4/* GCC visibility */
5#if defined(__GNUC__) && __GNUC__ >= 4
6#define WL_EXPORT __attribute__ ((visibility("default")))
7#else
8#define WL_EXPORT
9#endif
10
11#define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0])
12
13#define container_of(ptr, type, member) ({ \
14 const typeof( ((type *)0)->member ) *__mptr = (ptr); \
15 (type *)( (char *)__mptr - offsetof(type,member) );})
16
17struct wl_hash {
18 struct wl_object **objects;
19 uint32_t count, alloc, id;
20};
21
22int wl_hash_insert(struct wl_hash *hash, struct wl_object *object);
23struct wl_object *wl_hash_lookup(struct wl_hash *hash, uint32_t id);
24void wl_hash_delete(struct wl_hash *hash, struct wl_object *object);
25
26struct wl_list {
27 struct wl_list *prev;
28 struct wl_list *next;
29};
30
31void wl_list_init(struct wl_list *list);
32void wl_list_insert(struct wl_list *list, struct wl_list *elm);
33void wl_list_remove(struct wl_list *elm);
34int wl_list_length(struct wl_list *list);
35
36
37#endif