Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
cloud-kernel
提交
65903265
cloud-kernel
项目概览
openanolis
/
cloud-kernel
1 年多 前同步成功
通知
160
Star
36
Fork
7
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
10
列表
看板
标记
里程碑
合并请求
2
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
cloud-kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
10
Issue
10
列表
看板
标记
里程碑
合并请求
2
合并请求
2
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
65903265
编写于
7月 12, 2005
作者:
R
Ralf Baechle
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use clz / dclz on MIPS32 / MIPS64 processors.
Signed-off-by:
N
Ralf Baechle
<
ralf@linux-mips.org
>
上级
e5de3b46
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
115 addition
and
22 deletion
+115
-22
include/asm-mips/bitops.h
include/asm-mips/bitops.h
+115
-22
未找到文件。
include/asm-mips/bitops.h
浏览文件 @
65903265
...
...
@@ -546,17 +546,60 @@ static inline int test_bit(unsigned long nr, const volatile unsigned long *addr)
return
1UL
&
(
addr
[
nr
>>
SZLONG_LOG
]
>>
(
nr
&
SZLONG_MASK
));
}
#ifdef CONFIG_CPU_MIPS32_R1
/*
* ffz - find first zero in word.
* Return the bit position (0..31) of the most significant 1 bit in a word
* Returns -1 if no 1 bit exists
*/
static
__inline__
int
__ilog2
(
unsigned
long
x
)
{
int
lz
;
__asm__
(
" .set push
\n
"
" .set mips32
\n
"
" clz %0, %1
\n
"
" .set pop
\n
"
:
"=r"
(
lz
)
:
"r"
(
x
));
return
31
-
lz
;
}
#elif defined(CONFIG_CPU_MIPS64_R1)
/*
* Return the bit position (0..63) of the most significant 1 bit in a word
* Returns -1 if no 1 bit exists
*/
static
__inline__
int
__ilog2
(
unsigned
long
x
)
{
int
lz
;
__asm__
(
" .set push
\n
"
" .set mips64
\n
"
" dclz %0, %1
\n
"
" .set pop
\n
"
:
"=r"
(
lz
)
:
"r"
(
x
));
return
63
-
lz
;
}
#endif
/*
* __ffs - find first bit in word.
* @word: The word to search
*
* Undefined if no zero exists, so code should check against ~0UL first.
* Returns 0..SZLONG-1
* Undefined if no bit exists, so code should check against 0 first.
*/
static
inline
unsigned
long
ffz
(
unsigned
long
word
)
static
inline
unsigned
long
__ffs
(
unsigned
long
word
)
{
#if defined(CONFIG_CPU_MIPS32_R1) || defined(CONFIG_CPU_MIPS64_R1)
return
__ilog2
(
word
&
-
word
);
#else
int
b
=
0
,
s
;
word
=
~
word
;
#ifdef CONFIG_32BIT
s
=
16
;
if
(
word
<<
16
!=
0
)
s
=
0
;
b
+=
s
;
word
>>=
s
;
s
=
8
;
if
(
word
<<
24
!=
0
)
s
=
0
;
b
+=
s
;
word
>>=
s
;
...
...
@@ -572,26 +615,87 @@ static inline unsigned long ffz(unsigned long word)
s
=
2
;
if
(
word
<<
62
!=
0
)
s
=
0
;
b
+=
s
;
word
>>=
s
;
s
=
1
;
if
(
word
<<
63
!=
0
)
s
=
0
;
b
+=
s
;
#endif
return
b
;
#endif
}
/*
*
__ffs - find first bit in word
.
*
ffs - find first bit set
.
* @word: The word to search
*
* Undefined if no bit exists, so code should check against 0 first.
* Returns 1..SZLONG
* Returns 0 if no bit exists
*/
static
inline
unsigned
long
__ffs
(
unsigned
long
word
)
static
inline
unsigned
long
ffs
(
unsigned
long
word
)
{
return
ffz
(
~
word
);
if
(
!
word
)
return
0
;
return
__ffs
(
word
)
+
1
;
}
/*
* fls: find last bit set.
* ffz - find first zero in word.
* @word: The word to search
*
* Undefined if no zero exists, so code should check against ~0UL first.
*/
static
inline
unsigned
long
ffz
(
unsigned
long
word
)
{
return
__ffs
(
~
word
);
}
/*
* flz - find last zero in word.
* @word: The word to search
*
* Returns 0..SZLONG-1
* Undefined if no zero exists, so code should check against ~0UL first.
*/
static
inline
unsigned
long
flz
(
unsigned
long
word
)
{
#if defined(CONFIG_CPU_MIPS32_R1) || defined(CONFIG_CPU_MIPS64_R1)
return
__ilog2
(
~
word
);
#else
#if defined(CONFIG_32BIT)
int
r
=
31
,
s
;
word
=
~
word
;
s
=
16
;
if
((
word
&
0xffff0000
))
s
=
0
;
r
-=
s
;
word
<<=
s
;
s
=
8
;
if
((
word
&
0xff000000
))
s
=
0
;
r
-=
s
;
word
<<=
s
;
s
=
4
;
if
((
word
&
0xf0000000
))
s
=
0
;
r
-=
s
;
word
<<=
s
;
s
=
2
;
if
((
word
&
0xc0000000
))
s
=
0
;
r
-=
s
;
word
<<=
s
;
s
=
1
;
if
((
word
&
0x80000000
))
s
=
0
;
r
-=
s
;
#endif
#if defined(CONFIG_64BIT)
int
r
=
63
,
s
;
word
=
~
word
;
s
=
32
;
if
((
word
&
0xffffffff00000000UL
))
s
=
0
;
r
-=
s
;
word
<<=
s
;
s
=
16
;
if
((
word
&
0xffff000000000000UL
))
s
=
0
;
r
-=
s
;
word
<<=
s
;
s
=
8
;
if
((
word
&
0xff00000000000000UL
))
s
=
0
;
r
-=
s
;
word
<<=
s
;
s
=
4
;
if
((
word
&
0xf000000000000000UL
))
s
=
0
;
r
-=
s
;
word
<<=
s
;
s
=
2
;
if
((
word
&
0xc000000000000000UL
))
s
=
0
;
r
-=
s
;
word
<<=
s
;
s
=
1
;
if
((
word
&
0x8000000000000000UL
))
s
=
0
;
r
-=
s
;
#endif
return
r
;
#endif
}
/*
* fls - find last bit set.
* @word: The word to search
*
* Returns 1..SZLONG
* Returns 0 if no bit exists
*/
static
inline
unsigned
long
fls
(
unsigned
long
word
)
{
if
(
word
==
0
)
return
0
;
return
flz
(
~
word
)
+
1
;
}
#define fls(x) generic_fls(x)
/*
* find_next_zero_bit - find the first zero bit in a memory region
...
...
@@ -727,17 +831,6 @@ static inline int sched_find_first_bit(const unsigned long *b)
#endif
}
/*
* ffs - find first bit set
* @x: the word to search
*
* This is defined the same way as
* the libc and compiler builtin ffs routines, therefore
* differs in spirit from the above ffz (man ffs).
*/
#define ffs(x) generic_ffs(x)
/*
* hweightN - returns the hamming weight of a N-bit word
* @x: the word to weigh
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录