]>
Commit | Line | Data |
---|---|---|
9c9990ba DW |
1 | /* |
2 | * Copyright (C) 2016 Oracle. All Rights Reserved. | |
3 | * | |
4 | * Author: Darrick J. Wong <darrick.wong@oracle.com> | |
5 | * | |
6 | * This program is free software; you can redistribute it and/or | |
7 | * modify it under the terms of the GNU General Public License | |
8 | * as published by the Free Software Foundation; either version 2 | |
9 | * of the License, or (at your option) any later version. | |
10 | * | |
11 | * This program is distributed in the hope that it would be useful, | |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | * GNU General Public License for more details. | |
15 | * | |
16 | * You should have received a copy of the GNU General Public License | |
17 | * along with this program; if not, write the Free Software Foundation, | |
18 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. | |
19 | */ | |
20 | #ifndef SLAB_H_ | |
21 | #define SLAB_H_ | |
22 | ||
23 | struct xfs_slab; | |
24 | struct xfs_slab_cursor; | |
25 | ||
26 | extern int init_slab(struct xfs_slab **, size_t); | |
27 | extern void free_slab(struct xfs_slab **); | |
28 | ||
29 | extern int slab_add(struct xfs_slab *, void *); | |
30 | extern void qsort_slab(struct xfs_slab *, int (*)(const void *, const void *)); | |
31 | extern size_t slab_count(struct xfs_slab *); | |
32 | ||
33 | extern int init_slab_cursor(struct xfs_slab *, | |
34 | int (*)(const void *, const void *), struct xfs_slab_cursor **); | |
35 | extern void free_slab_cursor(struct xfs_slab_cursor **); | |
36 | ||
37 | extern void *peek_slab_cursor(struct xfs_slab_cursor *); | |
38 | extern void advance_slab_cursor(struct xfs_slab_cursor *); | |
39 | extern void *pop_slab_cursor(struct xfs_slab_cursor *); | |
40 | ||
41 | struct xfs_bag; | |
42 | ||
43 | extern int init_bag(struct xfs_bag **); | |
44 | extern void free_bag(struct xfs_bag **); | |
45 | extern int bag_add(struct xfs_bag *, void *); | |
46 | extern int bag_remove(struct xfs_bag *, size_t); | |
47 | extern size_t bag_count(struct xfs_bag *); | |
48 | extern void *bag_item(struct xfs_bag *, size_t); | |
49 | ||
50 | #define foreach_bag_ptr(bag, idx, ptr) \ | |
51 | for ((idx) = 0, (ptr) = bag_item((bag), (idx)); \ | |
52 | (idx) < bag_count(bag); \ | |
53 | (idx)++, (ptr) = bag_item((bag), (idx))) | |
54 | ||
55 | #define foreach_bag_ptr_reverse(bag, idx, ptr) \ | |
56 | for ((idx) = bag_count(bag) - 1, (ptr) = bag_item((bag), (idx)); \ | |
ff14f594 | 57 | (ptr) != NULL; \ |
9c9990ba DW |
58 | (idx)--, (ptr) = bag_item((bag), (idx))) |
59 | ||
60 | #endif /* SLAB_H_ */ |