ucx
UAP Common Extensions
|
Main UCX Header providing most common definitions. More...
#include <stdlib.h>
#include <stdint.h>
#include <sys/types.h>
Go to the source code of this file.
Macros | |
#define | UCX_VERSION_MAJOR 2 |
Major UCX version as integer constant. More... | |
#define | UCX_VERSION_MINOR 1 |
Minor UCX version as integer constant. More... | |
#define | UCX_VERSION (((UCX_VERSION_MAJOR)<<16)|UCX_VERSION_MINOR) |
Version constant which ensures to increase monotonically. More... | |
#define | ucx_szmul(a, b, result) ucx_szmul_impl(a, b, result) |
Performs a multiplication of size_t values and checks for overflow. More... | |
Typedefs | |
typedef void(* | ucx_destructor) (void *) |
A function pointer to a destructor function. More... | |
typedef int(* | cmp_func) (const void *, const void *, void *) |
Function pointer to a compare function. More... | |
typedef intmax_t(* | distance_func) (const void *, const void *, void *) |
Function pointer to a distance function. More... | |
typedef void *(* | copy_func) (const void *, void *) |
Function pointer to a copy function. More... | |
typedef size_t(* | write_func) (const void *, size_t, size_t, void *) |
Function pointer to a write function. More... | |
typedef size_t(* | read_func) (void *, size_t, size_t, void *) |
Function pointer to a read function. More... | |
Functions | |
int | ucx_szmul_impl (size_t a, size_t b, size_t *result) |
Performs a multiplication of size_t values and checks for overflow. More... | |
Main UCX Header providing most common definitions.
#define ucx_szmul | ( | a, | |
b, | |||
result | |||
) | ucx_szmul_impl(a, b, result) |
Performs a multiplication of size_t values and checks for overflow.
a | first operand |
b | second operand |
result | a pointer to a size_t, where the result should be stored |
#define UCX_VERSION (((UCX_VERSION_MAJOR)<<16)|UCX_VERSION_MINOR) |
Version constant which ensures to increase monotonically.
#define UCX_VERSION_MAJOR 2 |
Major UCX version as integer constant.
#define UCX_VERSION_MINOR 1 |
Minor UCX version as integer constant.
typedef int(* cmp_func) (const void *, const void *, void *) |
Function pointer to a compare function.
The compare function shall take three arguments: the two values that shall be compared and optional additional data. The function shall then return -1 if the first argument is less than the second argument, 1 if the first argument is greater than the second argument and 0 if both arguments are equal. If the third argument is NULL
, it shall be ignored.
typedef void*(* copy_func) (const void *, void *) |
Function pointer to a copy function.
The copy function shall create a copy of the first argument and may use additional data provided by the second argument. If the second argument is NULL
, it shall be ignored.
Attention: if pointers returned by functions of this type may be passed to free()
depends on the implementation of the respective copy_func
.
typedef intmax_t(* distance_func) (const void *, const void *, void *) |
Function pointer to a distance function.
The distance function shall take three arguments: the two values for which the distance shall be computed and optional additional data. The function shall then return the signed distance as integer value.
typedef size_t(* read_func) (void *, size_t, size_t, void *) |
Function pointer to a read function.
The signature of the read function shall be compatible to the signature of standard fread
, though it may use arbitrary data types for source and destination.
The arguments shall contain (in ascending order): a pointer to the destination, the length of one element, the element count and a pointer to the source.
typedef void(* ucx_destructor) (void *) |
A function pointer to a destructor function.
typedef size_t(* write_func) (const void *, size_t, size_t, void *) |
Function pointer to a write function.
The signature of the write function shall be compatible to the signature of standard fwrite
, though it may use arbitrary data types for source and destination.
The arguments shall contain (in ascending order): a pointer to the source, the length of one element, the element count and a pointer to the destination.
int ucx_szmul_impl | ( | size_t | a, |
size_t | b, | ||
size_t * | result | ||
) |
Performs a multiplication of size_t values and checks for overflow.
This is a custom implementation in case there is no compiler builtin available.
a | first operand |
b | second operand |
result | a pointer to a size_t where the result should be stored |