Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenlib/BLI_compiler_attrs.h
| Show All 19 Lines | |||||
| */ | */ | ||||
| #ifdef __GNUC__ | #ifdef __GNUC__ | ||||
| # define ATTR_NONNULL(args...) __attribute__((nonnull(args))) | # define ATTR_NONNULL(args...) __attribute__((nonnull(args))) | ||||
| #else | #else | ||||
| # define ATTR_NONNULL(...) | # define ATTR_NONNULL(...) | ||||
| #endif | #endif | ||||
| /* never returns NULL */ | /* never returns NULL */ | ||||
| #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 409 /* gcc4.9+ only */ | #ifdef __GNUC__ | ||||
| # define ATTR_RETURNS_NONNULL __attribute__((returns_nonnull)) | # define ATTR_RETURNS_NONNULL __attribute__((returns_nonnull)) | ||||
| #else | #else | ||||
| # define ATTR_RETURNS_NONNULL | # define ATTR_RETURNS_NONNULL | ||||
| #endif | #endif | ||||
| /* hint to mark function as it wouldn't return */ | /* hint to mark function as it wouldn't return */ | ||||
| #if defined(__GNUC__) || defined(__clang__) | #if defined(__GNUC__) || defined(__clang__) | ||||
| # define ATTR_NORETURN __attribute__((noreturn)) | # define ATTR_NORETURN __attribute__((noreturn)) | ||||
| #else | #else | ||||
| # define ATTR_NORETURN | # define ATTR_NORETURN | ||||
| #endif | #endif | ||||
| /* hint to treat any non-null function return value cannot alias any other pointer */ | /* hint to treat any non-null function return value cannot alias any other pointer */ | ||||
| #if (defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 403)) | #ifdef __GNUC__ | ||||
| # define ATTR_MALLOC __attribute__((malloc)) | # define ATTR_MALLOC __attribute__((malloc)) | ||||
| #else | #else | ||||
| # define ATTR_MALLOC | # define ATTR_MALLOC | ||||
| #endif | #endif | ||||
| /* the function return value points to memory (2 args for 'size * tot') */ | /* the function return value points to memory (2 args for 'size * tot') */ | ||||
| #if (defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 403)) | #ifdef __GNUC__ | ||||
| # define ATTR_ALLOC_SIZE(args...) __attribute__((alloc_size(args))) | # define ATTR_ALLOC_SIZE(args...) __attribute__((alloc_size(args))) | ||||
| #else | #else | ||||
| # define ATTR_ALLOC_SIZE(...) | # define ATTR_ALLOC_SIZE(...) | ||||
| #endif | #endif | ||||
| /* ensures a NULL terminating argument as the n'th last argument of a variadic function */ | /* ensures a NULL terminating argument as the n'th last argument of a variadic function */ | ||||
| #ifdef __GNUC__ | #ifdef __GNUC__ | ||||
| # define ATTR_SENTINEL(arg_pos) __attribute__((sentinel(arg_pos))) | # define ATTR_SENTINEL(arg_pos) __attribute__((sentinel(arg_pos))) | ||||
| #else | #else | ||||
| # define ATTR_SENTINEL(arg_pos) | # define ATTR_SENTINEL(arg_pos) | ||||
| #endif | #endif | ||||
| /* hint to compiler that function uses printf-style format string */ | /* hint to compiler that function uses printf-style format string */ | ||||
| #ifdef __GNUC__ | #ifdef __GNUC__ | ||||
| # define ATTR_PRINTF_FORMAT(format_param, dots_param) \ | # define ATTR_PRINTF_FORMAT(format_param, dots_param) \ | ||||
| __attribute__((format(printf, format_param, dots_param))) | __attribute__((format(printf, format_param, dots_param))) | ||||
| #else | #else | ||||
| # define ATTR_PRINTF_FORMAT(format_param, dots_param) | # define ATTR_PRINTF_FORMAT(format_param, dots_param) | ||||
| #endif | #endif | ||||
| /* Use to suppress '-Wimplicit-fallthrough' (in place of 'break'). */ | /* Use to suppress '-Wimplicit-fallthrough' (in place of 'break'). */ | ||||
| #ifndef ATTR_FALLTHROUGH | #ifndef ATTR_FALLTHROUGH | ||||
| # if defined(__GNUC__) && (__GNUC__ >= 7) /* gcc7.0+ only */ | # ifdef __GNUC__ | ||||
| # define ATTR_FALLTHROUGH __attribute__((fallthrough)) | # define ATTR_FALLTHROUGH __attribute__((fallthrough)) | ||||
| # else | # else | ||||
| # define ATTR_FALLTHROUGH ((void)0) | # define ATTR_FALLTHROUGH ((void)0) | ||||
| # endif | # endif | ||||
| #endif | #endif | ||||
| /* Declare the memory alignment in Bytes. */ | /* Declare the memory alignment in Bytes. */ | ||||
| #if defined(_WIN32) && !defined(FREE_WINDOWS) | #if defined(_WIN32) && !defined(FREE_WINDOWS) | ||||
| Show All 11 Lines | |||||