]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Library/BrotliCustomDecompressLib/common/types.h
MdeModulePkg: Add Brotli algorithm decompression library
[mirror_edk2.git] / MdeModulePkg / Library / BrotliCustomDecompressLib / common / types.h
CommitLineData
36ff6d80
SB
1/* Copyright 2013 Google Inc. All Rights Reserved.\r
2\r
3 Distributed under MIT license.\r
4 See file LICENSE for detail or copy at https://opensource.org/licenses/MIT\r
5*/\r
6\r
7/* Common types */\r
8\r
9#ifndef BROTLI_COMMON_TYPES_H_\r
10#define BROTLI_COMMON_TYPES_H_\r
11\r
841b2590
SB
12//#include <stddef.h> /* for size_t */\r
13#ifndef _SIZE_T_DEFINED\r
14#if !defined(_WIN64) || defined(__GNUC__)\r
15typedef unsigned int size_t;\r
16#endif\r
17#endif\r
18\r
36ff6d80
SB
19\r
20#if defined(_MSC_VER) && (_MSC_VER < 1600)\r
21typedef __int8 int8_t;\r
22typedef unsigned __int8 uint8_t;\r
23typedef __int16 int16_t;\r
24typedef unsigned __int16 uint16_t;\r
25typedef __int32 int32_t;\r
26typedef unsigned __int32 uint32_t;\r
27typedef unsigned __int64 uint64_t;\r
28typedef __int64 int64_t;\r
29#else\r
841b2590
SB
30//#include <stdint.h>\r
31typedef INT8 int8_t;\r
32typedef INT16 int16_t;\r
33typedef INT32 int32_t;\r
34typedef INT64 int64_t;\r
35typedef UINT8 uint8_t;\r
36typedef UINT16 uint16_t;\r
37typedef UINT32 uint32_t;\r
38typedef UINT64 uint64_t;\r
36ff6d80
SB
39#endif /* defined(_MSC_VER) && (_MSC_VER < 1600) */\r
40\r
41#if (!defined(_MSC_VER) || (_MSC_VER >= 1800)) && \\r
42 (defined(__cplusplus) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L))\r
43#include <stdbool.h>\r
44#define BROTLI_BOOL bool\r
45#define BROTLI_TRUE true\r
46#define BROTLI_FALSE false\r
47#define TO_BROTLI_BOOL(X) (!!(X))\r
48#else\r
49typedef enum {\r
50 BROTLI_FALSE = 0,\r
51 BROTLI_TRUE = !BROTLI_FALSE\r
52} BROTLI_BOOL;\r
53#define TO_BROTLI_BOOL(X) (!!(X) ? BROTLI_TRUE : BROTLI_FALSE)\r
54#endif\r
55\r
56#define MAKE_UINT64_T(high, low) ((((uint64_t)(high)) << 32) | low)\r
57\r
58#define BROTLI_UINT32_MAX (~((uint32_t)0))\r
59#define BROTLI_SIZE_MAX (~((size_t)0))\r
60\r
61/* Allocating function pointer. Function MUST return 0 in the case of failure.\r
62 Otherwise it MUST return a valid pointer to a memory region of at least\r
63 size length. Neither items nor size are allowed to be 0.\r
64 opaque argument is a pointer provided by client and could be used to bind\r
65 function to specific object (memory pool). */\r
66typedef void* (*brotli_alloc_func)(void* opaque, size_t size);\r
67\r
68/* Deallocating function pointer. Function SHOULD be no-op in the case the\r
69 address is 0. */\r
70typedef void (*brotli_free_func)(void* opaque, void* address);\r
71\r
72#endif /* BROTLI_COMMON_TYPES_H_ */\r