10 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
13 #include <bits/strings.h>
16 * Find first (i.e. least significant) set bit
19 * @ret lsb Least significant bit set in value (LSB=1), or zero
21 static inline __attribute__ (( always_inline )) int
22 __constant_ffsll ( unsigned long long x ) {
25 if ( ! ( x & 0x00000000ffffffffULL ) ) {
29 if ( ! ( x & 0x0000ffffUL ) ) {
33 if ( ! ( x & 0x00ff ) ) {
37 if ( ! ( x & 0x0f ) ) {
41 if ( ! ( x & 0x3 ) ) {
45 if ( ! ( x & 0x1 ) ) {
49 return ( x ? ( r + 1 ) : 0 );
53 * Find first (i.e. least significant) set bit
56 * @ret lsb Least significant bit set in value (LSB=1), or zero
58 static inline __attribute__ (( always_inline )) int
59 __constant_ffsl ( unsigned long x ) {
60 return __constant_ffsll ( x );
64 * Find last (i.e. most significant) set bit
67 * @ret msb Most significant bit set in value (LSB=1), or zero
69 static inline __attribute__ (( always_inline )) int
70 __constant_flsll ( unsigned long long x ) {
73 if ( x & 0xffffffff00000000ULL ) {
77 if ( x & 0xffff0000UL ) {
97 return ( x ? ( r + 1 ) : 0 );
101 * Find last (i.e. most significant) set bit
104 * @ret msb Most significant bit set in value (LSB=1), or zero
106 static inline __attribute__ (( always_inline )) int
107 __constant_flsl ( unsigned long x ) {
108 return __constant_flsll ( x );
111 int __ffsll ( long long x );
112 int __ffsl ( long x );
113 int __flsll ( long long x );
114 int __flsl ( long x );
117 * Find first (i.e. least significant) set bit
120 * @ret lsb Least significant bit set in value (LSB=1), or zero
123 ( __builtin_constant_p ( x ) ? __constant_ffsll ( x ) : __ffsll ( x ) )
126 * Find first (i.e. least significant) set bit
129 * @ret lsb Least significant bit set in value (LSB=1), or zero
132 ( __builtin_constant_p ( x ) ? __constant_ffsl ( x ) : __ffsl ( x ) )
135 * Find first (i.e. least significant) set bit
138 * @ret lsb Least significant bit set in value (LSB=1), or zero
140 #define ffs( x ) ffsl ( x )
143 * Find last (i.e. most significant) set bit
146 * @ret msb Most significant bit set in value (LSB=1), or zero
149 ( __builtin_constant_p ( x ) ? __constant_flsll ( x ) : __flsll ( x ) )
152 * Find last (i.e. most significant) set bit
155 * @ret msb Most significant bit set in value (LSB=1), or zero
158 ( __builtin_constant_p ( x ) ? __constant_flsl ( x ) : __flsl ( x ) )
161 * Find last (i.e. most significant) set bit
164 * @ret msb Most significant bit set in value (LSB=1), or zero
166 #define fls( x ) flsl ( x )
172 * @v dest Destination
175 static inline __attribute__ (( always_inline )) void
176 bcopy ( const void *src, void *dest, size_t len ) {
177 memmove ( dest, src, len );
183 * @v dest Destination
186 static inline __attribute__ (( always_inline )) void
187 bzero ( void *dest, size_t len ) {
188 memset ( dest, 0, len );
191 int __pure strcasecmp ( const char *first, const char *second ) __nonnull;
193 #endif /* _STRINGS_H */