src/ucx/ucx.h

Tue, 23 Aug 2016 13:49:38 +0200

author
Mike Becker <universe@uap-core.de>
date
Tue, 23 Aug 2016 13:49:38 +0200
changeset 39
ac35daceb24c
permissions
-rw-r--r--

adds UCX + changes how the input file is read (uses an consecutive memory area now)

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

mercurial