]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Library/BrotliCustomDecompressLib/common/types.h
MdeModulePkg: Copy Brotli algorithm 3rd party source code for 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
12#include <stddef.h> /* for size_t */\r
13\r
14#if defined(_MSC_VER) && (_MSC_VER < 1600)\r
15typedef __int8 int8_t;\r
16typedef unsigned __int8 uint8_t;\r
17typedef __int16 int16_t;\r
18typedef unsigned __int16 uint16_t;\r
19typedef __int32 int32_t;\r
20typedef unsigned __int32 uint32_t;\r
21typedef unsigned __int64 uint64_t;\r
22typedef __int64 int64_t;\r
23#else\r
24#include <stdint.h>\r
25#endif /* defined(_MSC_VER) && (_MSC_VER < 1600) */\r
26\r
27#if (!defined(_MSC_VER) || (_MSC_VER >= 1800)) && \\r
28 (defined(__cplusplus) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L))\r
29#include <stdbool.h>\r
30#define BROTLI_BOOL bool\r
31#define BROTLI_TRUE true\r
32#define BROTLI_FALSE false\r
33#define TO_BROTLI_BOOL(X) (!!(X))\r
34#else\r
35typedef enum {\r
36 BROTLI_FALSE = 0,\r
37 BROTLI_TRUE = !BROTLI_FALSE\r
38} BROTLI_BOOL;\r
39#define TO_BROTLI_BOOL(X) (!!(X) ? BROTLI_TRUE : BROTLI_FALSE)\r
40#endif\r
41\r
42#define MAKE_UINT64_T(high, low) ((((uint64_t)(high)) << 32) | low)\r
43\r
44#define BROTLI_UINT32_MAX (~((uint32_t)0))\r
45#define BROTLI_SIZE_MAX (~((size_t)0))\r
46\r
47/* Allocating function pointer. Function MUST return 0 in the case of failure.\r
48 Otherwise it MUST return a valid pointer to a memory region of at least\r
49 size length. Neither items nor size are allowed to be 0.\r
50 opaque argument is a pointer provided by client and could be used to bind\r
51 function to specific object (memory pool). */\r
52typedef void* (*brotli_alloc_func)(void* opaque, size_t size);\r
53\r
54/* Deallocating function pointer. Function SHOULD be no-op in the case the\r
55 address is 0. */\r
56typedef void (*brotli_free_func)(void* opaque, void* address);\r
57\r
58#endif /* BROTLI_COMMON_TYPES_H_ */\r