Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 5307
b: refs/heads/master
c: cd85c8b
h: refs/heads/master
i:
  5305: 4bd90e2
  5303: 669e424
v: v3
  • Loading branch information
Steven Rostedt authored and Linus Torvalds committed Jul 28, 2005
1 parent b9fd77a commit d25b629
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 31 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 79a8810221ee9ea96c4e5a5817afb88f22ea698c
refs/heads/master: cd85c8b4457a52d3545fdb9532082b2c1ebd5f21
54 changes: 24 additions & 30 deletions trunk/include/asm-i386/bitops.h
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,20 @@ static inline int find_first_zero_bit(const unsigned long *addr, unsigned size)
*/
int find_next_zero_bit(const unsigned long *addr, int size, int offset);

/**
* __ffs - find first bit in word.
* @word: The word to search
*
* Undefined if no bit exists, so code should check against 0 first.
*/
static inline unsigned long __ffs(unsigned long word)
{
__asm__("bsfl %1,%0"
:"=r" (word)
:"rm" (word));
return word;
}

/**
* find_first_bit - find the first set bit in a memory region
* @addr: The address to start the search at
Expand All @@ -320,22 +334,16 @@ int find_next_zero_bit(const unsigned long *addr, int size, int offset);
*/
static inline int find_first_bit(const unsigned long *addr, unsigned size)
{
int d0, d1;
int res;

/* This looks at memory. Mark it volatile to tell gcc not to move it around */
__asm__ __volatile__(
"xorl %%eax,%%eax\n\t"
"repe; scasl\n\t"
"jz 1f\n\t"
"leal -4(%%edi),%%edi\n\t"
"bsfl (%%edi),%%eax\n"
"1:\tsubl %%ebx,%%edi\n\t"
"shll $3,%%edi\n\t"
"addl %%edi,%%eax"
:"=a" (res), "=&c" (d0), "=&D" (d1)
:"1" ((size + 31) >> 5), "2" (addr), "b" (addr) : "memory");
return res;
int x = 0;
do {
if (*addr)
return __ffs(*addr) + x;
addr++;
if (x >= size)
break;
x += (sizeof(*addr)<<3);
} while (1);
return x;
}

/**
Expand All @@ -360,20 +368,6 @@ static inline unsigned long ffz(unsigned long word)
return word;
}

/**
* __ffs - find first bit in word.
* @word: The word to search
*
* Undefined if no bit exists, so code should check against 0 first.
*/
static inline unsigned long __ffs(unsigned long word)
{
__asm__("bsfl %1,%0"
:"=r" (word)
:"rm" (word));
return word;
}

/*
* fls: find last bit set.
*/
Expand Down

0 comments on commit d25b629

Please sign in to comment.