universe@390: universe@390: universe@390: universe@390: universe@390: universe@390: universe@390: universe@390: ucx: /home/mike/workspace/c/ucx/src/ucx/ucx.h File Reference universe@390: universe@390: universe@390: universe@390: universe@390: universe@390: universe@390: universe@390: universe@390: universe@390:
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:
universe@390: universe@390: universe@390: universe@390: universe@390: universe@390: universe@390: universe@390: universe@390:
universe@390:
universe@390: universe@390: universe@390:
universe@390: universe@390:
universe@390: universe@390: universe@390:
universe@390:
universe@390:
universe@390: Macros | universe@390: Typedefs | universe@390: Functions
universe@390:
universe@390:
ucx.h File Reference
universe@390:
universe@390:
universe@390: universe@390:

Main UCX Header providing most common definitions. universe@390: More...

universe@390:
#include <stdlib.h>
universe@390: #include <stdint.h>
universe@390: #include <sys/types.h>
universe@390:
universe@390:

Go to the source code of this file.

universe@390: universe@390: universe@390: universe@390: universe@390: universe@390: universe@390: universe@390: universe@390: universe@390: universe@390: universe@390: universe@390: universe@390: 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: universe@390: universe@390: universe@390: universe@390: universe@390: universe@390: universe@390: universe@390: universe@390: universe@390: universe@390: universe@390: universe@390: universe@390: universe@390: universe@390: universe@390: universe@390: universe@390:

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: universe@390: universe@390: universe@390: universe@390:

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...
 
universe@390:

Detailed Description

universe@390:

Main UCX Header providing most common definitions.

universe@390:
Author
Mike Becker
universe@390:
universe@390: Olaf Wintermann
universe@390:

Macro Definition Documentation

universe@390: universe@390:

◆ ucx_szmul

universe@390: universe@390:
universe@390:
universe@390: universe@390: universe@390: universe@390: universe@390: universe@390: universe@390: universe@390: universe@390: universe@390: universe@390: universe@390: universe@390: universe@390: universe@390: universe@390: universe@390: universe@390: universe@390: universe@390: universe@390: universe@390: universe@390: universe@390: universe@390:
#define ucx_szmul( a,
 b,
 result 
)   ucx_szmul_impl(a, b, result)
universe@390:
universe@390: universe@390:

Performs a multiplication of size_t values and checks for overflow.

universe@390:
Parameters
universe@390: universe@390: universe@390: universe@390: universe@390:
afirst operand
bsecond operand
resulta pointer to a size_t, where the result should be stored
universe@390:
universe@390:
universe@390:
Returns
zero, if no overflow occurred and the result is correct, non-zero otherwise
universe@390: universe@390:
universe@390:
universe@390: universe@390:

◆ UCX_VERSION

universe@390: universe@390:
universe@390:
universe@390: universe@390: universe@390: universe@390: universe@390:
#define UCX_VERSION   (((UCX_VERSION_MAJOR)<<16)|UCX_VERSION_MINOR)
universe@390:
universe@390: universe@390:

Version constant which ensures to increase monotonically.

universe@390: universe@390:
universe@390:
universe@390: universe@390:

◆ UCX_VERSION_MAJOR

universe@390: universe@390:
universe@390:
universe@390: universe@390: universe@390: universe@390: universe@390:
#define UCX_VERSION_MAJOR   2
universe@390:
universe@390: universe@390:

Major UCX version as integer constant.

universe@390: universe@390:
universe@390:
universe@390: universe@390:

◆ UCX_VERSION_MINOR

universe@390: universe@390:
universe@390:
universe@390: universe@390: universe@390: universe@390: universe@390:
#define UCX_VERSION_MINOR   1
universe@390:
universe@390: universe@390:

Minor UCX version as integer constant.

universe@390: universe@390:
universe@390:
universe@390:

Typedef Documentation

universe@390: universe@390:

◆ cmp_func

universe@390: universe@390:
universe@390:
universe@390: universe@390: universe@390: universe@390: universe@390:
typedef int(* cmp_func) (const void *, const void *, void *)
universe@390:
universe@390: 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.

universe@390: universe@390:
universe@390:
universe@390: universe@390:

◆ copy_func

universe@390: universe@390:
universe@390:
universe@390: universe@390: universe@390: universe@390: universe@390:
typedef void*(* copy_func) (const void *, void *)
universe@390:
universe@390: 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.

universe@390:

Attention: if pointers returned by functions of this type may be passed to free() depends on the implementation of the respective copy_func.

universe@390: universe@390:
universe@390:
universe@390: universe@390:

◆ distance_func

universe@390: universe@390:
universe@390:
universe@390: universe@390: universe@390: universe@390: universe@390:
typedef intmax_t(* distance_func) (const void *, const void *, void *)
universe@390:
universe@390: 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:
universe@390:
universe@390: universe@390:

◆ read_func

universe@390: universe@390:
universe@390:
universe@390: universe@390: universe@390: universe@390: universe@390:
typedef size_t(* read_func) (void *, size_t, size_t, void *)
universe@390:
universe@390: 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.

universe@390:

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:
universe@390:
universe@390: universe@390:

◆ ucx_destructor

universe@390: universe@390:
universe@390:
universe@390: universe@390: universe@390: universe@390: universe@390:
typedef void(* ucx_destructor) (void *)
universe@390:
universe@390: universe@390:

A function pointer to a destructor function.

universe@390:
See also
ucx_mempool_setdestr()
universe@390:
universe@390: ucx_mempool_regdestr()
universe@390: universe@390:
universe@390:
universe@390: universe@390:

◆ write_func

universe@390: universe@390:
universe@390:
universe@390: universe@390: universe@390: universe@390: universe@390:
typedef size_t(* write_func) (const void *, size_t, size_t, void *)
universe@390:
universe@390: 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.

universe@390:

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:
universe@390:
universe@390:

Function Documentation

universe@390: universe@390:

◆ ucx_szmul_impl()

universe@390: universe@390:
universe@390:
universe@390: universe@390: universe@390: universe@390: universe@390: universe@390: universe@390: universe@390: universe@390: universe@390: universe@390: universe@390: universe@390: universe@390: universe@390: universe@390: universe@390: universe@390: universe@390: universe@390: universe@390: universe@390: universe@390: universe@390: universe@390:
int ucx_szmul_impl (size_t a,
size_t b,
size_t * result 
)
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:
Parameters
universe@390: universe@390: universe@390: universe@390: universe@390:
afirst operand
bsecond operand
resulta pointer to a size_t where the result should be stored
universe@390:
universe@390:
universe@390:
Returns
zero, if no overflow occurred and the result is correct, non-zero otherwise
universe@390: universe@390:
universe@390:
universe@390:
universe@390: universe@390: universe@390: universe@390: