|
libusual
0.1
|
Basic C environment. More...
Defines | |
| #define | PRIdZ |
| printf 'd' format specifier for ssize_t | |
| #define | PRIiZ |
| printf 'i' format specifier for ssize_t | |
| #define | PRIoZ |
| printf 'o' format specifier for size_t | |
| #define | PRIuZ |
| printf 'u' format specifier for size_t | |
| #define | PRIxZ |
| printf 'x' format specifier for size_t | |
| #define | PRIXZ |
| printf 'X' format specifier for size_t | |
| #define | offsetof(type, field) |
| give offset of a field inside struct | |
| #define | container_of(ptr, type, field) |
| given pointer to field inside struct, return pointer to struct | |
| #define | alignof(type) |
| get alignment requirement for a type | |
| #define | CUSTOM_ALIGN(x, a) |
| power-of-2 alignment | |
| #define | ALIGN(x) |
| preferred alignment | |
| #define | ARRAY_NELEM(a) |
| number of elements in array | |
| #define | FLEX_ARRAY |
| Compat helper to specify array with unknown length. | |
| #define | STR(x) |
| Make string token from C expression. | |
| #define | CONCAT(a, b) |
| Make single C token from 2 separate tokens. | |
| #define | CONCAT3(a, b, c) |
| Make single C token from 3 separate tokens. | |
| #define | CONCAT4(a, b, c, d) |
| Make single C token from 4 separate tokens. | |
| #define | __func__ |
| Pre-processor macro for current function name. | |
| #define | static_assert(expr, msg) |
| Compile-time assert. | |
| #define | Assert(e) |
| assert() that uses <usual/logging> module | |
| #define | free(x) |
| Compat: make free() accept const pointer. | |
Compiler checks, mainly for internal usage. | |
| #define | _COMPILER_GNUC(maj, min) |
| Pre-processor macro to check if compiler is GCC with high enough version. | |
| #define | _COMPILER_CLANG(maj, min) |
| Pre-processor macro to check if compiler is CLANG with high enough version. | |
| #define | _COMPILER_MSC(ver) |
| Pre-processor macro to check if compiler is Visual C with high enough version. | |
| #define | _COMPILER_ICC(ver) |
| Pre-processor macro to check if compiler is Intel CC with high enough version. | |
| #define | __has_builtin(x) |
| #define | __has_feature(x) |
| #define | __has_extension(x) |
| #define | __has_attribute(x) |
Function/struct attributes. | |
| #define | _PACKED |
| Disable padding for structure. | |
| #define | _MUSTCHECK |
| Show warning if function result is not used. | |
| #define | _DEPRECATED |
| Show warning if used. | |
| #define | _PRINTF(fmtpos, argpos) |
| Check printf-style format and arg sanity. | |
| #define | _MALLOC |
| Function returns new pointer. | |
| #define | _UNUSED |
| Disable 'unused' warning for function/argument. | |
| #define | _NOINLINE |
| Do not inline function. | |
| #define | _NORETURN |
| Indicates that function never returns. | |
| #define | likely(x) |
| Hint for compiler that expression (x) is likely to be true. | |
| #define | unlikely(x) |
| Hint for compiler that expression (x) is likely to be false. | |
Functions | |
| static _MUSTCHECK void * | zmalloc (size_t len) |
| Zeroing malloc. | |
| int | posix_memalign (void **ptr_p, size_t align, size_t len) |
| Compat: posix_memalign() | |
| void * | reallocarray (void *p, size_t count, size_t size) |
| Same as realloc(), but safely calculates total size. | |
Basic C environment.
| #define PRIdZ |
printf 'd' format specifier for ssize_t
| #define PRIiZ |
printf 'i' format specifier for ssize_t
| #define PRIoZ |
printf 'o' format specifier for size_t
| #define PRIuZ |
printf 'u' format specifier for size_t
| #define PRIxZ |
printf 'x' format specifier for size_t
| #define PRIXZ |
printf 'X' format specifier for size_t
| #define offsetof | ( | type, | |
| field | |||
| ) |
give offset of a field inside struct
| #define container_of | ( | ptr, | |
| type, | |||
| field | |||
| ) |
given pointer to field inside struct, return pointer to struct
Referenced by hashtab_delete().
| #define alignof | ( | type | ) |
get alignment requirement for a type
| #define CUSTOM_ALIGN | ( | x, | |
| a | |||
| ) |
power-of-2 alignment
| #define ALIGN | ( | x | ) |
preferred alignment
| #define ARRAY_NELEM | ( | a | ) |
number of elements in array
| #define FLEX_ARRAY |
| #define STR | ( | x | ) |
Make string token from C expression.
| #define CONCAT | ( | a, | |
| b | |||
| ) |
Make single C token from 2 separate tokens.
| #define CONCAT3 | ( | a, | |
| b, | |||
| c | |||
| ) |
Make single C token from 3 separate tokens.
| #define CONCAT4 | ( | a, | |
| b, | |||
| c, | |||
| d | |||
| ) |
Make single C token from 4 separate tokens.
| #define __func__ |
Pre-processor macro for current function name.
| #define _COMPILER_GNUC | ( | maj, | |
| min | |||
| ) |
Pre-processor macro to check if compiler is GCC with high enough version.
| #define _COMPILER_CLANG | ( | maj, | |
| min | |||
| ) |
Pre-processor macro to check if compiler is CLANG with high enough version.
| #define _COMPILER_MSC | ( | ver | ) |
Pre-processor macro to check if compiler is Visual C with high enough version.
| #define _COMPILER_ICC | ( | ver | ) |
Pre-processor macro to check if compiler is Intel CC with high enough version.
| #define _PACKED |
Disable padding for structure.
| #define _MUSTCHECK |
Show warning if function result is not used.
| #define _DEPRECATED |
Show warning if used.
| #define _PRINTF | ( | fmtpos, | |
| argpos | |||
| ) |
Check printf-style format and arg sanity.
| #define _MALLOC |
Function returns new pointer.
| #define _UNUSED |
Disable 'unused' warning for function/argument.
| #define _NOINLINE |
Do not inline function.
| #define _NORETURN |
Indicates that function never returns.
| #define likely | ( | x | ) |
Hint for compiler that expression (x) is likely to be true.
| #define unlikely | ( | x | ) |
Hint for compiler that expression (x) is likely to be false.
| #define static_assert | ( | expr, | |
| msg | |||
| ) |
Compile-time assert.
Expression must be evaluatable at compile time. If false, stop compilation with message.
It can be used in either global or function scope.
| #define Assert | ( | e | ) |
assert() that uses <usual/logging> module
| #define free | ( | x | ) |
Compat: make free() accept const pointer.
Referenced by mbuf_free().
| static _MUSTCHECK void* zmalloc | ( | size_t | len | ) | [inline, static] |
Zeroing malloc.
| int posix_memalign | ( | void ** | ptr_p, |
| size_t | align, | ||
| size_t | len | ||
| ) |
Compat: posix_memalign()
| void* reallocarray | ( | void * | p, |
| size_t | count, | ||
| size_t | size | ||
| ) |
Same as realloc(), but safely calculates total size.
1.7.6.1