common: add GCC malloc and warn_unused_result attribute macro
This commit is contained in:
parent
35c9323de6
commit
1357057bd8
1 changed files with 14 additions and 0 deletions
|
@ -79,11 +79,22 @@ typedef uint64_t longtime_t;
|
||||||
#define GAME_EXPORT
|
#define GAME_EXPORT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define MALLOC __attribute__(( malloc ))
|
||||||
|
|
||||||
|
// added in GCC 11
|
||||||
|
#if __GNUC__ >= 11
|
||||||
|
// might want to set noclone due to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116893
|
||||||
|
// but it's easier to not force mismatched-dealloc to error yet
|
||||||
|
#define MALLOC_LIKE( x, y ) __attribute__(( malloc( x, y )))
|
||||||
|
#else
|
||||||
|
#define MALLOC_LIKE( x, y ) MALLOC
|
||||||
|
#endif
|
||||||
#define NORETURN __attribute__(( noreturn ))
|
#define NORETURN __attribute__(( noreturn ))
|
||||||
#define NONNULL __attribute__(( nonnull ))
|
#define NONNULL __attribute__(( nonnull ))
|
||||||
#define _format( x ) __attribute__(( format( printf, x, x + 1 )))
|
#define _format( x ) __attribute__(( format( printf, x, x + 1 )))
|
||||||
#define ALLOC_CHECK( x ) __attribute__(( alloc_size( x )))
|
#define ALLOC_CHECK( x ) __attribute__(( alloc_size( x )))
|
||||||
#define NO_ASAN __attribute__(( no_sanitize( "address" )))
|
#define NO_ASAN __attribute__(( no_sanitize( "address" )))
|
||||||
|
#define WARN_UNUSED_RESULT __attribute__(( warn_unused_result ))
|
||||||
#define RENAME_SYMBOL( x ) asm( x )
|
#define RENAME_SYMBOL( x ) asm( x )
|
||||||
#else
|
#else
|
||||||
#if defined( _MSC_VER )
|
#if defined( _MSC_VER )
|
||||||
|
@ -99,6 +110,9 @@ typedef uint64_t longtime_t;
|
||||||
#define _format( x )
|
#define _format( x )
|
||||||
#define ALLOC_CHECK( x )
|
#define ALLOC_CHECK( x )
|
||||||
#define RENAME_SYMBOL( x )
|
#define RENAME_SYMBOL( x )
|
||||||
|
#define MALLOC
|
||||||
|
#define MALLOC_LIKE( x, y )
|
||||||
|
#define WARN_UNUSED_RESULT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if __GNUC__ >= 3
|
#if __GNUC__ >= 3
|
||||||
|
|
Loading…
Add table
Reference in a new issue