From: Darrick J. Wong <darrick.wong@xxxxxxxxxx> Move this header to libfrog since the code is there already. Signed-off-by: Darrick J. Wong <darrick.wong@xxxxxxxxxx> --- include/Makefile | 1 - include/libxfs.h | 2 +- include/radix-tree.h | 63 -------------------------------------------------- libfrog/Makefile | 1 + libfrog/radix-tree.h | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++ libxfs/libxfs_priv.h | 2 +- 6 files changed, 66 insertions(+), 66 deletions(-) delete mode 100644 include/radix-tree.h create mode 100644 libfrog/radix-tree.h diff --git a/include/Makefile b/include/Makefile index 7b922420..2a00dea9 100644 --- a/include/Makefile +++ b/include/Makefile @@ -16,7 +16,6 @@ LIBHFILES = libxfs.h \ kmem.h \ list.h \ parent.h \ - radix-tree.h \ xfs_btree_trace.h \ xfs_inode.h \ xfs_log_recover.h \ diff --git a/include/libxfs.h b/include/libxfs.h index dd5fe542..663063bc 100644 --- a/include/libxfs.h +++ b/include/libxfs.h @@ -16,7 +16,7 @@ #include "cache.h" #include "bitops.h" #include "kmem.h" -#include "radix-tree.h" +#include "libfrog/radix-tree.h" #include "atomic.h" #include "xfs_types.h" diff --git a/include/radix-tree.h b/include/radix-tree.h deleted file mode 100644 index 81ee010c..00000000 --- a/include/radix-tree.h +++ /dev/null @@ -1,63 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* - * Copyright (C) 2001 Momchil Velikov - * Portions Copyright (C) 2001 Christoph Hellwig - */ -#ifndef __XFS_SUPPORT_RADIX_TREE_H__ -#define __XFS_SUPPORT_RADIX_TREE_H__ - -#define RADIX_TREE_TAGS - -struct radix_tree_root { - unsigned int height; - struct radix_tree_node *rnode; -}; - -#define RADIX_TREE_INIT(mask) { \ - .height = 0, \ - .rnode = NULL, \ -} - -#define RADIX_TREE(name, mask) \ - struct radix_tree_root name = RADIX_TREE_INIT(mask) - -#define INIT_RADIX_TREE(root, mask) \ -do { \ - (root)->height = 0; \ - (root)->rnode = NULL; \ -} while (0) - -#ifdef RADIX_TREE_TAGS -#define RADIX_TREE_MAX_TAGS 2 -#endif - -int radix_tree_insert(struct radix_tree_root *, unsigned long, void *); -void *radix_tree_lookup(struct radix_tree_root *, unsigned long); -void **radix_tree_lookup_slot(struct radix_tree_root *, unsigned long); -void *radix_tree_lookup_first(struct radix_tree_root *, unsigned long *); -void *radix_tree_delete(struct radix_tree_root *, unsigned long); -unsigned int -radix_tree_gang_lookup(struct radix_tree_root *root, void **results, - unsigned long first_index, unsigned int max_items); -unsigned int -radix_tree_gang_lookup_ex(struct radix_tree_root *root, void **results, - unsigned long first_index, unsigned long last_index, - unsigned int max_items); - -void radix_tree_init(void); - -#ifdef RADIX_TREE_TAGS -void *radix_tree_tag_set(struct radix_tree_root *root, - unsigned long index, unsigned int tag); -void *radix_tree_tag_clear(struct radix_tree_root *root, - unsigned long index, unsigned int tag); -int radix_tree_tag_get(struct radix_tree_root *root, - unsigned long index, unsigned int tag); -unsigned int -radix_tree_gang_lookup_tag(struct radix_tree_root *root, void **results, - unsigned long first_index, unsigned int max_items, - unsigned int tag); -int radix_tree_tagged(struct radix_tree_root *root, unsigned int tag); -#endif - -#endif /* __XFS_SUPPORT_RADIX_TREE_H__ */ diff --git a/libfrog/Makefile b/libfrog/Makefile index 25ea248e..482893ef 100644 --- a/libfrog/Makefile +++ b/libfrog/Makefile @@ -36,6 +36,7 @@ crc32defs.h \ crc32table.h \ fsgeom.h \ ptvar.h \ +radix-tree.h \ topology.h LSRCFILES += gen_crc32table.c diff --git a/libfrog/radix-tree.h b/libfrog/radix-tree.h new file mode 100644 index 00000000..f08156b9 --- /dev/null +++ b/libfrog/radix-tree.h @@ -0,0 +1,63 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2001 Momchil Velikov + * Portions Copyright (C) 2001 Christoph Hellwig + */ +#ifndef __LIBFROG_RADIX_TREE_H__ +#define __LIBFROG_RADIX_TREE_H__ + +#define RADIX_TREE_TAGS + +struct radix_tree_root { + unsigned int height; + struct radix_tree_node *rnode; +}; + +#define RADIX_TREE_INIT(mask) { \ + .height = 0, \ + .rnode = NULL, \ +} + +#define RADIX_TREE(name, mask) \ + struct radix_tree_root name = RADIX_TREE_INIT(mask) + +#define INIT_RADIX_TREE(root, mask) \ +do { \ + (root)->height = 0; \ + (root)->rnode = NULL; \ +} while (0) + +#ifdef RADIX_TREE_TAGS +#define RADIX_TREE_MAX_TAGS 2 +#endif + +int radix_tree_insert(struct radix_tree_root *, unsigned long, void *); +void *radix_tree_lookup(struct radix_tree_root *, unsigned long); +void **radix_tree_lookup_slot(struct radix_tree_root *, unsigned long); +void *radix_tree_lookup_first(struct radix_tree_root *, unsigned long *); +void *radix_tree_delete(struct radix_tree_root *, unsigned long); +unsigned int +radix_tree_gang_lookup(struct radix_tree_root *root, void **results, + unsigned long first_index, unsigned int max_items); +unsigned int +radix_tree_gang_lookup_ex(struct radix_tree_root *root, void **results, + unsigned long first_index, unsigned long last_index, + unsigned int max_items); + +void radix_tree_init(void); + +#ifdef RADIX_TREE_TAGS +void *radix_tree_tag_set(struct radix_tree_root *root, + unsigned long index, unsigned int tag); +void *radix_tree_tag_clear(struct radix_tree_root *root, + unsigned long index, unsigned int tag); +int radix_tree_tag_get(struct radix_tree_root *root, + unsigned long index, unsigned int tag); +unsigned int +radix_tree_gang_lookup_tag(struct radix_tree_root *root, void **results, + unsigned long first_index, unsigned int max_items, + unsigned int tag); +int radix_tree_tagged(struct radix_tree_root *root, unsigned int tag); +#endif + +#endif /* __LIBFROG_RADIX_TREE_H__ */ diff --git a/libxfs/libxfs_priv.h b/libxfs/libxfs_priv.h index 8b3de170..ec4d7d3b 100644 --- a/libxfs/libxfs_priv.h +++ b/libxfs/libxfs_priv.h @@ -46,7 +46,7 @@ #include "cache.h" #include "bitops.h" #include "kmem.h" -#include "radix-tree.h" +#include "libfrog/radix-tree.h" #include "atomic.h" #include "xfs_types.h"