1*3117ece4Schristos /** 2*3117ece4Schristos * \file zstd.c 3*3117ece4Schristos * Single-file Zstandard library. 4*3117ece4Schristos * 5*3117ece4Schristos * Generate using: 6*3117ece4Schristos * \code 7*3117ece4Schristos * python combine.py -r ../../lib -x legacy/zstd_legacy.h -o zstd.c zstd-in.c 8*3117ece4Schristos * \endcode 9*3117ece4Schristos */ 10*3117ece4Schristos /* 11*3117ece4Schristos * Copyright (c) Meta Platforms, Inc. and affiliates. 12*3117ece4Schristos * All rights reserved. 13*3117ece4Schristos * 14*3117ece4Schristos * This source code is licensed under both the BSD-style license (found in the 15*3117ece4Schristos * LICENSE file in the root directory of this source tree) and the GPLv2 (found 16*3117ece4Schristos * in the COPYING file in the root directory of this source tree). 17*3117ece4Schristos * You may select, at your option, one of the above-listed licenses. 18*3117ece4Schristos */ 19*3117ece4Schristos /* 20*3117ece4Schristos * Settings to bake for the single library file. 21*3117ece4Schristos * 22*3117ece4Schristos * Note: It's important that none of these affects 'zstd.h' (only the 23*3117ece4Schristos * implementation files we're amalgamating). 24*3117ece4Schristos * 25*3117ece4Schristos * Note: MEM_MODULE stops xxhash redefining BYTE, U16, etc., which are also 26*3117ece4Schristos * defined in mem.h (breaking C99 compatibility). 27*3117ece4Schristos * 28*3117ece4Schristos * Note: the undefs for xxHash allow Zstd's implementation to coincide with 29*3117ece4Schristos * standalone xxHash usage (with global defines). 30*3117ece4Schristos * 31*3117ece4Schristos * Note: if you enable ZSTD_LEGACY_SUPPORT the combine.py script will need 32*3117ece4Schristos * re-running without the "-x legacy/zstd_legacy.h" option (it excludes the 33*3117ece4Schristos * legacy support at the source level). 34*3117ece4Schristos * 35*3117ece4Schristos * Note: multithreading is enabled for all platforms apart from Emscripten. 36*3117ece4Schristos */ 37*3117ece4Schristos #define DEBUGLEVEL 0 38*3117ece4Schristos #define MEM_MODULE 39*3117ece4Schristos #undef XXH_NAMESPACE 40*3117ece4Schristos #define XXH_NAMESPACE ZSTD_ 41*3117ece4Schristos #undef XXH_PRIVATE_API 42*3117ece4Schristos #define XXH_PRIVATE_API 43*3117ece4Schristos #undef XXH_INLINE_ALL 44*3117ece4Schristos #define XXH_INLINE_ALL 45*3117ece4Schristos #define ZSTD_LEGACY_SUPPORT 0 46*3117ece4Schristos #ifndef __EMSCRIPTEN__ 47*3117ece4Schristos #define ZSTD_MULTITHREAD 48*3117ece4Schristos #endif 49*3117ece4Schristos #define ZSTD_TRACE 0 50*3117ece4Schristos /* TODO: Can't amalgamate ASM function */ 51*3117ece4Schristos #define ZSTD_DISABLE_ASM 1 52*3117ece4Schristos 53*3117ece4Schristos /* Include zstd_deps.h first with all the options we need enabled. */ 54*3117ece4Schristos #define ZSTD_DEPS_NEED_MALLOC 55*3117ece4Schristos #define ZSTD_DEPS_NEED_MATH64 56*3117ece4Schristos #include "common/zstd_deps.h" 57*3117ece4Schristos 58*3117ece4Schristos #include "common/debug.c" 59*3117ece4Schristos #include "common/entropy_common.c" 60*3117ece4Schristos #include "common/error_private.c" 61*3117ece4Schristos #include "common/fse_decompress.c" 62*3117ece4Schristos #include "common/threading.c" 63*3117ece4Schristos #include "common/pool.c" 64*3117ece4Schristos #include "common/zstd_common.c" 65*3117ece4Schristos 66*3117ece4Schristos #include "compress/fse_compress.c" 67*3117ece4Schristos #include "compress/hist.c" 68*3117ece4Schristos #include "compress/huf_compress.c" 69*3117ece4Schristos #include "compress/zstd_compress_literals.c" 70*3117ece4Schristos #include "compress/zstd_compress_sequences.c" 71*3117ece4Schristos #include "compress/zstd_compress_superblock.c" 72*3117ece4Schristos #include "compress/zstd_compress.c" 73*3117ece4Schristos #include "compress/zstd_double_fast.c" 74*3117ece4Schristos #include "compress/zstd_fast.c" 75*3117ece4Schristos #include "compress/zstd_lazy.c" 76*3117ece4Schristos #include "compress/zstd_ldm.c" 77*3117ece4Schristos #include "compress/zstd_opt.c" 78*3117ece4Schristos #ifdef ZSTD_MULTITHREAD 79*3117ece4Schristos #include "compress/zstdmt_compress.c" 80*3117ece4Schristos #endif 81*3117ece4Schristos 82*3117ece4Schristos #include "decompress/huf_decompress.c" 83*3117ece4Schristos #include "decompress/zstd_ddict.c" 84*3117ece4Schristos #include "decompress/zstd_decompress.c" 85*3117ece4Schristos #include "decompress/zstd_decompress_block.c" 86*3117ece4Schristos 87*3117ece4Schristos #include "dictBuilder/cover.c" 88*3117ece4Schristos #include "dictBuilder/divsufsort.c" 89*3117ece4Schristos #include "dictBuilder/fastcover.c" 90*3117ece4Schristos #include "dictBuilder/zdict.c" 91