![]() Spin on an expression with a timeout and optional delay between iterationsĬommonly needed when waiting on hardware to complete an asynchronous request to read/write/initialize/reset, but useful for any expression. Wait for an expression to return true with a timeout. Parameters :Ģ^ceil(log2(x)) or 0 if 2^ceil(log2(x)) would saturate 64-bits KB ( x ) This macro expands its argument multiple times (to permit use in constant expressions), which must not have side effects. Value of x rounded down to the previous word boundary. Value of x rounded up to the next word boundary. Value of x rounded down to the previous multiple of align. Value of x rounded up to the next multiple of align. This can be used to, for ex., build an identifier out of two parts, where one of those parts may be, for ex, a number, another macro, or a macro argument. Type – name of the type that ptr is an element ofįield – the name of the field within the struct ptr points toĪ pointer to the structure that contains ptr CONCAT ( x, y ) Ĭoncatenate two tokens, x and y, into a combined token during the preprocessor pass. Struct foo *container = CONTAINER_OF(ptr, struct foo, bar) Ībove, container points at my_foo. Get a pointer to a structure containing the element. Validate CONTAINER_OF parameters, only applies to C mode. Parameters :ġ if the two elements are compatible, 0 if they are not CONTAINER_OF_VALIDATE ( ptr, type, field ) Validate if two entities have a compatible type. The array index of ptr within array, on success SAME_TYPE ( a, b ) ![]() With CONFIG_ASSERT=y, this macro will trigger a runtime assertion when ptr does not fall into the range of array. This macro behaves much like ARRAY_INDEX with the notable difference that it accepts any ptr in the range of array rather than exclusively a ptr aligned to an array-element boundary of array. Parameters :ġ if ptr is part of array, 0 otherwise ARRAY_INDEX_FLOOR ( array, ptr ) Īrray-index of ptr within array, rounded down. In C but not C++, this causes a compile error if array is not an array (e.g. The array index of ptr within array, on success PART_OF_ARRAY ( array, ptr ) Ĭheck if a pointer ptr lies within array. With CONFIG_ASSERT=y, this macro will trigger a runtime assertion when ptr does not fall into the range of array or when ptr is not aligned to an array-element boundary of array. Parameters :ġ if ptr is part of array, 0 otherwise ARRAY_INDEX ( array, ptr ) In C, passing a pointer as array causes a compile error. This macro can be seen as a slightly stricter version of PART_OF_ARRAY in that it also ensures that ptr is aligned to an array-element boundary of array. The results may not be particularly meaningful in this case. ![]() ![]() In C++, due to language limitations, this will accept as array any type that implements operator. This macro is available only from C, not C++. Zero if array has an array type, a compile error otherwise. ZERO_OR_COMPILE_ERROR ( cond ) Ġ if cond is true-ish causes a compile error otherwise. The result should be combined with other fields using a logical OR. Prepare a bitfield element using value with mask representing its field position and width. FIELD_GET ( mask, value ) Įxtract a bitfield element from value corresponding to the field mask mask. LSB_GET ( value ) Įxtract the Least Significant Bit from value. GENMASK64 ( h, l ) Ĭreate a contiguous 64-bit bitmask starting at bit position l and ending at position h. GENMASK ( h, l ) Ĭreate a contiguous bitmask starting at bit position l and ending at position h. INT_TO_POINTER ( x ) Ĭast x, a signed integer, to a void*. POINTER_TO_INT ( x ) Ĭast x, a pointer, to a signed integer. UINT_TO_POINTER ( x ) Ĭast x, an unsigned integer, to a void*. Cast x, a pointer, to an unsigned integer.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |