xref: /illumos-gate/usr/src/tools/smatch/src/validation/alloc-align.c (revision 8a2b682e57a046b828f37bcde1776f131ef4629f)
1 typedef unsigned long int size_t;
2 
3 /*
4  * The alloc_align attribute is used to tell the compiler that the return
5  * value points to memory, where the returned pointer minimum alignment is given
6  * by one of the functions parameters. GCC uses this information to improve
7  * pointer alignment analysis.
8  *
9  * The function parameter denoting the allocated alignment is specified by one
10  * integer argument, whose number is the argument of the attribute. Argument
11  * numbering starts at one.
12  *
13  * For instance,
14  *
15  *    void* my_memalign(size_t, size_t) __attribute__((alloc_align(1)))
16  *
17  * declares that my_memalign returns memory with minimum alignment given by
18  * parameter 1.
19  */
20 
21 #define __alloc_align(x)  __attribute__((__alloc_align__(x)))
22 
23 /*
24  * The aligned_alloc function allocates space for an object whose alignment is
25  * specified by alignment, whose size is specified by size, and whose value is
26  * indeterminate. The value of alignment shall be a valid alignment supported
27  * by the implementation and the value of size shall be an integral multiple
28  * of alignment.
29  *
30  * The aligned_alloc function returns either a null pointer or a pointer to the
31  * allocated space.
32  */
33 void *aligned_alloc(size_t alignment, size_t size) __alloc_align(1);
34 
35 
36 /*
37  * check-name: attribute __alloc_align__
38  */
39