1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/ucx/ucx.h Tue Aug 23 13:49:38 2016 +0200 1.3 @@ -0,0 +1,138 @@ 1.4 +/* 1.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 1.6 + * 1.7 + * Copyright 2015 Olaf Wintermann. All rights reserved. 1.8 + * 1.9 + * Redistribution and use in source and binary forms, with or without 1.10 + * modification, are permitted provided that the following conditions are met: 1.11 + * 1.12 + * 1. Redistributions of source code must retain the above copyright 1.13 + * notice, this list of conditions and the following disclaimer. 1.14 + * 1.15 + * 2. Redistributions in binary form must reproduce the above copyright 1.16 + * notice, this list of conditions and the following disclaimer in the 1.17 + * documentation and/or other materials provided with the distribution. 1.18 + * 1.19 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 1.20 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1.21 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1.22 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 1.23 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 1.24 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 1.25 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 1.26 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 1.27 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 1.28 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 1.29 + * POSSIBILITY OF SUCH DAMAGE. 1.30 + */ 1.31 +/** 1.32 + * Main UCX Header providing most common definitions. 1.33 + * 1.34 + * @file ucx.h 1.35 + * @author Mike Becker 1.36 + * @author Olaf Wintermann 1.37 + */ 1.38 + 1.39 +#ifndef UCX_H 1.40 +#define UCX_H 1.41 + 1.42 +/** Major UCX version as integer constant. */ 1.43 +#define UCX_VERSION_MAJOR 0 1.44 + 1.45 +/** Minor UCX version as integer constant. */ 1.46 +#define UCX_VERSION_MINOR 9 1.47 + 1.48 +/** The UCX version in format [major].[minor] */ 1.49 +#define UCX_VERSION UCX_VERSION_MAJOR.UCX_VERSION_MINOR 1.50 + 1.51 +#include <stdlib.h> 1.52 + 1.53 +#ifdef _WIN32 1.54 +#if !(defined __ssize_t_defined || defined _SSIZE_T_) 1.55 +#include <BaseTsd.h> 1.56 +typedef SSIZE_T ssize_t; 1.57 +#define __ssize_t_defined 1.58 +#define _SSIZE_T_ 1.59 +#endif /* __ssize_t_defined and _SSIZE_T */ 1.60 +#else /* !_WIN32 */ 1.61 +#include <sys/types.h> 1.62 +#endif /* _WIN32 */ 1.63 + 1.64 +#ifdef __cplusplus 1.65 +#ifndef _Bool 1.66 +#define _Bool bool 1.67 +#define restrict 1.68 +#endif 1.69 +/** Use C naming even when compiling with C++. */ 1.70 +#define UCX_EXTERN extern "C" 1.71 +extern "C" { 1.72 +#else 1.73 +/** Pointless in C. */ 1.74 +#define UCX_EXTERN 1.75 +#endif 1.76 + 1.77 + 1.78 +/** 1.79 + * A function pointer to a destructor function. 1.80 + * @see ucx_mempool_setdestr() 1.81 + * @see ucx_mempool_regdestr() 1.82 + */ 1.83 +typedef void(*ucx_destructor)(void*); 1.84 + 1.85 +/** 1.86 + * Function pointer to a compare function. 1.87 + * 1.88 + * The compare function shall take three arguments: the two values that shall be 1.89 + * compared and optional additional data. 1.90 + * The function shall then return -1 if the first argument is less than the 1.91 + * second argument, 1 if the first argument is greater than the second argument 1.92 + * and 0 if both arguments are equal. If the third argument is 1.93 + * <code>NULL</code>, it shall be ignored. 1.94 + */ 1.95 +typedef int(*cmp_func)(void*,void*,void*); 1.96 + 1.97 +/** 1.98 + * Function pointer to a copy function. 1.99 + * 1.100 + * The copy function shall create a copy of the first argument and may use 1.101 + * additional data provided by the second argument. If the second argument is 1.102 + * <code>NULL</code>, it shall be ignored. 1.103 + 1.104 + * <b>Attention:</b> if pointers returned by functions of this type may be 1.105 + * passed to <code>free()</code> depends on the implementation of the 1.106 + * respective <code>copy_func</code>. 1.107 + */ 1.108 +typedef void*(*copy_func)(void*,void*); 1.109 + 1.110 +/** 1.111 + * Function pointer to a write function. 1.112 + * 1.113 + * The signature of the write function shall be compatible to the signature 1.114 + * of standard <code>fwrite</code>, though it may use arbitrary data types for 1.115 + * source and destination. 1.116 + * 1.117 + * The arguments shall contain (in ascending order): a pointer to the source, 1.118 + * the length of one element, the element count and a pointer to the 1.119 + * destination. 1.120 + */ 1.121 +typedef size_t(*write_func)(const void*, size_t, size_t, void*); 1.122 + 1.123 +/** 1.124 + * Function pointer to a read function. 1.125 + * 1.126 + * The signature of the read function shall be compatible to the signature 1.127 + * of standard <code>fread</code>, though it may use arbitrary data types for 1.128 + * source and destination. 1.129 + * 1.130 + * The arguments shall contain (in ascending order): a pointer to the 1.131 + * destination, the length of one element, the element count and a pointer to 1.132 + * the source. 1.133 + */ 1.134 +typedef size_t(*read_func)(void*, size_t, size_t, void*); 1.135 + 1.136 +#ifdef __cplusplus 1.137 +} 1.138 +#endif 1.139 + 1.140 +#endif /* UCX_H */ 1.141 +