Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
linux
Commits
dd2deeb9
Commit
dd2deeb9
authored
May 14, 2004
by
Andrew Morton
Committed by
Linus Torvalds
May 14, 2004
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[PATCH] H8/300: bitops.h add find_next_bit
From: Yoshinori Sato <ysato@users.sourceforge.jp> - add find_next_bit
parent
35181da9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
13 deletions
+52
-13
include/asm-h8300/bitops.h
include/asm-h8300/bitops.h
+52
-13
No files found.
include/asm-h8300/bitops.h
View file @
dd2deeb9
...
...
@@ -181,6 +181,23 @@ H8300_GEN_TEST_BITOP(test_and_change_bit,"bnot")
#define find_first_zero_bit(addr, size) \
find_next_zero_bit((addr), (size), 0)
static
__inline__
unsigned
long
__ffs
(
unsigned
long
word
)
{
unsigned
long
result
;
result
=
-
1
;
__asm__
(
"1:
\n\t
"
"shlr.l %2
\n\t
"
"adds #1,%0
\n\t
"
"bcc 1b"
:
"=r"
(
result
)
:
"0"
(
result
),
"r"
(
word
));
return
result
;
}
#define ffs(x) generic_ffs(x)
#define fls(x) generic_fls(x)
static
__inline__
int
find_next_zero_bit
(
void
*
addr
,
int
size
,
int
offset
)
{
unsigned
long
*
p
=
(
unsigned
long
*
)(((
unsigned
long
)
addr
+
(
offset
>>
3
))
&
~
3
);
...
...
@@ -217,22 +234,44 @@ static __inline__ int find_next_zero_bit (void * addr, int size, int offset)
return
result
+
ffz
(
tmp
);
}
static
__inline__
unsigned
long
__ffs
(
unsigned
long
word
)
static
__inline__
unsigned
long
find_next_bit
(
const
unsigned
long
*
addr
,
unsigned
long
size
,
unsigned
long
offset
)
{
unsigned
long
result
;
unsigned
long
*
p
=
(
unsigned
long
*
)(((
unsigned
long
)
addr
+
(
offset
>>
3
))
&
~
3
);
unsigned
int
result
=
offset
&
~
31UL
;
unsigned
int
tmp
;
result
=
-
1
;
__asm__
(
"1:
\n\t
"
"shlr.l %2
\n\t
"
"adds #1,%0
\n\t
"
"bcc 1b"
:
"=r"
(
result
)
:
"0"
(
result
),
"r"
(
word
));
return
result
;
}
if
(
offset
>=
size
)
return
size
;
size
-=
result
;
offset
&=
31UL
;
if
(
offset
)
{
tmp
=
*
(
p
++
);
tmp
&=
~
0UL
<<
offset
;
if
(
size
<
32
)
goto
found_first
;
if
(
tmp
)
goto
found_middle
;
size
-=
32
;
result
+=
32
;
}
while
(
size
>=
32
)
{
if
((
tmp
=
*
p
++
)
!=
0
)
goto
found_middle
;
result
+=
32
;
size
-=
32
;
}
if
(
!
size
)
return
result
;
tmp
=
*
p
;
#define ffs(x) generic_ffs(x)
#define fls(x) generic_fls(x)
found_first:
tmp
&=
~
0UL
>>
(
32
-
size
);
if
(
tmp
==
0UL
)
return
result
+
size
;
found_middle:
return
result
+
__ffs
(
tmp
);
}
/*
* Every architecture must define this function. It's the fastest
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment