]>
git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Library/BrotliCustomDecompressLib/brotli/types.h
1 /* Copyright 2013 Google Inc. All Rights Reserved.
3 Distributed under MIT license.
4 See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
9 * Common types used in decoder and encoder API.
12 #ifndef BROTLI_COMMON_TYPES_H_
13 #define BROTLI_COMMON_TYPES_H_
15 //#include <stddef.h> /* for size_t */
16 #ifndef _SIZE_T_DEFINED
17 #if !defined(_WIN64) || defined(__GNUC__)
18 typedef unsigned int size_t;
22 #if defined(_MSC_VER) && (_MSC_VER < 1600)
23 typedef __int8
int8_t;
24 typedef unsigned __int8
uint8_t;
25 typedef __int16
int16_t;
26 typedef unsigned __int16
uint16_t;
27 typedef __int32
int32_t;
28 typedef unsigned __int32
uint32_t;
29 typedef unsigned __int64
uint64_t;
30 typedef __int64
int64_t;
34 typedef INT16
int16_t;
35 typedef INT32
int32_t;
36 typedef INT64
int64_t;
37 typedef UINT8
uint8_t;
38 typedef UINT16
uint16_t;
39 typedef UINT32
uint32_t;
40 typedef UINT64
uint64_t;
41 #endif /* defined(_MSC_VER) && (_MSC_VER < 1600) */
44 * A portable @c bool replacement.
46 * ::BROTLI_BOOL is a "documentation" type: actually it is @c int, but in API it
47 * denotes a type, whose only values are ::BROTLI_TRUE and ::BROTLI_FALSE.
49 * ::BROTLI_BOOL values passed to Brotli should either be ::BROTLI_TRUE or
50 * ::BROTLI_FALSE, or be a result of ::TO_BROTLI_BOOL macros.
52 * ::BROTLI_BOOL values returned by Brotli should not be tested for equality
53 * with @c true, @c false, ::BROTLI_TRUE, ::BROTLI_FALSE, but rather should be
54 * evaluated, for example: @code{.cpp}
55 * if (SomeBrotliFunction(encoder, BROTLI_TRUE) &&
56 * !OtherBrotliFunction(decoder, BROTLI_FALSE)) {
57 * bool x = !!YetAnotherBrotliFunction(encoder, TO_BROLTI_BOOL(2 * 2 == 4));
62 #define BROTLI_BOOL int
63 /** Portable @c true replacement. */
65 /** Portable @c false replacement. */
66 #define BROTLI_FALSE 0
67 /** @c bool to ::BROTLI_BOOL conversion macros. */
68 #define TO_BROTLI_BOOL(X) (!!(X) ? BROTLI_TRUE : BROTLI_FALSE)
70 #define BROTLI_MAKE_UINT64_T(high, low) ((((uint64_t)(high)) << 32) | low)
72 #define BROTLI_UINT32_MAX (~((uint32_t)0))
73 #define BROTLI_SIZE_MAX (~((size_t)0))
76 * Allocating function pointer type.
78 * @param opaque custom memory manager handle provided by client
79 * @param size requested memory region size; can not be @c 0
80 * @returns @c 0 in the case of failure
81 * @returns a valid pointer to a memory region of at least @p size bytes
84 typedef void* (*brotli_alloc_func
)(void* opaque
, size_t size
);
87 * Deallocating function pointer type.
89 * This function @b SHOULD do nothing if @p address is @c 0.
91 * @param opaque custom memory manager handle provided by client
92 * @param address memory region pointer returned by ::brotli_alloc_func, or @c 0
94 typedef void (*brotli_free_func
)(void* opaque
, void* address
);
96 #endif /* BROTLI_COMMON_TYPES_H_ */