ARM: tizen_tm1_defconfig: Enable missing features related with CGROUPS
[profile/mobile/platform/kernel/linux-3.10-sc7730.git] / kernel / swap / ks_features / ks_map.h
1 #ifndef __KS_MAP__
2 #define __KS_MAP__
3
4 #include <linux/rbtree.h>
5
6 typedef void *(*key_func_t)(void *);
7 typedef int (*cmp_func_t)(void *, void *);
8 typedef int (*act_func_t)(void *, void *);
9
10 struct map {
11         struct rb_root root;
12         int size;
13         key_func_t key_f;
14         cmp_func_t cmp_f;
15 };
16
17 #define __MAP_INITIALIZER(_key_f, _cmp_f) \
18         { \
19                 .root = RB_ROOT, \
20                 .size = 0, \
21                 .key_f = _key_f, \
22                 .cmp_f = _cmp_f \
23         }
24
25 #define DEFINE_MAP(_name, _key_f, _cmp_f) \
26         struct map _name = __MAP_INITIALIZER(_key_f, _cmp_f)
27
28 void *search(struct map *map, void *key);
29 void *remove(struct map *map, void *key);
30 void *replace(struct map *map, void *data);
31 int insert(struct map *map, void *data);
32 int for_each_entry(struct map *map, act_func_t func, void *arg);
33 int for_each_entry_reverse(struct map *map, act_func_t act, void *arg);
34 void clear(struct map *map, act_func_t destructor, void *arg);
35
36 #endif /* __KS_MAP__ */