]>
Commit | Line | Data |
---|---|---|
959ef981 | 1 | // SPDX-License-Identifier: GPL-2.0+ |
9c9990ba DW |
2 | /* |
3 | * Copyright (C) 2016 Oracle. All Rights Reserved. | |
9c9990ba | 4 | * Author: Darrick J. Wong <darrick.wong@oracle.com> |
9c9990ba DW |
5 | */ |
6 | #ifndef SLAB_H_ | |
7 | #define SLAB_H_ | |
8 | ||
9 | struct xfs_slab; | |
10 | struct xfs_slab_cursor; | |
11 | ||
12 | extern int init_slab(struct xfs_slab **, size_t); | |
13 | extern void free_slab(struct xfs_slab **); | |
14 | ||
15 | extern int slab_add(struct xfs_slab *, void *); | |
16 | extern void qsort_slab(struct xfs_slab *, int (*)(const void *, const void *)); | |
17 | extern size_t slab_count(struct xfs_slab *); | |
18 | ||
19 | extern int init_slab_cursor(struct xfs_slab *, | |
20 | int (*)(const void *, const void *), struct xfs_slab_cursor **); | |
21 | extern void free_slab_cursor(struct xfs_slab_cursor **); | |
22 | ||
23 | extern void *peek_slab_cursor(struct xfs_slab_cursor *); | |
24 | extern void advance_slab_cursor(struct xfs_slab_cursor *); | |
25 | extern void *pop_slab_cursor(struct xfs_slab_cursor *); | |
26 | ||
27 | struct xfs_bag; | |
28 | ||
29 | extern int init_bag(struct xfs_bag **); | |
30 | extern void free_bag(struct xfs_bag **); | |
31 | extern int bag_add(struct xfs_bag *, void *); | |
32 | extern int bag_remove(struct xfs_bag *, size_t); | |
33 | extern size_t bag_count(struct xfs_bag *); | |
34 | extern void *bag_item(struct xfs_bag *, size_t); | |
35 | ||
36 | #define foreach_bag_ptr(bag, idx, ptr) \ | |
37 | for ((idx) = 0, (ptr) = bag_item((bag), (idx)); \ | |
38 | (idx) < bag_count(bag); \ | |
39 | (idx)++, (ptr) = bag_item((bag), (idx))) | |
40 | ||
41 | #define foreach_bag_ptr_reverse(bag, idx, ptr) \ | |
42 | for ((idx) = bag_count(bag) - 1, (ptr) = bag_item((bag), (idx)); \ | |
ff14f594 | 43 | (ptr) != NULL; \ |
9c9990ba DW |
44 | (idx)--, (ptr) = bag_item((bag), (idx))) |
45 | ||
46 | #endif /* SLAB_H_ */ |