Kristian Høgsberg | 1e4b86a | 2008-11-23 23:41:08 -0500 | [diff] [blame^] | 1 | #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 | |
| 17 | struct wl_hash { |
| 18 | struct wl_object **objects; |
| 19 | uint32_t count, alloc, id; |
| 20 | }; |
| 21 | |
| 22 | int wl_hash_insert(struct wl_hash *hash, struct wl_object *object); |
| 23 | struct wl_object *wl_hash_lookup(struct wl_hash *hash, uint32_t id); |
| 24 | void wl_hash_delete(struct wl_hash *hash, struct wl_object *object); |
| 25 | |
| 26 | struct wl_list { |
| 27 | struct wl_list *prev; |
| 28 | struct wl_list *next; |
| 29 | }; |
| 30 | |
| 31 | void wl_list_init(struct wl_list *list); |
| 32 | void wl_list_insert(struct wl_list *list, struct wl_list *elm); |
| 33 | void wl_list_remove(struct wl_list *elm); |
| 34 | int wl_list_length(struct wl_list *list); |
| 35 | |
| 36 | |
| 37 | #endif |