按某类型对齐的C代码实现

来源:本站
导读:目前正在解读《按某类型对齐的C代码实现》的相关信息,《按某类型对齐的C代码实现》是由用户自行发布的知识型内容!下面请观看由(电工技术网 - www.9ddd.net)用户发布《按某类型对齐的C代码实现》的详细说明。

#define ALIGN_UP(addr, align) ((((nlm_uintptr_t) (addr)) + ((align) - 1)) & ~((align) - 1))

test programing:#include <stdio.h>#include <stdlib.h>int main(){ int i = 0, n = 0; printf("----sizeof(long) len is %d----n", sizeof(long)); for(; i < 50; i++) { n = (i + sizeof(long) -1) & ~((sizeof(long) - 1)); printf("--- i is %d n is %d---n", i, n); } return 0;}----sizeof(long) len is 4------- i is 0 n is 0------ i is 1 n is 4------ i is 2 n is 4------ i is 3 n is 4------ i is 4 n is 4------ i is 5 n is 8------ i is 6 n is 8------ i is 7 n is 8------ i is 8 n is 8------ i is 9 n is 12------ i is 10 n is 12------ i is 11 n is 12------ i is 12 n is 12------ i is 13 n is 16------ i is 14 n is 16------ i is 15 n is 16------ i is 16 n is 16------ i is 17 n is 20------ i is 18 n is 20------ i is 19 n is 20------ i is 20 n is 20------ i is 21 n is 24------ i is 22 n is 24------ i is 23 n is 24------ i is 24 n is 24------ i is 25 n is 28------ i is 26 n is 28------ i is 27 n is 28------ i is 28 n is 28------ i is 29 n is 32------ i is 30 n is 32------ i is 31 n is 32------ i is 32 n is 32------ i is 33 n is 36------ i is 34 n is 36------ i is 35 n is 36------ i is 36 n is 36------ i is 37 n is 40------ i is 38 n is 40------ i is 39 n is 40------ i is 40 n is 40------ i is 41 n is 44------ i is 42 n is 44------ i is 43 n is 44------ i is 44 n is 44------ i is 45 n is 48------ i is 46 n is 48------ i is 47 n is 48------ i is 48 n is 48------ i is 49 n is 52---

提醒:《按某类型对齐的C代码实现》最后刷新时间 2024-03-14 01:05:32,本站为公益型个人网站,仅供个人学习和记录信息,不进行任何商业性质的盈利。如果内容、图片资源失效或内容涉及侵权,请反馈至,我们会及时处理。本站只保证内容的可读性,无法保证真实性,《按某类型对齐的C代码实现》该内容的真实性请自行鉴别。