Embedded Artistry libc
C Standard Library Support for Bare-metal Systems
strings.h File Reference
#include <stddef.h>
#include <stdint.h>
Include dependency graph for strings.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int fls (int mask)
 Finds the last (most significant) bit set in the given mask. More...
 
int flsl (long mask)
 Finds the last (most significant) bit set in the given mask. More...
 
int flsll (long long mask)
 Finds the last (most significant) bit set in the given mask. More...
 

Function Documentation

◆ fls()

int fls ( int  mask)

Finds the last (most significant) bit set in the given mask.

Finds the last (most significant) bit set in the given (int) mask and return the index of that bit.

Bits are numbered starting at 1, the least significant bit.

Parameters
maskThe bit mask
Returns
The index of the bit if mask is not zero, 0 otherwise.

Definition at line 68 of file fls.c.

69 {
70  if(mask == 0)
71  {
72  {
73  return (0);
74  }
75  }
76 
77  return ((int)sizeof(mask) << 3) - __builtin_clz((unsigned)mask);
78 }

◆ flsl()

int flsl ( long  mask)

Finds the last (most significant) bit set in the given mask.

Finds the last (most significant) bit set in the given (long) mask and return the index of that bit.

Bits are numbered starting at 1, the least significant bit.

Parameters
maskThe bit mask
Returns
The index of the bit if mask is not zero, 0 otherwise.

Definition at line 62 of file flsl.c.

63 {
64  if(mask == 0)
65  {
66  {
67  return (0);
68  }
69  }
70 
71  return ((int)sizeof(mask) << 3) - __builtin_clzl((unsigned long)mask);
72 }

◆ flsll()

int flsll ( long long  mask)

Finds the last (most significant) bit set in the given mask.

Finds the last (most significant) bit set in the given (long long) mask and return the index of that bit.

Bits are numbered starting at 1, the least significant bit.

Parameters
maskThe bit mask
Returns
The index of the bit if mask is not zero, 0 otherwise.

Definition at line 62 of file flsll.c.

63 {
64  if(mask == 0)
65  {
66  {
67  return (0);
68  }
69  }
70 
71  return ((int)sizeof(mask) << 3) - __builtin_clzll((unsigned long long)mask);
72 }