Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:54:01

0001 /* Copyright 2013 Google Inc. All Rights Reserved.
0002 
0003    Distributed under MIT license.
0004    See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
0005 */
0006 
0007 /**
0008  * @file
0009  * Common types used in decoder and encoder API.
0010  */
0011 
0012 #ifndef BROTLI_COMMON_TYPES_H_
0013 #define BROTLI_COMMON_TYPES_H_
0014 
0015 #include <stddef.h>  /* for size_t */
0016 
0017 #if defined(_MSC_VER) && (_MSC_VER < 1600)
0018 typedef __int8 int8_t;
0019 typedef unsigned __int8 uint8_t;
0020 typedef __int16 int16_t;
0021 typedef unsigned __int16 uint16_t;
0022 typedef __int32 int32_t;
0023 typedef unsigned __int32 uint32_t;
0024 typedef unsigned __int64 uint64_t;
0025 typedef __int64 int64_t;
0026 #else
0027 #include <stdint.h>
0028 #endif  /* defined(_MSC_VER) && (_MSC_VER < 1600) */
0029 
0030 /**
0031  * A portable @c bool replacement.
0032  *
0033  * ::BROTLI_BOOL is a "documentation" type: actually it is @c int, but in API it
0034  * denotes a type, whose only values are ::BROTLI_TRUE and ::BROTLI_FALSE.
0035  *
0036  * ::BROTLI_BOOL values passed to Brotli should either be ::BROTLI_TRUE or
0037  * ::BROTLI_FALSE, or be a result of ::TO_BROTLI_BOOL macros.
0038  *
0039  * ::BROTLI_BOOL values returned by Brotli should not be tested for equality
0040  * with @c true, @c false, ::BROTLI_TRUE, ::BROTLI_FALSE, but rather should be
0041  * evaluated, for example: @code{.cpp}
0042  * if (SomeBrotliFunction(encoder, BROTLI_TRUE) &&
0043  *     !OtherBrotliFunction(decoder, BROTLI_FALSE)) {
0044  *   bool x = !!YetAnotherBrotliFunction(encoder, TO_BROLTI_BOOL(2 * 2 == 4));
0045  *   DoSomething(x);
0046  * }
0047  * @endcode
0048  */
0049 #define BROTLI_BOOL int
0050 /** Portable @c true replacement. */
0051 #define BROTLI_TRUE 1
0052 /** Portable @c false replacement. */
0053 #define BROTLI_FALSE 0
0054 /** @c bool to ::BROTLI_BOOL conversion macros. */
0055 #define TO_BROTLI_BOOL(X) (!!(X) ? BROTLI_TRUE : BROTLI_FALSE)
0056 
0057 #define BROTLI_MAKE_UINT64_T(high, low) ((((uint64_t)(high)) << 32) | low)
0058 
0059 #define BROTLI_UINT32_MAX (~((uint32_t)0))
0060 #define BROTLI_SIZE_MAX (~((size_t)0))
0061 
0062 /**
0063  * Allocating function pointer type.
0064  *
0065  * @param opaque custom memory manager handle provided by client
0066  * @param size requested memory region size; can not be @c 0
0067  * @returns @c 0 in the case of failure
0068  * @returns a valid pointer to a memory region of at least @p size bytes
0069  *          long otherwise
0070  */
0071 typedef void* (*brotli_alloc_func)(void* opaque, size_t size);
0072 
0073 /**
0074  * Deallocating function pointer type.
0075  *
0076  * This function @b SHOULD do nothing if @p address is @c 0.
0077  *
0078  * @param opaque custom memory manager handle provided by client
0079  * @param address memory region pointer returned by ::brotli_alloc_func, or @c 0
0080  */
0081 typedef void (*brotli_free_func)(void* opaque, void* address);
0082 
0083 #endif  /* BROTLI_COMMON_TYPES_H_ */