![]() |
ucx
UAP Common Extensions
|
Common definitions and feature checks. More...
#include <stdlib.h>
#include <stddef.h>
#include <stdbool.h>
#include <stdint.h>
#include <sys/types.h>
Go to the source code of this file.
Macros | |
#define | UCX_VERSION_MAJOR 3 |
Major UCX version as integer constant. | |
#define | UCX_VERSION_MINOR 1 |
Minor UCX version as integer constant. | |
#define | UCX_VERSION (((UCX_VERSION_MAJOR)<<16)|UCX_VERSION_MINOR) |
Version constant which ensures to increase monotonically. | |
#define | CX_WORDSIZE 64 |
The address width in bits on this platform. | |
#define | __attribute__(x) |
Removes GNU C attributes where they are not supported. | |
#define | cx_attr_nonnull __attribute__((__nonnull__)) |
All pointer arguments must be non-NULL. | |
#define | cx_attr_nonnull_arg(...) __attribute__((__nonnull__(__VA_ARGS__))) |
The specified pointer arguments must be non-NULL. | |
#define | cx_attr_returns_nonnull __attribute__((__returns_nonnull__)) |
The returned value is guaranteed to be non-NULL. | |
#define | cx_attr_malloc __attribute__((__malloc__)) |
The attributed function always returns freshly allocated memory. | |
#define | cx_attr_dealloc(...) |
Not supported in clang. | |
#define | cx_attr_dealloc_ucx cx_attr_dealloc(cxFree, 2) |
Shortcut to specify cxFree() as deallocator. | |
#define | cx_attr_allocsize(...) __attribute__((__alloc_size__(__VA_ARGS__))) |
Specifies the parameters from which the allocation size is calculated. | |
#define | cx_attr_access(mode, ...) |
No support for access attribute in GCC < 10. | |
#define | cx_attr_cstr_arg(idx) |
No support for null_terminated_string_arg in clang or GCC below 14. | |
#define | cx_attr_access_r(...) cx_attr_access(__read_only__, __VA_ARGS__) |
Specifies that the function will only read through the given pointer. | |
#define | cx_attr_access_rw(...) cx_attr_access(__read_write__, __VA_ARGS__) |
Specifies that the function will read and write through the given pointer. | |
#define | cx_attr_access_w(...) cx_attr_access(__write_only__, __VA_ARGS__) |
Specifies that the function will only write through the given pointer. | |
#define | cx_attr_unused __attribute__((__unused__)) |
Do not warn about unused variable. | |
#define | cx_attr_nodiscard __attribute__((__warn_unused_result__)) |
Warn about discarded return value. | |
#define | cx_attr_export |
Only used for building Windows DLLs. | |
#define | cx_nmemb(arr) (sizeof(arr)/sizeof((arr)[0])) |
Determines the number of members in a static C array. | |
#define | cx_szmul(a, b, result) cx_szmul_impl(a, b, result) |
Performs a multiplication of size_t values and checks for overflow. | |
Functions | |
int | cx_szmul_impl (size_t a, size_t b, size_t *result) |
Implementation of cx_szmul() when no compiler builtin is available. | |
Common definitions and feature checks.
#define cx_attr_access_r | ( | ... | ) | cx_attr_access(__read_only__, __VA_ARGS__) |
Specifies that the function will only read through the given pointer.
Takes one or two arguments: the index of the pointer and (optionally) the index of another argument specifying the maximum number of accessed bytes.
#define cx_attr_access_rw | ( | ... | ) | cx_attr_access(__read_write__, __VA_ARGS__) |
Specifies that the function will read and write through the given pointer.
Takes one or two arguments: the index of the pointer and (optionally) the index of another argument specifying the maximum number of accessed bytes.
#define cx_attr_access_w | ( | ... | ) | cx_attr_access(__write_only__, __VA_ARGS__) |
Specifies that the function will only write through the given pointer.
Takes one or two arguments: the index of the pointer and (optionally) the index of another argument specifying the maximum number of accessed bytes.
#define cx_nmemb | ( | arr | ) | (sizeof(arr)/sizeof((arr)[0])) |
Determines the number of members in a static C array.
arr | the array identifier |
#define cx_szmul | ( | a, | |
b, | |||
result ) cx_szmul_impl(a, b, result) |
Performs a multiplication of size_t values and checks for overflow.
a | (size_t ) first operand |
b | (size_t ) second operand |
result | (size_t* ) a pointer to a variable, where the result should be stored |
zero | success |
non-zero | the multiplication would overflow |
int cx_szmul_impl | ( | size_t | a, |
size_t | b, | ||
size_t * | result ) |
Implementation of cx_szmul() when no compiler builtin is available.
Do not use in application code.
a | first operand |
b | second operand |
result | a pointer to a variable, where the result should be stored |
zero | success |
non-zero | the multiplication would overflow |