iPXE
Functions
strings.h File Reference

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
static __attribute__ ((always_inline)) int __ffsl(long value)
 Find first (i.e.

Function Documentation

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )
static __attribute__ ( (always_inline)  ) [inline, static]

Find first (i.e.

Find last (i.e.

least significant) set bit

Parameters:
valueValue
Return values:
lsbLeast significant bit set in value (LSB=1), or zero

most significant) set bit

Parameters:
valueValue
Return values:
msbMost significant bit set in value (LSB=1), or zero

Definition at line 12 of file strings.h.

References __asm__().

                                                                          {
        long lsb_minus_one;

        /* If the input value is zero, the BSF instruction returns
         * ZF=0 and leaves an undefined value in the output register.
         * Perform this check in C rather than asm so that it can be
         * omitted in cases where the compiler is able to prove that
         * the input is non-zero.
         */
        if ( value ) {
                __asm__ ( "bsfl %1, %0"
                          : "=r" ( lsb_minus_one )
                          : "rm" ( value ) );
                return ( lsb_minus_one + 1 );
        } else {
                return 0;
        }
}