|
ic-macros
0.1.5
|
#include "ic_macros/assert_constant.h"#include "ic_macros/assert_type.h"#include "ic_macros/enum_cast.h"#include "ic_macros/integer_cast.h"#include "zephyr/build_assert.h"#include "zephyr/util.h"Go to the source code of this file.
Macros | |
| #define | IC_G_ABS(x) ((x) < 0 ? (-(x)) : (x)) |
| Only use in global scope; absolute value. More... | |
| #define | IC_ABS(x) _IC_MAKE_SINGLE_EVAL_1(IC_G_ABS, x) |
| Absolute value. More... | |
| #define | IC_ANSI_RED "\x1b[31m" |
| #define | IC_ANSI_GREEN "\x1b[32m" |
| #define | IC_ANSI_YELLOW "\x1b[33m" |
| #define | IC_ANSI_BLUE "\x1b[34m" |
| #define | IC_ANSI_MAGENTA "\x1b[95m" |
| #define | IC_ANSI_CYAN "\x1b[96m" |
| #define | IC_ANSI_BOLD "\x1b[1m" |
| #define | IC_ANSI_DIM "\x1b[2m" |
| #define | IC_ANSI_DIM2 "\x1b[38;5;241m" |
| #define | IC_ANSI_NONE "" |
| #define | IC_ANSI_RESET "\x1b[0m" |
| #define | IC_INLINE inline __attribute__((always_inline)) |
| Inline the function regardless of optimization level. More... | |
| #define | IC_PACK __attribute__((packed)) |
| The packed attribute specifies that a variable or structure field should have the smallest possible alignment—one byte for a variable, and one bit for a field, unless you specify a larger value with the aligned attribute. More... | |
| #define | IC_CONST __attribute__((const)) |
| Calls to functions whose return value is not affected by changes to the observable state of the program and that have no observable effects on such state other than to return a value may lend themselves to optimizations such as common subexpression elimination. Declaring such functions with the const attribute allows GCC to avoid emitting some calls in repeated invocations of the function with the same argument values. More... | |
| #define | IC_PURE __attribute__((pure)) |
| Calls to functions that have no observable effects on the state of the program other than to return a value may lend themselves to optimizations such as common subexpression elimination. Declaring such functions with the pure attribute allows GCC to avoid emitting some calls in repeated invocations of the function with the same argument values. More... | |
| #define IC_ABS | ( | x | ) | _IC_MAKE_SINGLE_EVAL_1(IC_G_ABS, x) |
Absolute value.
Definition at line 36 of file ic_macros.h.
| #define IC_ANSI_BLUE "\x1b[34m" |
Definition at line 41 of file ic_macros.h.
| #define IC_ANSI_BOLD "\x1b[1m" |
Definition at line 44 of file ic_macros.h.
| #define IC_ANSI_CYAN "\x1b[96m" |
Definition at line 43 of file ic_macros.h.
| #define IC_ANSI_DIM "\x1b[2m" |
Definition at line 45 of file ic_macros.h.
| #define IC_ANSI_DIM2 "\x1b[38;5;241m" |
Definition at line 46 of file ic_macros.h.
| #define IC_ANSI_GREEN "\x1b[32m" |
Definition at line 39 of file ic_macros.h.
| #define IC_ANSI_MAGENTA "\x1b[95m" |
Definition at line 42 of file ic_macros.h.
| #define IC_ANSI_NONE "" |
Definition at line 47 of file ic_macros.h.
| #define IC_ANSI_RED "\x1b[31m" |
Definition at line 38 of file ic_macros.h.
| #define IC_ANSI_RESET "\x1b[0m" |
Definition at line 48 of file ic_macros.h.
| #define IC_ANSI_YELLOW "\x1b[33m" |
Definition at line 40 of file ic_macros.h.
| #define IC_CONST __attribute__((const)) |
Calls to functions whose return value is not affected by changes to the observable state of the program and that have no observable effects on such state other than to return a value may lend themselves to optimizations such as common subexpression elimination. Declaring such functions with the const attribute allows GCC to avoid emitting some calls in repeated invocations of the function with the same argument values.
For example, int square (int) attribute ((const)); tells GCC that subsequent calls to function square with the same argument value can be replaced by the result of the first call regardless of the statements in between.
The const attribute prohibits a function from reading objects that affect its return value between successive invocations. However, functions declared with the attribute can safely read objects that do not change their return value, such as non-volatile constants.
The const attribute imposes greater restrictions on a function’s definition than the similar pure attribute. Declaring the same function with both the const and the pure attribute is diagnosed. Because a const function cannot have any observable side effects it does not make sense for it to return void. Declaring such a function is diagnosed.
Definition at line 102 of file ic_macros.h.
| #define IC_G_ABS | ( | x | ) | ((x) < 0 ? (-(x)) : (x)) |
Only use in global scope; absolute value.
Definition at line 30 of file ic_macros.h.
| #define IC_INLINE inline __attribute__((always_inline)) |
Inline the function regardless of optimization level.
Generally, functions are not inlined unless optimization is specified. For functions declared inline, this attribute inlines the function independent of any restrictions that otherwise apply to inlining. Failure to inline such a function is diagnosed as an error. Note that if such a function is called indirectly the compiler may or may not inline it depending on optimization level and a failure to inline an indirect call may or may not be diagnosed.
Definition at line 60 of file ic_macros.h.
| #define IC_PACK __attribute__((packed)) |
The packed attribute specifies that a variable or structure field should have the smallest possible alignment—one byte for a variable, and one bit for a field, unless you specify a larger value with the aligned attribute.
Definition at line 68 of file ic_macros.h.
| #define IC_PURE __attribute__((pure)) |
Calls to functions that have no observable effects on the state of the program other than to return a value may lend themselves to optimizations such as common subexpression elimination. Declaring such functions with the pure attribute allows GCC to avoid emitting some calls in repeated invocations of the function with the same argument values.
The pure attribute prohibits a function from modifying the state of the program that is observable by means other than inspecting the function’s return value. However, functions declared with the pure attribute can safely read any non-volatile objects, and modify the value of objects in a way that does not affect their return value or the observable state of the program.
For example, int hash (char *) attribute ((pure)); tells GCC that subsequent calls to the function hash with the same string can be replaced by the result of the first call provided the state of the program observable by hash, including the contents of the array itself, does not change in between. Even though hash takes a non-const pointer argument it must not modify the array it points to, or any other object whose value the rest of the program may depend on. However, the caller may safely change the contents of the array between successive calls to the function (doing so disables the optimization). The restriction also applies to member objects referenced by the this pointer in C++ non-static member functions.
Some common examples of pure functions are strlen or memcmp. Interesting non-pure functions are functions with infinite loops or those depending on volatile memory or other system resource, that may change between consecutive calls (such as the standard C feof function in a multithreading environment).
Definition at line 142 of file ic_macros.h.