1 /**************************************************************************
3 * Copyright 2013-2014 RAD Game Tools and Valve Software
4 * Copyright 2010-2014 Rich Geldreich and Tenacious Software LLC
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 **************************************************************************/
27 // File: vogl_miniz_common.h
29 #ifndef VOGL_MINIZ_COMMON_H
30 #define VOGL_MINIZ_COMMON_H
32 #include "vogl_core.h"
38 #define MZ_ASSERT(x) assert(x)
40 #ifdef MINIZ_NO_MALLOC
41 #define MZ_MALLOC(x) NULL
42 #define MZ_FREE(x) (void) x, ((void)0)
43 #define MZ_REALLOC(p, x) NULL
45 #define MZ_MALLOC(x) vogl_malloc(x)
46 #define MZ_FREE(x) vogl_free(x)
47 #define MZ_REALLOC(p, x) vogl_realloc(p, x)
50 #define MZ_MAX(a, b) (((a) > (b)) ? (a) : (b))
51 #define MZ_MIN(a, b) (((a) < (b)) ? (a) : (b))
52 #define MZ_CLEAR_OBJ(obj) memset(&(obj), 0, sizeof(obj))
54 #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES &&MINIZ_LITTLE_ENDIAN
55 #define MZ_READ_LE16(p) *((const mz_uint16 *)(p))
56 #define MZ_READ_LE32(p) *((const mz_uint32 *)(p))
58 #define MZ_READ_LE16(p) ((mz_uint32)(((const mz_uint8 *)(p))[0]) | ((mz_uint32)(((const mz_uint8 *)(p))[1]) << 8U))
59 #define MZ_READ_LE32(p) ((mz_uint32)(((const mz_uint8 *)(p))[0]) | ((mz_uint32)(((const mz_uint8 *)(p))[1]) << 8U) | ((mz_uint32)(((const mz_uint8 *)(p))[2]) << 16U) | ((mz_uint32)(((const mz_uint8 *)(p))[3]) << 24U))
62 #define MZ_READ_LE64(p) (((mz_uint64)MZ_READ_LE32(p)) | (((mz_uint64)MZ_READ_LE32((const mz_uint8 *)(p) + sizeof(mz_uint32))) << 32U))
65 #define MZ_FORCEINLINE __forceinline
66 #elif defined(__GNUC__)
67 #define MZ_FORCEINLINE inline __attribute__((__always_inline__))
69 #define MZ_FORCEINLINE inline
76 extern void *miniz_def_alloc_func(void *opaque, size_t items, size_t size);
77 extern void miniz_def_free_func(void *opaque, void *address);
78 extern void *miniz_def_realloc_func(void *opaque, void *address, size_t items, size_t size);
80 #define MZ_UINT16_MAX (0xFFFFU)
81 #define MZ_UINT32_MAX (0xFFFFFFFFU)
87 #endif // VOGL_MINIZ_COMMON_H