关于_nassert()函数的疑问

[复制链接]
1492|2
 楼主| lefeng 发表于 2017-8-22 19:18 | 显示全部楼层 |阅读模式
今天在阅读SPRU198k.pdf 文档时,看到下面函数,我想知道,编译器在编译时遇到

WORD_ALIGNED(xptr);
WORD_ALIGNED(yptr);

函数,自动将传入函数的指针所指地址xptr和yptr四字节对齐,还是在此判断xptr和yptr地址是否是四字节对齐?

#define WORD_ALIGNED(x) (_nassert(((int)(x) & 0x3) == 0))

void lesson3_c(short * restrict xptr, short * restrict yptr, short *zptr,short *w_sum, int N)
{
int i, w_vec1, w_vec2;
short w1,w2;
WORD_ALIGNED(xptr);
WORD_ALIGNED(yptr);
w1 = zptr[0];
w2 = zptr[1];
#pragma MUST_ITERATE(20, , 2);
for (i = 0; i < N; i++)
{
w_vec1 = xptr[i] * w1;
w_vec2 = yptr[i] * w2;
w_sum[i] = (w_vec1+w_vec2) >> 15;
}
}

非常感谢!
lwsn 发表于 2017-8-22 19:23 | 显示全部楼层

是在判断xptr和yptr地址是否是四字节对齐。
Thor9 发表于 2017-8-22 20:21 | 显示全部楼层
void _nassert(int);

Generates no code. Tells the optimizer that the expression declared with the assert function is
true; this gives a hint to the optimizer as to what optimizations might be valid.
您需要登录后才可以回帖 登录 | 注册

本版积分规则

200

主题

1087

帖子

0

粉丝
快速回复 在线客服 返回列表 返回顶部