/* SPDX-License-Identifier: GPL-2.0+ */#ifndef _LINUX_XARRAY_H#define _LINUX_XARRAY_H/* * eXtensible Arrays * Copyright (c) 2017 Microsoft Corporation * Author: Matthew Wilcox <willy@infradead.org> * * See Documentation/core-api/xarray.rst for how to use the XArray. */#include<linux/bug.h>#include<linux/compiler.h>#include<linux/gfp.h>#include<linux/kconfig.h>#include<linux/kernel.h>#include<linux/rcupdate.h>#include<linux/spinlock.h>#include<linux/types.h>/* * The bottom two bits of the entry determine how the XArray interprets * the contents: * * 00: Pointer entry * 10: Internal entry * x1: Value entry or tagged pointer * * Attempting to store internal entries in the XArray is a bug. * * Most internal entries are pointers to the next node in the tree. * The following internal entries have a special meaning: * * 0-62: Sibling entries * 256: Zero entry * 257: Retry entry * * Errors are also represented as internal entries, but use the negative * space (-4094 to -2). They're never stored in the slots array; only * returned by the normal API. */#define BITS_PER_XA_VALUE (BITS_PER_LONG - 1)/** * xa_mk_value() - Create an XArray entry from an integer. * @v: Value to store in XArray. * * Context: Any context. * Return: An entry suitable for storing in the XArray. */staticinlinevoid*xa_mk_value(unsignedlongv){WARN_ON((long)v<0);return(void*)((v<<1)|1);}/** * xa_to_value() - Get value stored in an XArray entry. * @entry: XArray entry. * * Context: Any context. * Return: The value stored in the XArray entry. */staticinlineunsignedlongxa_to_value(constvoid*entry){return(unsignedlong)entry>>1;}/** * xa_is_value() - Determine if an entry is a value. * @entry: XArray entry. * * Context: Any context. * Return: True if the entry is a value, false if it is a pointer. */staticinlineboolxa_is_value(constvoid*entry){re