#include <stdarg.h> defines the following macro
#define _INTSIZEOF (N) ((sizeof (n) + sizeof (int)-1) & ~ (sizeof (int)-1))
The primary function is to align the variable n according to the size of the int-sized memory address, returning the size of the memory-aligned N (General >=sizeof (n))
The formula is calculated as follows: it's reproduced.
for two positive integers x, n always has an integer q, R makes
x = NQ + R, where 0<= R <n//min non-negative remaining
Q, R is the only certainty. Q = [x/n], r = x-n[x/n]. This is a simple form with the remainder division. In the C language, Q, R is easy to calculate: Q = x/n, r = x% n.
The so-called X by n alignment refers to: If the r=0, take qn, if r>0, take (q+1) n. This is also equivalent to the X represented as:
x = nq + R ', where-n < R ' <=0//MAX non-positive remaining
NQ is what we ask. The key is how to calculate it in C language. Since we can handle the standard band-Rest division, we can convert the equation to a standard band-rest division and then handle it:
x+n = qn + (n+r '), where 0<n+r ' <=n//MAX positive remaining
x+n-1 = qn + (n+r '-1), where 0<= n+r '-1 <n//min non-negative remaining
so qn = [(x+n-1)/n]n. The C language is:
((x+n-1)/n) *n
if n is a power of 2, such as 2^m, then the M-bit is shifted to the left by the M-bit. So the x+n-1 of the lowest m bits clear 0. Get:
(x+n-1) & (~ (n-1))
Because it is used in va_start, the alignment of parameters in the stack should be int-aligned, so
"Original" _intsizeof memory aligned with INT