|
CAEN Utility
2.0.2
Utilities for CAEN projects
|
Macros to set function attributes compilers and improve optimization. More...
Macros | |
| #define | c_attribute_format(_FMT_, _ARGS_) __attribute__((__format__(__printf__, _FMT_, _ARGS_))) |
| #define | c_attribute_alloc_size(...) __attribute__(()) |
| #define | c_declspec_allocator __declspec(allocator) |
| #define | c_attribute_malloc __attribute__((__malloc__)) |
| #define | c_attribute_pure __attribute__((__pure__)) |
| #define | c_attribute_nonnull(...) __attribute__((__nonnull__(__VA_ARGS__))) |
| #define | c_attribute_fallthrough c_nop |
| #define | c_force_inline inline |
| #define | c_nodiscard |
| #define | c_noreturn |
| #define | c_acquires_lock_on_success(m) |
| #define | c_releases_lock_on_success(m) |
| #define | c_use_decl_annotations |
Macros to set function attributes compilers and improve optimization.
| #define c_attribute_format | ( | _FMT_, | |
| _ARGS_ | |||
| ) | __attribute__((__format__(__printf__, _FMT_, _ARGS_))) |
The format attribute specifies that a function takes printf, scanf, strftime or strfmon style arguments that should be type-checked against a format string.
Definition at line 173 of file CAENUtility.h.
| #define c_attribute_alloc_size | ( | ... | ) | __attribute__(()) |
The alloc_size attribute is used to tell the compiler that the function return value points to memory, where the size is given by one or two of the functions parameters.
GCC uses this information to improve the correctness of __builtin_object_size. Works differently on clang: clang will only trace const pointers.
Definition at line 183 of file CAENUtility.h.
| #define c_declspec_allocator __declspec(allocator) |
The allocator __declspec is used to mark custom allocator functions, to work with the Visual Studio native memory profiler
The native memory profiler works by collecting allocation ETW event data emitted by during runtime. Any functions that return a pointer to newly allocated heap memory can be decorated with __declspec(allocator).
Definition at line 191 of file CAENUtility.h.
| #define c_attribute_malloc __attribute__((__malloc__)) |
This tells the compiler that a function is malloc-like.
It tells that the pointer P returned by the function cannot alias any other pointer valid when the function returns, and moreover no pointers to valid objects occur in any storage addressed by P. Using this attribute can improve optimization. Should not be used with realloc.
Definition at line 199 of file CAENUtility.h.
| #define c_attribute_pure __attribute__((__pure__)) |
Pure functions. Calls to such functions can be subject to common subexpression elimination and loop optimization just as an arithmetic operator would be.
Many functions have no effects except the return value and their return value depends only on the parameters and/or global variables.
Definition at line 205 of file CAENUtility.h.
| #define c_attribute_nonnull | ( | ... | ) | __attribute__((__nonnull__(__VA_ARGS__))) |
This tells the compiler that an attribute must be non-null.
The nonull function attribute allows to mark pointer parameters which must not be NULL. It causes the compiler to check that arguments are non-null. If the compiler determines that a null pointer is passed in an argument slot marked as non-null, and the -Wnonnull option is enabled, a warning is issued. The compiler may also choose to make optimizations based on the knowledge that certain function arguments will not be null.
Definition at line 213 of file CAENUtility.h.
| #define c_attribute_fallthrough c_nop |
Explicit fallthrough in switch cases.
To suppress warning given by -Wimplicit-fallthrough in GCC version 7 and above.
Definition at line 222 of file CAENUtility.h.
| #define c_force_inline inline |
Platform independent macro to force inline function
Definition at line 232 of file CAENUtility.h.
| #define c_nodiscard |
The compiler will warn if the return value of a function is not used
Equivalent of C++17 [[nodiscard]], but pn Windows the check is performed on static code analysis
Definition at line 245 of file CAENUtility.h.
| #define c_noreturn |
Equivalent to C11 _Noreturn
Equivalent of C++17 [[nodiscard]], but pn Windows the check is performed on static code analysis
Definition at line 258 of file CAENUtility.h.
| #define c_acquires_lock_on_success | ( | m | ) |
Portable version of When to annotate locks.
May be used on a function definition (also known as a function body) in place of the list of annotations in the header.
Definition at line 268 of file CAENUtility.h.
| #define c_releases_lock_on_success | ( | m | ) |
Definition at line 269 of file CAENUtility.h.
| #define c_use_decl_annotations |
Portable version of Use_decl_annotations macro to remove Visual Studio warnings in function definitions that have annotations in their declaration.
May be used on a function definition (also known as a function body) in place of the list of annotations in the header.
Definition at line 278 of file CAENUtility.h.