Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
raspberrypi-kernel
提交
4816227b
R
raspberrypi-kernel
项目概览
openeuler
/
raspberrypi-kernel
通知
13
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
raspberrypi-kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
4816227b
编写于
10月 28, 2008
作者:
R
Ralf Baechle
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
MIPS: Clean up MIPSxx-optimized bitop functions
Signed-off-by:
N
Ralf Baechle
<
ralf@linux-mips.org
>
上级
c46b302b
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
76 addition
and
38 deletion
+76
-38
arch/mips/include/asm/bitops.h
arch/mips/include/asm/bitops.h
+76
-38
未找到文件。
arch/mips/include/asm/bitops.h
浏览文件 @
4816227b
...
...
@@ -558,39 +558,67 @@ static inline void __clear_bit_unlock(unsigned long nr, volatile unsigned long *
__clear_bit
(
nr
,
addr
);
}
#if defined(CONFIG_CPU_MIPS32) || defined(CONFIG_CPU_MIPS64)
/*
* Return the bit position (0..63) of the most significant 1 bit in a word
* Returns -1 if no 1 bit exists
*/
static
inline
unsigned
long
__fls
(
unsigned
long
x
)
static
inline
unsigned
long
__fls
(
unsigned
long
word
)
{
int
lz
;
int
num
;
if
(
sizeof
(
x
)
==
4
)
{
if
(
BITS_PER_LONG
==
32
&&
__builtin_constant_p
(
cpu_has_mips_r
)
&&
cpu_has_mips_r
)
{
__asm__
(
" .set push
\n
"
" .set mips32
\n
"
" clz %0, %1
\n
"
" .set pop
\n
"
:
"=r"
(
lz
)
:
"r"
(
x
));
:
"=r"
(
num
)
:
"r"
(
word
));
return
31
-
lz
;
return
31
-
num
;
}
BUG_ON
(
sizeof
(
x
)
!=
8
);
if
(
BITS_PER_LONG
==
64
&&
__builtin_constant_p
(
cpu_has_mips64
)
&&
cpu_has_mips64
)
{
__asm__
(
" .set push
\n
"
" .set mips64
\n
"
" dclz %0, %1
\n
"
" .set pop
\n
"
:
"=r"
(
num
)
:
"r"
(
word
));
__asm__
(
" .set push
\n
"
" .set mips64
\n
"
" dclz %0, %1
\n
"
" .set pop
\n
"
:
"=r"
(
lz
)
:
"r"
(
x
));
return
63
-
num
;
}
num
=
BITS_PER_LONG
-
1
;
return
63
-
lz
;
#if BITS_PER_LONG == 64
if
(
!
(
word
&
(
~
0ul
<<
32
)))
{
num
-=
32
;
word
<<=
32
;
}
#endif
if
(
!
(
word
&
(
~
0ul
<<
(
BITS_PER_LONG
-
16
))))
{
num
-=
16
;
word
<<=
16
;
}
if
(
!
(
word
&
(
~
0ul
<<
(
BITS_PER_LONG
-
8
))))
{
num
-=
8
;
word
<<=
8
;
}
if
(
!
(
word
&
(
~
0ul
<<
(
BITS_PER_LONG
-
4
))))
{
num
-=
4
;
word
<<=
4
;
}
if
(
!
(
word
&
(
~
0ul
<<
(
BITS_PER_LONG
-
2
))))
{
num
-=
2
;
word
<<=
2
;
}
if
(
!
(
word
&
(
~
0ul
<<
(
BITS_PER_LONG
-
1
))))
num
-=
1
;
return
num
;
}
/*
...
...
@@ -612,23 +640,43 @@ static inline unsigned long __ffs(unsigned long word)
* This is defined the same way as ffs.
* Note fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32.
*/
static
inline
int
fls
(
int
word
)
static
inline
int
fls
(
int
x
)
{
__asm__
(
"clz %0, %1"
:
"=r"
(
word
)
:
"r"
(
word
))
;
int
r
;
return
32
-
word
;
}
if
(
__builtin_constant_p
(
cpu_has_mips_r
)
&&
cpu_has_mips_r
)
{
__asm__
(
"clz %0, %1"
:
"=r"
(
x
)
:
"r"
(
x
));
#if defined(CONFIG_64BIT) && defined(CONFIG_CPU_MIPS64)
static
inline
int
fls64
(
__u64
word
)
{
__asm__
(
"dclz %0, %1"
:
"=r"
(
word
)
:
"r"
(
word
));
return
32
-
x
;
}
return
64
-
word
;
r
=
32
;
if
(
!
x
)
return
0
;
if
(
!
(
x
&
0xffff0000u
))
{
x
<<=
16
;
r
-=
16
;
}
if
(
!
(
x
&
0xff000000u
))
{
x
<<=
8
;
r
-=
8
;
}
if
(
!
(
x
&
0xf0000000u
))
{
x
<<=
4
;
r
-=
4
;
}
if
(
!
(
x
&
0xc0000000u
))
{
x
<<=
2
;
r
-=
2
;
}
if
(
!
(
x
&
0x80000000u
))
{
x
<<=
1
;
r
-=
1
;
}
return
r
;
}
#else
#include <asm-generic/bitops/fls64.h>
#endif
/*
* ffs - find first bit set.
...
...
@@ -646,16 +694,6 @@ static inline int ffs(int word)
return
fls
(
word
&
-
word
);
}
#else
#include <asm-generic/bitops/__ffs.h>
#include <asm-generic/bitops/__fls.h>
#include <asm-generic/bitops/ffs.h>
#include <asm-generic/bitops/fls.h>
#include <asm-generic/bitops/fls64.h>
#endif
/*defined(CONFIG_CPU_MIPS32) || defined(CONFIG_CPU_MIPS64) */
#include <asm-generic/bitops/ffz.h>
#include <asm-generic/bitops/find.h>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录