FreeBSD kernel kern code
subr_unit.c File Reference
#include <sys/types.h>
#include <sys/queue.h>
#include <sys/bitstring.h>
#include <sys/param.h>
#include <sys/malloc.h>
#include <sys/kernel.h>
#include <sys/systm.h>
#include <sys/limits.h>
#include <sys/lock.h>
#include <sys/mutex.h>
Include dependency graph for subr_unit.c:

Go to the source code of this file.

Data Structures

struct  unr
 
struct  unrb
 
struct  unrhdr
 

Macros

#define Malloc(foo)   malloc(foo, M_UNIT, M_WAITOK | M_ZERO)
 
#define Free(foo)   free(foo, M_UNIT)
 
#define NBITS   ((int)sizeof(((struct unrb *)NULL)->map) * 8)
 

Functions

static MALLOC_DEFINE (M_UNIT,"Unitno","Unit number allocation")
 
 MTX_SYSINIT (unit,&unitmtx,"unit# allocation", MTX_DEF)
 
 CTASSERT (sizeof(struct unr)==sizeof(struct unrb))
 
static __inline void check_unrhdr (struct unrhdr *uh, int line)
 
static __inline void * new_unr (struct unrhdr *uh, void **p1, void **p2)
 
static __inline void delete_unr (struct unrhdr *uh, void *ptr)
 
void clean_unrhdrl (struct unrhdr *uh)
 
void clean_unrhdr (struct unrhdr *uh)
 
struct unrhdrnew_unrhdr (int low, int high, struct mtx *mutex)
 
void delete_unrhdr (struct unrhdr *uh)
 
static __inline int is_bitmap (struct unrhdr *uh, struct unr *up)
 
static int optimize_unr (struct unrhdr *uh)
 
static void collapse_unr (struct unrhdr *uh, struct unr *up)
 
int alloc_unrl (struct unrhdr *uh)
 
int alloc_unr (struct unrhdr *uh)
 
static int alloc_unr_specificl (struct unrhdr *uh, u_int item, void **p1, void **p2)
 
int alloc_unr_specific (struct unrhdr *uh, u_int item)
 
static void free_unrl (struct unrhdr *uh, u_int item, void **p1, void **p2)
 
void free_unr (struct unrhdr *uh, u_int item)
 

Variables

static struct mtx unitmtx
 

Macro Definition Documentation

#define Free (   foo)    free(foo, M_UNIT)

Definition at line 93 of file subr_unit.c.

Referenced by alloc_unr_specific(), clean_unrhdrl(), delete_unrhdr(), and free_unr().

#define Malloc (   foo)    malloc(foo, M_UNIT, M_WAITOK | M_ZERO)

Definition at line 92 of file subr_unit.c.

Referenced by alloc_unr_specific(), free_unr(), and new_unrhdr().

#define NBITS   ((int)sizeof(((struct unrb *)NULL)->map) * 8)

Definition at line 188 of file subr_unit.c.

Referenced by optimize_unr().

Function Documentation

int alloc_unr ( struct unrhdr uh)

Definition at line 620 of file subr_unit.c.

References alloc_unrl(), and clean_unrhdrl().

Referenced by aio_newproc(), cpuset_create(), mqfs_fileno_alloc(), pipe_stat(), pts_alloc(), and shm_alloc().

Here is the call graph for this function:

Here is the caller graph for this function:

int alloc_unr_specific ( struct unrhdr uh,
u_int  item 
)

Definition at line 735 of file subr_unit.c.

References alloc_unr_specificl(), Free, and Malloc.

Here is the call graph for this function:

static int alloc_unr_specificl ( struct unrhdr uh,
u_int  item,
void **  p1,
void **  p2 
)
static

Definition at line 632 of file subr_unit.c.

References unrb::busy, check_unrhdr(), collapse_unr(), is_bitmap(), unrb::map, and new_unr().

Referenced by alloc_unr_specific().

Here is the call graph for this function:

Here is the caller graph for this function:

int alloc_unrl ( struct unrhdr uh)

Definition at line 570 of file subr_unit.c.

References unrb::busy, check_unrhdr(), collapse_unr(), and unrb::map.

Referenced by alloc_unr().

Here is the call graph for this function:

Here is the caller graph for this function:

static __inline void check_unrhdr ( struct unrhdr uh,
int  line 
)
static

Definition at line 253 of file subr_unit.c.

Referenced by alloc_unr_specificl(), alloc_unrl(), delete_unrhdr(), free_unrl(), and new_unrhdr().

Here is the caller graph for this function:

void clean_unrhdr ( struct unrhdr uh)

Definition at line 310 of file subr_unit.c.

References clean_unrhdrl().

Here is the call graph for this function:

void clean_unrhdrl ( struct unrhdr uh)

Definition at line 295 of file subr_unit.c.

References Free.

Referenced by alloc_unr(), clean_unrhdr(), free_unr(), make_dev_alias_v(), and make_dev_credv().

Here is the caller graph for this function:

static void collapse_unr ( struct unrhdr uh,
struct unr up 
)
static

Definition at line 498 of file subr_unit.c.

References unrb::busy, delete_unr(), is_bitmap(), and optimize_unr().

Referenced by alloc_unr_specificl(), alloc_unrl(), and free_unrl().

Here is the call graph for this function:

Here is the caller graph for this function:

CTASSERT ( sizeof(struct unr = =sizeof(struct unrb))
static __inline void delete_unr ( struct unrhdr uh,
void *  ptr 
)
static

Definition at line 285 of file subr_unit.c.

Referenced by collapse_unr(), and optimize_unr().

Here is the caller graph for this function:

void delete_unrhdr ( struct unrhdr uh)

Definition at line 347 of file subr_unit.c.

References check_unrhdr(), and Free.

Referenced by aio_unload(), and mqfs_fileno_uninit().

Here is the call graph for this function:

Here is the caller graph for this function:

void free_unr ( struct unrhdr uh,
u_int  item 
)

Definition at line 872 of file subr_unit.c.

References clean_unrhdrl(), Free, free_unrl(), and Malloc.

Referenced by aio_daemon(), aio_newproc(), cpuset_create(), cpuset_rel(), mqfs_fileno_free(), pipeclose(), ptsdrv_free(), shm_drop(), and tid_free().

Here is the call graph for this function:

Here is the caller graph for this function:

static void free_unrl ( struct unrhdr uh,
u_int  item,
void **  p1,
void **  p2 
)
static

Definition at line 763 of file subr_unit.c.

References unrb::busy, check_unrhdr(), collapse_unr(), is_bitmap(), unrb::map, and new_unr().

Referenced by free_unr().

Here is the call graph for this function:

Here is the caller graph for this function:

static __inline int is_bitmap ( struct unrhdr uh,
struct unr up 
)
static

Definition at line 359 of file subr_unit.c.

Referenced by alloc_unr_specificl(), collapse_unr(), free_unrl(), and optimize_unr().

Here is the caller graph for this function:

static MALLOC_DEFINE ( M_UNIT  ,
"Unitno"  ,
"Unit number allocation"   
)
static
MTX_SYSINIT ( unit  ,
unitmtx,
"unit# allocation"  ,
MTX_DEF   
)
static __inline void* new_unr ( struct unrhdr uh,
void **  p1,
void **  p2 
)
static

Definition at line 267 of file subr_unit.c.

Referenced by alloc_unr_specificl(), free_unrl(), and pipe_stat().

Here is the caller graph for this function:

struct unrhdr* new_unrhdr ( int  low,
int  high,
struct mtx *  mutex 
)

Definition at line 325 of file subr_unit.c.

References check_unrhdr(), Malloc, and unitmtx.

Referenced by aio_onceonly(), cpuset_thread0(), mqfs_fileno_init(), pipeinit(), pts_init(), shm_init(), and threadinit().

Here is the call graph for this function:

Here is the caller graph for this function:

static int optimize_unr ( struct unrhdr uh)
static

Definition at line 374 of file subr_unit.c.

References unrb::busy, delete_unr(), is_bitmap(), unrb::map, and NBITS.

Referenced by collapse_unr().

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

struct mtx unitmtx
static

Definition at line 95 of file subr_unit.c.

Referenced by new_unrhdr().