1 /* 2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 * 4 * Copyright 2016 Olaf Wintermann. All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions are met: 8 * 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 * POSSIBILITY OF SUCH DAMAGE. 27 */ 28 /** 29 * Main UCX Header providing most common definitions. 30 * 31 * @file ucx.h 32 * @author Mike Becker 33 * @author Olaf Wintermann 34 */ 35 36 #ifndefUCX_H 37 #defineUCX_H 38 39 /** Major UCX version as integer constant. */ 40 #defineUCX_VERSION_MAJOR0 41 42 /** Minor UCX version as integer constant. */ 43 #defineUCX_VERSION_MINOR10 44 45 #include<stdlib.h> 46 47 #ifdef_WIN32 48 #if !(defined __ssize_t_defined || defined _SSIZE_T_)
49 #include<BaseTsd.h> 50 typedefSSIZE_Tssize_t;
51 #define __ssize_t_defined
52 #define_SSIZE_T_ 53 #endif/* __ssize_t_defined and _SSIZE_T */ 54 #else/* !_WIN32 */ 55 #include<sys/types.h> 56 #endif/* _WIN32 */ 57 58 #ifdef __cplusplus
59 #ifndef _Bool
60 #define _Bool bool
61 #define restrict
62 #endif 63 /** Use C naming even when compiling with C++. */ 64 #defineUCX_EXTERNextern"C" 65 extern"C" {
66 #else 67 /** Pointless in C. */ 68 #defineUCX_EXTERN 69 #endif 70 71 72 /** 73 * A function pointer to a destructor function. 74 * @see ucx_mempool_setdestr() 75 * @see ucx_mempool_regdestr() 76 */ 77 typedefvoid(*ucx_destructor)(void*);
78 79 /** 80 * Function pointer to a compare function. 81 * 82 * The compare function shall take three arguments: the two values that shall be 83 * compared and optional additional data. 84 * The function shall then return -1 if the first argument is less than the 85 * second argument, 1 if the first argument is greater than the second argument 86 * and 0 if both arguments are equal. If the third argument is 87 * <code>NULL</code>, it shall be ignored. 88 */ 89 typedefint(*cmp_func)(void*,void*,void*);
90 91 /** 92 * Function pointer to a copy function. 93 * 94 * The copy function shall create a copy of the first argument and may use 95 * additional data provided by the second argument. If the second argument is 96 * <code>NULL</code>, it shall be ignored. 97 98 * <b>Attention:</b> if pointers returned by functions of this type may be 99 * passed to <code>free()</code> depends on the implementation of the100 * respective <code>copy_func</code>.101 */102 typedefvoid*(*copy_func)(void*,void*);
103 104 /**105 * Function pointer to a write function.106 * 107 * The signature of the write function shall be compatible to the signature108 * of standard <code>fwrite</code>, though it may use arbitrary data types for109 * source and destination.110 * 111 * The arguments shall contain (in ascending order): a pointer to the source,112 * the length of one element, the element count and a pointer to the113 * destination.114 */115 typedefsize_t(*write_func)(constvoid*, size_t, size_t, void*);
116 117 /**118 * Function pointer to a read function.119 * 120 * The signature of the read function shall be compatible to the signature121 * of standard <code>fread</code>, though it may use arbitrary data types for122 * source and destination.123 * 124 * The arguments shall contain (in ascending order): a pointer to the125 * destination, the length of one element, the element count and a pointer to126 * the source.127 */128 typedefsize_t(*read_func)(void*, size_t, size_t, void*);
129 130 #ifdef __cplusplus
131 }
132 #endif133 134 #endif/* UCX_H */135 136