Go to main content

man pages section 3: Basic Library Functions

Exit Print View

Updated: Wednesday, July 27, 2022
 
 

flsll(3C)

Name

ffs, ffsl, ffsll, fls, flsl, flsll - find first or last bit set in a bit string

Synopsis

#include <strings.h>

int ffs(int value);
#include <string.h>

int ffsl(long value);
int ffsll(long long value);
int fls(int value);
int flsl(long value);
int flsll(long long value);

Description

The ffs(), ffsl(), and ffsll() functions find the first bit set in value and return the position of that bit.

The fls(), flsl(), and flsll() functions find the last bit set in value and return the position of that bit.

Bits are numbered starting at one (the least significant bit).

Return Values

These functions return the position of the requested bit, or 0 if no bits are set in value.

Errors

No errors are defined.

Attributes

See attributes(7) for descriptions of the following attributes:

ATTRIBUTE TYPE
ATTRIBUTE VALUE
Interface Stability
Committed
MT-Level
Async-Signal-Safe
Standard
See below

Standard

See standards(7) for descriptions of the following standards:

INTERFACES
APPLICABLE STANDARDS
ffs()
  • POSIX.1-2001 through 2008,
  • SUS through SUSv4,
  • XPG4v2 through XPG7
ffsl(), ffsll(), fls(), flsl(), flsll()
None

See Also

attributes(7), standards(7)

History

The ffsl(), fls(), and flsl() functions appeared in FreeBSD 5.3. The ffsll() and flsll() functions appeared in FreeBSD 7.1. All of these functions were added to Oracle Solaris in the Solaris 11.0 release.

The ffs() function appeared in 4.3BSD. It was added to Solaris in the Solaris 2.0 release, with a prototype in the <string.h> header. The prototype for ffs() was added to the <strings.h> header in the Solaris 2.6 release as required by the XPG4v2 standard.