#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---