From f3ecfc1ee49e1c3ddd3d19ca6166424d72a08a5c Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Wed, 10 May 2023 15:42:09 -0400 Subject: config: Group attribute wrappers together --- src/config.h | 44 +++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/src/config.h b/src/config.h index ed3f6ab..e17f90b 100644 --- a/src/config.h +++ b/src/config.h @@ -129,18 +129,7 @@ # define __GLIBC_PREREQ(maj, min) false #endif -// Wrappers for fundamental language features/extensions - -/** - * Silence compiler warnings about switch/case fall-throughs. - */ -#if __has_c_attribute(fallthrough) -# define BFS_FALLTHROUGH [[fallthrough]] -#elif __has_attribute(fallthrough) -# define BFS_FALLTHROUGH __attribute__((fallthrough)) -#else -# define BFS_FALLTHROUGH ((void)0) -#endif +// Fundamental utilities /** * Get the length of an array. @@ -169,6 +158,28 @@ ? BFS_FLEX_LB(type, member, length) \ : BFS_FLEX_MAX(sizeof(type), BFS_FLEX_LB(type, member, length))) +/** + * Initialize a variable, unless sanitizers would detect uninitialized uses. + */ +#if __has_feature(memory_sanitizer) +# define BFS_UNINIT(var, value) var +#else +# define BFS_UNINIT(var, value) value +#endif + +// Wrappers for attributes + +/** + * Silence compiler warnings about switch/case fall-throughs. + */ +#if __has_c_attribute(fallthrough) +# define BFS_FALLTHROUGH [[fallthrough]] +#elif __has_attribute(fallthrough) +# define BFS_FALLTHROUGH __attribute__((fallthrough)) +#else +# define BFS_FALLTHROUGH ((void)0) +#endif + /** * Adds compiler warnings for bad printf()-style function calls, if supported. */ @@ -200,13 +211,4 @@ # define BFS_UNSUPPRESS() #endif -/** - * Initialize a variable, unless sanitizers would detect uninitialized uses. - */ -#if __has_feature(memory_sanitizer) -# define BFS_UNINIT(var, value) var -#else -# define BFS_UNINIT(var, value) value -#endif - #endif // BFS_CONFIG_H -- cgit v1.2.3