Changeset View
Changeset View
Standalone View
Standalone View
head/share/man/man9/unr.9
Show All 18 Lines | |||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||||
.\" SUCH DAMAGE. | .\" SUCH DAMAGE. | ||||
.\" | .\" | ||||
.\" $FreeBSD$ | .\" $FreeBSD$ | ||||
.\" | .\" | ||||
.Dd July 5, 2010 | .Dd October 4, 2017 | ||||
.Dt UNR 9 | .Dt UNR 9 | ||||
.Os | .Os | ||||
.Sh NAME | .Sh NAME | ||||
.Nm new_unrhdr , | .Nm new_unrhdr , | ||||
.Nm clear_unrhdr , | |||||
.Nm delete_unrhdr , | .Nm delete_unrhdr , | ||||
.Nm alloc_unr , | .Nm alloc_unr , | ||||
.Nm alloc_unr_specific , | .Nm alloc_unr_specific , | ||||
.Nm free_unr | .Nm free_unr | ||||
.Nd "kernel unit number allocator" | .Nd "kernel unit number allocator" | ||||
.Sh SYNOPSIS | .Sh SYNOPSIS | ||||
.In sys/systm.h | .In sys/systm.h | ||||
.Ft "struct unrhdr *" | .Ft "struct unrhdr *" | ||||
.Fn new_unrhdr "int low" "int high" "struct mtx *mutex" | .Fn new_unrhdr "int low" "int high" "struct mtx *mutex" | ||||
.Ft void | .Ft void | ||||
.Fn clear_unrhdr "struct unrhdr *uh" | |||||
.Ft void | |||||
.Fn delete_unrhdr "struct unrhdr *uh" | .Fn delete_unrhdr "struct unrhdr *uh" | ||||
.Ft int | .Ft int | ||||
.Fn alloc_unr "struct unrhdr *uh" | .Fn alloc_unr "struct unrhdr *uh" | ||||
.Ft int | .Ft int | ||||
.Fn alloc_unrl "struct unrhdr *uh" | .Fn alloc_unrl "struct unrhdr *uh" | ||||
.Ft int | .Ft int | ||||
.Fn alloc_unr_specific "struct unrhdr *uh" "u_int item" | .Fn alloc_unr_specific "struct unrhdr *uh" "u_int item" | ||||
.Ft void | .Ft void | ||||
Show All 15 Lines | |||||
.Dv INT_MAX | .Dv INT_MAX | ||||
can be used. | can be used. | ||||
If | If | ||||
.Fa mutex | .Fa mutex | ||||
is not | is not | ||||
.Dv NULL , | .Dv NULL , | ||||
it is used for locking when allocating and freeing units. | it is used for locking when allocating and freeing units. | ||||
Otherwise, internal mutex is used. | Otherwise, internal mutex is used. | ||||
.It Fn clear_unrhdr uh | |||||
Clear all units from the specified unit number allocator entity. | |||||
This function resets the entity as if it were just initialized with | |||||
.Fn new_unrhdr . | |||||
.It Fn delete_unrhdr uh | .It Fn delete_unrhdr uh | ||||
Destroy specified unit number allocator entity. | Delete specified unit number allocator entity. | ||||
This function frees the memory associated with the entity, it does not free | |||||
any units. | |||||
To free all units use | |||||
.Fn clear_unrhdr . | |||||
.It Fn alloc_unr uh | .It Fn alloc_unr uh | ||||
Return a new unit number. | Return a new unit number. | ||||
The lowest free number is always allocated. | The lowest free number is always allocated. | ||||
This function does not allocate memory and never sleeps, however it may | This function does not allocate memory and never sleeps, however it may | ||||
block on a mutex. | block on a mutex. | ||||
If no free unit numbers are left, | If no free unit numbers are left, | ||||
.Li \-1 | .Li \-1 | ||||
is returned. | is returned. | ||||
Show All 28 Lines |