mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	Compiler Attributes: counted_by: Adjust name and identifier expansion
GCC and Clang's current RFCs name this attribute "counted_by", and have
moved away from using a string for the member name. Update the kernel's
macros to match. Additionally provide a UAPI no-op macro for UAPI structs
that will gain annotations.
Cc: Miguel Ojeda <ojeda@kernel.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Fixes: dd06e72e68 ("Compiler Attributes: Add __counted_by macro")
Acked-by: Miguel Ojeda <ojeda@kernel.org>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Link: https://lore.kernel.org/r/20230817200558.never.077-kees@kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
			
			
This commit is contained in:
		
							parent
							
								
									be8dffa04d
								
							
						
					
					
						commit
						c8248faf3c
					
				
					 2 changed files with 17 additions and 13 deletions
				
			
		| 
						 | 
					@ -94,6 +94,19 @@
 | 
				
			||||||
# define __copy(symbol)
 | 
					# define __copy(symbol)
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Optional: only supported since gcc >= 14
 | 
				
			||||||
 | 
					 * Optional: only supported since clang >= 18
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 *   gcc: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108896
 | 
				
			||||||
 | 
					 * clang: https://reviews.llvm.org/D148381
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					#if __has_attribute(__counted_by__)
 | 
				
			||||||
 | 
					# define __counted_by(member)		__attribute__((__counted_by__(member)))
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					# define __counted_by(member)
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * Optional: not supported by gcc
 | 
					 * Optional: not supported by gcc
 | 
				
			||||||
 * Optional: only supported since clang >= 14.0
 | 
					 * Optional: only supported since clang >= 14.0
 | 
				
			||||||
| 
						 | 
					@ -129,19 +142,6 @@
 | 
				
			||||||
# define __designated_init
 | 
					# define __designated_init
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
 * Optional: only supported since gcc >= 14
 | 
					 | 
				
			||||||
 * Optional: only supported since clang >= 17
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 *   gcc: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108896
 | 
					 | 
				
			||||||
 * clang: https://reviews.llvm.org/D148381
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
#if __has_attribute(__element_count__)
 | 
					 | 
				
			||||||
# define __counted_by(member)		__attribute__((__element_count__(#member)))
 | 
					 | 
				
			||||||
#else
 | 
					 | 
				
			||||||
# define __counted_by(member)
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * Optional: only supported since clang >= 14.0
 | 
					 * Optional: only supported since clang >= 14.0
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -45,3 +45,7 @@
 | 
				
			||||||
		TYPE NAME[]; \
 | 
							TYPE NAME[]; \
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef __counted_by
 | 
				
			||||||
 | 
					#define __counted_by(m)
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue