1*aaceae98SRobert Mustacchi.\" 2*aaceae98SRobert Mustacchi.\" This file and its contents are supplied under the terms of the 3*aaceae98SRobert Mustacchi.\" Common Development and Distribution License ("CDDL"), version 1.0. 4*aaceae98SRobert Mustacchi.\" You may only use this file in accordance with the terms of version 5*aaceae98SRobert Mustacchi.\" 1.0 of the CDDL. 6*aaceae98SRobert Mustacchi.\" 7*aaceae98SRobert Mustacchi.\" A full copy of the text of the CDDL should have accompanied this 8*aaceae98SRobert Mustacchi.\" source. A copy of the CDDL is also available via the Internet at 9*aaceae98SRobert Mustacchi.\" http://www.illumos.org/license/CDDL. 10*aaceae98SRobert Mustacchi.\" 11*aaceae98SRobert Mustacchi.\" 12*aaceae98SRobert Mustacchi.\" Copyright 2024 Oxide Computer Company 13*aaceae98SRobert Mustacchi.\" 14*aaceae98SRobert Mustacchi.Dd October 27, 2024 15*aaceae98SRobert Mustacchi.Dt STDC_LEADING_ZEROS 9F 16*aaceae98SRobert Mustacchi.Os 17*aaceae98SRobert Mustacchi.Sh NAME 18*aaceae98SRobert Mustacchi.Nm stdc_leading_zeros , 19*aaceae98SRobert Mustacchi.Nm stdc_leading_zeros_uc , 20*aaceae98SRobert Mustacchi.Nm stdc_leading_zeros_us , 21*aaceae98SRobert Mustacchi.Nm stdc_leading_zeros_ui , 22*aaceae98SRobert Mustacchi.Nm stdc_leading_zeros_ul , 23*aaceae98SRobert Mustacchi.Nm stdc_leading_zeros_ull 24*aaceae98SRobert Mustacchi.Nd count consecutive leading zero bits 25*aaceae98SRobert Mustacchi.Sh SYNOPSIS 26*aaceae98SRobert Mustacchi.In sys/stdbit.h 27*aaceae98SRobert Mustacchi.Ft "unsigned int" 28*aaceae98SRobert Mustacchi.Fo stdc_leading_zeros 29*aaceae98SRobert Mustacchi.Fa "generic_value_type value" 30*aaceae98SRobert Mustacchi.Fc 31*aaceae98SRobert Mustacchi.Ft "unsigned int" 32*aaceae98SRobert Mustacchi.Fo stdc_leading_zeros_uc 33*aaceae98SRobert Mustacchi.Fa "unsigned char value" 34*aaceae98SRobert Mustacchi.Fc 35*aaceae98SRobert Mustacchi.Ft "unsigned int" 36*aaceae98SRobert Mustacchi.Fo stdc_leading_zeros_us 37*aaceae98SRobert Mustacchi.Fa "unsigned short value" 38*aaceae98SRobert Mustacchi.Fc 39*aaceae98SRobert Mustacchi.Ft "unsigned int" 40*aaceae98SRobert Mustacchi.Fo stdc_leading_zeros_ui 41*aaceae98SRobert Mustacchi.Fa "unsigned int value" 42*aaceae98SRobert Mustacchi.Fc 43*aaceae98SRobert Mustacchi.Ft "unsigned int" 44*aaceae98SRobert Mustacchi.Fo stdc_leading_zeros_ul 45*aaceae98SRobert Mustacchi.Fa "unsigned long value" 46*aaceae98SRobert Mustacchi.Fc 47*aaceae98SRobert Mustacchi.Ft "unsigned int" 48*aaceae98SRobert Mustacchi.Fo stdc_leading_zeros_ull 49*aaceae98SRobert Mustacchi.Fa "unsigned long long value" 50*aaceae98SRobert Mustacchi.Fc 51*aaceae98SRobert Mustacchi.Sh DESCRIPTION 52*aaceae98SRobert MustacchiThe 53*aaceae98SRobert Mustacchi.Fn stdc_leading_zeros 54*aaceae98SRobert Mustacchifamily of functions counts the number of consecutive zero bits present in 55*aaceae98SRobert Mustacchi.Fa value 56*aaceae98SRobert Mustacchistarting at the most significant bit. 57*aaceae98SRobert Mustacchi.Pp 58*aaceae98SRobert MustacchiThe 59*aaceae98SRobert Mustacchi.Fn stdc_leading_zeros 60*aaceae98SRobert Mustacchifunction is generic and will operate on all 8, 16, 32, and 64-bit 61*aaceae98SRobert Mustacchiunsigned integers; however, it is only available in C23. 62*aaceae98SRobert MustacchiThe other functions all operate on a specific integer type, but 63*aaceae98SRobert Mustacchiotherwise behave the same and are available regardless of the C language 64*aaceae98SRobert Mustacchiversion. 65*aaceae98SRobert Mustacchi.Pp 66*aaceae98SRobert MustacchiNote that promoting an integer from one type to another increases the 67*aaceae98SRobert Mustacchiquantity of leading zeros, thus increasing the return value. 68*aaceae98SRobert Mustacchi.Sh CONTEXT 69*aaceae98SRobert MustacchiThese functions may be called from 70*aaceae98SRobert Mustacchi.Sy user , 71*aaceae98SRobert Mustacchi.Sy kernel , 72*aaceae98SRobert Mustacchior 73*aaceae98SRobert Mustacchi.Sy interrupt 74*aaceae98SRobert Mustacchicontext. 75*aaceae98SRobert Mustacchi.Sh RETURN VALUES 76*aaceae98SRobert MustacchiThe functions in the 77*aaceae98SRobert Mustacchi.Fn stdc_leading_zeros 78*aaceae98SRobert Mustacchifamily always return the number of leading zeros found in 79*aaceae98SRobert Mustacchi.Fa value . 80*aaceae98SRobert MustacchiThese functions cannot fail. 81*aaceae98SRobert Mustacchi.Sh INTERFACE STABILITY 82*aaceae98SRobert Mustacchi.Sy Committed 83*aaceae98SRobert Mustacchi.Sh SEE ALSO 84*aaceae98SRobert Mustacchi.Xr stdc_leading_zeros 3C , 85*aaceae98SRobert Mustacchi.Xr stdc_bit_ceil 9F , 86*aaceae98SRobert Mustacchi.Xr stdc_bit_floor 9F , 87*aaceae98SRobert Mustacchi.Xr stdc_bit_width 9F , 88*aaceae98SRobert Mustacchi.Xr stdc_count_ones 9F , 89*aaceae98SRobert Mustacchi.Xr stdc_count_zeros 9F , 90*aaceae98SRobert Mustacchi.Xr stdc_first_leading_one 9F , 91*aaceae98SRobert Mustacchi.Xr stdc_first_leading_zero 9F , 92*aaceae98SRobert Mustacchi.Xr stdc_first_trailing_one 9F , 93*aaceae98SRobert Mustacchi.Xr stdc_first_trailing_zero 9F , 94*aaceae98SRobert Mustacchi.Xr stdc_has_single_bit 9F , 95*aaceae98SRobert Mustacchi.Xr stdc_leading_ones 9F , 96*aaceae98SRobert Mustacchi.Xr stdc_trailing_ones 9F , 97*aaceae98SRobert Mustacchi.Xr stdc_trailing_zeros 9F 98