我在Cell处理器上调整DMA传输的内存时遇到问题.我需要地址的最后4位为0.
我有4个数组,unsigned int其中每个元素必须在内存中对齐,以便其(十六进制)地址以零结尾.
例如
int main()
{
size_t i;
static unsigned int a[2] __attribute__ ((aligned (16)));
static unsigned int b[2] __attribute__ ((aligned (16)));
static unsigned int c[2] __attribute__ ((aligned (16)));
static unsigned int d[2] __attribute__ ((aligned (16)));
for (i = 0; i < 2; ++i) {
printf("a[%u] = %p\n", &a[i]);
printf("b[%u] = %p\n", &b[i]);
printf("c[%u] = %p\n", &c[i]);
printf("d[%u] = %p\n", &d[i]);
}
return 0;
}
Run Code Online (Sandbox Code Playgroud)
输出:
a[0] = 0x10010b60
b[0] = 0x10010b50
c[0] = 0x10010b40 …Run Code Online (Sandbox Code Playgroud) 在我的程序中,我需要申请__attribute__(( aligned(32)))一个int *或float *
我试过这样但我不确定它会起作用。
int *rarray __attribute__(( aligned(32)));
Run Code Online (Sandbox Code Playgroud)
我看到了这个,但没有找到答案