1.\" 2.\" This file and its contents are supplied under the terms of the 3.\" Common Development and Distribution License ("CDDL"), version 1.0. 4.\" You may only use this file in accordance with the terms of version 5.\" 1.0 of the CDDL. 6.\" 7.\" A full copy of the text of the CDDL should have accompanied this 8.\" source. A copy of the CDDL is also available via the Internet at 9.\" http://www.illumos.org/license/CDDL. 10.\" 11.\" 12.\" Copyright 2022 Oxide Computer Company 13.\" 14.Dd April 12, 2022 15.Dt BITX64 9F 16.Os 17.Sh NAME 18.Nm bitx8 , 19.Nm bitx16 , 20.Nm bitx32 , 21.Nm bitx64 22.Nd extract bits from an integer 23.Sh SYNOPSIS 24.In sys/bitext.h 25.Ft uint8_t 26.Fo bitx8 27.Fa "uint8_t value" 28.Fa "uint_t high" 29.Fa "uint_t low" 30.Fc 31.Ft uint16_t 32.Fo bitx16 33.Fa "uint16_t value" 34.Fa "uint_t high" 35.Fa "uint_t low" 36.Fc 37.Ft uint32_t 38.Fo bitx32 39.Fa "uint32_t value" 40.Fa "uint_t high" 41.Fa "uint_t low" 42.Fc 43.Ft uint64_t 44.Fo bitx64 45.Fa "uint64_t value" 46.Fa "uint_t high" 47.Fa "uint_t low" 48.Fc 49.Sh INTERFACE LEVEL 50.Sy Volatile - 51This interface is still evolving in illumos. 52API and ABI stability is not guaranteed. 53.Sh PARAMETERS 54.Bl -tag -width Fa 55.It Fa value 56An integer to extract a value from. 57.It Fa high 58The high end, inclusive, of the bit range to extract from 59.Fa value . 60.It Fa low 61The low end, inclusive, of the bit range to extract from 62.Fa value . 63.El 64.Sh DESCRIPTION 65The 66.Fn bitx8 , 67.Fn bitx16 , 68.Fn bitx32 , 69and 70.Fn bitx64 71functions are used to extract a range of bits from on an 8, 16, 32, and 7264-bit value respectively. 73These functions are all implementations of a classical application of a 74bitwise-AND of a mask and a logical right shift. 75More specifically, the arguments 76.Fa high 77and 78.Fa low 79describe an inclusive range of bits 80.Po 81.Pf [ Fa low , 82.Fa high ] 83.Pc 84to extract from 85.Fa value . 86The extracted bits are all shifted right such that the resulting value 87starts at bit 0 88.Po that is, shifted over by 89.Fa low 90.Pc . 91.Pp 92Each of the variants here operates on a specifically sized integer. 93.Fa high 94and 95.Fa low 96must fit within the bit range that the integer implies. 97For example, the valid range for 98.Fa bitx32 99is from 0 to 31. 100.Fa high 101must not be less than 102.Fa low . 103.Sh CONTEXT 104These functions may be called in all contexts, 105.Sy user , 106.Sy kernel , 107and 108.Sy interrupt . 109.Sh RETURN VALUES 110Upon successful completion, the 111.Fn bitx8 , 112.Fn bitx16 , 113.Fn bitx32 , 114and 115.Fn bitx64 116functions all return the indicated portion of 117.Fa val . 118.Sh SEE ALSO 119.Xr bitdel64 9F , 120.Xr bitset64 9F 121