1 /*************************************************************************** 2 * 3 * BSD LICENSE 4 * 5 * Copyright(c) 2007-2023 Intel Corporation. All rights reserved. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 12 * * Redistributions of source code must retain the above copyright 13 * notice, this list of conditions and the following disclaimer. 14 * * Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in 16 * the documentation and/or other materials provided with the 17 * distribution. 18 * * Neither the name of Intel Corporation nor the names of its 19 * contributors may be used to endorse or promote products derived 20 * from this software without specific prior written permission. 21 * 22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 * 34 * 35 ***************************************************************************/ 36 37 /* 38 ***************************************************************************** 39 * Doxygen group definitions 40 ****************************************************************************/ 41 42 /** 43 ***************************************************************************** 44 * @file cpa_types.h 45 * 46 * @defgroup cpa_Types CPA Type Definition 47 * 48 * @ingroup cpa 49 * 50 * @description 51 * This is the CPA Type Definitions. 52 * 53 *****************************************************************************/ 54 55 #ifndef CPA_TYPES_H 56 #define CPA_TYPES_H 57 58 #ifdef __cplusplus 59 extern "C" { 60 #endif 61 62 #if defined (__FreeBSD__) && defined (_KERNEL) 63 64 /* FreeBSD kernel mode */ 65 #include <sys/types.h> 66 #include <sys/param.h> 67 #include <sys/kernel.h> 68 69 #else 70 71 /* Linux, FreeBSD, or Windows user mode */ 72 #include <stdio.h> 73 #include <stddef.h> 74 #include <stdint.h> 75 76 #endif 77 78 #if defined (WIN32) || defined (_WIN64) 79 /* nonstandard extension used : zero-sized array in struct/union */ 80 #pragma warning (disable: 4200) 81 #endif 82 83 typedef uint8_t Cpa8U; 84 /**< 85 * @file cpa_types.h 86 * @ingroup cpa_Types 87 * Unsigned byte base type. */ 88 typedef int8_t Cpa8S; 89 /**< 90 * @file cpa_types.h 91 * @ingroup cpa_Types 92 * Signed byte base type. */ 93 typedef uint16_t Cpa16U; 94 /**< 95 * @file cpa_types.h 96 * @ingroup cpa_Types 97 * Unsigned double-byte base type. */ 98 typedef int16_t Cpa16S; 99 /**< 100 * @file cpa_types.h 101 * @ingroup cpa_Types 102 * Signed double-byte base type. */ 103 typedef uint32_t Cpa32U; 104 /**< 105 * @file cpa_types.h 106 * @ingroup cpa_Types 107 * Unsigned quad-byte base type. */ 108 typedef int32_t Cpa32S; 109 /**< 110 * @file cpa_types.h 111 * @ingroup cpa_Types 112 * Signed quad-byte base type. */ 113 typedef uint64_t Cpa64U; 114 /**< 115 * @file cpa_types.h 116 * @ingroup cpa_Types 117 * Unsigned double-quad-byte base type. */ 118 typedef int64_t Cpa64S; 119 /**< 120 * @file cpa_types.h 121 * @ingroup cpa_Types 122 * Signed double-quad-byte base type. */ 123 124 /***************************************************************************** 125 * Generic Base Data Type definitions 126 *****************************************************************************/ 127 #ifndef NULL 128 #define NULL (0) 129 /**< 130 * @file cpa_types.h 131 * @ingroup cpa_Types 132 * NULL definition. */ 133 #endif 134 135 /** 136 ***************************************************************************** 137 * @ingroup cpa_Types 138 * Boolean type. 139 * 140 * @description 141 * Functions in this API use this type for Boolean variables that take 142 * true or false values. 143 * 144 *****************************************************************************/ 145 typedef enum _CpaBoolean 146 { 147 CPA_FALSE = (0==1), /**< False value */ 148 CPA_TRUE = (1==1) /**< True value */ 149 } CpaBoolean; 150 151 152 /** 153 ***************************************************************************** 154 * @ingroup cpa_Types 155 * Declare a bitmap of specified size (in bits). 156 * 157 * @description 158 * This macro is used to declare a bitmap of arbitrary size. 159 * 160 * To test whether a bit in the bitmap is set, use @ref 161 * CPA_BITMAP_BIT_TEST. 162 * 163 * While most uses of bitmaps on the API are read-only, macros are also 164 * provided to set (see @ref CPA_BITMAP_BIT_SET) and clear (see @ref 165 * CPA_BITMAP_BIT_CLEAR) bits in the bitmap. 166 *****************************************************************************/ 167 #define CPA_BITMAP(name, sizeInBits) \ 168 Cpa32U name[((sizeInBits)+31)/32] 169 170 #define CPA_BITMAP_BIT_TEST(bitmask, bit) \ 171 ((bitmask[(bit)/32]) & (0x1 << ((bit)%32))) 172 /**< 173 * @ingroup cpa_Types 174 * Test a specified bit in the specified bitmap. The bitmap may have been 175 * declared using @ref CPA_BITMAP. Returns a Boolean (true if the bit is 176 * set, false otherwise). */ 177 178 #define CPA_BITMAP_BIT_SET(bitmask, bit) \ 179 (bitmask[(bit)/32] |= (0x1 << ((bit)%32))) 180 /**< 181 * @file cpa_types.h 182 * @ingroup cpa_Types 183 * Set a specified bit in the specified bitmap. The bitmap may have been 184 * declared using @ref CPA_BITMAP. */ 185 186 #define CPA_BITMAP_BIT_CLEAR(bitmask, bit) \ 187 (bitmask[(bit)/32] &= ~(0x1 << ((bit)%32))) 188 /**< 189 * @ingroup cpa_Types 190 * Clear a specified bit in the specified bitmap. The bitmap may have been 191 * declared using @ref CPA_BITMAP. */ 192 193 194 /** 195 ********************************************************************** 196 * 197 * @ingroup cpa_Types 198 * 199 * @description 200 * Declare a function or type and mark it as deprecated so that 201 * usages get flagged with a warning. 202 * 203 ********************************************************************** 204 */ 205 #if defined(__GNUC__) || defined(__INTEL_COMPILER) || defined(_WIN64) 206 /* 207 * gcc and icc support the __attribute__ ((deprecated)) syntax for marking 208 * functions and other constructs as deprecated. 209 */ 210 /* 211 * Uncomment the deprecated macro if you need to see which structs are deprecated 212 */ 213 #define CPA_DEPRECATED 214 /*#define CPA_DEPRECATED __attribute__ ((deprecated)) */ 215 #else 216 /* 217 * for all other compilers, define deprecated to do nothing 218 * 219 */ 220 /* #define CPA_DEPRECATED_FUNC(func) func; #pragma deprecated(func) */ 221 #pragma message("WARNING: You need to implement the CPA_DEPRECATED macro for this compiler") 222 #define CPA_DEPRECATED 223 #endif 224 225 #ifdef __cplusplus 226 } /* close the extern "C" { */ 227 #endif 228 229 #endif /* CPA_TYPES_H */ 230