Go to the documentation of this file.
15 #include <linux/types.h>
16 #include <linux/bitops.h>
20 #if BITS_PER_LONG == 32
22 # define IDR_FULL 0xfffffffful
26 # define TOP_LEVEL_FULL (IDR_FULL >> 30)
27 #elif BITS_PER_LONG == 64
29 # define IDR_FULL 0xfffffffffffffffful
33 # define TOP_LEVEL_FULL (IDR_FULL >> 62)
35 # error "BITS_PER_LONG is not 32 or 64"
38 #define IDR_SIZE (1 << IDR_BITS)
39 #define IDR_MASK ((1 << IDR_BITS)-1)
41 #define MAX_IDR_SHIFT (sizeof(int)*8 - 1)
42 #define MAX_IDR_BIT (1U << MAX_IDR_SHIFT)
43 #define MAX_IDR_MASK (MAX_IDR_BIT - 1)
46 #define MAX_IDR_LEVEL ((MAX_IDR_SHIFT + IDR_BITS - 1) / IDR_BITS)
49 #define MAX_IDR_FREE (MAX_IDR_LEVEL * 2)
67 #define IDR_INIT(name) \
73 .lock = __SPIN_LOCK_UNLOCKED(name.lock), \
75 #define DEFINE_IDR(name) struct idr name = IDR_INIT(name)
78 #define IDR_NEED_TO_GROW -2
79 #define IDR_NOMORE_SPACE -3
81 #define _idr_rc_to_errno(rc) ((rc) == -1 ? -EAGAIN : -ENOSPC)
109 int (*
fn)(
int id,
void *
p,
void *
data),
void *data);
125 #define IDA_CHUNK_SIZE 128
126 #define IDA_BITMAP_LONGS (IDA_CHUNK_SIZE / sizeof(long) - 1)
127 #define IDA_BITMAP_BITS (IDA_BITMAP_LONGS * sizeof(long) * 8)
139 #define IDA_INIT(name) { .idr = IDR_INIT(name), .free_bitmap = NULL, }
140 #define DEFINE_IDA(name) struct ida name = IDA_INIT(name)