ucx/ucx.h

Tue, 17 Oct 2017 15:15:54 +0200

author
Mike Becker <universe@uap-core.de>
date
Tue, 17 Oct 2017 15:15:54 +0200
changeset 250
b7d1317b138e
parent 244
98dc2d3a9b1d
permissions
-rw-r--r--

updates license

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

mercurial