Back to index

glibc  2.9
Defines | Functions
ffs.c File Reference
#include <limits.h>
#include <string.h>

Go to the source code of this file.

Defines

#define ffsl   __something_else

Functions

int __ffs (int x)

Define Documentation

#define ffsl   __something_else

Definition at line 23 of file ffs.c.


Function Documentation

int __ffs ( int  x)

Definition at line 33 of file ffs.c.

{
       int r;

       if (x == 0)
         return 0;
       __asm__("    lr        %%r1,%1\n"
              "    sr         %0,%0\n"
              "    tml  %%r1,0xFFFF\n"
              "    jnz  0f\n"
              "    ahi  %0,16\n"
              "    srl  %%r1,16\n"
              "0:  tml  %%r1,0x00FF\n"
              "    jnz  1f\n"
              "    ahi  %0,8\n"
              "    srl  %%r1,8\n"
              "1:  tml  %%r1,0x000F\n"
              "    jnz  2f\n"
              "    ahi  %0,4\n"
              "    srl  %%r1,4\n"
              "2:  tml  %%r1,0x0003\n"
              "    jnz  3f\n"
              "    ahi  %0,2\n"
              "    srl  %%r1,2\n"
              "3:  tml  %%r1,0x0001\n"
              "    jnz  4f\n"
              "    ahi  %0,1\n"
              "4:"
              : "=&d" (r) : "d" (x) : "cc", "1" );
       return r+1;
}

Here is the call graph for this function: