Changeset View
Changeset View
Standalone View
Standalone View
sys/sys/pctrie.h
Show All 28 Lines | |||||
* | * | ||||
* $FreeBSD$ | * $FreeBSD$ | ||||
*/ | */ | ||||
#ifndef _SYS_PCTRIE_H_ | #ifndef _SYS_PCTRIE_H_ | ||||
#define _SYS_PCTRIE_H_ | #define _SYS_PCTRIE_H_ | ||||
#include <sys/_pctrie.h> | #include <sys/_pctrie.h> | ||||
#include <sys/_smr.h> | |||||
#ifdef _KERNEL | #ifdef _KERNEL | ||||
#define PCTRIE_DEFINE_SMR(name, type, field, allocfn, freefn, smr) \ | |||||
PCTRIE_DEFINE(name, type, field, allocfn, freefn) \ | |||||
\ | |||||
static __inline struct type * \ | |||||
name##_PCTRIE_LOOKUP_UNLOCKED(struct pctrie *ptree, uint64_t key) \ | |||||
{ \ | |||||
\ | |||||
return name##_PCTRIE_VAL2PTR(pctrie_lookup_unlocked(ptree, \ | |||||
key, (smr))); \ | |||||
} \ | |||||
#define PCTRIE_DEFINE(name, type, field, allocfn, freefn) \ | #define PCTRIE_DEFINE(name, type, field, allocfn, freefn) \ | ||||
\ | \ | ||||
CTASSERT(sizeof(((struct type *)0)->field) == sizeof(uint64_t)); \ | CTASSERT(sizeof(((struct type *)0)->field) == sizeof(uint64_t)); \ | ||||
/* \ | /* \ | ||||
* XXX This assert protects flag bits, it does not enforce natural \ | * XXX This assert protects flag bits, it does not enforce natural \ | ||||
* alignment. 32bit architectures do not naturally align 64bit fields. \ | * alignment. 32bit architectures do not naturally align 64bit fields. \ | ||||
*/ \ | */ \ | ||||
CTASSERT((__offsetof(struct type, field) & (sizeof(uint32_t) - 1)) == 0); \ | CTASSERT((__offsetof(struct type, field) & (sizeof(uint32_t) - 1)) == 0); \ | ||||
▲ Show 20 Lines • Show All 61 Lines • ▼ Show 20 Lines | |||||
typedef void *(*pctrie_alloc_t)(struct pctrie *ptree); | typedef void *(*pctrie_alloc_t)(struct pctrie *ptree); | ||||
typedef void (*pctrie_free_t)(struct pctrie *ptree, void *node); | typedef void (*pctrie_free_t)(struct pctrie *ptree, void *node); | ||||
int pctrie_insert(struct pctrie *ptree, uint64_t *val, | int pctrie_insert(struct pctrie *ptree, uint64_t *val, | ||||
pctrie_alloc_t allocfn); | pctrie_alloc_t allocfn); | ||||
uint64_t *pctrie_lookup(struct pctrie *ptree, uint64_t key); | uint64_t *pctrie_lookup(struct pctrie *ptree, uint64_t key); | ||||
uint64_t *pctrie_lookup_ge(struct pctrie *ptree, uint64_t key); | uint64_t *pctrie_lookup_ge(struct pctrie *ptree, uint64_t key); | ||||
uint64_t *pctrie_lookup_le(struct pctrie *ptree, uint64_t key); | uint64_t *pctrie_lookup_le(struct pctrie *ptree, uint64_t key); | ||||
uint64_t *pctrie_lookup_unlocked(struct pctrie *ptree, uint64_t key, | |||||
smr_t smr); | |||||
void pctrie_reclaim_allnodes(struct pctrie *ptree, | void pctrie_reclaim_allnodes(struct pctrie *ptree, | ||||
pctrie_free_t freefn); | pctrie_free_t freefn); | ||||
void pctrie_remove(struct pctrie *ptree, uint64_t key, | void pctrie_remove(struct pctrie *ptree, uint64_t key, | ||||
pctrie_free_t freefn); | pctrie_free_t freefn); | ||||
size_t pctrie_node_size(void); | size_t pctrie_node_size(void); | ||||
int pctrie_zone_init(void *mem, int size, int flags); | int pctrie_zone_init(void *mem, int size, int flags); | ||||
static __inline void | static __inline void | ||||
Show All 28 Lines |