universe@390: universe@390: universe@390:
universe@390: universe@390: universe@390: universe@390: universe@390:universe@390: |
universe@390: ucx
universe@390:
universe@390: UAP Common Extensions
universe@390: |
universe@390:
Main UCX Header providing most common definitions. universe@390: More...
universe@390:#include <stdlib.h>
#include <stdint.h>
#include <sys/types.h>
Go to the source code of this file.
universe@390:universe@390: 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... | |
universe@390: 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... | |
universe@390: 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.
universe@390: universe@390:#define ucx_szmul | universe@390:( | universe@390:universe@390: | a, | universe@390:
universe@390: | universe@390: | universe@390: | b, | universe@390:
universe@390: | universe@390: | universe@390: | result | universe@390:
universe@390: | ) | universe@390:ucx_szmul_impl(a, b, result) | universe@390:
Performs a multiplication of size_t values and checks for overflow.
universe@390: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) | universe@390:
Version constant which ensures to increase monotonically.
universe@390: universe@390:#define UCX_VERSION_MAJOR 2 | universe@390:
Major UCX version as integer constant.
universe@390: universe@390:#define UCX_VERSION_MINOR 1 | universe@390:
Minor UCX version as integer constant.
universe@390: universe@390:typedef int(* cmp_func) (const void *, const void *, void *) | universe@390:
Function pointer to a compare function.
universe@390: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 *) | universe@390:
Function pointer to a copy function.
universe@390: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 *) | universe@390:
Function pointer to a distance function.
universe@390: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.
universe@390: universe@390:typedef size_t(* read_func) (void *, size_t, size_t, void *) | universe@390:
Function pointer to a read function.
universe@390: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.
universe@390: universe@390:typedef void(* ucx_destructor) (void *) | universe@390:
A function pointer to a destructor function.
universe@390:typedef size_t(* write_func) (const void *, size_t, size_t, void *) | universe@390:
Function pointer to a write function.
universe@390: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.
universe@390: universe@390:int ucx_szmul_impl | universe@390:( | universe@390:size_t | universe@390:a, | universe@390:
universe@390: | universe@390: | size_t | universe@390:b, | universe@390:
universe@390: | universe@390: | size_t * | universe@390:result | universe@390:
universe@390: | ) | universe@390:universe@390: |
Performs a multiplication of size_t values and checks for overflow.
universe@390:This is a custom implementation in case there is no compiler builtin available.
universe@390:a | first operand |
b | second operand |
result | a pointer to a size_t where the result should be stored |