본문 바로가기

Programming/Linux_Kernel

ffs, ffsl, ffsll, fls, flsl, flsll 함수 설명

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

LIBRARY
     Standard C Library (libc, -lc)

SYNOPSIS
     #include <strings.h>

     int
     ffs(int value);

     int
     ffsl(long value);

     int

     int
     ffsll(long long value);

     fls(int value);

     int
     flsl(long value);

     int
     flsll(long long value);

DESCRIPTION
     The ffs(), ffsl() and ffsll() functions find the first bit set (beginning with the least
     significant bit) in value and return the index of that bit.

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

예를 들면

0x0000 0000 0000 8000

2진수로

00000000 00000000 10000000 00000000

이고

fls 의 값은

16 이 된다.


16번째에 1로 check 되어 있다는 의미


0x10000

= 0b00000000 00000001 00000000 00000000

fls(0x1000) == 11

     Bits are numbered starting at 1 (the least significant bit).  A return value of zero from
     any of these functions means that the argument was zero.

SEE ALSO
     bitstring(3)

HISTORY
     The ffs() function appeared in 4.3BSD.  Its prototype existed previously in <string.h>
     before it was moved to <strings.h> for IEEE Std 1003.1-2001 (``POSIX.1'') compliance.

     The ffsl(), fls() and flsl() functions appeared in FreeBSD 5.3.  The ffsll() and flsll()
     functions appeared in FreeBSD 7.1.

BSD					 October 26, 2008				      BSD


'Programming > Linux_Kernel' 카테고리의 다른 글

linux 명령어 dd  (0) 2014.03.12
TLB (Translation Lookaside Buffer)  (0) 2014.03.12
__builtin_return_address(0)  (0) 2013.11.28
kernel log back ground 로 저장하기  (0) 2013.11.27
local_irq_disable(), local_irq_save(flags) 분석  (0) 2013.10.31