uclinux-2008R1.5-RC3(bf561)到VDSP5的移植(49):likely
来源:互联网 发布:网络赌托 编辑:程序博客网 时间:2024/05/17 22:48
快乐虾
http://blog.csdn.net/lights_joy/
lights@hb165.com
本文适用于
ADI bf561 DSP
优视BF561EVB开发板
uclinux-2008r1.5-rc3(smp patch)
Visual DSP++ 5.0(update 5)
欢迎转载,但请保留作者信息
在include/linux/compiler.h中定义了两个宏:
/*
* Generic compiler-dependent macros required for kernel
* build go below this comment. Actual compiler/compiler version
* specific implementations come from the above header files
*/
#define likely(x) __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)
__builtin_expect(exp, val)是GCC的一个内建函数,而VDSP无此函数,它用于为编译器提供分支预测信息,其返回值是整数表达式exp的值。这个内建函数的语义是 exp 的预期值是 val,编译器可以根据这个信息适当地重排语句块的顺序,使程序在预期的情况下有更高的执行效率。
在VDSP中,提供了两个相似的函数:
You can use the expected_true and expected_false built-in functions to control the compiler’s behavior for specific cases. By using these functions, you can tell the compiler which way a condition is most likely to evaluate. This influences the default flow of execution.
For example,
if (buffer_valid(data_buffer))
if (send_msg(data_buffer))
system_failure();
shows two nested conditional statements. If it was known that, for this example, buffer_valid() would usually return true, but that send_msg() would rarely do so, the code could be written as
if (expected_true(buffer_valid(data_buffer)))
if (expected_false(send_msg(data_buffer)))
system_failure();
因此,我们将这两个宏定义改为:
/*
* Generic compiler-dependent macros required for kernel
* build go below this comment. Actual compiler/compiler version
* specific implementations come from the above header files
*/
#define likely(x) expected_true(!!(x))
#define unlikely(x) expected_false(!!(x))
1 参考资料
uclinux-2008R1.5-RC3(bf561)到VDSP5的移植(43):exception_stacks(2009-1-18)
uclinux-2008R1.5-RC3(bf561)到VDSP5的移植(44):Out of memory(2009-01-19)
uclinux-2008R1.5-RC3(bf561)到VDSP5的移植(45):未命名union的后遗症(2009-01-21)
uclinux-2008R1.5-RC3(bf561)到VDSP5的移植(46):fls_long的问题(2009-1-21)
uclinux-2008R1.5-RC3(bf561)到VDSP5的移植(47):per_cpu的奇怪问题(2009-1-22)
uclinux-2008R1.5-RC3(bf561)到VDSP5的移植(48):__start___param(2009-1-22)
- uclinux-2008R1.5-RC3(bf561)到VDSP5的移植(49):likely
- uclinux-2008R1.5-RC3(bf561)到VDSP5的移植(5):'bf561.h'的问题
- uclinux-2008R1.5-RC3(bf561)到VDSP5的移植(38):未命名union的问题
- uclinux-2008R1.5-RC3(bf561)到VDSP5的移植(45):未命名union的后遗症
- uclinux-2008R1.5-RC3(bf561)到VDSP5的移植(46):fls_long的问题
- uclinux-2008R1.5-RC3(bf561)到VDSP5的移植(47):per_cpu的奇怪问题
- uclinux-2008R1.5-RC3(bf561)到VDSP5的移植(70):保留VDSP的heap
- uclinux-2008R1.5-RC3(bf561)到VDSP5的移植(71):l1_data_sram_init的疑惑
- uclinux-2008R1.5-RC3(bf561)到VDSP5的移植(72):中断时SP的保存
- uclinux-2008R1.5-RC3(bf561)到VDSP5的移植(1):前言
- uclinux-2008R1.5-RC3(bf561)到VDSP5的移植(2):代码注释
- uclinux-2008R1.5-RC3(bf561)到VDSP5的移植(3):vdsp项目创建
- uclinux-2008R1.5-RC3(bf561)到VDSP5的移植(4):目录差异
- uclinux-2008R1.5-RC3(bf561)到VDSP5的移植(6):CONFIG_BFIN_KERNEL_CLOCK
- uclinux-2008R1.5-RC3(bf561)到VDSP5的移植(7):CONFIG_MEM_MT48LC16M16A2TG_75
- uclinux-2008R1.5-RC3(bf561)到VDSP5的移植(8):CONFIG_CLKIN_HZ
- uclinux-2008R1.5-RC3(bf561)到VDSP5的移植(9):CONFIG_MEM_SIZE
- uclinux-2008R1.5-RC3(bf561)到VDSP5的移植(10):CONFIG_FLASH_SPEED_BTT
- 程序员应具备的素质
- C#之属性及其示范代码
- 跨站Script攻击的防范
- 用ASP制作强大的搜索引擎
- 菜鸟网上找了个简单游戏,自己修改的,请各位多指教,再告诉我下接下去可以看比这个稍难一点的游戏,举个例子,谢谢
- uclinux-2008R1.5-RC3(bf561)到VDSP5的移植(49):likely
- OpenCms显示总新闻篇数和当前篇数 第*篇/共***篇
- Tour de Flex
- PPTP Server Installation in CentOS 5
- uclinux-2008R1.5-RC3(bf561)到VDSP5的移植(50):.spinlock.text
- Symbian 命令行编译程序
- 一个人的战斗
- 按键精灵
- openGL的局限