xarray.h (b59ffedae8f3707bf0079b4fd0cbf8190eed0c5e) | xarray.h (e705066cd87559831096f9638603f35d2fea635f) |
---|---|
1/*- 2 * Copyright (c) 2020 Mellanox Technologies, Ltd. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 26 unchanged lines hidden (view full) --- 35#include <sys/lock.h> 36#include <sys/mutex.h> 37 38#define XA_LIMIT(min, max) \ 39 ({ CTASSERT((min) == 0); (uint32_t)(max); }) 40 41#define XA_FLAGS_ALLOC (1U << 0) 42#define XA_FLAGS_LOCK_IRQ (1U << 1) | 1/*- 2 * Copyright (c) 2020 Mellanox Technologies, Ltd. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 26 unchanged lines hidden (view full) --- 35#include <sys/lock.h> 36#include <sys/mutex.h> 37 38#define XA_LIMIT(min, max) \ 39 ({ CTASSERT((min) == 0); (uint32_t)(max); }) 40 41#define XA_FLAGS_ALLOC (1U << 0) 42#define XA_FLAGS_LOCK_IRQ (1U << 1) |
43#define XA_FLAGS_ALLOC1 (1U << 2) |
|
43 44#define XA_ERROR(x) \ 45 ERR_PTR(x) 46 47#define xa_limit_32b XA_LIMIT(0, 0xFFFFFFFF) 48 49#define XA_ASSERT_LOCKED(xa) mtx_assert(&(xa)->mtx, MA_OWNED) 50#define xa_lock(xa) mtx_lock(&(xa)->mtx) 51#define xa_unlock(xa) mtx_unlock(&(xa)->mtx) 52 53struct xarray { 54 struct radix_tree_root root; 55 struct mtx mtx; /* internal mutex */ | 44 45#define XA_ERROR(x) \ 46 ERR_PTR(x) 47 48#define xa_limit_32b XA_LIMIT(0, 0xFFFFFFFF) 49 50#define XA_ASSERT_LOCKED(xa) mtx_assert(&(xa)->mtx, MA_OWNED) 51#define xa_lock(xa) mtx_lock(&(xa)->mtx) 52#define xa_unlock(xa) mtx_unlock(&(xa)->mtx) 53 54struct xarray { 55 struct radix_tree_root root; 56 struct mtx mtx; /* internal mutex */ |
57 uint32_t flags; /* see XA_FLAGS_XXX */ |
|
56}; 57 58/* 59 * Extensible arrays API implemented as a wrapper 60 * around the radix tree implementation. 61 */ 62void *xa_erase(struct xarray *, uint32_t); 63void *xa_load(struct xarray *, uint32_t); --- 60 unchanged lines hidden --- | 58}; 59 60/* 61 * Extensible arrays API implemented as a wrapper 62 * around the radix tree implementation. 63 */ 64void *xa_erase(struct xarray *, uint32_t); 65void *xa_load(struct xarray *, uint32_t); --- 60 unchanged lines hidden --- |