macros (C Macros)ο
Header: udo/macros.h
Table of contents (click to go)ο
Macrosο
Enumsο
Unionsο
Structsο
Functionsο
API Documentationο
UDO_APIο
-
UDO_APIο
Used to prevent C++ name mangling when
using library in a C++ software package.
/* Prevent c++ name mangling */ #ifdef __cplusplus #define UDO_API extern "C" #else #define UDO_API #endif
UDO_UNUSEDο
-
UDO_UNUSEDο
Informs the compiler that you expect a variable
to be unused and instructs compiler to not issue
a warning on the variable.
#define UDO_UNUSED __attribute__((unused))
UDO_INLINEο
-
UDO_INLINEο
βalways_inlineβ instructs GCC to
- Ignore flag
-fno-inline - Donβt produce external definition of afunction with external linkage.
- Ignore inlining limits. Use alloca(3) to inline.
#define UDO_INLINE inline __attribute__((always_inline))
UDO_STATIC_INLINEο
-
UDO_STATIC_INLINEο
βalways_inlineβ instructs GCC to
- Ignore flag
-fno-inline - Donβt produce external definition of afunction with external linkage.
- Ignore inlining limits. Use alloca(3) to inline.
Any function declared with static keyword will
be visible only to the source file itβs declared in.
#define UDO_STATIC_INLINE static inline __attribute__((always_inline))
UDO_DIR_NAME_MAXο
-
UDO_DIR_NAME_MAXο
Amount of character ext file system
support for directory paths.
#define UDO_DIR_NAME_MAX (1<<12)
UDO_FILE_NAME_MAXο
-
UDO_FILE_NAME_MAXο
Amount of character ext file system
support for a given file name.
#define UDO_FILE_NAME_MAX (1<<8)
UDO_FILE_PATH_MAXο
-
UDO_FILE_PATH_MAXο
Amount of character ext filesystem
supports when specifying a path and
file.
#define UDO_FILE_PATH_MAX (UDO_DIR_NAME_MAX + UDO_FILE_NAME_MAX)
UDO_MAXο
-
UDO_MAXο
Returns the maximum value between
a and b.
Param
Decription
a
Must pass an integer value.b
Must pass an integer value.#define UDO_MAX(a,b) \ ({ typeof (a) _a = (a); \ typeof (b) _b = (b); \ _a > _b ? _a : _b; })
UDO_MINο
-
UDO_MINο
Returns the minimum value between
a and b.
Param
Decription
a
Must pass an integer value.b
Must pass an integer value.#define UDO_MIN(a,b) \ ({ typeof (a) _a = (a); \ typeof (b) _b = (b); \ _a < _b ? _a : _b; })
- Returns:
Minimum value between2numbers
UDO_BYTE_ALIGNο
-
UDO_BYTE_ALIGNο
Returns the upper bound byte alignment value.
Alignment value must be a power of
2 number.
Param
Decription
bytes
Integer value to align.power_two_align
Power of2number to alignbytesto.#define UDO_BYTE_ALIGN(bytes, power_two_align) \ ((bytes+(power_two_align-1))&~(power_two_align-1))
- Returns
Upper bound memory alignment
UDO_PAGE_SIZEο
-
UDO_PAGE_SIZEο
Defines typical page size.
#define UDO_PAGE_SIZE (1<<12)
UDO_PAGE_GETο
-
UDO_PAGE_GETο
Retrieves the starting address of
the page
ptr resides in.
Param
Decription
ptr
Address caller wants to find page of.#define UDO_PAGE_GET(ptr) \ ((void*)((uintptr_t)ptr & ~(UDO_PAGE_SIZE-1)))
- Returns:
Starting address of the page
UDO_STRTOUο
-
UDO_STRTOUο
Converts string to an unsigned integer.
Simple one way hash function.
Param
Decription
str
Pointer to string to hash.#define UDO_STRTOU(str) \ __extension__ \ ({ \ __label__ __out; \ uint32_t hash=0; \ if (!str) goto __out; \ const char *s = str; \ while (*s) hash += *s++; \ __out: hash; \ })
- Returns:
unsignedinteger representing string
UDO_ATOMIC_DEFο
-
UDO_ATOMIC_DEFο
Create atomic variable type of a
caller defined data type.
Param
Decription
name
Name of atomic type.type
Data type of the atomic type.#define UDO_ATOMIC_DEF(name, type) \ typedef _Atomic __typeof__(type) name; /* Atomic Types */ UDO_ATOMIC_DEF(udo_atomic_int, int) UDO_ATOMIC_DEF(udo_atomic_bool, unsigned char) UDO_ATOMIC_DEF(udo_atomic_u32, unsigned int) UDO_ATOMIC_DEF(udo_atomic_addr, unsigned char *)
- Returns:
The atomic type