| 1 | /* 7zTypes.h -- Basic types\r |
| 2 | 2022-04-01 : Igor Pavlov : Public domain */\r |
| 3 | \r |
| 4 | #ifndef __7Z_TYPES_H\r |
| 5 | #define __7Z_TYPES_H\r |
| 6 | \r |
| 7 | #ifdef _WIN32\r |
| 8 | /* #include <windows.h> */\r |
| 9 | #else\r |
| 10 | #include <errno.h>\r |
| 11 | #endif\r |
| 12 | \r |
| 13 | #include <stddef.h>\r |
| 14 | \r |
| 15 | #ifndef EXTERN_C_BEGIN\r |
| 16 | #ifdef __cplusplus\r |
| 17 | #define EXTERN_C_BEGIN extern "C" {\r |
| 18 | #define EXTERN_C_END }\r |
| 19 | #else\r |
| 20 | #define EXTERN_C_BEGIN\r |
| 21 | #define EXTERN_C_END\r |
| 22 | #endif\r |
| 23 | #endif\r |
| 24 | \r |
| 25 | EXTERN_C_BEGIN\r |
| 26 | \r |
| 27 | #define SZ_OK 0\r |
| 28 | \r |
| 29 | #define SZ_ERROR_DATA 1\r |
| 30 | #define SZ_ERROR_MEM 2\r |
| 31 | #define SZ_ERROR_CRC 3\r |
| 32 | #define SZ_ERROR_UNSUPPORTED 4\r |
| 33 | #define SZ_ERROR_PARAM 5\r |
| 34 | #define SZ_ERROR_INPUT_EOF 6\r |
| 35 | #define SZ_ERROR_OUTPUT_EOF 7\r |
| 36 | #define SZ_ERROR_READ 8\r |
| 37 | #define SZ_ERROR_WRITE 9\r |
| 38 | #define SZ_ERROR_PROGRESS 10\r |
| 39 | #define SZ_ERROR_FAIL 11\r |
| 40 | #define SZ_ERROR_THREAD 12\r |
| 41 | \r |
| 42 | #define SZ_ERROR_ARCHIVE 16\r |
| 43 | #define SZ_ERROR_NO_ARCHIVE 17\r |
| 44 | \r |
| 45 | typedef int SRes;\r |
| 46 | \r |
| 47 | \r |
| 48 | #ifdef _MSC_VER\r |
| 49 | #if _MSC_VER > 1200\r |
| 50 | #define MY_ALIGN(n) __declspec(align(n))\r |
| 51 | #else\r |
| 52 | #define MY_ALIGN(n)\r |
| 53 | #endif\r |
| 54 | #else\r |
| 55 | #define MY_ALIGN(n) __attribute__ ((aligned(n)))\r |
| 56 | #endif\r |
| 57 | \r |
| 58 | \r |
| 59 | #ifdef _WIN32\r |
| 60 | \r |
| 61 | /* typedef DWORD WRes; */\r |
| 62 | typedef unsigned WRes;\r |
| 63 | #define MY_SRes_HRESULT_FROM_WRes(x) HRESULT_FROM_WIN32(x)\r |
| 64 | \r |
| 65 | // #define MY_HRES_ERROR__INTERNAL_ERROR MY_SRes_HRESULT_FROM_WRes(ERROR_INTERNAL_ERROR)\r |
| 66 | \r |
| 67 | #else // _WIN32\r |
| 68 | \r |
| 69 | // #define ENV_HAVE_LSTAT\r |
| 70 | typedef int WRes;\r |
| 71 | \r |
| 72 | // (FACILITY_ERRNO = 0x800) is 7zip's FACILITY constant to represent (errno) errors in HRESULT\r |
| 73 | #define MY__FACILITY_ERRNO 0x800\r |
| 74 | #define MY__FACILITY_WIN32 7\r |
| 75 | #define MY__FACILITY__WRes MY__FACILITY_ERRNO\r |
| 76 | \r |
| 77 | #define MY_HRESULT_FROM_errno_CONST_ERROR(x) ((HRESULT)( \\r |
| 78 | ( (HRESULT)(x) & 0x0000FFFF) \\r |
| 79 | | (MY__FACILITY__WRes << 16) \\r |
| 80 | | (HRESULT)0x80000000 ))\r |
| 81 | \r |
| 82 | #define MY_SRes_HRESULT_FROM_WRes(x) \\r |
| 83 | ((HRESULT)(x) <= 0 ? ((HRESULT)(x)) : MY_HRESULT_FROM_errno_CONST_ERROR(x))\r |
| 84 | \r |
| 85 | // we call macro HRESULT_FROM_WIN32 for system errors (WRes) that are (errno)\r |
| 86 | #define HRESULT_FROM_WIN32(x) MY_SRes_HRESULT_FROM_WRes(x)\r |
| 87 | \r |
| 88 | /*\r |
| 89 | #define ERROR_FILE_NOT_FOUND 2L\r |
| 90 | #define ERROR_ACCESS_DENIED 5L\r |
| 91 | #define ERROR_NO_MORE_FILES 18L\r |
| 92 | #define ERROR_LOCK_VIOLATION 33L\r |
| 93 | #define ERROR_FILE_EXISTS 80L\r |
| 94 | #define ERROR_DISK_FULL 112L\r |
| 95 | #define ERROR_NEGATIVE_SEEK 131L\r |
| 96 | #define ERROR_ALREADY_EXISTS 183L\r |
| 97 | #define ERROR_DIRECTORY 267L\r |
| 98 | #define ERROR_TOO_MANY_POSTS 298L\r |
| 99 | \r |
| 100 | #define ERROR_INTERNAL_ERROR 1359L\r |
| 101 | #define ERROR_INVALID_REPARSE_DATA 4392L\r |
| 102 | #define ERROR_REPARSE_TAG_INVALID 4393L\r |
| 103 | #define ERROR_REPARSE_TAG_MISMATCH 4394L\r |
| 104 | */\r |
| 105 | \r |
| 106 | // we use errno equivalents for some WIN32 errors:\r |
| 107 | \r |
| 108 | #define ERROR_INVALID_PARAMETER EINVAL\r |
| 109 | #define ERROR_INVALID_FUNCTION EINVAL\r |
| 110 | #define ERROR_ALREADY_EXISTS EEXIST\r |
| 111 | #define ERROR_FILE_EXISTS EEXIST\r |
| 112 | #define ERROR_PATH_NOT_FOUND ENOENT\r |
| 113 | #define ERROR_FILE_NOT_FOUND ENOENT\r |
| 114 | #define ERROR_DISK_FULL ENOSPC\r |
| 115 | // #define ERROR_INVALID_HANDLE EBADF\r |
| 116 | \r |
| 117 | // we use FACILITY_WIN32 for errors that has no errno equivalent\r |
| 118 | // Too many posts were made to a semaphore.\r |
| 119 | #define ERROR_TOO_MANY_POSTS ((HRESULT)0x8007012AL)\r |
| 120 | #define ERROR_INVALID_REPARSE_DATA ((HRESULT)0x80071128L)\r |
| 121 | #define ERROR_REPARSE_TAG_INVALID ((HRESULT)0x80071129L)\r |
| 122 | \r |
| 123 | // if (MY__FACILITY__WRes != FACILITY_WIN32),\r |
| 124 | // we use FACILITY_WIN32 for COM errors:\r |
| 125 | #define E_OUTOFMEMORY ((HRESULT)0x8007000EL)\r |
| 126 | #define E_INVALIDARG ((HRESULT)0x80070057L)\r |
| 127 | #define MY__E_ERROR_NEGATIVE_SEEK ((HRESULT)0x80070083L)\r |
| 128 | \r |
| 129 | /*\r |
| 130 | // we can use FACILITY_ERRNO for some COM errors, that have errno equivalents:\r |
| 131 | #define E_OUTOFMEMORY MY_HRESULT_FROM_errno_CONST_ERROR(ENOMEM)\r |
| 132 | #define E_INVALIDARG MY_HRESULT_FROM_errno_CONST_ERROR(EINVAL)\r |
| 133 | #define MY__E_ERROR_NEGATIVE_SEEK MY_HRESULT_FROM_errno_CONST_ERROR(EINVAL)\r |
| 134 | */\r |
| 135 | \r |
| 136 | #define TEXT(quote) quote\r |
| 137 | \r |
| 138 | #define FILE_ATTRIBUTE_READONLY 0x0001\r |
| 139 | #define FILE_ATTRIBUTE_HIDDEN 0x0002\r |
| 140 | #define FILE_ATTRIBUTE_SYSTEM 0x0004\r |
| 141 | #define FILE_ATTRIBUTE_DIRECTORY 0x0010\r |
| 142 | #define FILE_ATTRIBUTE_ARCHIVE 0x0020\r |
| 143 | #define FILE_ATTRIBUTE_DEVICE 0x0040\r |
| 144 | #define FILE_ATTRIBUTE_NORMAL 0x0080\r |
| 145 | #define FILE_ATTRIBUTE_TEMPORARY 0x0100\r |
| 146 | #define FILE_ATTRIBUTE_SPARSE_FILE 0x0200\r |
| 147 | #define FILE_ATTRIBUTE_REPARSE_POINT 0x0400\r |
| 148 | #define FILE_ATTRIBUTE_COMPRESSED 0x0800\r |
| 149 | #define FILE_ATTRIBUTE_OFFLINE 0x1000\r |
| 150 | #define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x2000\r |
| 151 | #define FILE_ATTRIBUTE_ENCRYPTED 0x4000\r |
| 152 | \r |
| 153 | #define FILE_ATTRIBUTE_UNIX_EXTENSION 0x8000 /* trick for Unix */\r |
| 154 | \r |
| 155 | #endif\r |
| 156 | \r |
| 157 | \r |
| 158 | #ifndef RINOK\r |
| 159 | #define RINOK(x) { int __result__ = (x); if (__result__ != 0) return __result__; }\r |
| 160 | #endif\r |
| 161 | \r |
| 162 | #ifndef RINOK_WRes\r |
| 163 | #define RINOK_WRes(x) { WRes __result__ = (x); if (__result__ != 0) return __result__; }\r |
| 164 | #endif\r |
| 165 | \r |
| 166 | typedef unsigned char Byte;\r |
| 167 | typedef short Int16;\r |
| 168 | typedef unsigned short UInt16;\r |
| 169 | \r |
| 170 | #ifdef _LZMA_UINT32_IS_ULONG\r |
| 171 | typedef long Int32;\r |
| 172 | typedef unsigned long UInt32;\r |
| 173 | #else\r |
| 174 | typedef int Int32;\r |
| 175 | typedef unsigned int UInt32;\r |
| 176 | #endif\r |
| 177 | \r |
| 178 | \r |
| 179 | #ifndef _WIN32\r |
| 180 | \r |
| 181 | typedef int INT;\r |
| 182 | typedef Int32 INT32;\r |
| 183 | typedef unsigned int UINT;\r |
| 184 | typedef UInt32 UINT32;\r |
| 185 | typedef INT32 LONG; // LONG, ULONG and DWORD must be 32-bit for _WIN32 compatibility\r |
| 186 | typedef UINT32 ULONG;\r |
| 187 | \r |
| 188 | #undef DWORD\r |
| 189 | typedef UINT32 DWORD;\r |
| 190 | \r |
| 191 | #define VOID void\r |
| 192 | \r |
| 193 | #define HRESULT LONG\r |
| 194 | \r |
| 195 | typedef void *LPVOID;\r |
| 196 | // typedef void VOID;\r |
| 197 | // typedef ULONG_PTR DWORD_PTR, *PDWORD_PTR;\r |
| 198 | // gcc / clang on Unix : sizeof(long==sizeof(void*) in 32 or 64 bits)\r |
| 199 | typedef long INT_PTR;\r |
| 200 | typedef unsigned long UINT_PTR;\r |
| 201 | typedef long LONG_PTR;\r |
| 202 | typedef unsigned long DWORD_PTR;\r |
| 203 | \r |
| 204 | typedef size_t SIZE_T;\r |
| 205 | \r |
| 206 | #endif // _WIN32\r |
| 207 | \r |
| 208 | \r |
| 209 | #define MY_HRES_ERROR__INTERNAL_ERROR ((HRESULT)0x8007054FL)\r |
| 210 | \r |
| 211 | \r |
| 212 | #ifdef _SZ_NO_INT_64\r |
| 213 | \r |
| 214 | /* define _SZ_NO_INT_64, if your compiler doesn't support 64-bit integers.\r |
| 215 | NOTES: Some code will work incorrectly in that case! */\r |
| 216 | \r |
| 217 | typedef long Int64;\r |
| 218 | typedef unsigned long UInt64;\r |
| 219 | \r |
| 220 | #else\r |
| 221 | \r |
| 222 | #if defined(_MSC_VER) || defined(__BORLANDC__)\r |
| 223 | typedef __int64 Int64;\r |
| 224 | typedef unsigned __int64 UInt64;\r |
| 225 | #define UINT64_CONST(n) n\r |
| 226 | #else\r |
| 227 | typedef long long int Int64;\r |
| 228 | typedef unsigned long long int UInt64;\r |
| 229 | #define UINT64_CONST(n) n ## ULL\r |
| 230 | #endif\r |
| 231 | \r |
| 232 | #endif\r |
| 233 | \r |
| 234 | #ifdef _LZMA_NO_SYSTEM_SIZE_T\r |
| 235 | typedef UInt32 SizeT;\r |
| 236 | #else\r |
| 237 | typedef size_t SizeT;\r |
| 238 | #endif\r |
| 239 | \r |
| 240 | typedef int BoolInt;\r |
| 241 | /* typedef BoolInt Bool; */\r |
| 242 | #define True 1\r |
| 243 | #define False 0\r |
| 244 | \r |
| 245 | \r |
| 246 | #ifdef _WIN32\r |
| 247 | #define MY_STD_CALL __stdcall\r |
| 248 | #else\r |
| 249 | #define MY_STD_CALL\r |
| 250 | #endif\r |
| 251 | \r |
| 252 | #ifdef _MSC_VER\r |
| 253 | \r |
| 254 | #if _MSC_VER >= 1300\r |
| 255 | #define MY_NO_INLINE __declspec(noinline)\r |
| 256 | #else\r |
| 257 | #define MY_NO_INLINE\r |
| 258 | #endif\r |
| 259 | \r |
| 260 | #define MY_FORCE_INLINE __forceinline\r |
| 261 | \r |
| 262 | #define MY_CDECL __cdecl\r |
| 263 | #define MY_FAST_CALL __fastcall\r |
| 264 | \r |
| 265 | #else // _MSC_VER\r |
| 266 | \r |
| 267 | #if (defined(__GNUC__) && (__GNUC__ >= 4)) \\r |
| 268 | || (defined(__clang__) && (__clang_major__ >= 4)) \\r |
| 269 | || defined(__INTEL_COMPILER) \\r |
| 270 | || defined(__xlC__)\r |
| 271 | #define MY_NO_INLINE __attribute__((noinline))\r |
| 272 | // #define MY_FORCE_INLINE __attribute__((always_inline)) inline\r |
| 273 | #else\r |
| 274 | #define MY_NO_INLINE\r |
| 275 | #endif\r |
| 276 | \r |
| 277 | #define MY_FORCE_INLINE\r |
| 278 | \r |
| 279 | \r |
| 280 | #define MY_CDECL\r |
| 281 | \r |
| 282 | #if defined(_M_IX86) \\r |
| 283 | || defined(__i386__)\r |
| 284 | // #define MY_FAST_CALL __attribute__((fastcall))\r |
| 285 | // #define MY_FAST_CALL __attribute__((cdecl))\r |
| 286 | #define MY_FAST_CALL\r |
| 287 | #elif defined(MY_CPU_AMD64)\r |
| 288 | // #define MY_FAST_CALL __attribute__((ms_abi))\r |
| 289 | #define MY_FAST_CALL\r |
| 290 | #else\r |
| 291 | #define MY_FAST_CALL\r |
| 292 | #endif\r |
| 293 | \r |
| 294 | #endif // _MSC_VER\r |
| 295 | \r |
| 296 | \r |
| 297 | /* The following interfaces use first parameter as pointer to structure */\r |
| 298 | \r |
| 299 | typedef struct IByteIn IByteIn;\r |
| 300 | struct IByteIn\r |
| 301 | {\r |
| 302 | Byte (*Read)(const IByteIn *p); /* reads one byte, returns 0 in case of EOF or error */\r |
| 303 | };\r |
| 304 | #define IByteIn_Read(p) (p)->Read(p)\r |
| 305 | \r |
| 306 | \r |
| 307 | typedef struct IByteOut IByteOut;\r |
| 308 | struct IByteOut\r |
| 309 | {\r |
| 310 | void (*Write)(const IByteOut *p, Byte b);\r |
| 311 | };\r |
| 312 | #define IByteOut_Write(p, b) (p)->Write(p, b)\r |
| 313 | \r |
| 314 | \r |
| 315 | typedef struct ISeqInStream ISeqInStream;\r |
| 316 | struct ISeqInStream\r |
| 317 | {\r |
| 318 | SRes (*Read)(const ISeqInStream *p, void *buf, size_t *size);\r |
| 319 | /* if (input(*size) != 0 && output(*size) == 0) means end_of_stream.\r |
| 320 | (output(*size) < input(*size)) is allowed */\r |
| 321 | };\r |
| 322 | #define ISeqInStream_Read(p, buf, size) (p)->Read(p, buf, size)\r |
| 323 | \r |
| 324 | /* it can return SZ_ERROR_INPUT_EOF */\r |
| 325 | SRes SeqInStream_Read(const ISeqInStream *stream, void *buf, size_t size);\r |
| 326 | SRes SeqInStream_Read2(const ISeqInStream *stream, void *buf, size_t size, SRes errorType);\r |
| 327 | SRes SeqInStream_ReadByte(const ISeqInStream *stream, Byte *buf);\r |
| 328 | \r |
| 329 | \r |
| 330 | typedef struct ISeqOutStream ISeqOutStream;\r |
| 331 | struct ISeqOutStream\r |
| 332 | {\r |
| 333 | size_t (*Write)(const ISeqOutStream *p, const void *buf, size_t size);\r |
| 334 | /* Returns: result - the number of actually written bytes.\r |
| 335 | (result < size) means error */\r |
| 336 | };\r |
| 337 | #define ISeqOutStream_Write(p, buf, size) (p)->Write(p, buf, size)\r |
| 338 | \r |
| 339 | typedef enum\r |
| 340 | {\r |
| 341 | SZ_SEEK_SET = 0,\r |
| 342 | SZ_SEEK_CUR = 1,\r |
| 343 | SZ_SEEK_END = 2\r |
| 344 | } ESzSeek;\r |
| 345 | \r |
| 346 | \r |
| 347 | typedef struct ISeekInStream ISeekInStream;\r |
| 348 | struct ISeekInStream\r |
| 349 | {\r |
| 350 | SRes (*Read)(const ISeekInStream *p, void *buf, size_t *size); /* same as ISeqInStream::Read */\r |
| 351 | SRes (*Seek)(const ISeekInStream *p, Int64 *pos, ESzSeek origin);\r |
| 352 | };\r |
| 353 | #define ISeekInStream_Read(p, buf, size) (p)->Read(p, buf, size)\r |
| 354 | #define ISeekInStream_Seek(p, pos, origin) (p)->Seek(p, pos, origin)\r |
| 355 | \r |
| 356 | \r |
| 357 | typedef struct ILookInStream ILookInStream;\r |
| 358 | struct ILookInStream\r |
| 359 | {\r |
| 360 | SRes (*Look)(const ILookInStream *p, const void **buf, size_t *size);\r |
| 361 | /* if (input(*size) != 0 && output(*size) == 0) means end_of_stream.\r |
| 362 | (output(*size) > input(*size)) is not allowed\r |
| 363 | (output(*size) < input(*size)) is allowed */\r |
| 364 | SRes (*Skip)(const ILookInStream *p, size_t offset);\r |
| 365 | /* offset must be <= output(*size) of Look */\r |
| 366 | \r |
| 367 | SRes (*Read)(const ILookInStream *p, void *buf, size_t *size);\r |
| 368 | /* reads directly (without buffer). It's same as ISeqInStream::Read */\r |
| 369 | SRes (*Seek)(const ILookInStream *p, Int64 *pos, ESzSeek origin);\r |
| 370 | };\r |
| 371 | \r |
| 372 | #define ILookInStream_Look(p, buf, size) (p)->Look(p, buf, size)\r |
| 373 | #define ILookInStream_Skip(p, offset) (p)->Skip(p, offset)\r |
| 374 | #define ILookInStream_Read(p, buf, size) (p)->Read(p, buf, size)\r |
| 375 | #define ILookInStream_Seek(p, pos, origin) (p)->Seek(p, pos, origin)\r |
| 376 | \r |
| 377 | \r |
| 378 | SRes LookInStream_LookRead(const ILookInStream *stream, void *buf, size_t *size);\r |
| 379 | SRes LookInStream_SeekTo(const ILookInStream *stream, UInt64 offset);\r |
| 380 | \r |
| 381 | /* reads via ILookInStream::Read */\r |
| 382 | SRes LookInStream_Read2(const ILookInStream *stream, void *buf, size_t size, SRes errorType);\r |
| 383 | SRes LookInStream_Read(const ILookInStream *stream, void *buf, size_t size);\r |
| 384 | \r |
| 385 | \r |
| 386 | \r |
| 387 | typedef struct\r |
| 388 | {\r |
| 389 | ILookInStream vt;\r |
| 390 | const ISeekInStream *realStream;\r |
| 391 | \r |
| 392 | size_t pos;\r |
| 393 | size_t size; /* it's data size */\r |
| 394 | \r |
| 395 | /* the following variables must be set outside */\r |
| 396 | Byte *buf;\r |
| 397 | size_t bufSize;\r |
| 398 | } CLookToRead2;\r |
| 399 | \r |
| 400 | void LookToRead2_CreateVTable(CLookToRead2 *p, int lookahead);\r |
| 401 | \r |
| 402 | #define LookToRead2_Init(p) { (p)->pos = (p)->size = 0; }\r |
| 403 | \r |
| 404 | \r |
| 405 | typedef struct\r |
| 406 | {\r |
| 407 | ISeqInStream vt;\r |
| 408 | const ILookInStream *realStream;\r |
| 409 | } CSecToLook;\r |
| 410 | \r |
| 411 | void SecToLook_CreateVTable(CSecToLook *p);\r |
| 412 | \r |
| 413 | \r |
| 414 | \r |
| 415 | typedef struct\r |
| 416 | {\r |
| 417 | ISeqInStream vt;\r |
| 418 | const ILookInStream *realStream;\r |
| 419 | } CSecToRead;\r |
| 420 | \r |
| 421 | void SecToRead_CreateVTable(CSecToRead *p);\r |
| 422 | \r |
| 423 | \r |
| 424 | typedef struct ICompressProgress ICompressProgress;\r |
| 425 | \r |
| 426 | struct ICompressProgress\r |
| 427 | {\r |
| 428 | SRes (*Progress)(const ICompressProgress *p, UInt64 inSize, UInt64 outSize);\r |
| 429 | /* Returns: result. (result != SZ_OK) means break.\r |
| 430 | Value (UInt64)(Int64)-1 for size means unknown value. */\r |
| 431 | };\r |
| 432 | #define ICompressProgress_Progress(p, inSize, outSize) (p)->Progress(p, inSize, outSize)\r |
| 433 | \r |
| 434 | \r |
| 435 | \r |
| 436 | typedef struct ISzAlloc ISzAlloc;\r |
| 437 | typedef const ISzAlloc * ISzAllocPtr;\r |
| 438 | \r |
| 439 | struct ISzAlloc\r |
| 440 | {\r |
| 441 | void *(*Alloc)(ISzAllocPtr p, size_t size);\r |
| 442 | void (*Free)(ISzAllocPtr p, void *address); /* address can be 0 */\r |
| 443 | };\r |
| 444 | \r |
| 445 | #define ISzAlloc_Alloc(p, size) (p)->Alloc(p, size)\r |
| 446 | #define ISzAlloc_Free(p, a) (p)->Free(p, a)\r |
| 447 | \r |
| 448 | /* deprecated */\r |
| 449 | #define IAlloc_Alloc(p, size) ISzAlloc_Alloc(p, size)\r |
| 450 | #define IAlloc_Free(p, a) ISzAlloc_Free(p, a)\r |
| 451 | \r |
| 452 | \r |
| 453 | \r |
| 454 | \r |
| 455 | \r |
| 456 | #ifndef MY_offsetof\r |
| 457 | #ifdef offsetof\r |
| 458 | #define MY_offsetof(type, m) offsetof(type, m)\r |
| 459 | /*\r |
| 460 | #define MY_offsetof(type, m) FIELD_OFFSET(type, m)\r |
| 461 | */\r |
| 462 | #else\r |
| 463 | #define MY_offsetof(type, m) ((size_t)&(((type *)0)->m))\r |
| 464 | #endif\r |
| 465 | #endif\r |
| 466 | \r |
| 467 | \r |
| 468 | \r |
| 469 | #ifndef MY_container_of\r |
| 470 | \r |
| 471 | /*\r |
| 472 | #define MY_container_of(ptr, type, m) container_of(ptr, type, m)\r |
| 473 | #define MY_container_of(ptr, type, m) CONTAINING_RECORD(ptr, type, m)\r |
| 474 | #define MY_container_of(ptr, type, m) ((type *)((char *)(ptr) - offsetof(type, m)))\r |
| 475 | #define MY_container_of(ptr, type, m) (&((type *)0)->m == (ptr), ((type *)(((char *)(ptr)) - MY_offsetof(type, m))))\r |
| 476 | */\r |
| 477 | \r |
| 478 | /*\r |
| 479 | GCC shows warning: "perhaps the 'offsetof' macro was used incorrectly"\r |
| 480 | GCC 3.4.4 : classes with constructor\r |
| 481 | GCC 4.8.1 : classes with non-public variable members"\r |
| 482 | */\r |
| 483 | \r |
| 484 | #define MY_container_of(ptr, type, m) ((type *)(void *)((char *)(void *)(1 ? (ptr) : &((type *)0)->m) - MY_offsetof(type, m)))\r |
| 485 | \r |
| 486 | #endif\r |
| 487 | \r |
| 488 | #define CONTAINER_FROM_VTBL_SIMPLE(ptr, type, m) ((type *)(void *)(ptr))\r |
| 489 | \r |
| 490 | /*\r |
| 491 | #define CONTAINER_FROM_VTBL(ptr, type, m) CONTAINER_FROM_VTBL_SIMPLE(ptr, type, m)\r |
| 492 | */\r |
| 493 | #define CONTAINER_FROM_VTBL(ptr, type, m) MY_container_of(ptr, type, m)\r |
| 494 | \r |
| 495 | #define CONTAINER_FROM_VTBL_CLS(ptr, type, m) CONTAINER_FROM_VTBL_SIMPLE(ptr, type, m)\r |
| 496 | /*\r |
| 497 | #define CONTAINER_FROM_VTBL_CLS(ptr, type, m) CONTAINER_FROM_VTBL(ptr, type, m)\r |
| 498 | */\r |
| 499 | \r |
| 500 | \r |
| 501 | #define MY_memset_0_ARRAY(a) memset((a), 0, sizeof(a))\r |
| 502 | \r |
| 503 | #ifdef _WIN32\r |
| 504 | \r |
| 505 | #define CHAR_PATH_SEPARATOR '\\'\r |
| 506 | #define WCHAR_PATH_SEPARATOR L'\\'\r |
| 507 | #define STRING_PATH_SEPARATOR "\\"\r |
| 508 | #define WSTRING_PATH_SEPARATOR L"\\"\r |
| 509 | \r |
| 510 | #else\r |
| 511 | \r |
| 512 | #define CHAR_PATH_SEPARATOR '/'\r |
| 513 | #define WCHAR_PATH_SEPARATOR L'/'\r |
| 514 | #define STRING_PATH_SEPARATOR "/"\r |
| 515 | #define WSTRING_PATH_SEPARATOR L"/"\r |
| 516 | \r |
| 517 | #endif\r |
| 518 | \r |
| 519 | #define k_PropVar_TimePrec_0 0\r |
| 520 | #define k_PropVar_TimePrec_Unix 1\r |
| 521 | #define k_PropVar_TimePrec_DOS 2\r |
| 522 | #define k_PropVar_TimePrec_HighPrec 3\r |
| 523 | #define k_PropVar_TimePrec_Base 16\r |
| 524 | #define k_PropVar_TimePrec_100ns (k_PropVar_TimePrec_Base + 7)\r |
| 525 | #define k_PropVar_TimePrec_1ns (k_PropVar_TimePrec_Base + 9)\r |
| 526 | \r |
| 527 | EXTERN_C_END\r |
| 528 | \r |
| 529 | #endif\r |