1 /* SPDX-License-Identifier: BSD-3-Clause */ 2 /* Copyright(c) 2007-2025 Intel Corporation */ 3 4 /* 5 ***************************************************************************** 6 * Doxygen group definitions 7 ****************************************************************************/ 8 9 /** 10 ***************************************************************************** 11 * @file cpa_types.h 12 * 13 * @defgroup cpa_Types CPA Type Definition 14 * 15 * @ingroup cpa 16 * 17 * @description 18 * This is the CPA Type Definitions. 19 * 20 *****************************************************************************/ 21 22 #ifndef CPA_TYPES_H 23 #define CPA_TYPES_H 24 25 #ifdef __cplusplus 26 extern "C" { 27 #endif 28 29 #if defined (__FreeBSD__) && defined (_KERNEL) 30 31 /* FreeBSD kernel mode */ 32 #include <sys/types.h> 33 #include <sys/param.h> 34 #include <sys/kernel.h> 35 36 #else 37 38 /* Linux, FreeBSD, or Windows user mode */ 39 #include <stdio.h> 40 #include <stddef.h> 41 #include <stdint.h> 42 43 #endif 44 45 #if defined (WIN32) || defined (_WIN64) 46 /* nonstandard extension used : zero-sized array in struct/union */ 47 #pragma warning (disable: 4200) 48 #endif 49 50 typedef uint8_t Cpa8U; 51 /**< 52 * @file cpa_types.h 53 * @ingroup cpa_Types 54 * Unsigned byte base type. */ 55 typedef int8_t Cpa8S; 56 /**< 57 * @file cpa_types.h 58 * @ingroup cpa_Types 59 * Signed byte base type. */ 60 typedef uint16_t Cpa16U; 61 /**< 62 * @file cpa_types.h 63 * @ingroup cpa_Types 64 * Unsigned double-byte base type. */ 65 typedef int16_t Cpa16S; 66 /**< 67 * @file cpa_types.h 68 * @ingroup cpa_Types 69 * Signed double-byte base type. */ 70 typedef uint32_t Cpa32U; 71 /**< 72 * @file cpa_types.h 73 * @ingroup cpa_Types 74 * Unsigned quad-byte base type. */ 75 typedef int32_t Cpa32S; 76 /**< 77 * @file cpa_types.h 78 * @ingroup cpa_Types 79 * Signed quad-byte base type. */ 80 typedef uint64_t Cpa64U; 81 /**< 82 * @file cpa_types.h 83 * @ingroup cpa_Types 84 * Unsigned double-quad-byte base type. */ 85 typedef int64_t Cpa64S; 86 /**< 87 * @file cpa_types.h 88 * @ingroup cpa_Types 89 * Signed double-quad-byte base type. */ 90 91 /***************************************************************************** 92 * Generic Base Data Type definitions 93 *****************************************************************************/ 94 #ifndef NULL 95 #define NULL (0) 96 /**< 97 * @file cpa_types.h 98 * @ingroup cpa_Types 99 * NULL definition. */ 100 #endif 101 102 /** 103 ***************************************************************************** 104 * @ingroup cpa_Types 105 * Boolean type. 106 * 107 * @description 108 * Functions in this API use this type for Boolean variables that take 109 * true or false values. 110 * 111 *****************************************************************************/ 112 typedef enum _CpaBoolean 113 { 114 CPA_FALSE = (0==1), /**< False value */ 115 CPA_TRUE = (1==1) /**< True value */ 116 } CpaBoolean; 117 118 119 /** 120 ***************************************************************************** 121 * @ingroup cpa_Types 122 * Declare a bitmap of specified size (in bits). 123 * 124 * @description 125 * This macro is used to declare a bitmap of arbitrary size. 126 * 127 * To test whether a bit in the bitmap is set, use @ref 128 * CPA_BITMAP_BIT_TEST. 129 * 130 * While most uses of bitmaps on the API are read-only, macros are also 131 * provided to set (see @ref CPA_BITMAP_BIT_SET) and clear (see @ref 132 * CPA_BITMAP_BIT_CLEAR) bits in the bitmap. 133 *****************************************************************************/ 134 #define CPA_BITMAP(name, sizeInBits) \ 135 Cpa32U name[((sizeInBits)+31)/32] 136 137 #define CPA_BITMAP_BIT_TEST(bitmask, bit) \ 138 ((bitmask[(bit)/32]) & (0x1 << ((bit)%32))) 139 /**< 140 * @ingroup cpa_Types 141 * Test a specified bit in the specified bitmap. The bitmap may have been 142 * declared using @ref CPA_BITMAP. Returns a Boolean (true if the bit is 143 * set, false otherwise). */ 144 145 #define CPA_BITMAP_BIT_SET(bitmask, bit) \ 146 (bitmask[(bit)/32] |= (0x1 << ((bit)%32))) 147 /**< 148 * @file cpa_types.h 149 * @ingroup cpa_Types 150 * Set a specified bit in the specified bitmap. The bitmap may have been 151 * declared using @ref CPA_BITMAP. */ 152 153 #define CPA_BITMAP_BIT_CLEAR(bitmask, bit) \ 154 (bitmask[(bit)/32] &= ~(0x1 << ((bit)%32))) 155 /**< 156 * @ingroup cpa_Types 157 * Clear a specified bit in the specified bitmap. The bitmap may have been 158 * declared using @ref CPA_BITMAP. */ 159 160 161 /** 162 ********************************************************************** 163 * 164 * @ingroup cpa_Types 165 * 166 * @description 167 * Declare a function or type and mark it as deprecated so that 168 * usages get flagged with a warning. 169 * 170 ********************************************************************** 171 */ 172 #if defined(__GNUC__) || defined(__INTEL_COMPILER) || defined(_WIN64) 173 /* 174 * gcc and icc support the __attribute__ ((deprecated)) syntax for marking 175 * functions and other constructs as deprecated. 176 */ 177 /* 178 * Uncomment the deprecated macro if you need to see which structs are deprecated 179 */ 180 #define CPA_DEPRECATED 181 /*#define CPA_DEPRECATED __attribute__ ((deprecated)) */ 182 #else 183 /* 184 * for all other compilers, define deprecated to do nothing 185 * 186 */ 187 /* #define CPA_DEPRECATED_FUNC(func) func; #pragma deprecated(func) */ 188 #pragma message("WARNING: You need to implement the CPA_DEPRECATED macro for this compiler") 189 #define CPA_DEPRECATED 190 #endif 191 192 #ifdef __cplusplus 193 } /* close the extern "C" { */ 194 #endif 195 196 #endif /* CPA_TYPES_H */ 197