universe@39: /* universe@39: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. universe@39: * universe@39: * Copyright 2015 Olaf Wintermann. All rights reserved. universe@39: * universe@39: * Redistribution and use in source and binary forms, with or without universe@39: * modification, are permitted provided that the following conditions are met: universe@39: * universe@39: * 1. Redistributions of source code must retain the above copyright universe@39: * notice, this list of conditions and the following disclaimer. universe@39: * universe@39: * 2. Redistributions in binary form must reproduce the above copyright universe@39: * notice, this list of conditions and the following disclaimer in the universe@39: * documentation and/or other materials provided with the distribution. universe@39: * universe@39: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" universe@39: * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE universe@39: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE universe@39: * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE universe@39: * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR universe@39: * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF universe@39: * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS universe@39: * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN universe@39: * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) universe@39: * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE universe@39: * POSSIBILITY OF SUCH DAMAGE. universe@39: */ universe@39: /** universe@39: * Main UCX Header providing most common definitions. universe@39: * universe@39: * @file ucx.h universe@39: * @author Mike Becker universe@39: * @author Olaf Wintermann universe@39: */ universe@39: universe@39: #ifndef UCX_H universe@39: #define UCX_H universe@39: universe@39: /** Major UCX version as integer constant. */ universe@39: #define UCX_VERSION_MAJOR 0 universe@39: universe@39: /** Minor UCX version as integer constant. */ universe@39: #define UCX_VERSION_MINOR 9 universe@39: universe@39: /** The UCX version in format [major].[minor] */ universe@39: #define UCX_VERSION UCX_VERSION_MAJOR.UCX_VERSION_MINOR universe@39: universe@39: #include universe@39: universe@39: #ifdef _WIN32 universe@39: #if !(defined __ssize_t_defined || defined _SSIZE_T_) universe@39: #include universe@39: typedef SSIZE_T ssize_t; universe@39: #define __ssize_t_defined universe@39: #define _SSIZE_T_ universe@39: #endif /* __ssize_t_defined and _SSIZE_T */ universe@39: #else /* !_WIN32 */ universe@39: #include universe@39: #endif /* _WIN32 */ universe@39: universe@39: #ifdef __cplusplus universe@39: #ifndef _Bool universe@39: #define _Bool bool universe@39: #define restrict universe@39: #endif universe@39: /** Use C naming even when compiling with C++. */ universe@39: #define UCX_EXTERN extern "C" universe@39: extern "C" { universe@39: #else universe@39: /** Pointless in C. */ universe@39: #define UCX_EXTERN universe@39: #endif universe@39: universe@39: universe@39: /** universe@39: * A function pointer to a destructor function. universe@39: * @see ucx_mempool_setdestr() universe@39: * @see ucx_mempool_regdestr() universe@39: */ universe@39: typedef void(*ucx_destructor)(void*); universe@39: universe@39: /** universe@39: * Function pointer to a compare function. universe@39: * universe@39: * The compare function shall take three arguments: the two values that shall be universe@39: * compared and optional additional data. universe@39: * The function shall then return -1 if the first argument is less than the universe@39: * second argument, 1 if the first argument is greater than the second argument universe@39: * and 0 if both arguments are equal. If the third argument is universe@39: * NULL, it shall be ignored. universe@39: */ universe@39: typedef int(*cmp_func)(void*,void*,void*); universe@39: universe@39: /** universe@39: * Function pointer to a copy function. universe@39: * universe@39: * The copy function shall create a copy of the first argument and may use universe@39: * additional data provided by the second argument. If the second argument is universe@39: * NULL, it shall be ignored. universe@39: universe@39: * Attention: if pointers returned by functions of this type may be universe@39: * passed to free() depends on the implementation of the universe@39: * respective copy_func. universe@39: */ universe@39: typedef void*(*copy_func)(void*,void*); universe@39: universe@39: /** universe@39: * Function pointer to a write function. universe@39: * universe@39: * The signature of the write function shall be compatible to the signature universe@39: * of standard fwrite, though it may use arbitrary data types for universe@39: * source and destination. universe@39: * universe@39: * The arguments shall contain (in ascending order): a pointer to the source, universe@39: * the length of one element, the element count and a pointer to the universe@39: * destination. universe@39: */ universe@39: typedef size_t(*write_func)(const void*, size_t, size_t, void*); universe@39: universe@39: /** universe@39: * Function pointer to a read function. universe@39: * universe@39: * The signature of the read function shall be compatible to the signature universe@39: * of standard fread, though it may use arbitrary data types for universe@39: * source and destination. universe@39: * universe@39: * The arguments shall contain (in ascending order): a pointer to the universe@39: * destination, the length of one element, the element count and a pointer to universe@39: * the source. universe@39: */ universe@39: typedef size_t(*read_func)(void*, size_t, size_t, void*); universe@39: universe@39: #ifdef __cplusplus universe@39: } universe@39: #endif universe@39: universe@39: #endif /* UCX_H */ universe@39: