Merge tag 'trace-printf-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace...
[drm/drm-misc.git] / drivers / md / dm-vdo / int-map.h
blob1858ad7998877db1fe325620199beb44f5efe77e
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3 * Copyright 2023 Red Hat
4 */
6 #ifndef VDO_INT_MAP_H
7 #define VDO_INT_MAP_H
9 #include <linux/compiler.h>
10 #include <linux/types.h>
12 /**
13 * DOC: int_map
15 * An int_map associates pointers (void *) with integer keys (u64). NULL pointer values are
16 * not supported.
18 * The map is implemented as hash table, which should provide constant-time insert, query, and
19 * remove operations, although the insert may occasionally grow the table, which is linear in the
20 * number of entries in the map. The table will grow as needed to hold new entries, but will not
21 * shrink as entries are removed.
24 struct int_map;
26 int __must_check vdo_int_map_create(size_t initial_capacity, struct int_map **map_ptr);
28 void vdo_int_map_free(struct int_map *map);
30 size_t vdo_int_map_size(const struct int_map *map);
32 void *vdo_int_map_get(struct int_map *map, u64 key);
34 int __must_check vdo_int_map_put(struct int_map *map, u64 key, void *new_value,
35 bool update, void **old_value_ptr);
37 void *vdo_int_map_remove(struct int_map *map, u64 key);
39 #endif /* VDO_INT_MAP_H */