![]() |
|
||||||||||||||
| | 首页 | 新闻 | 文库 | 方案 | 技术 | 独家 | 座谈 | 下载 | 电路图 | 开发套件 | 仿真器 | 邮购 | 帮助 | VIP会员 | 芯片代购 | | ||
|
||
|
|||||
| uclinux-2008R1-RC8(bf561)到VDSP5的移植(28):likely | |||||
作者:快乐虾 文章来源:http://blog.csdn.net/lights_joy 点击数: 更新时间:2008-5-12 ![]() |
|||||
|
在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))
|
|||||
| 文章录入:admin 责任编辑:admin | |||||
| 【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口】 | |||||
| 最新热点 | 最新推荐 | 相关文章 | ||
| ucos-ii在嵌入式智能视觉监控 14bit 40 MSamples/s ADC应用 打造windows下的嵌入式开发工 DSP和FPGA在汽车电子中的广泛 [连载]ADSP-TSl01S系列之一 ADI ADIS1625x低功耗陀螺仪方 基于DSP的实时图像跟踪系统的 wxWidgets和MFC动态类型信息 用dll方式编译wxWidgets-2.8 Blackfin时钟控制 |
| 网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!) |
| | 本站介绍 | 合作联络 | 欢迎投稿 | 广告业务 | 网站地图 | 设为首页 | 加入收藏 | 友情链接 | 网站公告 | 联系我们 | | |||
|