Add early config file parsing
Also cleaned up contrib/ and made lz4 and xxhash subprojects installed via wrap.
This commit is contained in:
		
							parent
							
								
									8c5b87f1de
								
							
						
					
					
						commit
						4e02d43514
					
				
							
								
								
									
										11
									
								
								cfg/engine_early.cfg
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								cfg/engine_early.cfg
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,11 @@
 | 
				
			|||||||
 | 
					; This file contains configuration options that are used during runtime init.
 | 
				
			||||||
 | 
					rt_AssertEnabled = 1
 | 
				
			||||||
 | 
					rt_MaxConcurrentAsyncIO = 1024
 | 
				
			||||||
 | 
					rt_BufferMemoryBudget = 1073741824 ; 1GB
 | 
				
			||||||
 | 
					rt_FileTabCapacity = 1024
 | 
				
			||||||
 | 
					rt_TemporaryArenaSize = 33554432 ; 32 MB
 | 
				
			||||||
 | 
					rt_ResourceDirectory = res
 | 
				
			||||||
 | 
					rt_ResourceCacheSize = 536870912 ; 512 MB
 | 
				
			||||||
 | 
					rt_MaxCachedResources = 1024
 | 
				
			||||||
 | 
					rt_ResourceNamespaceSize = 1048576
 | 
				
			||||||
 | 
					rt_DisableResourceNamespaceLoad = 0
 | 
				
			||||||
@ -1,24 +0,0 @@
 | 
				
			|||||||
LZ4 Library
 | 
					 | 
				
			||||||
Copyright (c) 2011-2020, Yann Collet
 | 
					 | 
				
			||||||
All rights reserved.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Redistribution and use in source and binary forms, with or without modification,
 | 
					 | 
				
			||||||
are permitted provided that the following conditions are met:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
* Redistributions of source code must retain the above copyright notice, this
 | 
					 | 
				
			||||||
  list of conditions and the following disclaimer.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
* Redistributions in binary form must reproduce the above copyright notice, this
 | 
					 | 
				
			||||||
  list of conditions and the following disclaimer in the documentation and/or
 | 
					 | 
				
			||||||
  other materials provided with the distribution.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 | 
					 | 
				
			||||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 | 
					 | 
				
			||||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 | 
					 | 
				
			||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
 | 
					 | 
				
			||||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 | 
					 | 
				
			||||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 | 
					 | 
				
			||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
 | 
					 | 
				
			||||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 | 
					 | 
				
			||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 | 
					 | 
				
			||||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 | 
					 | 
				
			||||||
							
								
								
									
										2766
									
								
								contrib/lz4/lz4.c
									
									
									
									
									
								
							
							
						
						
									
										2766
									
								
								contrib/lz4/lz4.c
									
									
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@ -1,862 +0,0 @@
 | 
				
			|||||||
/*
 | 
					 | 
				
			||||||
 *  LZ4 - Fast LZ compression algorithm
 | 
					 | 
				
			||||||
 *  Header File
 | 
					 | 
				
			||||||
 *  Copyright (C) 2011-2020, Yann Collet.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
   BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
   Redistribution and use in source and binary forms, with or without
 | 
					 | 
				
			||||||
   modification, are permitted provided that the following conditions are
 | 
					 | 
				
			||||||
   met:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
       * Redistributions of source code must retain the above copyright
 | 
					 | 
				
			||||||
   notice, this list of conditions and the following disclaimer.
 | 
					 | 
				
			||||||
       * Redistributions in binary form must reproduce the above
 | 
					 | 
				
			||||||
   copyright notice, this list of conditions and the following disclaimer
 | 
					 | 
				
			||||||
   in the documentation and/or other materials provided with the
 | 
					 | 
				
			||||||
   distribution.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 | 
					 | 
				
			||||||
   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 | 
					 | 
				
			||||||
   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 | 
					 | 
				
			||||||
   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 | 
					 | 
				
			||||||
   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 | 
					 | 
				
			||||||
   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 | 
					 | 
				
			||||||
   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 | 
					 | 
				
			||||||
   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 | 
					 | 
				
			||||||
   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 | 
					 | 
				
			||||||
   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 | 
					 | 
				
			||||||
   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
   You can contact the author at :
 | 
					 | 
				
			||||||
    - LZ4 homepage : http://www.lz4.org
 | 
					 | 
				
			||||||
    - LZ4 source repository : https://github.com/lz4/lz4
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
#if defined (__cplusplus)
 | 
					 | 
				
			||||||
extern "C" {
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifndef LZ4_H_2983827168210
 | 
					 | 
				
			||||||
#define LZ4_H_2983827168210
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* --- Dependency --- */
 | 
					 | 
				
			||||||
#include <stddef.h>   /* size_t */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/**
 | 
					 | 
				
			||||||
  Introduction
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  LZ4 is lossless compression algorithm, providing compression speed >500 MB/s per core,
 | 
					 | 
				
			||||||
  scalable with multi-cores CPU. It features an extremely fast decoder, with speed in
 | 
					 | 
				
			||||||
  multiple GB/s per core, typically reaching RAM speed limits on multi-core systems.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  The LZ4 compression library provides in-memory compression and decompression functions.
 | 
					 | 
				
			||||||
  It gives full buffer control to user.
 | 
					 | 
				
			||||||
  Compression can be done in:
 | 
					 | 
				
			||||||
    - a single step (described as Simple Functions)
 | 
					 | 
				
			||||||
    - a single step, reusing a context (described in Advanced Functions)
 | 
					 | 
				
			||||||
    - unbounded multiple steps (described as Streaming compression)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  lz4.h generates and decodes LZ4-compressed blocks (doc/lz4_Block_format.md).
 | 
					 | 
				
			||||||
  Decompressing such a compressed block requires additional metadata.
 | 
					 | 
				
			||||||
  Exact metadata depends on exact decompression function.
 | 
					 | 
				
			||||||
  For the typical case of LZ4_decompress_safe(),
 | 
					 | 
				
			||||||
  metadata includes block's compressed size, and maximum bound of decompressed size.
 | 
					 | 
				
			||||||
  Each application is free to encode and pass such metadata in whichever way it wants.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  lz4.h only handle blocks, it can not generate Frames.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  Blocks are different from Frames (doc/lz4_Frame_format.md).
 | 
					 | 
				
			||||||
  Frames bundle both blocks and metadata in a specified manner.
 | 
					 | 
				
			||||||
  Embedding metadata is required for compressed data to be self-contained and portable.
 | 
					 | 
				
			||||||
  Frame format is delivered through a companion API, declared in lz4frame.h.
 | 
					 | 
				
			||||||
  The `lz4` CLI can only manage frames.
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*^***************************************************************
 | 
					 | 
				
			||||||
*  Export parameters
 | 
					 | 
				
			||||||
*****************************************************************/
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
*  LZ4_DLL_EXPORT :
 | 
					 | 
				
			||||||
*  Enable exporting of functions when building a Windows DLL
 | 
					 | 
				
			||||||
*  LZ4LIB_VISIBILITY :
 | 
					 | 
				
			||||||
*  Control library symbols visibility.
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
#ifndef LZ4LIB_VISIBILITY
 | 
					 | 
				
			||||||
#  if defined(__GNUC__) && (__GNUC__ >= 4)
 | 
					 | 
				
			||||||
#    define LZ4LIB_VISIBILITY __attribute__ ((visibility ("default")))
 | 
					 | 
				
			||||||
#  else
 | 
					 | 
				
			||||||
#    define LZ4LIB_VISIBILITY
 | 
					 | 
				
			||||||
#  endif
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
#if defined(LZ4_DLL_EXPORT) && (LZ4_DLL_EXPORT==1)
 | 
					 | 
				
			||||||
#  define LZ4LIB_API __declspec(dllexport) LZ4LIB_VISIBILITY
 | 
					 | 
				
			||||||
#elif defined(LZ4_DLL_IMPORT) && (LZ4_DLL_IMPORT==1)
 | 
					 | 
				
			||||||
#  define LZ4LIB_API __declspec(dllimport) LZ4LIB_VISIBILITY /* It isn't required but allows to generate better code, saving a function pointer load from the IAT and an indirect jump.*/
 | 
					 | 
				
			||||||
#else
 | 
					 | 
				
			||||||
#  define LZ4LIB_API LZ4LIB_VISIBILITY
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*! LZ4_FREESTANDING :
 | 
					 | 
				
			||||||
 *  When this macro is set to 1, it enables "freestanding mode" that is
 | 
					 | 
				
			||||||
 *  suitable for typical freestanding environment which doesn't support
 | 
					 | 
				
			||||||
 *  standard C library.
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 *  - LZ4_FREESTANDING is a compile-time switch.
 | 
					 | 
				
			||||||
 *  - It requires the following macros to be defined:
 | 
					 | 
				
			||||||
 *    LZ4_memcpy, LZ4_memmove, LZ4_memset.
 | 
					 | 
				
			||||||
 *  - It only enables LZ4/HC functions which don't use heap.
 | 
					 | 
				
			||||||
 *    All LZ4F_* functions are not supported.
 | 
					 | 
				
			||||||
 *  - See tests/freestanding.c to check its basic setup.
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
#if defined(LZ4_FREESTANDING) && (LZ4_FREESTANDING == 1)
 | 
					 | 
				
			||||||
#  define LZ4_HEAPMODE 0
 | 
					 | 
				
			||||||
#  define LZ4HC_HEAPMODE 0
 | 
					 | 
				
			||||||
#  define LZ4_STATIC_LINKING_ONLY_DISABLE_MEMORY_ALLOCATION 1
 | 
					 | 
				
			||||||
#  if !defined(LZ4_memcpy)
 | 
					 | 
				
			||||||
#    error "LZ4_FREESTANDING requires macro 'LZ4_memcpy'."
 | 
					 | 
				
			||||||
#  endif
 | 
					 | 
				
			||||||
#  if !defined(LZ4_memset)
 | 
					 | 
				
			||||||
#    error "LZ4_FREESTANDING requires macro 'LZ4_memset'."
 | 
					 | 
				
			||||||
#  endif
 | 
					 | 
				
			||||||
#  if !defined(LZ4_memmove)
 | 
					 | 
				
			||||||
#    error "LZ4_FREESTANDING requires macro 'LZ4_memmove'."
 | 
					 | 
				
			||||||
#  endif
 | 
					 | 
				
			||||||
#elif ! defined(LZ4_FREESTANDING)
 | 
					 | 
				
			||||||
#  define LZ4_FREESTANDING 0
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*------   Version   ------*/
 | 
					 | 
				
			||||||
#define LZ4_VERSION_MAJOR    1    /* for breaking interface changes  */
 | 
					 | 
				
			||||||
#define LZ4_VERSION_MINOR    9    /* for new (non-breaking) interface capabilities */
 | 
					 | 
				
			||||||
#define LZ4_VERSION_RELEASE  5    /* for tweaks, bug-fixes, or development */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define LZ4_VERSION_NUMBER (LZ4_VERSION_MAJOR *100*100 + LZ4_VERSION_MINOR *100 + LZ4_VERSION_RELEASE)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define LZ4_LIB_VERSION LZ4_VERSION_MAJOR.LZ4_VERSION_MINOR.LZ4_VERSION_RELEASE
 | 
					 | 
				
			||||||
#define LZ4_QUOTE(str) #str
 | 
					 | 
				
			||||||
#define LZ4_EXPAND_AND_QUOTE(str) LZ4_QUOTE(str)
 | 
					 | 
				
			||||||
#define LZ4_VERSION_STRING LZ4_EXPAND_AND_QUOTE(LZ4_LIB_VERSION)  /* requires v1.7.3+ */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
LZ4LIB_API int LZ4_versionNumber (void);  /**< library version number; useful to check dll version; requires v1.3.0+ */
 | 
					 | 
				
			||||||
LZ4LIB_API const char* LZ4_versionString (void);   /**< library version string; useful to check dll version; requires v1.7.5+ */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*-************************************
 | 
					 | 
				
			||||||
*  Tuning parameter
 | 
					 | 
				
			||||||
**************************************/
 | 
					 | 
				
			||||||
#define LZ4_MEMORY_USAGE_MIN 10
 | 
					 | 
				
			||||||
#define LZ4_MEMORY_USAGE_DEFAULT 14
 | 
					 | 
				
			||||||
#define LZ4_MEMORY_USAGE_MAX 20
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*!
 | 
					 | 
				
			||||||
 * LZ4_MEMORY_USAGE :
 | 
					 | 
				
			||||||
 * Memory usage formula : N->2^N Bytes (examples : 10 -> 1KB; 12 -> 4KB ; 16 -> 64KB; 20 -> 1MB; )
 | 
					 | 
				
			||||||
 * Increasing memory usage improves compression ratio, at the cost of speed.
 | 
					 | 
				
			||||||
 * Reduced memory usage may improve speed at the cost of ratio, thanks to better cache locality.
 | 
					 | 
				
			||||||
 * Default value is 14, for 16KB, which nicely fits into Intel x86 L1 cache
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
#ifndef LZ4_MEMORY_USAGE
 | 
					 | 
				
			||||||
# define LZ4_MEMORY_USAGE LZ4_MEMORY_USAGE_DEFAULT
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#if (LZ4_MEMORY_USAGE < LZ4_MEMORY_USAGE_MIN)
 | 
					 | 
				
			||||||
#  error "LZ4_MEMORY_USAGE is too small !"
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#if (LZ4_MEMORY_USAGE > LZ4_MEMORY_USAGE_MAX)
 | 
					 | 
				
			||||||
#  error "LZ4_MEMORY_USAGE is too large !"
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*-************************************
 | 
					 | 
				
			||||||
*  Simple Functions
 | 
					 | 
				
			||||||
**************************************/
 | 
					 | 
				
			||||||
/*! LZ4_compress_default() :
 | 
					 | 
				
			||||||
 *  Compresses 'srcSize' bytes from buffer 'src'
 | 
					 | 
				
			||||||
 *  into already allocated 'dst' buffer of size 'dstCapacity'.
 | 
					 | 
				
			||||||
 *  Compression is guaranteed to succeed if 'dstCapacity' >= LZ4_compressBound(srcSize).
 | 
					 | 
				
			||||||
 *  It also runs faster, so it's a recommended setting.
 | 
					 | 
				
			||||||
 *  If the function cannot compress 'src' into a more limited 'dst' budget,
 | 
					 | 
				
			||||||
 *  compression stops *immediately*, and the function result is zero.
 | 
					 | 
				
			||||||
 *  In which case, 'dst' content is undefined (invalid).
 | 
					 | 
				
			||||||
 *      srcSize : max supported value is LZ4_MAX_INPUT_SIZE.
 | 
					 | 
				
			||||||
 *      dstCapacity : size of buffer 'dst' (which must be already allocated)
 | 
					 | 
				
			||||||
 *     @return  : the number of bytes written into buffer 'dst' (necessarily <= dstCapacity)
 | 
					 | 
				
			||||||
 *                or 0 if compression fails
 | 
					 | 
				
			||||||
 * Note : This function is protected against buffer overflow scenarios (never writes outside 'dst' buffer, nor read outside 'source' buffer).
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
LZ4LIB_API int LZ4_compress_default(const char* src, char* dst, int srcSize, int dstCapacity);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*! LZ4_decompress_safe() :
 | 
					 | 
				
			||||||
 * @compressedSize : is the exact complete size of the compressed block.
 | 
					 | 
				
			||||||
 * @dstCapacity : is the size of destination buffer (which must be already allocated),
 | 
					 | 
				
			||||||
 *                is an upper bound of decompressed size.
 | 
					 | 
				
			||||||
 * @return : the number of bytes decompressed into destination buffer (necessarily <= dstCapacity)
 | 
					 | 
				
			||||||
 *           If destination buffer is not large enough, decoding will stop and output an error code (negative value).
 | 
					 | 
				
			||||||
 *           If the source stream is detected malformed, the function will stop decoding and return a negative result.
 | 
					 | 
				
			||||||
 * Note 1 : This function is protected against malicious data packets :
 | 
					 | 
				
			||||||
 *          it will never writes outside 'dst' buffer, nor read outside 'source' buffer,
 | 
					 | 
				
			||||||
 *          even if the compressed block is maliciously modified to order the decoder to do these actions.
 | 
					 | 
				
			||||||
 *          In such case, the decoder stops immediately, and considers the compressed block malformed.
 | 
					 | 
				
			||||||
 * Note 2 : compressedSize and dstCapacity must be provided to the function, the compressed block does not contain them.
 | 
					 | 
				
			||||||
 *          The implementation is free to send / store / derive this information in whichever way is most beneficial.
 | 
					 | 
				
			||||||
 *          If there is a need for a different format which bundles together both compressed data and its metadata, consider looking at lz4frame.h instead.
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
LZ4LIB_API int LZ4_decompress_safe (const char* src, char* dst, int compressedSize, int dstCapacity);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*-************************************
 | 
					 | 
				
			||||||
*  Advanced Functions
 | 
					 | 
				
			||||||
**************************************/
 | 
					 | 
				
			||||||
#define LZ4_MAX_INPUT_SIZE        0x7E000000   /* 2 113 929 216 bytes */
 | 
					 | 
				
			||||||
#define LZ4_COMPRESSBOUND(isize)  ((unsigned)(isize) > (unsigned)LZ4_MAX_INPUT_SIZE ? 0 : (isize) + ((isize)/255) + 16)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*! LZ4_compressBound() :
 | 
					 | 
				
			||||||
    Provides the maximum size that LZ4 compression may output in a "worst case" scenario (input data not compressible)
 | 
					 | 
				
			||||||
    This function is primarily useful for memory allocation purposes (destination buffer size).
 | 
					 | 
				
			||||||
    Macro LZ4_COMPRESSBOUND() is also provided for compilation-time evaluation (stack memory allocation for example).
 | 
					 | 
				
			||||||
    Note that LZ4_compress_default() compresses faster when dstCapacity is >= LZ4_compressBound(srcSize)
 | 
					 | 
				
			||||||
        inputSize  : max supported value is LZ4_MAX_INPUT_SIZE
 | 
					 | 
				
			||||||
        return : maximum output size in a "worst case" scenario
 | 
					 | 
				
			||||||
              or 0, if input size is incorrect (too large or negative)
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
LZ4LIB_API int LZ4_compressBound(int inputSize);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*! LZ4_compress_fast() :
 | 
					 | 
				
			||||||
    Same as LZ4_compress_default(), but allows selection of "acceleration" factor.
 | 
					 | 
				
			||||||
    The larger the acceleration value, the faster the algorithm, but also the lesser the compression.
 | 
					 | 
				
			||||||
    It's a trade-off. It can be fine tuned, with each successive value providing roughly +~3% to speed.
 | 
					 | 
				
			||||||
    An acceleration value of "1" is the same as regular LZ4_compress_default()
 | 
					 | 
				
			||||||
    Values <= 0 will be replaced by LZ4_ACCELERATION_DEFAULT (currently == 1, see lz4.c).
 | 
					 | 
				
			||||||
    Values > LZ4_ACCELERATION_MAX will be replaced by LZ4_ACCELERATION_MAX (currently == 65537, see lz4.c).
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
LZ4LIB_API int LZ4_compress_fast (const char* src, char* dst, int srcSize, int dstCapacity, int acceleration);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*! LZ4_compress_fast_extState() :
 | 
					 | 
				
			||||||
 *  Same as LZ4_compress_fast(), using an externally allocated memory space for its state.
 | 
					 | 
				
			||||||
 *  Use LZ4_sizeofState() to know how much memory must be allocated,
 | 
					 | 
				
			||||||
 *  and allocate it on 8-bytes boundaries (using `malloc()` typically).
 | 
					 | 
				
			||||||
 *  Then, provide this buffer as `void* state` to compression function.
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
LZ4LIB_API int LZ4_sizeofState(void);
 | 
					 | 
				
			||||||
LZ4LIB_API int LZ4_compress_fast_extState (void* state, const char* src, char* dst, int srcSize, int dstCapacity, int acceleration);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*! LZ4_compress_destSize() :
 | 
					 | 
				
			||||||
 *  Reverse the logic : compresses as much data as possible from 'src' buffer
 | 
					 | 
				
			||||||
 *  into already allocated buffer 'dst', of size >= 'targetDestSize'.
 | 
					 | 
				
			||||||
 *  This function either compresses the entire 'src' content into 'dst' if it's large enough,
 | 
					 | 
				
			||||||
 *  or fill 'dst' buffer completely with as much data as possible from 'src'.
 | 
					 | 
				
			||||||
 *  note: acceleration parameter is fixed to "default".
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * *srcSizePtr : will be modified to indicate how many bytes where read from 'src' to fill 'dst'.
 | 
					 | 
				
			||||||
 *               New value is necessarily <= input value.
 | 
					 | 
				
			||||||
 * @return : Nb bytes written into 'dst' (necessarily <= targetDestSize)
 | 
					 | 
				
			||||||
 *           or 0 if compression fails.
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * Note : from v1.8.2 to v1.9.1, this function had a bug (fixed in v1.9.2+):
 | 
					 | 
				
			||||||
 *        the produced compressed content could, in specific circumstances,
 | 
					 | 
				
			||||||
 *        require to be decompressed into a destination buffer larger
 | 
					 | 
				
			||||||
 *        by at least 1 byte than the content to decompress.
 | 
					 | 
				
			||||||
 *        If an application uses `LZ4_compress_destSize()`,
 | 
					 | 
				
			||||||
 *        it's highly recommended to update liblz4 to v1.9.2 or better.
 | 
					 | 
				
			||||||
 *        If this can't be done or ensured,
 | 
					 | 
				
			||||||
 *        the receiving decompression function should provide
 | 
					 | 
				
			||||||
 *        a dstCapacity which is > decompressedSize, by at least 1 byte.
 | 
					 | 
				
			||||||
 *        See https://github.com/lz4/lz4/issues/859 for details
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
LZ4LIB_API int LZ4_compress_destSize (const char* src, char* dst, int* srcSizePtr, int targetDstSize);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*! LZ4_decompress_safe_partial() :
 | 
					 | 
				
			||||||
 *  Decompress an LZ4 compressed block, of size 'srcSize' at position 'src',
 | 
					 | 
				
			||||||
 *  into destination buffer 'dst' of size 'dstCapacity'.
 | 
					 | 
				
			||||||
 *  Up to 'targetOutputSize' bytes will be decoded.
 | 
					 | 
				
			||||||
 *  The function stops decoding on reaching this objective.
 | 
					 | 
				
			||||||
 *  This can be useful to boost performance
 | 
					 | 
				
			||||||
 *  whenever only the beginning of a block is required.
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * @return : the number of bytes decoded in `dst` (necessarily <= targetOutputSize)
 | 
					 | 
				
			||||||
 *           If source stream is detected malformed, function returns a negative result.
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 *  Note 1 : @return can be < targetOutputSize, if compressed block contains less data.
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 *  Note 2 : targetOutputSize must be <= dstCapacity
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 *  Note 3 : this function effectively stops decoding on reaching targetOutputSize,
 | 
					 | 
				
			||||||
 *           so dstCapacity is kind of redundant.
 | 
					 | 
				
			||||||
 *           This is because in older versions of this function,
 | 
					 | 
				
			||||||
 *           decoding operation would still write complete sequences.
 | 
					 | 
				
			||||||
 *           Therefore, there was no guarantee that it would stop writing at exactly targetOutputSize,
 | 
					 | 
				
			||||||
 *           it could write more bytes, though only up to dstCapacity.
 | 
					 | 
				
			||||||
 *           Some "margin" used to be required for this operation to work properly.
 | 
					 | 
				
			||||||
 *           Thankfully, this is no longer necessary.
 | 
					 | 
				
			||||||
 *           The function nonetheless keeps the same signature, in an effort to preserve API compatibility.
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 *  Note 4 : If srcSize is the exact size of the block,
 | 
					 | 
				
			||||||
 *           then targetOutputSize can be any value,
 | 
					 | 
				
			||||||
 *           including larger than the block's decompressed size.
 | 
					 | 
				
			||||||
 *           The function will, at most, generate block's decompressed size.
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 *  Note 5 : If srcSize is _larger_ than block's compressed size,
 | 
					 | 
				
			||||||
 *           then targetOutputSize **MUST** be <= block's decompressed size.
 | 
					 | 
				
			||||||
 *           Otherwise, *silent corruption will occur*.
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
LZ4LIB_API int LZ4_decompress_safe_partial (const char* src, char* dst, int srcSize, int targetOutputSize, int dstCapacity);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*-*********************************************
 | 
					 | 
				
			||||||
*  Streaming Compression Functions
 | 
					 | 
				
			||||||
***********************************************/
 | 
					 | 
				
			||||||
typedef union LZ4_stream_u LZ4_stream_t;  /* incomplete type (defined later) */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/**
 | 
					 | 
				
			||||||
 Note about RC_INVOKED
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 - RC_INVOKED is predefined symbol of rc.exe (the resource compiler which is part of MSVC/Visual Studio).
 | 
					 | 
				
			||||||
   https://docs.microsoft.com/en-us/windows/win32/menurc/predefined-macros
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 - Since rc.exe is a legacy compiler, it truncates long symbol (> 30 chars)
 | 
					 | 
				
			||||||
   and reports warning "RC4011: identifier truncated".
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 - To eliminate the warning, we surround long preprocessor symbol with
 | 
					 | 
				
			||||||
   "#if !defined(RC_INVOKED) ... #endif" block that means
 | 
					 | 
				
			||||||
   "skip this block when rc.exe is trying to read it".
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
#if !defined(RC_INVOKED) /* https://docs.microsoft.com/en-us/windows/win32/menurc/predefined-macros */
 | 
					 | 
				
			||||||
#if !defined(LZ4_STATIC_LINKING_ONLY_DISABLE_MEMORY_ALLOCATION)
 | 
					 | 
				
			||||||
LZ4LIB_API LZ4_stream_t* LZ4_createStream(void);
 | 
					 | 
				
			||||||
LZ4LIB_API int           LZ4_freeStream (LZ4_stream_t* streamPtr);
 | 
					 | 
				
			||||||
#endif /* !defined(LZ4_STATIC_LINKING_ONLY_DISABLE_MEMORY_ALLOCATION) */
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*! LZ4_resetStream_fast() : v1.9.0+
 | 
					 | 
				
			||||||
 *  Use this to prepare an LZ4_stream_t for a new chain of dependent blocks
 | 
					 | 
				
			||||||
 *  (e.g., LZ4_compress_fast_continue()).
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 *  An LZ4_stream_t must be initialized once before usage.
 | 
					 | 
				
			||||||
 *  This is automatically done when created by LZ4_createStream().
 | 
					 | 
				
			||||||
 *  However, should the LZ4_stream_t be simply declared on stack (for example),
 | 
					 | 
				
			||||||
 *  it's necessary to initialize it first, using LZ4_initStream().
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 *  After init, start any new stream with LZ4_resetStream_fast().
 | 
					 | 
				
			||||||
 *  A same LZ4_stream_t can be re-used multiple times consecutively
 | 
					 | 
				
			||||||
 *  and compress multiple streams,
 | 
					 | 
				
			||||||
 *  provided that it starts each new stream with LZ4_resetStream_fast().
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 *  LZ4_resetStream_fast() is much faster than LZ4_initStream(),
 | 
					 | 
				
			||||||
 *  but is not compatible with memory regions containing garbage data.
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 *  Note: it's only useful to call LZ4_resetStream_fast()
 | 
					 | 
				
			||||||
 *        in the context of streaming compression.
 | 
					 | 
				
			||||||
 *        The *extState* functions perform their own resets.
 | 
					 | 
				
			||||||
 *        Invoking LZ4_resetStream_fast() before is redundant, and even counterproductive.
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
LZ4LIB_API void LZ4_resetStream_fast (LZ4_stream_t* streamPtr);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*! LZ4_loadDict() :
 | 
					 | 
				
			||||||
 *  Use this function to reference a static dictionary into LZ4_stream_t.
 | 
					 | 
				
			||||||
 *  The dictionary must remain available during compression.
 | 
					 | 
				
			||||||
 *  LZ4_loadDict() triggers a reset, so any previous data will be forgotten.
 | 
					 | 
				
			||||||
 *  The same dictionary will have to be loaded on decompression side for successful decoding.
 | 
					 | 
				
			||||||
 *  Dictionary are useful for better compression of small data (KB range).
 | 
					 | 
				
			||||||
 *  While LZ4 accept any input as dictionary,
 | 
					 | 
				
			||||||
 *  results are generally better when using Zstandard's Dictionary Builder.
 | 
					 | 
				
			||||||
 *  Loading a size of 0 is allowed, and is the same as reset.
 | 
					 | 
				
			||||||
 * @return : loaded dictionary size, in bytes (necessarily <= 64 KB)
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
LZ4LIB_API int LZ4_loadDict (LZ4_stream_t* streamPtr, const char* dictionary, int dictSize);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*! LZ4_compress_fast_continue() :
 | 
					 | 
				
			||||||
 *  Compress 'src' content using data from previously compressed blocks, for better compression ratio.
 | 
					 | 
				
			||||||
 * 'dst' buffer must be already allocated.
 | 
					 | 
				
			||||||
 *  If dstCapacity >= LZ4_compressBound(srcSize), compression is guaranteed to succeed, and runs faster.
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * @return : size of compressed block
 | 
					 | 
				
			||||||
 *           or 0 if there is an error (typically, cannot fit into 'dst').
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 *  Note 1 : Each invocation to LZ4_compress_fast_continue() generates a new block.
 | 
					 | 
				
			||||||
 *           Each block has precise boundaries.
 | 
					 | 
				
			||||||
 *           Each block must be decompressed separately, calling LZ4_decompress_*() with relevant metadata.
 | 
					 | 
				
			||||||
 *           It's not possible to append blocks together and expect a single invocation of LZ4_decompress_*() to decompress them together.
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 *  Note 2 : The previous 64KB of source data is __assumed__ to remain present, unmodified, at same address in memory !
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 *  Note 3 : When input is structured as a double-buffer, each buffer can have any size, including < 64 KB.
 | 
					 | 
				
			||||||
 *           Make sure that buffers are separated, by at least one byte.
 | 
					 | 
				
			||||||
 *           This construction ensures that each block only depends on previous block.
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 *  Note 4 : If input buffer is a ring-buffer, it can have any size, including < 64 KB.
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 *  Note 5 : After an error, the stream status is undefined (invalid), it can only be reset or freed.
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
LZ4LIB_API int LZ4_compress_fast_continue (LZ4_stream_t* streamPtr, const char* src, char* dst, int srcSize, int dstCapacity, int acceleration);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*! LZ4_saveDict() :
 | 
					 | 
				
			||||||
 *  If last 64KB data cannot be guaranteed to remain available at its current memory location,
 | 
					 | 
				
			||||||
 *  save it into a safer place (char* safeBuffer).
 | 
					 | 
				
			||||||
 *  This is schematically equivalent to a memcpy() followed by LZ4_loadDict(),
 | 
					 | 
				
			||||||
 *  but is much faster, because LZ4_saveDict() doesn't need to rebuild tables.
 | 
					 | 
				
			||||||
 * @return : saved dictionary size in bytes (necessarily <= maxDictSize), or 0 if error.
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
LZ4LIB_API int LZ4_saveDict (LZ4_stream_t* streamPtr, char* safeBuffer, int maxDictSize);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*-**********************************************
 | 
					 | 
				
			||||||
*  Streaming Decompression Functions
 | 
					 | 
				
			||||||
*  Bufferless synchronous API
 | 
					 | 
				
			||||||
************************************************/
 | 
					 | 
				
			||||||
typedef union LZ4_streamDecode_u LZ4_streamDecode_t;   /* tracking context */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*! LZ4_createStreamDecode() and LZ4_freeStreamDecode() :
 | 
					 | 
				
			||||||
 *  creation / destruction of streaming decompression tracking context.
 | 
					 | 
				
			||||||
 *  A tracking context can be re-used multiple times.
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
#if !defined(RC_INVOKED) /* https://docs.microsoft.com/en-us/windows/win32/menurc/predefined-macros */
 | 
					 | 
				
			||||||
#if !defined(LZ4_STATIC_LINKING_ONLY_DISABLE_MEMORY_ALLOCATION)
 | 
					 | 
				
			||||||
LZ4LIB_API LZ4_streamDecode_t* LZ4_createStreamDecode(void);
 | 
					 | 
				
			||||||
LZ4LIB_API int                 LZ4_freeStreamDecode (LZ4_streamDecode_t* LZ4_stream);
 | 
					 | 
				
			||||||
#endif /* !defined(LZ4_STATIC_LINKING_ONLY_DISABLE_MEMORY_ALLOCATION) */
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*! LZ4_setStreamDecode() :
 | 
					 | 
				
			||||||
 *  An LZ4_streamDecode_t context can be allocated once and re-used multiple times.
 | 
					 | 
				
			||||||
 *  Use this function to start decompression of a new stream of blocks.
 | 
					 | 
				
			||||||
 *  A dictionary can optionally be set. Use NULL or size 0 for a reset order.
 | 
					 | 
				
			||||||
 *  Dictionary is presumed stable : it must remain accessible and unmodified during next decompression.
 | 
					 | 
				
			||||||
 * @return : 1 if OK, 0 if error
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
LZ4LIB_API int LZ4_setStreamDecode (LZ4_streamDecode_t* LZ4_streamDecode, const char* dictionary, int dictSize);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*! LZ4_decoderRingBufferSize() : v1.8.2+
 | 
					 | 
				
			||||||
 *  Note : in a ring buffer scenario (optional),
 | 
					 | 
				
			||||||
 *  blocks are presumed decompressed next to each other
 | 
					 | 
				
			||||||
 *  up to the moment there is not enough remaining space for next block (remainingSize < maxBlockSize),
 | 
					 | 
				
			||||||
 *  at which stage it resumes from beginning of ring buffer.
 | 
					 | 
				
			||||||
 *  When setting such a ring buffer for streaming decompression,
 | 
					 | 
				
			||||||
 *  provides the minimum size of this ring buffer
 | 
					 | 
				
			||||||
 *  to be compatible with any source respecting maxBlockSize condition.
 | 
					 | 
				
			||||||
 * @return : minimum ring buffer size,
 | 
					 | 
				
			||||||
 *           or 0 if there is an error (invalid maxBlockSize).
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
LZ4LIB_API int LZ4_decoderRingBufferSize(int maxBlockSize);
 | 
					 | 
				
			||||||
#define LZ4_DECODER_RING_BUFFER_SIZE(maxBlockSize) (65536 + 14 + (maxBlockSize))  /* for static allocation; maxBlockSize presumed valid */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*! LZ4_decompress_safe_continue() :
 | 
					 | 
				
			||||||
 *  This decoding function allows decompression of consecutive blocks in "streaming" mode.
 | 
					 | 
				
			||||||
 *  The difference with the usual independent blocks is that
 | 
					 | 
				
			||||||
 *  new blocks are allowed to find references into former blocks.
 | 
					 | 
				
			||||||
 *  A block is an unsplittable entity, and must be presented entirely to the decompression function.
 | 
					 | 
				
			||||||
 *  LZ4_decompress_safe_continue() only accepts one block at a time.
 | 
					 | 
				
			||||||
 *  It's modeled after `LZ4_decompress_safe()` and behaves similarly.
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * @LZ4_streamDecode : decompression state, tracking the position in memory of past data
 | 
					 | 
				
			||||||
 * @compressedSize : exact complete size of one compressed block.
 | 
					 | 
				
			||||||
 * @dstCapacity : size of destination buffer (which must be already allocated),
 | 
					 | 
				
			||||||
 *                must be an upper bound of decompressed size.
 | 
					 | 
				
			||||||
 * @return : number of bytes decompressed into destination buffer (necessarily <= dstCapacity)
 | 
					 | 
				
			||||||
 *           If destination buffer is not large enough, decoding will stop and output an error code (negative value).
 | 
					 | 
				
			||||||
 *           If the source stream is detected malformed, the function will stop decoding and return a negative result.
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 *  The last 64KB of previously decoded data *must* remain available and unmodified
 | 
					 | 
				
			||||||
 *  at the memory position where they were previously decoded.
 | 
					 | 
				
			||||||
 *  If less than 64KB of data has been decoded, all the data must be present.
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 *  Special : if decompression side sets a ring buffer, it must respect one of the following conditions :
 | 
					 | 
				
			||||||
 *  - Decompression buffer size is _at least_ LZ4_decoderRingBufferSize(maxBlockSize).
 | 
					 | 
				
			||||||
 *    maxBlockSize is the maximum size of any single block. It can have any value > 16 bytes.
 | 
					 | 
				
			||||||
 *    In which case, encoding and decoding buffers do not need to be synchronized.
 | 
					 | 
				
			||||||
 *    Actually, data can be produced by any source compliant with LZ4 format specification, and respecting maxBlockSize.
 | 
					 | 
				
			||||||
 *  - Synchronized mode :
 | 
					 | 
				
			||||||
 *    Decompression buffer size is _exactly_ the same as compression buffer size,
 | 
					 | 
				
			||||||
 *    and follows exactly same update rule (block boundaries at same positions),
 | 
					 | 
				
			||||||
 *    and decoding function is provided with exact decompressed size of each block (exception for last block of the stream),
 | 
					 | 
				
			||||||
 *    _then_ decoding & encoding ring buffer can have any size, including small ones ( < 64 KB).
 | 
					 | 
				
			||||||
 *  - Decompression buffer is larger than encoding buffer, by a minimum of maxBlockSize more bytes.
 | 
					 | 
				
			||||||
 *    In which case, encoding and decoding buffers do not need to be synchronized,
 | 
					 | 
				
			||||||
 *    and encoding ring buffer can have any size, including small ones ( < 64 KB).
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 *  Whenever these conditions are not possible,
 | 
					 | 
				
			||||||
 *  save the last 64KB of decoded data into a safe buffer where it can't be modified during decompression,
 | 
					 | 
				
			||||||
 *  then indicate where this data is saved using LZ4_setStreamDecode(), before decompressing next block.
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
LZ4LIB_API int
 | 
					 | 
				
			||||||
LZ4_decompress_safe_continue (LZ4_streamDecode_t* LZ4_streamDecode,
 | 
					 | 
				
			||||||
                        const char* src, char* dst,
 | 
					 | 
				
			||||||
                        int srcSize, int dstCapacity);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*! LZ4_decompress_safe_usingDict() :
 | 
					 | 
				
			||||||
 *  Works the same as
 | 
					 | 
				
			||||||
 *  a combination of LZ4_setStreamDecode() followed by LZ4_decompress_safe_continue()
 | 
					 | 
				
			||||||
 *  However, it's stateless: it doesn't need any LZ4_streamDecode_t state.
 | 
					 | 
				
			||||||
 *  Dictionary is presumed stable : it must remain accessible and unmodified during decompression.
 | 
					 | 
				
			||||||
 *  Performance tip : Decompression speed can be substantially increased
 | 
					 | 
				
			||||||
 *                    when dst == dictStart + dictSize.
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
LZ4LIB_API int
 | 
					 | 
				
			||||||
LZ4_decompress_safe_usingDict(const char* src, char* dst,
 | 
					 | 
				
			||||||
                              int srcSize, int dstCapacity,
 | 
					 | 
				
			||||||
                              const char* dictStart, int dictSize);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*! LZ4_decompress_safe_partial_usingDict() :
 | 
					 | 
				
			||||||
 *  Behaves the same as LZ4_decompress_safe_partial()
 | 
					 | 
				
			||||||
 *  with the added ability to specify a memory segment for past data.
 | 
					 | 
				
			||||||
 *  Performance tip : Decompression speed can be substantially increased
 | 
					 | 
				
			||||||
 *                    when dst == dictStart + dictSize.
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
LZ4LIB_API int
 | 
					 | 
				
			||||||
LZ4_decompress_safe_partial_usingDict(const char* src, char* dst,
 | 
					 | 
				
			||||||
                                      int compressedSize,
 | 
					 | 
				
			||||||
                                      int targetOutputSize, int maxOutputSize,
 | 
					 | 
				
			||||||
                                      const char* dictStart, int dictSize);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#endif /* LZ4_H_2983827168210 */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*^*************************************
 | 
					 | 
				
			||||||
 * !!!!!!   STATIC LINKING ONLY   !!!!!!
 | 
					 | 
				
			||||||
 ***************************************/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*-****************************************************************************
 | 
					 | 
				
			||||||
 * Experimental section
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * Symbols declared in this section must be considered unstable. Their
 | 
					 | 
				
			||||||
 * signatures or semantics may change, or they may be removed altogether in the
 | 
					 | 
				
			||||||
 * future. They are therefore only safe to depend on when the caller is
 | 
					 | 
				
			||||||
 * statically linked against the library.
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * To protect against unsafe usage, not only are the declarations guarded,
 | 
					 | 
				
			||||||
 * the definitions are hidden by default
 | 
					 | 
				
			||||||
 * when building LZ4 as a shared/dynamic library.
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * In order to access these declarations,
 | 
					 | 
				
			||||||
 * define LZ4_STATIC_LINKING_ONLY in your application
 | 
					 | 
				
			||||||
 * before including LZ4's headers.
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * In order to make their implementations accessible dynamically, you must
 | 
					 | 
				
			||||||
 * define LZ4_PUBLISH_STATIC_FUNCTIONS when building the LZ4 library.
 | 
					 | 
				
			||||||
 ******************************************************************************/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifdef LZ4_STATIC_LINKING_ONLY
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifndef LZ4_STATIC_3504398509
 | 
					 | 
				
			||||||
#define LZ4_STATIC_3504398509
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifdef LZ4_PUBLISH_STATIC_FUNCTIONS
 | 
					 | 
				
			||||||
#define LZ4LIB_STATIC_API LZ4LIB_API
 | 
					 | 
				
			||||||
#else
 | 
					 | 
				
			||||||
#define LZ4LIB_STATIC_API
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*! LZ4_compress_fast_extState_fastReset() :
 | 
					 | 
				
			||||||
 *  A variant of LZ4_compress_fast_extState().
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 *  Using this variant avoids an expensive initialization step.
 | 
					 | 
				
			||||||
 *  It is only safe to call if the state buffer is known to be correctly initialized already
 | 
					 | 
				
			||||||
 *  (see above comment on LZ4_resetStream_fast() for a definition of "correctly initialized").
 | 
					 | 
				
			||||||
 *  From a high level, the difference is that
 | 
					 | 
				
			||||||
 *  this function initializes the provided state with a call to something like LZ4_resetStream_fast()
 | 
					 | 
				
			||||||
 *  while LZ4_compress_fast_extState() starts with a call to LZ4_resetStream().
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
LZ4LIB_STATIC_API int LZ4_compress_fast_extState_fastReset (void* state, const char* src, char* dst, int srcSize, int dstCapacity, int acceleration);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*! LZ4_attach_dictionary() :
 | 
					 | 
				
			||||||
 *  This is an experimental API that allows
 | 
					 | 
				
			||||||
 *  efficient use of a static dictionary many times.
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 *  Rather than re-loading the dictionary buffer into a working context before
 | 
					 | 
				
			||||||
 *  each compression, or copying a pre-loaded dictionary's LZ4_stream_t into a
 | 
					 | 
				
			||||||
 *  working LZ4_stream_t, this function introduces a no-copy setup mechanism,
 | 
					 | 
				
			||||||
 *  in which the working stream references the dictionary stream in-place.
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 *  Several assumptions are made about the state of the dictionary stream.
 | 
					 | 
				
			||||||
 *  Currently, only streams which have been prepared by LZ4_loadDict() should
 | 
					 | 
				
			||||||
 *  be expected to work.
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 *  Alternatively, the provided dictionaryStream may be NULL,
 | 
					 | 
				
			||||||
 *  in which case any existing dictionary stream is unset.
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 *  If a dictionary is provided, it replaces any pre-existing stream history.
 | 
					 | 
				
			||||||
 *  The dictionary contents are the only history that can be referenced and
 | 
					 | 
				
			||||||
 *  logically immediately precede the data compressed in the first subsequent
 | 
					 | 
				
			||||||
 *  compression call.
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 *  The dictionary will only remain attached to the working stream through the
 | 
					 | 
				
			||||||
 *  first compression call, at the end of which it is cleared. The dictionary
 | 
					 | 
				
			||||||
 *  stream (and source buffer) must remain in-place / accessible / unchanged
 | 
					 | 
				
			||||||
 *  through the completion of the first compression call on the stream.
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
LZ4LIB_STATIC_API void
 | 
					 | 
				
			||||||
LZ4_attach_dictionary(LZ4_stream_t* workingStream,
 | 
					 | 
				
			||||||
                const LZ4_stream_t* dictionaryStream);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*! In-place compression and decompression
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * It's possible to have input and output sharing the same buffer,
 | 
					 | 
				
			||||||
 * for highly constrained memory environments.
 | 
					 | 
				
			||||||
 * In both cases, it requires input to lay at the end of the buffer,
 | 
					 | 
				
			||||||
 * and decompression to start at beginning of the buffer.
 | 
					 | 
				
			||||||
 * Buffer size must feature some margin, hence be larger than final size.
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * |<------------------------buffer--------------------------------->|
 | 
					 | 
				
			||||||
 *                             |<-----------compressed data--------->|
 | 
					 | 
				
			||||||
 * |<-----------decompressed size------------------>|
 | 
					 | 
				
			||||||
 *                                                  |<----margin---->|
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * This technique is more useful for decompression,
 | 
					 | 
				
			||||||
 * since decompressed size is typically larger,
 | 
					 | 
				
			||||||
 * and margin is short.
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * In-place decompression will work inside any buffer
 | 
					 | 
				
			||||||
 * which size is >= LZ4_DECOMPRESS_INPLACE_BUFFER_SIZE(decompressedSize).
 | 
					 | 
				
			||||||
 * This presumes that decompressedSize > compressedSize.
 | 
					 | 
				
			||||||
 * Otherwise, it means compression actually expanded data,
 | 
					 | 
				
			||||||
 * and it would be more efficient to store such data with a flag indicating it's not compressed.
 | 
					 | 
				
			||||||
 * This can happen when data is not compressible (already compressed, or encrypted).
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * For in-place compression, margin is larger, as it must be able to cope with both
 | 
					 | 
				
			||||||
 * history preservation, requiring input data to remain unmodified up to LZ4_DISTANCE_MAX,
 | 
					 | 
				
			||||||
 * and data expansion, which can happen when input is not compressible.
 | 
					 | 
				
			||||||
 * As a consequence, buffer size requirements are much higher,
 | 
					 | 
				
			||||||
 * and memory savings offered by in-place compression are more limited.
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * There are ways to limit this cost for compression :
 | 
					 | 
				
			||||||
 * - Reduce history size, by modifying LZ4_DISTANCE_MAX.
 | 
					 | 
				
			||||||
 *   Note that it is a compile-time constant, so all compressions will apply this limit.
 | 
					 | 
				
			||||||
 *   Lower values will reduce compression ratio, except when input_size < LZ4_DISTANCE_MAX,
 | 
					 | 
				
			||||||
 *   so it's a reasonable trick when inputs are known to be small.
 | 
					 | 
				
			||||||
 * - Require the compressor to deliver a "maximum compressed size".
 | 
					 | 
				
			||||||
 *   This is the `dstCapacity` parameter in `LZ4_compress*()`.
 | 
					 | 
				
			||||||
 *   When this size is < LZ4_COMPRESSBOUND(inputSize), then compression can fail,
 | 
					 | 
				
			||||||
 *   in which case, the return code will be 0 (zero).
 | 
					 | 
				
			||||||
 *   The caller must be ready for these cases to happen,
 | 
					 | 
				
			||||||
 *   and typically design a backup scheme to send data uncompressed.
 | 
					 | 
				
			||||||
 * The combination of both techniques can significantly reduce
 | 
					 | 
				
			||||||
 * the amount of margin required for in-place compression.
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * In-place compression can work in any buffer
 | 
					 | 
				
			||||||
 * which size is >= (maxCompressedSize)
 | 
					 | 
				
			||||||
 * with maxCompressedSize == LZ4_COMPRESSBOUND(srcSize) for guaranteed compression success.
 | 
					 | 
				
			||||||
 * LZ4_COMPRESS_INPLACE_BUFFER_SIZE() depends on both maxCompressedSize and LZ4_DISTANCE_MAX,
 | 
					 | 
				
			||||||
 * so it's possible to reduce memory requirements by playing with them.
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define LZ4_DECOMPRESS_INPLACE_MARGIN(compressedSize)          (((compressedSize) >> 8) + 32)
 | 
					 | 
				
			||||||
#define LZ4_DECOMPRESS_INPLACE_BUFFER_SIZE(decompressedSize)   ((decompressedSize) + LZ4_DECOMPRESS_INPLACE_MARGIN(decompressedSize))  /**< note: presumes that compressedSize < decompressedSize. note2: margin is overestimated a bit, since it could use compressedSize instead */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifndef LZ4_DISTANCE_MAX   /* history window size; can be user-defined at compile time */
 | 
					 | 
				
			||||||
#  define LZ4_DISTANCE_MAX 65535   /* set to maximum value by default */
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define LZ4_COMPRESS_INPLACE_MARGIN                           (LZ4_DISTANCE_MAX + 32)   /* LZ4_DISTANCE_MAX can be safely replaced by srcSize when it's smaller */
 | 
					 | 
				
			||||||
#define LZ4_COMPRESS_INPLACE_BUFFER_SIZE(maxCompressedSize)   ((maxCompressedSize) + LZ4_COMPRESS_INPLACE_MARGIN)  /**< maxCompressedSize is generally LZ4_COMPRESSBOUND(inputSize), but can be set to any lower value, with the risk that compression can fail (return code 0(zero)) */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#endif   /* LZ4_STATIC_3504398509 */
 | 
					 | 
				
			||||||
#endif   /* LZ4_STATIC_LINKING_ONLY */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifndef LZ4_H_98237428734687
 | 
					 | 
				
			||||||
#define LZ4_H_98237428734687
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*-************************************************************
 | 
					 | 
				
			||||||
 *  Private Definitions
 | 
					 | 
				
			||||||
 **************************************************************
 | 
					 | 
				
			||||||
 * Do not use these definitions directly.
 | 
					 | 
				
			||||||
 * They are only exposed to allow static allocation of `LZ4_stream_t` and `LZ4_streamDecode_t`.
 | 
					 | 
				
			||||||
 * Accessing members will expose user code to API and/or ABI break in future versions of the library.
 | 
					 | 
				
			||||||
 **************************************************************/
 | 
					 | 
				
			||||||
#define LZ4_HASHLOG   (LZ4_MEMORY_USAGE-2)
 | 
					 | 
				
			||||||
#define LZ4_HASHTABLESIZE (1 << LZ4_MEMORY_USAGE)
 | 
					 | 
				
			||||||
#define LZ4_HASH_SIZE_U32 (1 << LZ4_HASHLOG)       /* required as macro for static allocation */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#if defined(__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */)
 | 
					 | 
				
			||||||
# include <stdint.h>
 | 
					 | 
				
			||||||
  typedef  int8_t  LZ4_i8;
 | 
					 | 
				
			||||||
  typedef uint8_t  LZ4_byte;
 | 
					 | 
				
			||||||
  typedef uint16_t LZ4_u16;
 | 
					 | 
				
			||||||
  typedef uint32_t LZ4_u32;
 | 
					 | 
				
			||||||
#else
 | 
					 | 
				
			||||||
  typedef   signed char  LZ4_i8;
 | 
					 | 
				
			||||||
  typedef unsigned char  LZ4_byte;
 | 
					 | 
				
			||||||
  typedef unsigned short LZ4_u16;
 | 
					 | 
				
			||||||
  typedef unsigned int   LZ4_u32;
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*! LZ4_stream_t :
 | 
					 | 
				
			||||||
 *  Never ever use below internal definitions directly !
 | 
					 | 
				
			||||||
 *  These definitions are not API/ABI safe, and may change in future versions.
 | 
					 | 
				
			||||||
 *  If you need static allocation, declare or allocate an LZ4_stream_t object.
 | 
					 | 
				
			||||||
**/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
typedef struct LZ4_stream_t_internal LZ4_stream_t_internal;
 | 
					 | 
				
			||||||
struct LZ4_stream_t_internal {
 | 
					 | 
				
			||||||
    LZ4_u32 hashTable[LZ4_HASH_SIZE_U32];
 | 
					 | 
				
			||||||
    const LZ4_byte* dictionary;
 | 
					 | 
				
			||||||
    const LZ4_stream_t_internal* dictCtx;
 | 
					 | 
				
			||||||
    LZ4_u32 currentOffset;
 | 
					 | 
				
			||||||
    LZ4_u32 tableType;
 | 
					 | 
				
			||||||
    LZ4_u32 dictSize;
 | 
					 | 
				
			||||||
    /* Implicit padding to ensure structure is aligned */
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define LZ4_STREAM_MINSIZE  ((1UL << LZ4_MEMORY_USAGE) + 32)  /* static size, for inter-version compatibility */
 | 
					 | 
				
			||||||
union LZ4_stream_u {
 | 
					 | 
				
			||||||
    char minStateSize[LZ4_STREAM_MINSIZE];
 | 
					 | 
				
			||||||
    LZ4_stream_t_internal internal_donotuse;
 | 
					 | 
				
			||||||
}; /* previously typedef'd to LZ4_stream_t */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*! LZ4_initStream() : v1.9.0+
 | 
					 | 
				
			||||||
 *  An LZ4_stream_t structure must be initialized at least once.
 | 
					 | 
				
			||||||
 *  This is automatically done when invoking LZ4_createStream(),
 | 
					 | 
				
			||||||
 *  but it's not when the structure is simply declared on stack (for example).
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 *  Use LZ4_initStream() to properly initialize a newly declared LZ4_stream_t.
 | 
					 | 
				
			||||||
 *  It can also initialize any arbitrary buffer of sufficient size,
 | 
					 | 
				
			||||||
 *  and will @return a pointer of proper type upon initialization.
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 *  Note : initialization fails if size and alignment conditions are not respected.
 | 
					 | 
				
			||||||
 *         In which case, the function will @return NULL.
 | 
					 | 
				
			||||||
 *  Note2: An LZ4_stream_t structure guarantees correct alignment and size.
 | 
					 | 
				
			||||||
 *  Note3: Before v1.9.0, use LZ4_resetStream() instead
 | 
					 | 
				
			||||||
**/
 | 
					 | 
				
			||||||
LZ4LIB_API LZ4_stream_t* LZ4_initStream (void* buffer, size_t size);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*! LZ4_streamDecode_t :
 | 
					 | 
				
			||||||
 *  Never ever use below internal definitions directly !
 | 
					 | 
				
			||||||
 *  These definitions are not API/ABI safe, and may change in future versions.
 | 
					 | 
				
			||||||
 *  If you need static allocation, declare or allocate an LZ4_streamDecode_t object.
 | 
					 | 
				
			||||||
**/
 | 
					 | 
				
			||||||
typedef struct {
 | 
					 | 
				
			||||||
    const LZ4_byte* externalDict;
 | 
					 | 
				
			||||||
    const LZ4_byte* prefixEnd;
 | 
					 | 
				
			||||||
    size_t extDictSize;
 | 
					 | 
				
			||||||
    size_t prefixSize;
 | 
					 | 
				
			||||||
} LZ4_streamDecode_t_internal;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define LZ4_STREAMDECODE_MINSIZE 32
 | 
					 | 
				
			||||||
union LZ4_streamDecode_u {
 | 
					 | 
				
			||||||
    char minStateSize[LZ4_STREAMDECODE_MINSIZE];
 | 
					 | 
				
			||||||
    LZ4_streamDecode_t_internal internal_donotuse;
 | 
					 | 
				
			||||||
} ;   /* previously typedef'd to LZ4_streamDecode_t */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*-************************************
 | 
					 | 
				
			||||||
*  Obsolete Functions
 | 
					 | 
				
			||||||
**************************************/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*! Deprecation warnings
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 *  Deprecated functions make the compiler generate a warning when invoked.
 | 
					 | 
				
			||||||
 *  This is meant to invite users to update their source code.
 | 
					 | 
				
			||||||
 *  Should deprecation warnings be a problem, it is generally possible to disable them,
 | 
					 | 
				
			||||||
 *  typically with -Wno-deprecated-declarations for gcc
 | 
					 | 
				
			||||||
 *  or _CRT_SECURE_NO_WARNINGS in Visual.
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 *  Another method is to define LZ4_DISABLE_DEPRECATE_WARNINGS
 | 
					 | 
				
			||||||
 *  before including the header file.
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
#ifdef LZ4_DISABLE_DEPRECATE_WARNINGS
 | 
					 | 
				
			||||||
#  define LZ4_DEPRECATED(message)   /* disable deprecation warnings */
 | 
					 | 
				
			||||||
#else
 | 
					 | 
				
			||||||
#  if defined (__cplusplus) && (__cplusplus >= 201402) /* C++14 or greater */
 | 
					 | 
				
			||||||
#    define LZ4_DEPRECATED(message) [[deprecated(message)]]
 | 
					 | 
				
			||||||
#  elif defined(_MSC_VER)
 | 
					 | 
				
			||||||
#    define LZ4_DEPRECATED(message) __declspec(deprecated(message))
 | 
					 | 
				
			||||||
#  elif defined(__clang__) || (defined(__GNUC__) && (__GNUC__ * 10 + __GNUC_MINOR__ >= 45))
 | 
					 | 
				
			||||||
#    define LZ4_DEPRECATED(message) __attribute__((deprecated(message)))
 | 
					 | 
				
			||||||
#  elif defined(__GNUC__) && (__GNUC__ * 10 + __GNUC_MINOR__ >= 31)
 | 
					 | 
				
			||||||
#    define LZ4_DEPRECATED(message) __attribute__((deprecated))
 | 
					 | 
				
			||||||
#  else
 | 
					 | 
				
			||||||
#    pragma message("WARNING: LZ4_DEPRECATED needs custom implementation for this compiler")
 | 
					 | 
				
			||||||
#    define LZ4_DEPRECATED(message)   /* disabled */
 | 
					 | 
				
			||||||
#  endif
 | 
					 | 
				
			||||||
#endif /* LZ4_DISABLE_DEPRECATE_WARNINGS */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*! Obsolete compression functions (since v1.7.3) */
 | 
					 | 
				
			||||||
LZ4_DEPRECATED("use LZ4_compress_default() instead")       LZ4LIB_API int LZ4_compress               (const char* src, char* dest, int srcSize);
 | 
					 | 
				
			||||||
LZ4_DEPRECATED("use LZ4_compress_default() instead")       LZ4LIB_API int LZ4_compress_limitedOutput (const char* src, char* dest, int srcSize, int maxOutputSize);
 | 
					 | 
				
			||||||
LZ4_DEPRECATED("use LZ4_compress_fast_extState() instead") LZ4LIB_API int LZ4_compress_withState               (void* state, const char* source, char* dest, int inputSize);
 | 
					 | 
				
			||||||
LZ4_DEPRECATED("use LZ4_compress_fast_extState() instead") LZ4LIB_API int LZ4_compress_limitedOutput_withState (void* state, const char* source, char* dest, int inputSize, int maxOutputSize);
 | 
					 | 
				
			||||||
LZ4_DEPRECATED("use LZ4_compress_fast_continue() instead") LZ4LIB_API int LZ4_compress_continue                (LZ4_stream_t* LZ4_streamPtr, const char* source, char* dest, int inputSize);
 | 
					 | 
				
			||||||
LZ4_DEPRECATED("use LZ4_compress_fast_continue() instead") LZ4LIB_API int LZ4_compress_limitedOutput_continue  (LZ4_stream_t* LZ4_streamPtr, const char* source, char* dest, int inputSize, int maxOutputSize);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*! Obsolete decompression functions (since v1.8.0) */
 | 
					 | 
				
			||||||
LZ4_DEPRECATED("use LZ4_decompress_fast() instead") LZ4LIB_API int LZ4_uncompress (const char* source, char* dest, int outputSize);
 | 
					 | 
				
			||||||
LZ4_DEPRECATED("use LZ4_decompress_safe() instead") LZ4LIB_API int LZ4_uncompress_unknownOutputSize (const char* source, char* dest, int isize, int maxOutputSize);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* Obsolete streaming functions (since v1.7.0)
 | 
					 | 
				
			||||||
 * degraded functionality; do not use!
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * In order to perform streaming compression, these functions depended on data
 | 
					 | 
				
			||||||
 * that is no longer tracked in the state. They have been preserved as well as
 | 
					 | 
				
			||||||
 * possible: using them will still produce a correct output. However, they don't
 | 
					 | 
				
			||||||
 * actually retain any history between compression calls. The compression ratio
 | 
					 | 
				
			||||||
 * achieved will therefore be no better than compressing each chunk
 | 
					 | 
				
			||||||
 * independently.
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
LZ4_DEPRECATED("Use LZ4_createStream() instead") LZ4LIB_API void* LZ4_create (char* inputBuffer);
 | 
					 | 
				
			||||||
LZ4_DEPRECATED("Use LZ4_createStream() instead") LZ4LIB_API int   LZ4_sizeofStreamState(void);
 | 
					 | 
				
			||||||
LZ4_DEPRECATED("Use LZ4_resetStream() instead")  LZ4LIB_API int   LZ4_resetStreamState(void* state, char* inputBuffer);
 | 
					 | 
				
			||||||
LZ4_DEPRECATED("Use LZ4_saveDict() instead")     LZ4LIB_API char* LZ4_slideInputBuffer (void* state);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*! Obsolete streaming decoding functions (since v1.7.0) */
 | 
					 | 
				
			||||||
LZ4_DEPRECATED("use LZ4_decompress_safe_usingDict() instead") LZ4LIB_API int LZ4_decompress_safe_withPrefix64k (const char* src, char* dst, int compressedSize, int maxDstSize);
 | 
					 | 
				
			||||||
LZ4_DEPRECATED("use LZ4_decompress_fast_usingDict() instead") LZ4LIB_API int LZ4_decompress_fast_withPrefix64k (const char* src, char* dst, int originalSize);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*! Obsolete LZ4_decompress_fast variants (since v1.9.0) :
 | 
					 | 
				
			||||||
 *  These functions used to be faster than LZ4_decompress_safe(),
 | 
					 | 
				
			||||||
 *  but this is no longer the case. They are now slower.
 | 
					 | 
				
			||||||
 *  This is because LZ4_decompress_fast() doesn't know the input size,
 | 
					 | 
				
			||||||
 *  and therefore must progress more cautiously into the input buffer to not read beyond the end of block.
 | 
					 | 
				
			||||||
 *  On top of that `LZ4_decompress_fast()` is not protected vs malformed or malicious inputs, making it a security liability.
 | 
					 | 
				
			||||||
 *  As a consequence, LZ4_decompress_fast() is strongly discouraged, and deprecated.
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 *  The last remaining LZ4_decompress_fast() specificity is that
 | 
					 | 
				
			||||||
 *  it can decompress a block without knowing its compressed size.
 | 
					 | 
				
			||||||
 *  Such functionality can be achieved in a more secure manner
 | 
					 | 
				
			||||||
 *  by employing LZ4_decompress_safe_partial().
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 *  Parameters:
 | 
					 | 
				
			||||||
 *  originalSize : is the uncompressed size to regenerate.
 | 
					 | 
				
			||||||
 *                 `dst` must be already allocated, its size must be >= 'originalSize' bytes.
 | 
					 | 
				
			||||||
 * @return : number of bytes read from source buffer (== compressed size).
 | 
					 | 
				
			||||||
 *           The function expects to finish at block's end exactly.
 | 
					 | 
				
			||||||
 *           If the source stream is detected malformed, the function stops decoding and returns a negative result.
 | 
					 | 
				
			||||||
 *  note : LZ4_decompress_fast*() requires originalSize. Thanks to this information, it never writes past the output buffer.
 | 
					 | 
				
			||||||
 *         However, since it doesn't know its 'src' size, it may read an unknown amount of input, past input buffer bounds.
 | 
					 | 
				
			||||||
 *         Also, since match offsets are not validated, match reads from 'src' may underflow too.
 | 
					 | 
				
			||||||
 *         These issues never happen if input (compressed) data is correct.
 | 
					 | 
				
			||||||
 *         But they may happen if input data is invalid (error or intentional tampering).
 | 
					 | 
				
			||||||
 *         As a consequence, use these functions in trusted environments with trusted data **only**.
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
LZ4_DEPRECATED("This function is deprecated and unsafe. Consider using LZ4_decompress_safe() instead")
 | 
					 | 
				
			||||||
LZ4LIB_API int LZ4_decompress_fast (const char* src, char* dst, int originalSize);
 | 
					 | 
				
			||||||
LZ4_DEPRECATED("This function is deprecated and unsafe. Consider using LZ4_decompress_safe_continue() instead")
 | 
					 | 
				
			||||||
LZ4LIB_API int LZ4_decompress_fast_continue (LZ4_streamDecode_t* LZ4_streamDecode, const char* src, char* dst, int originalSize);
 | 
					 | 
				
			||||||
LZ4_DEPRECATED("This function is deprecated and unsafe. Consider using LZ4_decompress_safe_usingDict() instead")
 | 
					 | 
				
			||||||
LZ4LIB_API int LZ4_decompress_fast_usingDict (const char* src, char* dst, int originalSize, const char* dictStart, int dictSize);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*! LZ4_resetStream() :
 | 
					 | 
				
			||||||
 *  An LZ4_stream_t structure must be initialized at least once.
 | 
					 | 
				
			||||||
 *  This is done with LZ4_initStream(), or LZ4_resetStream().
 | 
					 | 
				
			||||||
 *  Consider switching to LZ4_initStream(),
 | 
					 | 
				
			||||||
 *  invoking LZ4_resetStream() will trigger deprecation warnings in the future.
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
LZ4LIB_API void LZ4_resetStream (LZ4_stream_t* streamPtr);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#endif /* LZ4_H_98237428734687 */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#if defined (__cplusplus)
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
@ -1,19 +0,0 @@
 | 
				
			|||||||
Copyright (c) 2017 Tobias Hector
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
 | 
					 | 
				
			||||||
this software and associated documentation files (the "Software"), to deal in
 | 
					 | 
				
			||||||
the Software without restriction, including without limitation the rights to
 | 
					 | 
				
			||||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
 | 
					 | 
				
			||||||
of the Software, and to permit persons to whom the Software is furnished to do
 | 
					 | 
				
			||||||
so, subject to the following conditions:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
The above copyright notice and this permission notice shall be included in all
 | 
					 | 
				
			||||||
copies or substantial portions of the Software.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 | 
					 | 
				
			||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 | 
					 | 
				
			||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 | 
					 | 
				
			||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 | 
					 | 
				
			||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 | 
					 | 
				
			||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 | 
					 | 
				
			||||||
SOFTWARE.
 | 
					 | 
				
			||||||
@ -1,153 +0,0 @@
 | 
				
			|||||||
# Simplified Vulkan Synchronization
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
In an effort to make Vulkan synchronization more accessible, I created this
 | 
					 | 
				
			||||||
stb-inspired single-header library in order to somewhat simplify the core
 | 
					 | 
				
			||||||
synchronization mechanisms in Vulkan - pipeline barriers and events.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Rather than the complex maze of enums and bitflags in Vulkan - many
 | 
					 | 
				
			||||||
combinations of which are invalid or nonsensical - this library collapses
 | 
					 | 
				
			||||||
this to a much shorter list of 40 distinct usage types, and a couple of
 | 
					 | 
				
			||||||
options for handling image layouts.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Use of other synchonization mechanisms such as semaphores, fences and render
 | 
					 | 
				
			||||||
passes are not addressed in this API at present.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
## Usage
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define the symbol THSVS_SIMPLER_VULKAN_SYNCHRONIZATION_IMPLEMENTATION in
 | 
					 | 
				
			||||||
*one* C/C++ file before the #include of the header; the implementation
 | 
					 | 
				
			||||||
will be generated in that file.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
## Version
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
alpha.9
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Alpha.9 adds the thsvsGetAccessInfo function to translate access types into a thsvsVkAccessInfo.
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
## Version History
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
alpha.8
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Alpha.8 adds a host preinitialization state for linear images, as well as a number of new access sets for extensions released since the last update.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
alpha.7
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Alpha.7 incorporates a number of fixes from @gwihlidal, and fixes
 | 
					 | 
				
			||||||
handling of pipeline stages in the presence of multiple access types or
 | 
					 | 
				
			||||||
barriers in light of other recent changes.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
alpha.6
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Alpha.6 fixes a typo (VK_ACCESS_TYPE_MEMORY_READ|WRITE_BIT should have been VK_ACCESS_MEMORY_READ|WRITE_BIT), and sets the pipeline stage src and dst flag bits to VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT and VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT during initialization, not 0 as per alpha.5
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
alpha.5
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Alpha.5 now correctly zeroes out the pipeline stage flags before trying to incrementally set bits on them... common theme here, whoops.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
alpha.4
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Alpha.4 now correctly zeroes out the access types before trying to incrementally set bits on them (!)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
alpha.3
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
Alpha.3 changes the following:
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
Uniform and vertex buffer access in one enum, matching D3D12_RESOURCE_STATE_VERTEX_AND_CONSTANT_BUFFER:
 | 
					 | 
				
			||||||
 - THSVS_ACCESS_ANY_SHADER_READ_UNIFORM_BUFFER_OR_VERTEX_BUFFER
 | 
					 | 
				
			||||||
	 
 | 
					 | 
				
			||||||
Color read *and* write access, matching D3D12_RESOURCE_STATE_RENDER_TARGET:
 | 
					 | 
				
			||||||
 - THSVS_ACCESS_COLOR_ATTACHMENT_READ_WRITE
 | 
					 | 
				
			||||||
	 
 | 
					 | 
				
			||||||
Also the "THSVS_ACCESS_\*\_SHADER_READ_SAMPLED_IMAGE" enums have been renamed to the form "THSVS_ACCESS_\*\_SHADER_READ_SAMPLED_IMAGE_OR_UNIFORM_TEXEL_BUFFER"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
alpha.2
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Alpha.2 adds four new resource states for "ANY SHADER ACCESS":
 | 
					 | 
				
			||||||
 - THSVS_ACCESS_ANY_SHADER_READ_UNIFORM_BUFFER
 | 
					 | 
				
			||||||
 - THSVS_ACCESS_ANY_SHADER_READ_SAMPLED_IMAGE
 | 
					 | 
				
			||||||
 - THSVS_ACCESS_ANY_SHADER_READ_OTHER
 | 
					 | 
				
			||||||
 - THSVS_ACCESS_ANY_SHADER_WRITE
 | 
					 | 
				
			||||||
 
 | 
					 | 
				
			||||||
alpha.1
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Alpha.1 adds three new resource states:
 | 
					 | 
				
			||||||
 - THSVS_ACCESS_GENERAL (Any access on the device)
 | 
					 | 
				
			||||||
 - THSVS_ACCESS_DEPTH_ATTACHMENT_WRITE_STENCIL_READ_ONLY (Write access to only the depth aspect of a depth/stencil attachment)
 | 
					 | 
				
			||||||
 - THSVS_ACCESS_STENCIL_ATTACHMENT_WRITE_DEPTH_READ_ONLY (Write access to only the stencil aspect of a depth/stencil attachment)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
It also fixes a couple of typos, and adds clarification as to when extensions need to be enabled to use a feature.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
alpha.0
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
This is the very first public release of this library; future revisions
 | 
					 | 
				
			||||||
of this API may change the API in an incompatible manner as feedback is
 | 
					 | 
				
			||||||
received.
 | 
					 | 
				
			||||||
Once the version becomes stable, incompatible changes will only be made
 | 
					 | 
				
			||||||
to major revisions of the API - minor revisions will only contain
 | 
					 | 
				
			||||||
bugfixes or minor additions.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
## Memory Allocation
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
The thsvsCmdPipelineBarrier and thsvsCmdWaitEvents commands allocate
 | 
					 | 
				
			||||||
temporary storage for the Vulkan barrier equivalents in order to pass them
 | 
					 | 
				
			||||||
to the respective Vulkan commands.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
These use the `THSVS_TEMP_ALLOC(size)` and `THSVS_TEMP_FREE(x)` macros,
 | 
					 | 
				
			||||||
which are by default set to alloca(size) and ((void)(x)), respectively.
 | 
					 | 
				
			||||||
If you don't want to use stack space or would rather use your own
 | 
					 | 
				
			||||||
allocation strategy, these can be overridden by defining these macros
 | 
					 | 
				
			||||||
in before #include-ing the header file with
 | 
					 | 
				
			||||||
THSVS_SIMPLER_VULKAN_SYNCHRONIZATION_IMPLEMENTATION defined.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
I'd rather avoid the need for these allocations in what are likely to be
 | 
					 | 
				
			||||||
high-traffic commands, but currently just want to ship something - may
 | 
					 | 
				
			||||||
revisit this at a future date based on feedback.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
## Expressiveness Compared to Raw Vulkan
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Despite the fact that this API is fairly simple, it expresses 99% of
 | 
					 | 
				
			||||||
what you'd actually ever want to do in practice.
 | 
					 | 
				
			||||||
Adding the missing expressiveness would result in increased complexity
 | 
					 | 
				
			||||||
which didn't seem worth the tradeoff - however I would consider adding
 | 
					 | 
				
			||||||
something for them in future if it becomes an issue.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Here's a list of known things you can't express:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
* Execution only dependencies cannot be expressed.
 | 
					 | 
				
			||||||
  These are occasionally useful in conjunction with semaphores, or when
 | 
					 | 
				
			||||||
  trying to be clever with scheduling - but their usage is both limited
 | 
					 | 
				
			||||||
  and fairly tricky to get right anyway.
 | 
					 | 
				
			||||||
* Depth/Stencil Input Attachments can be read in a shader using either
 | 
					 | 
				
			||||||
  VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL or
 | 
					 | 
				
			||||||
  VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL - this library
 | 
					 | 
				
			||||||
  *always* uses VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL.
 | 
					 | 
				
			||||||
  It's possible (though highly unlikely) when aliasing images that this
 | 
					 | 
				
			||||||
  results in unnecessary transitions.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
## Error Checks
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
By default, as with the Vulkan API, this library does NOT check for
 | 
					 | 
				
			||||||
errors.
 | 
					 | 
				
			||||||
However, a number of optional error checks (`THSVS_ERROR_CHECK_*`) can be
 | 
					 | 
				
			||||||
enabled by uncommenting the relevant #defines.
 | 
					 | 
				
			||||||
Currently, error checks simply assert at the point a failure is detected
 | 
					 | 
				
			||||||
and do not output an error message.
 | 
					 | 
				
			||||||
I certainly do not claim they capture *all* possible errors, but they
 | 
					 | 
				
			||||||
capture what should be some of the more common ones.
 | 
					 | 
				
			||||||
Use of the Vulkan Validation Layers in tandem with this library is
 | 
					 | 
				
			||||||
strongly recommended:
 | 
					 | 
				
			||||||
    https://github.com/KhronosGroup/Vulkan-LoaderAndValidationLayers
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
## Issues
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
This header was clean of warnings using -Wall as of time of publishing
 | 
					 | 
				
			||||||
on both gcc 4.8.4 and clang 3.5, using the c99 standard.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
There's a potential pitfall in thsvsCmdPipelineBarrier and thsvsCmdWaitEvents
 | 
					 | 
				
			||||||
where alloca is used for temporary allocations. See
 | 
					 | 
				
			||||||
[Memory Allocation](#memory-allocation) for more information.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Testing of this library is so far extremely limited with no immediate
 | 
					 | 
				
			||||||
plans to add to that - so there's bound to be some amount of bugs.
 | 
					 | 
				
			||||||
Please raise these issues on the repo issue tracker, or provide a fix
 | 
					 | 
				
			||||||
via a pull request yourself if you're so inclined.
 | 
					 | 
				
			||||||
@ -1,26 +0,0 @@
 | 
				
			|||||||
# Tests
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
`tests.c` defines a number of unit tests to test that various scenarios
 | 
					 | 
				
			||||||
produce the desired output.
 | 
					 | 
				
			||||||
Tests are based on the common synchronization examples on the Vulkan-Docs
 | 
					 | 
				
			||||||
wiki: https://github.com/KhronosGroup/Vulkan-Docs/wiki/Synchronization-Examples.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
## Building
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
On a unix based system these tests can be built using:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
`gcc -o tests tests.c -lvulkan`
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
## Running
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Running is straightforward:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
`./tests`
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
The executable will write out the tests that are run, whether they pass or
 | 
					 | 
				
			||||||
fail, and what caused them to fail if they did.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
## Adding tests
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
If you'd like to add a test, just define a new test in main() as per those
 | 
					 | 
				
			||||||
that already exist.
 | 
					 | 
				
			||||||
@ -1,357 +0,0 @@
 | 
				
			|||||||
// Copyright (c) 2017-2019 Tobias Hector
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
 | 
					 | 
				
			||||||
// this software and associated documentation files (the "Software"), to deal in
 | 
					 | 
				
			||||||
// the Software without restriction, including without limitation the rights to
 | 
					 | 
				
			||||||
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
 | 
					 | 
				
			||||||
// of the Software, and to permit persons to whom the Software is furnished to do
 | 
					 | 
				
			||||||
// so, subject to the following conditions:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// The above copyright notice and this permission notice shall be included in all
 | 
					 | 
				
			||||||
// copies or substantial portions of the Software.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 | 
					 | 
				
			||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 | 
					 | 
				
			||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 | 
					 | 
				
			||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 | 
					 | 
				
			||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 | 
					 | 
				
			||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 | 
					 | 
				
			||||||
// SOFTWARE.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include <vulkan/vulkan.h>
 | 
					 | 
				
			||||||
#include <stdio.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define THSVS_SIMPLER_VULKAN_SYNCHRONIZATION_IMPLEMENTATION
 | 
					 | 
				
			||||||
#include "../thsvs_simpler_vulkan_synchronization.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void global_barrier_test_array(const char* testName,
 | 
					 | 
				
			||||||
                               unsigned int numPrevAccesses,
 | 
					 | 
				
			||||||
                               ThsvsAccessType* prevAccesses,
 | 
					 | 
				
			||||||
                               unsigned int numNextAccesses,
 | 
					 | 
				
			||||||
                               ThsvsAccessType* nextAccesses,
 | 
					 | 
				
			||||||
                               VkPipelineStageFlags expectedSrcStageMask,
 | 
					 | 
				
			||||||
                               VkPipelineStageFlags expectedDstStageMask,
 | 
					 | 
				
			||||||
                               VkAccessFlags expectedSrcAccessMask,
 | 
					 | 
				
			||||||
                               VkAccessFlags expectedDstAccessMask)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    ThsvsGlobalBarrier barrier = {numPrevAccesses, prevAccesses, numNextAccesses, nextAccesses};
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    VkMemoryBarrier vkBarrier = { 0 };
 | 
					 | 
				
			||||||
    VkPipelineStageFlags srcStages = 0;
 | 
					 | 
				
			||||||
    VkPipelineStageFlags dstStages = 0;
 | 
					 | 
				
			||||||
    unsigned int testPassed = 1;
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    thsvsGetVulkanMemoryBarrier(barrier, &srcStages, &dstStages, &vkBarrier);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    printf("Test: %s\n", testName);
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    if (srcStages != expectedSrcStageMask)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        printf("\tUnexpected source stage %0#10X\n", srcStages);
 | 
					 | 
				
			||||||
        testPassed = 0;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    if (dstStages != expectedDstStageMask)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        printf("\tUnexpected destination stage %0#10X\n", dstStages);
 | 
					 | 
				
			||||||
        testPassed = 0;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    if (vkBarrier.srcAccessMask != expectedSrcAccessMask)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        printf("\tUnexpected source access mask %0#10X\n", vkBarrier.srcAccessMask);
 | 
					 | 
				
			||||||
        testPassed = 0;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    if (vkBarrier.dstAccessMask != expectedDstAccessMask)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        printf("\tUnexpected destination access mask %0#10X\n", vkBarrier.dstAccessMask);
 | 
					 | 
				
			||||||
        testPassed = 0;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    if (testPassed == 1)
 | 
					 | 
				
			||||||
        printf("\tPASSED\n");
 | 
					 | 
				
			||||||
    else
 | 
					 | 
				
			||||||
        printf("\tFAILED\n");
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void global_barrier_test(const char* testName,
 | 
					 | 
				
			||||||
                         ThsvsAccessType prevAccess,
 | 
					 | 
				
			||||||
                         ThsvsAccessType nextAccess,
 | 
					 | 
				
			||||||
                         VkPipelineStageFlags expectedSrcStageMask,
 | 
					 | 
				
			||||||
                         VkPipelineStageFlags expectedDstStageMask,
 | 
					 | 
				
			||||||
                         VkAccessFlags expectedSrcAccessMask,
 | 
					 | 
				
			||||||
                         VkAccessFlags expectedDstAccessMask)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    global_barrier_test_array(testName, 1, &prevAccess, 1, &nextAccess, expectedSrcStageMask, expectedDstStageMask, expectedSrcAccessMask, expectedDstAccessMask);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void image_barrier_test_array(const char* testName,
 | 
					 | 
				
			||||||
                              unsigned int numPrevAccesses,
 | 
					 | 
				
			||||||
                              ThsvsAccessType* prevAccesses,
 | 
					 | 
				
			||||||
                              unsigned int numNextAccesses,
 | 
					 | 
				
			||||||
                              ThsvsAccessType* nextAccesses,
 | 
					 | 
				
			||||||
                              VkPipelineStageFlags expectedSrcStageMask,
 | 
					 | 
				
			||||||
                              VkPipelineStageFlags expectedDstStageMask,
 | 
					 | 
				
			||||||
                              VkAccessFlags expectedSrcAccessMask,
 | 
					 | 
				
			||||||
                              VkAccessFlags expectedDstAccessMask,
 | 
					 | 
				
			||||||
                              VkImageLayout expectedOldLayout,
 | 
					 | 
				
			||||||
                              VkImageLayout expectedNewLayout)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    ThsvsImageBarrier barrier = {numPrevAccesses, prevAccesses, numNextAccesses, nextAccesses};
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    VkImageMemoryBarrier vkBarrier = { 0 };
 | 
					 | 
				
			||||||
    VkPipelineStageFlags srcStages = 0;
 | 
					 | 
				
			||||||
    VkPipelineStageFlags dstStages = 0;
 | 
					 | 
				
			||||||
    unsigned int testPassed = 1;
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    thsvsGetVulkanImageMemoryBarrier(barrier, &srcStages, &dstStages, &vkBarrier);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    printf("Test: %s\n", testName);
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    if (srcStages != expectedSrcStageMask)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        printf("\tUnexpected source stage %0#10X\n", srcStages);
 | 
					 | 
				
			||||||
        testPassed = 0;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    if (dstStages != expectedDstStageMask)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        printf("\tUnexpected destination stage %0#10X\n", dstStages);
 | 
					 | 
				
			||||||
        testPassed = 0;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    if (vkBarrier.srcAccessMask != expectedSrcAccessMask)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        printf("\tUnexpected source access mask %0#10X\n", vkBarrier.srcAccessMask);
 | 
					 | 
				
			||||||
        testPassed = 0;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    if (vkBarrier.dstAccessMask != expectedDstAccessMask)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        printf("\tUnexpected destination access mask %0#10X\n", vkBarrier.dstAccessMask);
 | 
					 | 
				
			||||||
        testPassed = 0;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    if (vkBarrier.oldLayout != expectedOldLayout)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        printf("\tUnexpected old layout %d\n", vkBarrier.oldLayout);
 | 
					 | 
				
			||||||
        testPassed = 0;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    if (vkBarrier.newLayout != expectedNewLayout)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        printf("\tUnexpected new layout %d\n", vkBarrier.newLayout);
 | 
					 | 
				
			||||||
        testPassed = 0;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    if (testPassed == 1)
 | 
					 | 
				
			||||||
        printf("\tPASSED\n");
 | 
					 | 
				
			||||||
    else
 | 
					 | 
				
			||||||
        printf("\tFAILED\n");
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void image_barrier_test(const char* testName,
 | 
					 | 
				
			||||||
                        ThsvsAccessType prevAccess,
 | 
					 | 
				
			||||||
                        ThsvsAccessType nextAccess,
 | 
					 | 
				
			||||||
                        VkPipelineStageFlags expectedSrcStageMask,
 | 
					 | 
				
			||||||
                        VkPipelineStageFlags expectedDstStageMask,
 | 
					 | 
				
			||||||
                        VkAccessFlags expectedSrcAccessMask,
 | 
					 | 
				
			||||||
                        VkAccessFlags expectedDstAccessMask,
 | 
					 | 
				
			||||||
                        VkImageLayout expectedOldLayout,
 | 
					 | 
				
			||||||
                        VkImageLayout expectedNewLayout)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    image_barrier_test_array(testName, 1, &prevAccess, 1, &nextAccess, expectedSrcStageMask, expectedDstStageMask, expectedSrcAccessMask, expectedDstAccessMask, expectedOldLayout, expectedNewLayout);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int main(int argc, char* argv[])
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    global_barrier_test("Compute write to storage buffer/image, Compute read from storage buffer/image",
 | 
					 | 
				
			||||||
                        THSVS_ACCESS_COMPUTE_SHADER_WRITE,
 | 
					 | 
				
			||||||
                        THSVS_ACCESS_COMPUTE_SHADER_READ_OTHER,
 | 
					 | 
				
			||||||
                        VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
 | 
					 | 
				
			||||||
                        VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
 | 
					 | 
				
			||||||
                        VK_ACCESS_SHADER_WRITE_BIT,
 | 
					 | 
				
			||||||
                        VK_ACCESS_SHADER_READ_BIT);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    global_barrier_test("Compute read from storage buffer, Compute write from storage buffer",
 | 
					 | 
				
			||||||
                        THSVS_ACCESS_COMPUTE_SHADER_READ_OTHER,
 | 
					 | 
				
			||||||
                        THSVS_ACCESS_COMPUTE_SHADER_WRITE,
 | 
					 | 
				
			||||||
                        VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
 | 
					 | 
				
			||||||
                        VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
 | 
					 | 
				
			||||||
                        0,
 | 
					 | 
				
			||||||
                        0);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    global_barrier_test("Compute write to storage buffer, Graphics read as index buffer",
 | 
					 | 
				
			||||||
                        THSVS_ACCESS_COMPUTE_SHADER_WRITE,                        
 | 
					 | 
				
			||||||
                        THSVS_ACCESS_INDEX_BUFFER,
 | 
					 | 
				
			||||||
                        VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
 | 
					 | 
				
			||||||
                        VK_PIPELINE_STAGE_VERTEX_INPUT_BIT,
 | 
					 | 
				
			||||||
                        VK_ACCESS_SHADER_WRITE_BIT,
 | 
					 | 
				
			||||||
                        VK_ACCESS_INDEX_READ_BIT);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        ThsvsAccessType prevAccesses[] = {THSVS_ACCESS_COMPUTE_SHADER_WRITE};
 | 
					 | 
				
			||||||
        ThsvsAccessType nextAccesses[] = {THSVS_ACCESS_INDEX_BUFFER, THSVS_ACCESS_COMPUTE_SHADER_READ_UNIFORM_BUFFER};
 | 
					 | 
				
			||||||
        global_barrier_test_array("Compute write to storage buffer, Graphics read as index buffer & Compute read as uniform buffer",
 | 
					 | 
				
			||||||
                                  1, prevAccesses,
 | 
					 | 
				
			||||||
                                  2, nextAccesses,
 | 
					 | 
				
			||||||
                                  VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
 | 
					 | 
				
			||||||
                                  VK_PIPELINE_STAGE_VERTEX_INPUT_BIT | VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
 | 
					 | 
				
			||||||
                                  VK_ACCESS_SHADER_WRITE_BIT,
 | 
					 | 
				
			||||||
                                  VK_ACCESS_INDEX_READ_BIT | VK_ACCESS_UNIFORM_READ_BIT);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    global_barrier_test("Compute write to storage buffer, Graphics read as indirect buffer",
 | 
					 | 
				
			||||||
                        THSVS_ACCESS_COMPUTE_SHADER_WRITE,                        
 | 
					 | 
				
			||||||
                        THSVS_ACCESS_INDIRECT_BUFFER,
 | 
					 | 
				
			||||||
                        VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
 | 
					 | 
				
			||||||
                        VK_PIPELINE_STAGE_DRAW_INDIRECT_BIT,
 | 
					 | 
				
			||||||
                        VK_ACCESS_SHADER_WRITE_BIT,
 | 
					 | 
				
			||||||
                        VK_ACCESS_INDIRECT_COMMAND_READ_BIT);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    image_barrier_test("Compute write to storage image, Graphics fragment read as sampled image",
 | 
					 | 
				
			||||||
                        THSVS_ACCESS_COMPUTE_SHADER_WRITE,                        
 | 
					 | 
				
			||||||
                        THSVS_ACCESS_FRAGMENT_SHADER_READ_SAMPLED_IMAGE_OR_UNIFORM_TEXEL_BUFFER,
 | 
					 | 
				
			||||||
                        VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
 | 
					 | 
				
			||||||
                        VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
 | 
					 | 
				
			||||||
                        VK_ACCESS_SHADER_WRITE_BIT,
 | 
					 | 
				
			||||||
                        VK_ACCESS_SHADER_READ_BIT,
 | 
					 | 
				
			||||||
                        VK_IMAGE_LAYOUT_GENERAL,
 | 
					 | 
				
			||||||
                        VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        ThsvsAccessType prevAccesses[] = {THSVS_ACCESS_COMPUTE_SHADER_WRITE};
 | 
					 | 
				
			||||||
        ThsvsAccessType nextAccesses[] = {THSVS_ACCESS_INDIRECT_BUFFER, THSVS_ACCESS_FRAGMENT_SHADER_READ_UNIFORM_BUFFER};
 | 
					 | 
				
			||||||
        global_barrier_test_array("Compute write to storage texel buffer, Graphics read as indirect buffer & fragment read as uniform buffer",
 | 
					 | 
				
			||||||
                            1, prevAccesses,                        
 | 
					 | 
				
			||||||
                            2, nextAccesses,
 | 
					 | 
				
			||||||
                            VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
 | 
					 | 
				
			||||||
                            VK_PIPELINE_STAGE_DRAW_INDIRECT_BIT | VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
 | 
					 | 
				
			||||||
                            VK_ACCESS_SHADER_WRITE_BIT,
 | 
					 | 
				
			||||||
                            VK_ACCESS_INDIRECT_COMMAND_READ_BIT | VK_ACCESS_UNIFORM_READ_BIT);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    image_barrier_test("Graphics write to color attachment, Compute read from sampled image",
 | 
					 | 
				
			||||||
                        THSVS_ACCESS_COLOR_ATTACHMENT_WRITE,                        
 | 
					 | 
				
			||||||
                        THSVS_ACCESS_COMPUTE_SHADER_READ_SAMPLED_IMAGE_OR_UNIFORM_TEXEL_BUFFER,
 | 
					 | 
				
			||||||
                        VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
 | 
					 | 
				
			||||||
                        VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
 | 
					 | 
				
			||||||
                        VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
 | 
					 | 
				
			||||||
                        VK_ACCESS_SHADER_READ_BIT,
 | 
					 | 
				
			||||||
                        VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
 | 
					 | 
				
			||||||
                        VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    image_barrier_test("Graphics write to depth attachment, Compute read from sampled image",
 | 
					 | 
				
			||||||
                        THSVS_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE,                        
 | 
					 | 
				
			||||||
                        THSVS_ACCESS_COMPUTE_SHADER_READ_SAMPLED_IMAGE_OR_UNIFORM_TEXEL_BUFFER,
 | 
					 | 
				
			||||||
                        VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
 | 
					 | 
				
			||||||
                        VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
 | 
					 | 
				
			||||||
                        VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
 | 
					 | 
				
			||||||
                        VK_ACCESS_SHADER_READ_BIT,
 | 
					 | 
				
			||||||
                        VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
 | 
					 | 
				
			||||||
                        VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    image_barrier_test("Graphics write to depth attachment, Graphics fragment read from input attachment",
 | 
					 | 
				
			||||||
                        THSVS_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE,                        
 | 
					 | 
				
			||||||
                        THSVS_ACCESS_FRAGMENT_SHADER_READ_DEPTH_STENCIL_INPUT_ATTACHMENT,
 | 
					 | 
				
			||||||
                        VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
 | 
					 | 
				
			||||||
                        VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
 | 
					 | 
				
			||||||
                        VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
 | 
					 | 
				
			||||||
                        VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
 | 
					 | 
				
			||||||
                        VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
 | 
					 | 
				
			||||||
                        VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    image_barrier_test("Graphics write to depth attachment, Graphics fragment read from sampled image",
 | 
					 | 
				
			||||||
                        THSVS_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE,                        
 | 
					 | 
				
			||||||
                        THSVS_ACCESS_FRAGMENT_SHADER_READ_SAMPLED_IMAGE_OR_UNIFORM_TEXEL_BUFFER,
 | 
					 | 
				
			||||||
                        VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
 | 
					 | 
				
			||||||
                        VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
 | 
					 | 
				
			||||||
                        VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
 | 
					 | 
				
			||||||
                        VK_ACCESS_SHADER_READ_BIT,
 | 
					 | 
				
			||||||
                        VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
 | 
					 | 
				
			||||||
                        VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    image_barrier_test("Graphics write to color attachment, Graphics fragment read from input attachment",
 | 
					 | 
				
			||||||
                        THSVS_ACCESS_COLOR_ATTACHMENT_WRITE,                        
 | 
					 | 
				
			||||||
                        THSVS_ACCESS_FRAGMENT_SHADER_READ_COLOR_INPUT_ATTACHMENT,
 | 
					 | 
				
			||||||
                        VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
 | 
					 | 
				
			||||||
                        VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
 | 
					 | 
				
			||||||
                        VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
 | 
					 | 
				
			||||||
                        VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
 | 
					 | 
				
			||||||
                        VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
 | 
					 | 
				
			||||||
                        VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    image_barrier_test("Graphics write to color attachment, Graphics fragment read from sampled image",
 | 
					 | 
				
			||||||
                        THSVS_ACCESS_COLOR_ATTACHMENT_WRITE,                        
 | 
					 | 
				
			||||||
                        THSVS_ACCESS_FRAGMENT_SHADER_READ_SAMPLED_IMAGE_OR_UNIFORM_TEXEL_BUFFER,
 | 
					 | 
				
			||||||
                        VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
 | 
					 | 
				
			||||||
                        VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
 | 
					 | 
				
			||||||
                        VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
 | 
					 | 
				
			||||||
                        VK_ACCESS_SHADER_READ_BIT,
 | 
					 | 
				
			||||||
                        VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
 | 
					 | 
				
			||||||
                        VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    image_barrier_test("Graphics write to color attachment, Graphics vertex read from sampled image",
 | 
					 | 
				
			||||||
                        THSVS_ACCESS_COLOR_ATTACHMENT_WRITE,                        
 | 
					 | 
				
			||||||
                        THSVS_ACCESS_VERTEX_SHADER_READ_SAMPLED_IMAGE_OR_UNIFORM_TEXEL_BUFFER,
 | 
					 | 
				
			||||||
                        VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
 | 
					 | 
				
			||||||
                        VK_PIPELINE_STAGE_VERTEX_SHADER_BIT,
 | 
					 | 
				
			||||||
                        VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
 | 
					 | 
				
			||||||
                        VK_ACCESS_SHADER_READ_BIT,
 | 
					 | 
				
			||||||
                        VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
 | 
					 | 
				
			||||||
                        VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    image_barrier_test("Graphics fragment read from sampled image, Graphics write to color attachment",
 | 
					 | 
				
			||||||
                        THSVS_ACCESS_FRAGMENT_SHADER_READ_SAMPLED_IMAGE_OR_UNIFORM_TEXEL_BUFFER,                        
 | 
					 | 
				
			||||||
                        THSVS_ACCESS_COLOR_ATTACHMENT_WRITE,
 | 
					 | 
				
			||||||
                        VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
 | 
					 | 
				
			||||||
                        VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
 | 
					 | 
				
			||||||
                        0,
 | 
					 | 
				
			||||||
                        0,
 | 
					 | 
				
			||||||
                        VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
 | 
					 | 
				
			||||||
                        VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    global_barrier_test("None, Transfer read from buffer",
 | 
					 | 
				
			||||||
                        THSVS_ACCESS_NONE,                        
 | 
					 | 
				
			||||||
                        THSVS_ACCESS_TRANSFER_READ,
 | 
					 | 
				
			||||||
                        VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT,
 | 
					 | 
				
			||||||
                        VK_PIPELINE_STAGE_TRANSFER_BIT,
 | 
					 | 
				
			||||||
                        0,
 | 
					 | 
				
			||||||
                        0);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    global_barrier_test("Transfer write to buffer, Graphics read from vertex buffer",
 | 
					 | 
				
			||||||
                        THSVS_ACCESS_TRANSFER_WRITE,                        
 | 
					 | 
				
			||||||
                        THSVS_ACCESS_VERTEX_BUFFER,
 | 
					 | 
				
			||||||
                        VK_PIPELINE_STAGE_TRANSFER_BIT,
 | 
					 | 
				
			||||||
                        VK_PIPELINE_STAGE_VERTEX_INPUT_BIT,
 | 
					 | 
				
			||||||
                        VK_ACCESS_TRANSFER_WRITE_BIT,
 | 
					 | 
				
			||||||
                        VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    image_barrier_test("Transfer write to image, Graphics fragment read from sampled image",
 | 
					 | 
				
			||||||
                        THSVS_ACCESS_TRANSFER_WRITE,                        
 | 
					 | 
				
			||||||
                        THSVS_ACCESS_FRAGMENT_SHADER_READ_SAMPLED_IMAGE_OR_UNIFORM_TEXEL_BUFFER,
 | 
					 | 
				
			||||||
                        VK_PIPELINE_STAGE_TRANSFER_BIT,
 | 
					 | 
				
			||||||
                        VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
 | 
					 | 
				
			||||||
                        VK_ACCESS_TRANSFER_WRITE_BIT,
 | 
					 | 
				
			||||||
                        VK_ACCESS_SHADER_READ_BIT,
 | 
					 | 
				
			||||||
                        VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
 | 
					 | 
				
			||||||
                        VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    image_barrier_test("Graphics color attachment write, Presentation",
 | 
					 | 
				
			||||||
                        THSVS_ACCESS_COLOR_ATTACHMENT_WRITE,                        
 | 
					 | 
				
			||||||
                        THSVS_ACCESS_PRESENT,
 | 
					 | 
				
			||||||
                        VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
 | 
					 | 
				
			||||||
                        VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT,
 | 
					 | 
				
			||||||
                        VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
 | 
					 | 
				
			||||||
                        0,
 | 
					 | 
				
			||||||
                        VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
 | 
					 | 
				
			||||||
                        VK_IMAGE_LAYOUT_PRESENT_SRC_KHR);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    global_barrier_test("Full pipeline barrier",
 | 
					 | 
				
			||||||
                        THSVS_ACCESS_GENERAL,                        
 | 
					 | 
				
			||||||
                        THSVS_ACCESS_GENERAL,
 | 
					 | 
				
			||||||
                        VK_PIPELINE_STAGE_ALL_COMMANDS_BIT,
 | 
					 | 
				
			||||||
                        VK_PIPELINE_STAGE_ALL_COMMANDS_BIT,
 | 
					 | 
				
			||||||
                        VK_ACCESS_MEMORY_READ_BIT | VK_ACCESS_MEMORY_WRITE_BIT,
 | 
					 | 
				
			||||||
                        VK_ACCESS_MEMORY_READ_BIT | VK_ACCESS_MEMORY_WRITE_BIT);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@ -1,26 +0,0 @@
 | 
				
			|||||||
xxHash Library
 | 
					 | 
				
			||||||
Copyright (c) 2012-2021 Yann Collet
 | 
					 | 
				
			||||||
All rights reserved.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
BSD 2-Clause License (https://www.opensource.org/licenses/bsd-license.php)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Redistribution and use in source and binary forms, with or without modification,
 | 
					 | 
				
			||||||
are permitted provided that the following conditions are met:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
* Redistributions of source code must retain the above copyright notice, this
 | 
					 | 
				
			||||||
  list of conditions and the following disclaimer.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
* Redistributions in binary form must reproduce the above copyright notice, this
 | 
					 | 
				
			||||||
  list of conditions and the following disclaimer in the documentation and/or
 | 
					 | 
				
			||||||
  other materials provided with the distribution.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 | 
					 | 
				
			||||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 | 
					 | 
				
			||||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 | 
					 | 
				
			||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
 | 
					 | 
				
			||||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 | 
					 | 
				
			||||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 | 
					 | 
				
			||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
 | 
					 | 
				
			||||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 | 
					 | 
				
			||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 | 
					 | 
				
			||||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 | 
					 | 
				
			||||||
@ -1,43 +0,0 @@
 | 
				
			|||||||
/*
 | 
					 | 
				
			||||||
 * xxHash - Extremely Fast Hash algorithm
 | 
					 | 
				
			||||||
 * Copyright (C) 2012-2021 Yann Collet
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * BSD 2-Clause License (https://www.opensource.org/licenses/bsd-license.php)
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * Redistribution and use in source and binary forms, with or without
 | 
					 | 
				
			||||||
 * modification, are permitted provided that the following conditions are
 | 
					 | 
				
			||||||
 * met:
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 *    * Redistributions of source code must retain the above copyright
 | 
					 | 
				
			||||||
 *      notice, this list of conditions and the following disclaimer.
 | 
					 | 
				
			||||||
 *    * Redistributions in binary form must reproduce the above
 | 
					 | 
				
			||||||
 *      copyright notice, this list of conditions and the following disclaimer
 | 
					 | 
				
			||||||
 *      in the documentation and/or other materials provided with the
 | 
					 | 
				
			||||||
 *      distribution.
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 | 
					 | 
				
			||||||
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 | 
					 | 
				
			||||||
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 | 
					 | 
				
			||||||
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 | 
					 | 
				
			||||||
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 | 
					 | 
				
			||||||
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 | 
					 | 
				
			||||||
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 | 
					 | 
				
			||||||
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 | 
					 | 
				
			||||||
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 | 
					 | 
				
			||||||
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 | 
					 | 
				
			||||||
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * You can contact the author at:
 | 
					 | 
				
			||||||
 *   - xxHash homepage: https://www.xxhash.com
 | 
					 | 
				
			||||||
 *   - xxHash source repository: https://github.com/Cyan4973/xxHash
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
 * xxhash.c instantiates functions defined in xxhash.h
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define XXH_STATIC_LINKING_ONLY   /* access advanced declarations */
 | 
					 | 
				
			||||||
#define XXH_IMPLEMENTATION   /* access definitions */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "xxhash.h"
 | 
					 | 
				
			||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@ -1,6 +1,6 @@
 | 
				
			|||||||
project('rtengine', ['c', 'cpp'],
 | 
					project('rtengine', ['c', 'cpp'],
 | 
				
			||||||
  default_options: ['buildtype=debug', 
 | 
					  default_options: ['buildtype=debug', 
 | 
				
			||||||
    'b_sanitize=address', 
 | 
					    'b_sanitize=none', 
 | 
				
			||||||
    'c_std=c17', 
 | 
					    'c_std=c17', 
 | 
				
			||||||
    'cpp_std=c++20',
 | 
					    'cpp_std=c++20',
 | 
				
			||||||
    'warning_level=3',
 | 
					    'warning_level=3',
 | 
				
			||||||
 | 
				
			|||||||
@ -1,6 +1,6 @@
 | 
				
			|||||||
#include "compression.h"
 | 
					#include "compression.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <lz4/lz4.h>
 | 
					#include <lz4.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
RT_DLLEXPORT size_t rtGetCompressionBound(size_t uncompressed_size) {
 | 
					RT_DLLEXPORT size_t rtGetCompressionBound(size_t uncompressed_size) {
 | 
				
			||||||
    return (size_t)LZ4_compressBound((int)uncompressed_size);
 | 
					    return (size_t)LZ4_compressBound((int)uncompressed_size);
 | 
				
			||||||
 | 
				
			|||||||
@ -1,41 +1,304 @@
 | 
				
			|||||||
#include "config.h"
 | 
					#include "config.h"
 | 
				
			||||||
 | 
					#include "fsutils.h"
 | 
				
			||||||
#include "runtime.h"
 | 
					#include "runtime.h"
 | 
				
			||||||
#include "threading.h"
 | 
					#include "threading.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "aio.h"
 | 
				
			||||||
 | 
					#include "buffer_manager.h"
 | 
				
			||||||
 | 
					#include "file_tab.h"
 | 
				
			||||||
 | 
					#include "mem_arena.h"
 | 
				
			||||||
 | 
					#include "string_storage.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <ini.h>
 | 
				
			||||||
#include <stddef.h>
 | 
					#include <stddef.h>
 | 
				
			||||||
 | 
					#include <stdlib.h>
 | 
				
			||||||
#include <string.h>
 | 
					#include <string.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define RT_MAX_CVARS 1024
 | 
					#define RT_MAX_CVARS          1024
 | 
				
			||||||
 | 
					#define RT_MAX_EVENT_HANDLERS 1024
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static rt_cvar *_vars[RT_MAX_CVARS];
 | 
					typedef struct rt_cvar_change_event_list {
 | 
				
			||||||
static unsigned int _next = 0;
 | 
					    rt_cvar_change_event_handler_fn *Handler;
 | 
				
			||||||
static rt_mutex *_mutex   = NULL;
 | 
					    void *userdata;
 | 
				
			||||||
 | 
					    struct rt_cvar_change_event_list *next;
 | 
				
			||||||
 | 
					} rt_cvar_change_event_list;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void rtRegisterCVAR(rt_cvar *cvar) {
 | 
					typedef struct {
 | 
				
			||||||
    /* TODO(Kevin): Check if we have a loaded value for that cvar. 
 | 
					    rt_cvar *cvar;
 | 
				
			||||||
     * If yes, override the provided default value. */
 | 
					    rt_cvar_change_event_list *change_event_handlers;
 | 
				
			||||||
 | 
					} rt_cvar_container;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static rt_cvar_container _vars[RT_MAX_CVARS];
 | 
				
			||||||
 | 
					static unsigned int _next_cvar = 0;
 | 
				
			||||||
 | 
					static rt_cvar_change_event_list _change_event_handlers[RT_MAX_EVENT_HANDLERS];
 | 
				
			||||||
 | 
					static unsigned int _next_event_handler = 0;
 | 
				
			||||||
 | 
					static rt_mutex *_mutex                 = NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					RT_DLLEXPORT void rtRegisterCVAR(rt_cvar *cvar) {
 | 
				
			||||||
    if (!_mutex)
 | 
					    if (!_mutex)
 | 
				
			||||||
        _mutex = rtCreateMutex();
 | 
					        _mutex = rtCreateMutex();
 | 
				
			||||||
    rtLockMutex(_mutex);
 | 
					    rtLockMutex(_mutex);
 | 
				
			||||||
    if (_next < RT_MAX_CVARS) {
 | 
					    if (_next_cvar < RT_MAX_CVARS) {
 | 
				
			||||||
        _vars[_next++] = cvar;
 | 
					        rtLog("CVAR", "Registered cvar %s", cvar->name);
 | 
				
			||||||
 | 
					        _vars[_next_cvar].cvar                  = cvar;
 | 
				
			||||||
 | 
					        _vars[_next_cvar].change_event_handlers = NULL;
 | 
				
			||||||
 | 
					        ++_next_cvar;
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        rtReportError("cvar", "Ran out of space for CVars");
 | 
					        rtReportError("CVAR", "Ran out of space for CVars");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    rtUnlockMutex(_mutex);
 | 
					    rtUnlockMutex(_mutex);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
rt_cvar *rtGetCVAR(const char *name) {
 | 
					RT_DLLEXPORT rt_cvar *rtGetCVAR(const char *name) {
 | 
				
			||||||
    if (!_mutex)
 | 
					    if (!_mutex)
 | 
				
			||||||
        _mutex = rtCreateMutex();
 | 
					        _mutex = rtCreateMutex();
 | 
				
			||||||
    rt_cvar *var = NULL;
 | 
					    rt_cvar *var = NULL;
 | 
				
			||||||
    rtLockMutex(_mutex);
 | 
					    rtLockMutex(_mutex);
 | 
				
			||||||
    for (unsigned int i = 0; i < _next; ++i) {
 | 
					    for (unsigned int i = 0; i < _next_cvar; ++i) {
 | 
				
			||||||
        if (strcmp(name, _vars[i]->name) == 0) {
 | 
					        if (strcmp(name, _vars[i].cvar->name) == 0) {
 | 
				
			||||||
            var = _vars[i];
 | 
					            var = _vars[i].cvar;
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    rtUnlockMutex(_mutex);
 | 
					    rtUnlockMutex(_mutex);
 | 
				
			||||||
    return var;
 | 
					    return var;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					RT_DLLEXPORT void rtRegisterCVARChangeEventHandler(rt_cvar *cvar,
 | 
				
			||||||
 | 
					                                                   rt_cvar_change_event_handler_fn *event_handler,
 | 
				
			||||||
 | 
					                                                   void *userdata) {
 | 
				
			||||||
 | 
					    RT_VERIFY(_mutex);
 | 
				
			||||||
 | 
					    rtLockMutex(_mutex);
 | 
				
			||||||
 | 
					    if (_next_event_handler == RT_MAX_EVENT_HANDLERS) {
 | 
				
			||||||
 | 
					        rtReportError("CVAR", "Ran out of space for CVar change event handlers");
 | 
				
			||||||
 | 
					        rtUnlockMutex(_mutex);
 | 
				
			||||||
 | 
					        return;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    for (unsigned int i = 0; i < _next_cvar; ++i) {
 | 
				
			||||||
 | 
					        if (_vars[i].cvar == cvar) {
 | 
				
			||||||
 | 
					            rt_cvar_change_event_list *entry = &_change_event_handlers[_next_event_handler++];
 | 
				
			||||||
 | 
					            entry->Handler                   = event_handler;
 | 
				
			||||||
 | 
					            entry->next                      = _vars[i].change_event_handlers;
 | 
				
			||||||
 | 
					            entry->userdata                  = userdata;
 | 
				
			||||||
 | 
					            _vars[i].change_event_handlers   = entry;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    rtUnlockMutex(_mutex);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					RT_DLLEXPORT void rtNotifyCVARChange(const rt_cvar *cvar) {
 | 
				
			||||||
 | 
					#ifndef RT_DONT_LOG_CVAR_CHANGES
 | 
				
			||||||
 | 
					    switch (cvar->type) {
 | 
				
			||||||
 | 
					    case RT_CVAR_TYPE_INT:
 | 
				
			||||||
 | 
					        rtLog("CVAR", "Changed %s to %d.", cvar->name, cvar->i);
 | 
				
			||||||
 | 
					        break;
 | 
				
			||||||
 | 
					    case RT_CVAR_TYPE_FLOAT:
 | 
				
			||||||
 | 
					        rtLog("CVAR", "Changed %s to %f.", cvar->name, cvar->f);
 | 
				
			||||||
 | 
					        break;
 | 
				
			||||||
 | 
					    case RT_CVAR_TYPE_STRING:
 | 
				
			||||||
 | 
					        rtLog("CVAR", "Changed %s to '%s'.", cvar->name, cvar->s);
 | 
				
			||||||
 | 
					        break;
 | 
				
			||||||
 | 
					    case RT_CVAR_TYPE_SIZE:
 | 
				
			||||||
 | 
					        rtLog("CVAR", "Changed %s to %zu.", cvar->name, cvar->sz);
 | 
				
			||||||
 | 
					        break;
 | 
				
			||||||
 | 
					    default:
 | 
				
			||||||
 | 
					        rtLog("CVAR", "Changed %s, but the cvar has an invalid type.", cvar->name);
 | 
				
			||||||
 | 
					        break;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    RT_VERIFY(_mutex);
 | 
				
			||||||
 | 
					    rtLockMutex(_mutex);
 | 
				
			||||||
 | 
					    for (unsigned int i = 0; i < _next_cvar; ++i) {
 | 
				
			||||||
 | 
					        if (_vars[i].cvar == cvar) {
 | 
				
			||||||
 | 
					            rt_cvar_change_event_list *entry = _vars[i].change_event_handlers;
 | 
				
			||||||
 | 
					            rtUnlockMutex(_mutex);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            while (entry) {
 | 
				
			||||||
 | 
					                /* We don't want to hold the mutex while the event handler runs,
 | 
				
			||||||
 | 
					                 * because that would prevent any calls to CVar functions. */
 | 
				
			||||||
 | 
					                entry->Handler(_vars[i].cvar, entry->userdata);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                rtLockMutex(_mutex);
 | 
				
			||||||
 | 
					                entry = entry->next;
 | 
				
			||||||
 | 
					                rtUnlockMutex(_mutex);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    /* Not found... */
 | 
				
			||||||
 | 
					    rtUnlockMutex(_mutex);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static int Handler(void *user, const char *section, const char *name, const char *value) {
 | 
				
			||||||
 | 
					    /* We currently ignore sections. They could be used to categorize variables by system? */
 | 
				
			||||||
 | 
					    RT_UNUSED(section);
 | 
				
			||||||
 | 
					    const char *file_path = user;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    rt_cvar *cvar = rtGetCVAR(name);
 | 
				
			||||||
 | 
					    if (!cvar) {
 | 
				
			||||||
 | 
					        /* Not a critical error. */
 | 
				
			||||||
 | 
					        rtLog("CVAR", "Unknown CVar %s in config file %s.", name, file_path);
 | 
				
			||||||
 | 
					        return 1;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    int num_read = 0;
 | 
				
			||||||
 | 
					    switch (cvar->type) {
 | 
				
			||||||
 | 
					    case RT_CVAR_TYPE_INT:
 | 
				
			||||||
 | 
					        num_read = sscanf(value, "%d", &cvar->i);
 | 
				
			||||||
 | 
					        break;
 | 
				
			||||||
 | 
					    case RT_CVAR_TYPE_FLOAT:
 | 
				
			||||||
 | 
					        num_read = sscanf(value, "%f", &cvar->f);
 | 
				
			||||||
 | 
					        break;
 | 
				
			||||||
 | 
					    case RT_CVAR_TYPE_STRING: {
 | 
				
			||||||
 | 
					        num_read   = 1;
 | 
				
			||||||
 | 
					        char *copy = rtStoreString(value);
 | 
				
			||||||
 | 
					        if (!copy) {
 | 
				
			||||||
 | 
					            rtReportError("CVAR",
 | 
				
			||||||
 | 
					                          "Failed to store string value of cvar %s in config file %s.",
 | 
				
			||||||
 | 
					                          name,
 | 
				
			||||||
 | 
					                          file_path);
 | 
				
			||||||
 | 
					            return 0;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        cvar->s = copy;
 | 
				
			||||||
 | 
					        break;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    case RT_CVAR_TYPE_SIZE:
 | 
				
			||||||
 | 
					        num_read = sscanf(value, "%zu", &cvar->sz);
 | 
				
			||||||
 | 
					        break;
 | 
				
			||||||
 | 
					    default:
 | 
				
			||||||
 | 
					        rtReportError("CVAR", "CVar %s has an invalid type.", cvar->name);
 | 
				
			||||||
 | 
					        return 0;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (num_read == 1) {
 | 
				
			||||||
 | 
					        rtNotifyCVARChange(cvar);
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
 | 
					        rtLog("CVAR", "Failed to read value of CVar %s in config file %s.", cvar->name, file_path);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return 1;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Config files are ini files */
 | 
				
			||||||
 | 
					static rt_result ProcessConfigFile(const void *buffer, size_t fsz, const char *file_path) {
 | 
				
			||||||
 | 
					    rt_result result = RT_SUCCESS;
 | 
				
			||||||
 | 
					    if (ini_parse_string(buffer, Handler, (void *)file_path) < 0) {
 | 
				
			||||||
 | 
					        rtLog("CVAR", "Failed to parse config file '%s'.", file_path);
 | 
				
			||||||
 | 
					        return RT_UNKNOWN_ERROR;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    return result;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					RT_DLLEXPORT rt_result rtProcessConfigFiles(unsigned int count, const rt_file_id *fids) {
 | 
				
			||||||
 | 
					    if (count > RT_LOAD_BATCH_MAX_SIZE) {
 | 
				
			||||||
 | 
					        rtReportError("CVAR",
 | 
				
			||||||
 | 
					                      "Got %u config files, but the maximum number of config files is %u.",
 | 
				
			||||||
 | 
					                      count,
 | 
				
			||||||
 | 
					                      RT_LOAD_BATCH_MAX_SIZE);
 | 
				
			||||||
 | 
					        return RT_INVALID_VALUE;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    typedef struct {
 | 
				
			||||||
 | 
					        void *buffer;
 | 
				
			||||||
 | 
					        size_t fsz;
 | 
				
			||||||
 | 
					        const char *path;
 | 
				
			||||||
 | 
					    } config_file_buf;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    rt_temp_arena temp = rtGetTemporaryArena(NULL, 0);
 | 
				
			||||||
 | 
					    if (!temp.arena)
 | 
				
			||||||
 | 
					        return RT_OUT_OF_MEMORY;
 | 
				
			||||||
 | 
					    config_file_buf *configs = RT_ARENA_PUSH_ARRAY_ZERO(temp.arena, config_file_buf, count);
 | 
				
			||||||
 | 
					    if (!configs) {
 | 
				
			||||||
 | 
					        rtReturnTemporaryArena(temp);
 | 
				
			||||||
 | 
					        return RT_OUT_OF_MEMORY;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    rt_aio_handle *aios = RT_ARENA_PUSH_ARRAY_ZERO(temp.arena, rt_aio_handle, count);
 | 
				
			||||||
 | 
					    if (!configs) {
 | 
				
			||||||
 | 
					        rtReturnTemporaryArena(temp);
 | 
				
			||||||
 | 
					        return RT_OUT_OF_MEMORY;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    rt_result res = RT_SUCCESS;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    rt_load_batch load_batch;
 | 
				
			||||||
 | 
					    load_batch.num_loads = count;
 | 
				
			||||||
 | 
					    for (unsigned int i = 0; i < count; ++i) {
 | 
				
			||||||
 | 
					        const char *path = rtGetFilePath(fids[i]);
 | 
				
			||||||
 | 
					        if (!path) {
 | 
				
			||||||
 | 
					            rtReportError("CVAR", "Invalid config file path!");
 | 
				
			||||||
 | 
					            res = RT_INVALID_VALUE;
 | 
				
			||||||
 | 
					            goto out;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        size_t fsz               = rtGetFileSize(path);
 | 
				
			||||||
 | 
					        load_batch.loads[i].dest = rtAllocBuffer(fsz);
 | 
				
			||||||
 | 
					        if (!load_batch.loads[i].dest) {
 | 
				
			||||||
 | 
					            rtReportError("CVAR", "Failed to allocate memory for config file.");
 | 
				
			||||||
 | 
					            res = RT_OUT_OF_MEMORY;
 | 
				
			||||||
 | 
					            goto out;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        load_batch.loads[i].num_bytes = fsz;
 | 
				
			||||||
 | 
					        load_batch.loads[i].offset    = 0;
 | 
				
			||||||
 | 
					        load_batch.loads[i].file      = fids[i];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        configs[i].buffer = load_batch.loads[i].dest;
 | 
				
			||||||
 | 
					        configs[i].fsz    = fsz;
 | 
				
			||||||
 | 
					        configs[i].path   = path;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if ((res = rtSubmitLoadBatch(&load_batch, aios)) != RT_SUCCESS) {
 | 
				
			||||||
 | 
					        goto out;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    for (unsigned int i = 0; i < count; ++i) {
 | 
				
			||||||
 | 
					        rt_aio_state state = rtWaitForAIOCompletion(aios[i]);
 | 
				
			||||||
 | 
					        if (state == RT_AIO_STATE_FINISHED) {
 | 
				
			||||||
 | 
					            res = ProcessConfigFile(configs[i].buffer, configs[i].fsz, configs[i].path);
 | 
				
			||||||
 | 
					            if (res != RT_SUCCESS)
 | 
				
			||||||
 | 
					                goto out;
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            RT_ASSERT(state == RT_AIO_STATE_FAILED, "Unexpected aio state.");
 | 
				
			||||||
 | 
					            res = RT_UNKNOWN_ERROR;
 | 
				
			||||||
 | 
					            goto out;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					out:
 | 
				
			||||||
 | 
					    for (unsigned int i = 0; i < count; ++i) {
 | 
				
			||||||
 | 
					        if (configs[i].buffer)
 | 
				
			||||||
 | 
					            rtReleaseBuffer(configs[i].buffer, configs[i].fsz);
 | 
				
			||||||
 | 
					        if (aios[i] != RT_AIO_INVALID_HANDLE)
 | 
				
			||||||
 | 
					            rtReleaseAIO(aios[i]);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    rtReturnTemporaryArena(temp);
 | 
				
			||||||
 | 
					    return res;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* This gets called before _any_ engine systems are available (especially AIO, ftab and
 | 
				
			||||||
 | 
					 * Buffermanager) */
 | 
				
			||||||
 | 
					void ProcessEarlyEngineConfigs(void) {
 | 
				
			||||||
 | 
					    const char *engine_cfgs[] = {"cfg/engine_early.cfg"};
 | 
				
			||||||
 | 
					    void *buf                 = NULL;
 | 
				
			||||||
 | 
					    size_t buf_sz             = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    for (unsigned int i = 0; i < RT_ARRAY_COUNT(engine_cfgs); ++i) {
 | 
				
			||||||
 | 
					        if (!rtDoesFileExist(engine_cfgs[i])) {
 | 
				
			||||||
 | 
					            rtLog("CVAR", "Could not find early engine config file %s", engine_cfgs[i]);
 | 
				
			||||||
 | 
					            continue;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        size_t fsz = rtGetFileSize(engine_cfgs[i]);
 | 
				
			||||||
 | 
					        if ((fsz + 1) > buf_sz) {
 | 
				
			||||||
 | 
					            buf    = realloc(buf, fsz + 1);
 | 
				
			||||||
 | 
					            buf_sz = fsz + 1;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        if (!rtSyncReadWholeFile(engine_cfgs[i], buf, buf_sz)) {
 | 
				
			||||||
 | 
					            rtLog("CVAR", "Failed to read early engine config file %s", engine_cfgs[i]);
 | 
				
			||||||
 | 
					            continue;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        ((char *)buf)[fsz] = '\0';
 | 
				
			||||||
 | 
					        if (ProcessConfigFile(buf, fsz, engine_cfgs[i]) != RT_SUCCESS) {
 | 
				
			||||||
 | 
					            rtLog("CVAR", "Failed to process early engine config file %s", engine_cfgs[i]);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    free(buf);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -1,6 +1,7 @@
 | 
				
			|||||||
#ifndef RT_CONFIG_H
 | 
					#ifndef RT_CONFIG_H
 | 
				
			||||||
#define RT_CONFIG_H
 | 
					#define RT_CONFIG_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "file_tab.h"
 | 
				
			||||||
#include "runtime.h"
 | 
					#include "runtime.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef __cplusplus
 | 
					#ifdef __cplusplus
 | 
				
			||||||
@ -26,6 +27,8 @@ typedef struct {
 | 
				
			|||||||
    rt_cvar_type type;
 | 
					    rt_cvar_type type;
 | 
				
			||||||
} rt_cvar;
 | 
					} rt_cvar;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					typedef void(rt_cvar_change_event_handler_fn)(rt_cvar *cvar, void *userdata);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* n variable name, d description string, v default value*/
 | 
					/* n variable name, d description string, v default value*/
 | 
				
			||||||
#define RT_CVAR_I(n, d, v)                                                                         \
 | 
					#define RT_CVAR_I(n, d, v)                                                                         \
 | 
				
			||||||
    rt_cvar n = {.name = #n, .description = d, .i = (v), .type = RT_CVAR_TYPE_INT}
 | 
					    rt_cvar n = {.name = #n, .description = d, .i = (v), .type = RT_CVAR_TYPE_INT}
 | 
				
			||||||
@ -40,6 +43,20 @@ RT_DLLEXPORT void rtRegisterCVAR(rt_cvar *cvar);
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
RT_DLLEXPORT rt_cvar *rtGetCVAR(const char *name);
 | 
					RT_DLLEXPORT rt_cvar *rtGetCVAR(const char *name);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Change event handlers are called when rtNotifyCVARChange is called. 
 | 
				
			||||||
 | 
					 * The system gives no guarantees about the order in which these are called.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * NOTE: A internal mutex is held while the event handlers run, which means that */
 | 
				
			||||||
 | 
					RT_DLLEXPORT void rtRegisterCVARChangeEventHandler(rt_cvar *cvar,
 | 
				
			||||||
 | 
					                                                   rt_cvar_change_event_handler_fn *event_handler,
 | 
				
			||||||
 | 
					                                                   void *userdata);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					RT_DLLEXPORT void rtNotifyCVARChange(const rt_cvar *cvar);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Load and parse configuration files.
 | 
				
			||||||
 | 
					 * They are processed in-order, meaning later files can overwrite earlier files. */
 | 
				
			||||||
 | 
					RT_DLLEXPORT rt_result rtProcessConfigFiles(unsigned int count, const rt_file_id *fids);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef __cplusplus
 | 
					#ifdef __cplusplus
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
				
			|||||||
@ -98,7 +98,14 @@ RT_DLLEXPORT size_t rtGetFileSize(const char *path) {
 | 
				
			|||||||
    return (size_t)attribs.nFileSizeHigh << 32 | (size_t)attribs.nFileSizeLow;
 | 
					    return (size_t)attribs.nFileSizeHigh << 32 | (size_t)attribs.nFileSizeLow;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
uint64_t rtGetCurrentTimestamp(void) {
 | 
					RT_DLLEXPORT bool rtDoesFileExist(const char *path) {
 | 
				
			||||||
 | 
					    WCHAR wpath[MAX_PATH];
 | 
				
			||||||
 | 
					    MultiByteToWideChar(CP_UTF8, MB_PRECOMPOSED, path, -1, wpath, MAX_PATH);
 | 
				
			||||||
 | 
					    DWORD dwAttrib = GetFileAttributesW(wpath);
 | 
				
			||||||
 | 
					    return (dwAttrib != INVALID_FILE_ATTRIBUTES && !(dwAttrib & FILE_ATTRIBUTE_DIRECTORY));
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					RT_DLLEXPORT uint64_t rtGetCurrentTimestamp(void) {
 | 
				
			||||||
    FILETIME ft;
 | 
					    FILETIME ft;
 | 
				
			||||||
    GetSystemTimeAsFileTime(&ft);
 | 
					    GetSystemTimeAsFileTime(&ft);
 | 
				
			||||||
    uint64_t ts = ft.dwLowDateTime;
 | 
					    uint64_t ts = ft.dwLowDateTime;
 | 
				
			||||||
@ -106,7 +113,7 @@ uint64_t rtGetCurrentTimestamp(void) {
 | 
				
			|||||||
    return ts;
 | 
					    return ts;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
uint64_t rtGetFileModificationTimestamp(const char *path) {
 | 
					RT_DLLEXPORT uint64_t rtGetFileModificationTimestamp(const char *path) {
 | 
				
			||||||
    WCHAR wpath[MAX_PATH];
 | 
					    WCHAR wpath[MAX_PATH];
 | 
				
			||||||
    MultiByteToWideChar(CP_UTF8, MB_PRECOMPOSED, path, -1, wpath, MAX_PATH);
 | 
					    MultiByteToWideChar(CP_UTF8, MB_PRECOMPOSED, path, -1, wpath, MAX_PATH);
 | 
				
			||||||
    WIN32_FILE_ATTRIBUTE_DATA attribs;
 | 
					    WIN32_FILE_ATTRIBUTE_DATA attribs;
 | 
				
			||||||
@ -117,12 +124,34 @@ uint64_t rtGetFileModificationTimestamp(const char *path) {
 | 
				
			|||||||
    return ts;
 | 
					    return ts;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					RT_DLLEXPORT bool rtSyncReadWholeFile(const char *path, void *dest, size_t dest_size) {
 | 
				
			||||||
 | 
					    size_t fsz = rtGetFileSize(path);
 | 
				
			||||||
 | 
					    if (fsz > dest_size)
 | 
				
			||||||
 | 
					        return false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    WCHAR wpath[MAX_PATH];
 | 
				
			||||||
 | 
					    MultiByteToWideChar(CP_UTF8, MB_PRECOMPOSED, path, -1, wpath, MAX_PATH);
 | 
				
			||||||
 | 
					    HANDLE hFile = CreateFileW(wpath,
 | 
				
			||||||
 | 
					                               GENERIC_READ,
 | 
				
			||||||
 | 
					                               FILE_SHARE_READ,
 | 
				
			||||||
 | 
					                               NULL,
 | 
				
			||||||
 | 
					                               OPEN_EXISTING,
 | 
				
			||||||
 | 
					                               FILE_ATTRIBUTE_NORMAL,
 | 
				
			||||||
 | 
					                               NULL);
 | 
				
			||||||
 | 
					    if (!hFile)
 | 
				
			||||||
 | 
					        return false;
 | 
				
			||||||
 | 
					    BOOL bResult = ReadFile(hFile, dest, (DWORD)fsz, NULL, NULL);
 | 
				
			||||||
 | 
					    CloseHandle(hFile);
 | 
				
			||||||
 | 
					    return (bool)bResult;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#elif defined(__linux__)
 | 
					#elif defined(__linux__)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <string.h>
 | 
					#include <string.h>
 | 
				
			||||||
#include <sys/dir.h>
 | 
					#include <sys/dir.h>
 | 
				
			||||||
#include <sys/stat.h>
 | 
					#include <sys/stat.h>
 | 
				
			||||||
#include <time.h>
 | 
					#include <time.h>
 | 
				
			||||||
 | 
					#include <stdio.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct rt_scandir_handle_s {
 | 
					struct rt_scandir_handle_s {
 | 
				
			||||||
    DIR *handle;
 | 
					    DIR *handle;
 | 
				
			||||||
@ -208,17 +237,40 @@ RT_DLLEXPORT size_t rtGetFileSize(const char *path) {
 | 
				
			|||||||
    return (size_t)st.st_size;
 | 
					    return (size_t)st.st_size;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
uint64_t rtGetCurrentTimestamp(void) {
 | 
					RT_DLLEXPORT bool rtDoesFileExist(const char *path) {
 | 
				
			||||||
 | 
					    struct stat st;
 | 
				
			||||||
 | 
					    if (stat(path, &st) != 0)
 | 
				
			||||||
 | 
					        return 0;
 | 
				
			||||||
 | 
					    return 1;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					RT_DLLEXPORT uint64_t rtGetCurrentTimestamp(void) {
 | 
				
			||||||
    struct timespec ts;
 | 
					    struct timespec ts;
 | 
				
			||||||
    clock_gettime(CLOCK_REALTIME, &ts);
 | 
					    clock_gettime(CLOCK_REALTIME, &ts);
 | 
				
			||||||
    return (uint64_t)ts.tv_sec;
 | 
					    return (uint64_t)ts.tv_sec;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
uint64_t rtGetFileModificationTimestamp(const char *path) {
 | 
					RT_DLLEXPORT uint64_t rtGetFileModificationTimestamp(const char *path) {
 | 
				
			||||||
    struct stat st;
 | 
					    struct stat st;
 | 
				
			||||||
    if (stat(path, &st) != 0)
 | 
					    if (stat(path, &st) != 0)
 | 
				
			||||||
        return 0;
 | 
					        return 0;
 | 
				
			||||||
    return (uint64_t)st.st_mtim.tv_sec;
 | 
					    return (uint64_t)st.st_mtim.tv_sec;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					RT_DLLEXPORT bool rtSyncReadWholeFile(const char *path, void *dest, size_t dest_size) {
 | 
				
			||||||
 | 
					    FILE *f = fopen(path, "rb");
 | 
				
			||||||
 | 
					    if (!f)
 | 
				
			||||||
 | 
					        return false;
 | 
				
			||||||
 | 
					    fseek(f, SEEK_END, 0);
 | 
				
			||||||
 | 
					    size_t fsz = (size_t)ftell(f);
 | 
				
			||||||
 | 
					    fseek(f, SEEK_SET, 0);
 | 
				
			||||||
 | 
					    if (fsz > dest_size) {
 | 
				
			||||||
 | 
					        fclose(f);
 | 
				
			||||||
 | 
					        return false;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    size_t n = fread(dest, 1 fsz, f);
 | 
				
			||||||
 | 
					    fclose(f);
 | 
				
			||||||
 | 
					    return n == fsz;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
				
			|||||||
@ -35,9 +35,15 @@ RT_DLLEXPORT size_t rtGetFileSize(const char *path);
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
RT_DLLEXPORT uint64_t rtGetFileModificationTimestamp(const char *path);
 | 
					RT_DLLEXPORT uint64_t rtGetFileModificationTimestamp(const char *path);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					RT_DLLEXPORT bool rtDoesFileExist(const char *path);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Does not really fit here, but it is mostly useful for comparison with file timestamps. */
 | 
					/* Does not really fit here, but it is mostly useful for comparison with file timestamps. */
 | 
				
			||||||
RT_DLLEXPORT uint64_t rtGetCurrentTimestamp(void);
 | 
					RT_DLLEXPORT uint64_t rtGetCurrentTimestamp(void);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* CAUTION: This does a synchronous file read!!! ONLY use this IF YOU KNOW WHAT YOU ARE DOING.
 | 
				
			||||||
 | 
					 * 99.9% of file reads should probably use the AIO system instead. */
 | 
				
			||||||
 | 
					RT_DLLEXPORT bool rtSyncReadWholeFile(const char *path, void *dest, size_t dest_size);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef __cplusplus
 | 
					#ifdef __cplusplus
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
				
			|||||||
@ -1,17 +1,18 @@
 | 
				
			|||||||
#include "hashing.h"
 | 
					#include "hashing.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <xxhash/xxhash.h>
 | 
					#include <xxhash.h>
 | 
				
			||||||
#include <assert.h>
 | 
					#include <assert.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* XXH32 of "recreational.tech" */
 | 
					/* XXH32/64 of "recreational.tech" with seed 0 */
 | 
				
			||||||
#define HASH32_SEED 0xd9035e35
 | 
					#define HASH32_SEED 0xd9035e35
 | 
				
			||||||
 | 
					#define HASH64_SEED 0xa14e16c3ae8b282dULL
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static_assert(sizeof(rt_hash64) == sizeof(XXH64_hash_t), "Size mismatch between rt_hash64 and XXH64_hash_t!");
 | 
					static_assert(sizeof(rt_hash64) == sizeof(XXH64_hash_t), "Size mismatch between rt_hash64 and XXH64_hash_t!");
 | 
				
			||||||
static_assert(sizeof(rt_hash32) == sizeof(XXH32_hash_t),
 | 
					static_assert(sizeof(rt_hash32) == sizeof(XXH32_hash_t),
 | 
				
			||||||
              "Size mismatch between rt_hash32 and XXH32_hash_t!");
 | 
					              "Size mismatch between rt_hash32 and XXH32_hash_t!");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
RT_DLLEXPORT rt_hash64 rtHashBytes(const void *begin, size_t count) {
 | 
					RT_DLLEXPORT rt_hash64 rtHashBytes(const void *begin, size_t count) {
 | 
				
			||||||
    return XXH3_64bits(begin, count);
 | 
					    return XXH64(begin, count, HASH64_SEED);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -4,19 +4,23 @@
 | 
				
			|||||||
#include "file_tab.h"
 | 
					#include "file_tab.h"
 | 
				
			||||||
#include "buffer_manager.h"
 | 
					#include "buffer_manager.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					extern rt_cvar rt_MaxConcurrentAsyncIO;
 | 
				
			||||||
 | 
					extern rt_cvar rt_AssertEnabled;
 | 
				
			||||||
extern rt_cvar rt_BufferMemoryBudget;
 | 
					extern rt_cvar rt_BufferMemoryBudget;
 | 
				
			||||||
extern rt_cvar rt_FileTabCapacity;
 | 
					extern rt_cvar rt_FileTabCapacity;
 | 
				
			||||||
extern rt_cvar rt_MaxConcurrentAsyncIO;
 | 
					extern rt_cvar rt_TemporaryArenaSize;
 | 
				
			||||||
extern rt_cvar rt_ResourceDirectory;
 | 
					extern rt_cvar rt_ResourceDirectory;
 | 
				
			||||||
extern rt_cvar rt_ResourceCacheSize;
 | 
					extern rt_cvar rt_ResourceCacheSize;
 | 
				
			||||||
extern rt_cvar rt_MaxCachedResources;
 | 
					extern rt_cvar rt_MaxCachedResources;
 | 
				
			||||||
extern rt_cvar rt_ResourceNamespaceSize;
 | 
					extern rt_cvar rt_ResourceNamespaceSize;
 | 
				
			||||||
extern rt_cvar rt_DisableResourceNamespaceLoad;
 | 
					extern rt_cvar rt_DisableResourceNamespaceLoad;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void RegisterRuntimeCVars(void) {
 | 
					static void RegisterRuntimeCVars(void) {
 | 
				
			||||||
 | 
					    rtRegisterCVAR(&rt_MaxConcurrentAsyncIO);
 | 
				
			||||||
 | 
					    rtRegisterCVAR(&rt_AssertEnabled);
 | 
				
			||||||
    rtRegisterCVAR(&rt_BufferMemoryBudget);
 | 
					    rtRegisterCVAR(&rt_BufferMemoryBudget);
 | 
				
			||||||
    rtRegisterCVAR(&rt_FileTabCapacity);
 | 
					    rtRegisterCVAR(&rt_FileTabCapacity);
 | 
				
			||||||
    rtRegisterCVAR(&rt_MaxConcurrentAsyncIO);
 | 
					    rtRegisterCVAR(&rt_TemporaryArenaSize);
 | 
				
			||||||
    rtRegisterCVAR(&rt_ResourceDirectory);
 | 
					    rtRegisterCVAR(&rt_ResourceDirectory);
 | 
				
			||||||
    rtRegisterCVAR(&rt_ResourceCacheSize);
 | 
					    rtRegisterCVAR(&rt_ResourceCacheSize);
 | 
				
			||||||
    rtRegisterCVAR(&rt_MaxCachedResources);
 | 
					    rtRegisterCVAR(&rt_MaxCachedResources);
 | 
				
			||||||
@ -25,6 +29,8 @@ void RegisterRuntimeCVars(void) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern void SetMainThreadId(void);
 | 
					extern void SetMainThreadId(void);
 | 
				
			||||||
 | 
					extern void ProcessEarlyEngineConfigs(void);
 | 
				
			||||||
 | 
					extern void InitStringStorage(void);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern rt_result InitBufferManager(void);
 | 
					extern rt_result InitBufferManager(void);
 | 
				
			||||||
extern void ShutdownBufferManager(void);
 | 
					extern void ShutdownBufferManager(void);
 | 
				
			||||||
@ -39,6 +45,9 @@ extern rt_result InitTiming(void);
 | 
				
			|||||||
RT_DLLEXPORT rt_result rtInitRuntime(void) {
 | 
					RT_DLLEXPORT rt_result rtInitRuntime(void) {
 | 
				
			||||||
    SetMainThreadId();
 | 
					    SetMainThreadId();
 | 
				
			||||||
    RegisterRuntimeCVars();
 | 
					    RegisterRuntimeCVars();
 | 
				
			||||||
 | 
					    InitStringStorage();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    ProcessEarlyEngineConfigs();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    rt_result res;
 | 
					    rt_result res;
 | 
				
			||||||
    if ((res = InitTiming()) != RT_SUCCESS) {
 | 
					    if ((res = InitTiming()) != RT_SUCCESS) {
 | 
				
			||||||
 | 
				
			|||||||
@ -1,5 +1,12 @@
 | 
				
			|||||||
# Runtime 
 | 
					# Dependencies installed via wrap
 | 
				
			||||||
runtime_deps = [thread_dep, m_dep, windowing_dep]
 | 
					inih_proj = subproject('inih', default_options: ['default_library=static', 'b_sanitize=none', 'utf-8_bom=true', 'multi-line_entries=true', 'report_line_numbers=true'])
 | 
				
			||||||
 | 
					inih_dep = inih_proj.get_variable('inih_dep')
 | 
				
			||||||
 | 
					lz4_proj = subproject('lz4', default_options: ['default_library=static', 'b_sanitize=none'])
 | 
				
			||||||
 | 
					lz4_dep = lz4_proj.get_variable('liblz4_dep')
 | 
				
			||||||
 | 
					xxhash_proj = subproject('xxhash', default_options: ['default_library=static', 'b_sanitize=none'])
 | 
				
			||||||
 | 
					xxhash_dep = xxhash_proj.get_variable('xxhash_dep')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					runtime_deps = [thread_dep, m_dep, windowing_dep, inih_dep, lz4_dep, xxhash_dep]
 | 
				
			||||||
runtime_incdirs = contrib_incdir
 | 
					runtime_incdirs = contrib_incdir
 | 
				
			||||||
runtime_lib = library('rt',
 | 
					runtime_lib = library('rt',
 | 
				
			||||||
  # Project Sources
 | 
					  # Project Sources
 | 
				
			||||||
@ -18,6 +25,7 @@ runtime_lib = library('rt',
 | 
				
			|||||||
  'mem_arena.h',
 | 
					  'mem_arena.h',
 | 
				
			||||||
  'resources.h',
 | 
					  'resources.h',
 | 
				
			||||||
  'runtime.h',
 | 
					  'runtime.h',
 | 
				
			||||||
 | 
					  'string_storage.h',
 | 
				
			||||||
  'threading.h',
 | 
					  'threading.h',
 | 
				
			||||||
  'threading_helpers.hpp',
 | 
					  'threading_helpers.hpp',
 | 
				
			||||||
  'timing.h',
 | 
					  'timing.h',
 | 
				
			||||||
@ -40,6 +48,7 @@ runtime_lib = library('rt',
 | 
				
			|||||||
  'mem_arena.c',
 | 
					  'mem_arena.c',
 | 
				
			||||||
  'resource_manager.c',
 | 
					  'resource_manager.c',
 | 
				
			||||||
  'sprint.c',
 | 
					  'sprint.c',
 | 
				
			||||||
 | 
					  'string_storage.c',
 | 
				
			||||||
  'text.c',
 | 
					  'text.c',
 | 
				
			||||||
  'threading_cond.c',
 | 
					  'threading_cond.c',
 | 
				
			||||||
  'threading_mutex.c',
 | 
					  'threading_mutex.c',
 | 
				
			||||||
@ -48,9 +57,6 @@ runtime_lib = library('rt',
 | 
				
			|||||||
  'threading_thread.c',
 | 
					  'threading_thread.c',
 | 
				
			||||||
  'timing.c',
 | 
					  'timing.c',
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  # Contrib Sources
 | 
					 | 
				
			||||||
  contrib_dir / 'xxhash/xxhash.c',
 | 
					 | 
				
			||||||
  contrib_dir / 'lz4/lz4.c',
 | 
					 | 
				
			||||||
  dependencies : runtime_deps,
 | 
					  dependencies : runtime_deps,
 | 
				
			||||||
  include_directories : [engine_incdir, runtime_incdirs],
 | 
					  include_directories : [engine_incdir, runtime_incdirs],
 | 
				
			||||||
  c_pch : 'pch/rt_pch.h',
 | 
					  c_pch : 'pch/rt_pch.h',
 | 
				
			||||||
 | 
				
			|||||||
@ -17,13 +17,13 @@
 | 
				
			|||||||
#include <string.h>
 | 
					#include <string.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
RT_CVAR_S(rt_ResourceDirectory, "The directory used for storing resources. Default: res", "res");
 | 
					RT_CVAR_S(rt_ResourceDirectory, "The directory used for storing resources. Default: res", "res");
 | 
				
			||||||
RT_CVAR_I(rt_ResourceCacheSize,
 | 
					RT_CVAR_SZ(rt_ResourceCacheSize,
 | 
				
			||||||
          "The maximum amount of memory used for caching resources. Default: 512MB",
 | 
					          "The maximum amount of memory used for caching resources. Default: 512MB",
 | 
				
			||||||
          RT_MB(512));
 | 
					          RT_MB(512));
 | 
				
			||||||
RT_CVAR_I(rt_MaxCachedResources,
 | 
					RT_CVAR_SZ(rt_MaxCachedResources,
 | 
				
			||||||
          "The maximum number of simultaneously cached resources. Default: 1024",
 | 
					          "The maximum number of simultaneously cached resources. Default: 1024",
 | 
				
			||||||
          1024);
 | 
					          1024);
 | 
				
			||||||
RT_CVAR_I(rt_ResourceNamespaceSize,
 | 
					RT_CVAR_SZ(rt_ResourceNamespaceSize,
 | 
				
			||||||
          "The maximum number of resources that can exist. Default: 1.048.576",
 | 
					          "The maximum number of resources that can exist. Default: 1.048.576",
 | 
				
			||||||
          1048576);
 | 
					          1048576);
 | 
				
			||||||
RT_CVAR_I(rt_DisableResourceNamespaceLoad,
 | 
					RT_CVAR_I(rt_DisableResourceNamespaceLoad,
 | 
				
			||||||
@ -312,7 +312,7 @@ static void ShutdownResourceCache(void) {
 | 
				
			|||||||
/* NOTE(Kevin): Only call this while holding a write-lock on the cache.
 | 
					/* NOTE(Kevin): Only call this while holding a write-lock on the cache.
 | 
				
			||||||
 * The function locks the reclaim heap lock itself. */
 | 
					 * The function locks the reclaim heap lock itself. */
 | 
				
			||||||
static bool FreeCacheSpace(size_t space) {
 | 
					static bool FreeCacheSpace(size_t space) {
 | 
				
			||||||
    size_t free_space = (size_t)rt_ResourceCacheSize.i - _cache.current_size;
 | 
					    size_t free_space = rt_ResourceCacheSize.sz - _cache.current_size;
 | 
				
			||||||
    rtLockMutex(_cache.heap_lock);
 | 
					    rtLockMutex(_cache.heap_lock);
 | 
				
			||||||
    while (free_space < space && !rtMinheapIsEmpty(&_cache.reclaim_heap)) {
 | 
					    while (free_space < space && !rtMinheapIsEmpty(&_cache.reclaim_heap)) {
 | 
				
			||||||
        rt_cached_resource_ref ref;
 | 
					        rt_cached_resource_ref ref;
 | 
				
			||||||
@ -336,7 +336,7 @@ static bool FreeCacheSpace(size_t space) {
 | 
				
			|||||||
        res->size          = 0;
 | 
					        res->size          = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        /* Remove from lookup table */
 | 
					        /* Remove from lookup table */
 | 
				
			||||||
        size_t ht_size = (size_t)rt_MaxCachedResources.i * 2;
 | 
					        size_t ht_size = rt_MaxCachedResources.sz * 2;
 | 
				
			||||||
        for (size_t off = 0; off < ht_size; ++off) {
 | 
					        for (size_t off = 0; off < ht_size; ++off) {
 | 
				
			||||||
            size_t slot = (ref.id + off) % ht_size;
 | 
					            size_t slot = (ref.id + off) % ht_size;
 | 
				
			||||||
            if (_cache.resource_ids[slot] == ref.id) {
 | 
					            if (_cache.resource_ids[slot] == ref.id) {
 | 
				
			||||||
@ -352,7 +352,7 @@ static bool FreeCacheSpace(size_t space) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static unsigned int FindCachedResource(rt_resource_id id) {
 | 
					static unsigned int FindCachedResource(rt_resource_id id) {
 | 
				
			||||||
    size_t ht_size = (size_t)rt_MaxCachedResources.i * 2;
 | 
					    size_t ht_size = rt_MaxCachedResources.sz * 2;
 | 
				
			||||||
    for (size_t off = 0; off < ht_size; ++off) {
 | 
					    for (size_t off = 0; off < ht_size; ++off) {
 | 
				
			||||||
        size_t slot = (id + off) % ht_size;
 | 
					        size_t slot = (id + off) % ht_size;
 | 
				
			||||||
        if (_cache.resource_ids[slot] == id)
 | 
					        if (_cache.resource_ids[slot] == id)
 | 
				
			||||||
@ -378,7 +378,7 @@ static rt_resource *CacheResource(rt_resource_id id, const rt_resource *res) {
 | 
				
			|||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        /* Insert into cache */
 | 
					        /* Insert into cache */
 | 
				
			||||||
        size_t total_size = sizeof(rt_resource) + GetResourceDataSize(res);
 | 
					        size_t total_size = sizeof(rt_resource) + GetResourceDataSize(res);
 | 
				
			||||||
        if (_cache.current_size + total_size >= (size_t)rt_ResourceCacheSize.i) {
 | 
					        if (_cache.current_size + total_size >= rt_ResourceCacheSize.sz) {
 | 
				
			||||||
            if (!FreeCacheSpace(total_size)) {
 | 
					            if (!FreeCacheSpace(total_size)) {
 | 
				
			||||||
                rtLog("RESMGR",
 | 
					                rtLog("RESMGR",
 | 
				
			||||||
                      "Unable to reclaim %zu kB from the resource cache.",
 | 
					                      "Unable to reclaim %zu kB from the resource cache.",
 | 
				
			||||||
@ -421,7 +421,7 @@ static rt_resource *CacheResource(rt_resource_id id, const rt_resource *res) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        /* Insert into lookup table */
 | 
					        /* Insert into lookup table */
 | 
				
			||||||
        bool inserted  = false;
 | 
					        bool inserted  = false;
 | 
				
			||||||
        size_t ht_size = (size_t)rt_MaxCachedResources.i * 2;
 | 
					        size_t ht_size = rt_MaxCachedResources.sz * 2;
 | 
				
			||||||
        for (size_t off = 0; off < ht_size; ++off) {
 | 
					        for (size_t off = 0; off < ht_size; ++off) {
 | 
				
			||||||
            size_t slot = (id + off) % ht_size;
 | 
					            size_t slot = (id + off) % ht_size;
 | 
				
			||||||
            if (_cache.resource_ids[slot] == RT_INVALID_RESOURCE_ID ||
 | 
					            if (_cache.resource_ids[slot] == RT_INVALID_RESOURCE_ID ||
 | 
				
			||||||
@ -452,7 +452,7 @@ static void InsertPrefetchResourceIntoCache(rt_resource_id id,
 | 
				
			|||||||
        return;
 | 
					        return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (_cache.current_size + load_buffer_size >= (size_t)rt_ResourceCacheSize.i) {
 | 
					    if (_cache.current_size + load_buffer_size >= rt_ResourceCacheSize.sz) {
 | 
				
			||||||
        if (!FreeCacheSpace(load_buffer_size)) {
 | 
					        if (!FreeCacheSpace(load_buffer_size)) {
 | 
				
			||||||
            rtLog("RESMGR",
 | 
					            rtLog("RESMGR",
 | 
				
			||||||
                  "Unable to reclaim %zu kB from the resource cache.",
 | 
					                  "Unable to reclaim %zu kB from the resource cache.",
 | 
				
			||||||
@ -484,7 +484,7 @@ static void InsertPrefetchResourceIntoCache(rt_resource_id id,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    /* Insert into lookup table */
 | 
					    /* Insert into lookup table */
 | 
				
			||||||
    bool inserted  = false;
 | 
					    bool inserted  = false;
 | 
				
			||||||
    size_t ht_size = (size_t)rt_MaxCachedResources.i * 2;
 | 
					    size_t ht_size = rt_MaxCachedResources.sz * 2;
 | 
				
			||||||
    for (size_t off = 0; off < ht_size; ++off) {
 | 
					    for (size_t off = 0; off < ht_size; ++off) {
 | 
				
			||||||
        size_t slot = (id + off) % ht_size;
 | 
					        size_t slot = (id + off) % ht_size;
 | 
				
			||||||
        if (_cache.resource_ids[slot] == RT_INVALID_RESOURCE_ID ||
 | 
					        if (_cache.resource_ids[slot] == RT_INVALID_RESOURCE_ID ||
 | 
				
			||||||
@ -508,7 +508,7 @@ static void InsertPrefetchResourceIntoCache(rt_resource_id id,
 | 
				
			|||||||
static rt_resource_namespace _namespace;
 | 
					static rt_resource_namespace _namespace;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static rt_result InitResourceNamespace(void) {
 | 
					static rt_result InitResourceNamespace(void) {
 | 
				
			||||||
    size_t size = (size_t)rt_ResourceNamespaceSize.i;
 | 
					    size_t size = rt_ResourceNamespaceSize.sz;
 | 
				
			||||||
    if (size == 0) {
 | 
					    if (size == 0) {
 | 
				
			||||||
        rtReportError("RESMGR", "rt_ResourceNamespaceSize must be greater than 0.");
 | 
					        rtReportError("RESMGR", "rt_ResourceNamespaceSize must be greater than 0.");
 | 
				
			||||||
        return RT_INVALID_VALUE;
 | 
					        return RT_INVALID_VALUE;
 | 
				
			||||||
@ -567,7 +567,7 @@ static void LoadNamespace(void) {
 | 
				
			|||||||
            rt_hash64 entries_hash =
 | 
					            rt_hash64 entries_hash =
 | 
				
			||||||
                rtHashBytes(entries, sizeof(rt_namespace_file_entry) * header->num_entries);
 | 
					                rtHashBytes(entries, sizeof(rt_namespace_file_entry) * header->num_entries);
 | 
				
			||||||
            if (entries_hash == header->checksum) {
 | 
					            if (entries_hash == header->checksum) {
 | 
				
			||||||
                size_t ns_size = (size_t)rt_ResourceNamespaceSize.i;
 | 
					                size_t ns_size = rt_ResourceNamespaceSize.sz;
 | 
				
			||||||
                for (uint32_t i = 0; i < header->num_entries; ++i) {
 | 
					                for (uint32_t i = 0; i < header->num_entries; ++i) {
 | 
				
			||||||
                    bool inserted = false;
 | 
					                    bool inserted = false;
 | 
				
			||||||
                    for (size_t j = 0; j < ns_size; ++j) {
 | 
					                    for (size_t j = 0; j < ns_size; ++j) {
 | 
				
			||||||
@ -610,7 +610,7 @@ static void LoadNamespace(void) {
 | 
				
			|||||||
static rt_resource_ref GetResourceRef(rt_resource_id id) {
 | 
					static rt_resource_ref GetResourceRef(rt_resource_id id) {
 | 
				
			||||||
    rt_resource_ref ref = {.file = RT_INVALID_FILE_ID};
 | 
					    rt_resource_ref ref = {.file = RT_INVALID_FILE_ID};
 | 
				
			||||||
    rtLockRead(&_namespace.lock);
 | 
					    rtLockRead(&_namespace.lock);
 | 
				
			||||||
    size_t ns_size = (size_t)rt_ResourceNamespaceSize.i;
 | 
					    size_t ns_size = rt_ResourceNamespaceSize.sz;
 | 
				
			||||||
    for (size_t off = 0; off < ns_size; ++off) {
 | 
					    for (size_t off = 0; off < ns_size; ++off) {
 | 
				
			||||||
        size_t at = (id + off) % ns_size;
 | 
					        size_t at = (id + off) % ns_size;
 | 
				
			||||||
        if (_namespace.ids[at] == id) {
 | 
					        if (_namespace.ids[at] == id) {
 | 
				
			||||||
@ -772,7 +772,7 @@ RT_DLLEXPORT rt_result rtGetResource(rt_resource_id id, void *dest) {
 | 
				
			|||||||
RT_DLLEXPORT size_t rtGetResourceSize(rt_resource_id id) {
 | 
					RT_DLLEXPORT size_t rtGetResourceSize(rt_resource_id id) {
 | 
				
			||||||
    size_t size = 0;
 | 
					    size_t size = 0;
 | 
				
			||||||
    rtLockRead(&_namespace.lock);
 | 
					    rtLockRead(&_namespace.lock);
 | 
				
			||||||
    size_t ns_size = (size_t)rt_ResourceNamespaceSize.i;
 | 
					    size_t ns_size = rt_ResourceNamespaceSize.sz;
 | 
				
			||||||
    for (size_t off = 0; off < ns_size; ++off) {
 | 
					    for (size_t off = 0; off < ns_size; ++off) {
 | 
				
			||||||
        size_t at = (id + off) % ns_size;
 | 
					        size_t at = (id + off) % ns_size;
 | 
				
			||||||
        if (_namespace.ids[at] == id) {
 | 
					        if (_namespace.ids[at] == id) {
 | 
				
			||||||
@ -859,7 +859,7 @@ RT_DLLEXPORT rt_result rtCreateResources(uint32_t count,
 | 
				
			|||||||
                                         const rt_resource *resources,
 | 
					                                         const rt_resource *resources,
 | 
				
			||||||
                                         rt_resource_id *ids) {
 | 
					                                         rt_resource_id *ids) {
 | 
				
			||||||
    rt_result result = RT_SUCCESS;
 | 
					    rt_result result = RT_SUCCESS;
 | 
				
			||||||
    size_t ns_size   = (size_t)rt_ResourceNamespaceSize.i;
 | 
					    size_t ns_size   = rt_ResourceNamespaceSize.sz;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    rt_write_batch writes = {.num_writes = 0};
 | 
					    rt_write_batch writes = {.num_writes = 0};
 | 
				
			||||||
    rt_aio_handle write_handles[RT_WRITE_BATCH_MAX_SIZE];
 | 
					    rt_aio_handle write_handles[RT_WRITE_BATCH_MAX_SIZE];
 | 
				
			||||||
@ -1090,7 +1090,7 @@ RT_DLLEXPORT void rtSaveResourceNamespace(void) {
 | 
				
			|||||||
    rt_temp_arena temp = rtGetTemporaryArena(NULL, 0);
 | 
					    rt_temp_arena temp = rtGetTemporaryArena(NULL, 0);
 | 
				
			||||||
    rtLockRead(&_namespace.lock);
 | 
					    rtLockRead(&_namespace.lock);
 | 
				
			||||||
    uint32_t entry_count = 0;
 | 
					    uint32_t entry_count = 0;
 | 
				
			||||||
    for (size_t i = 0; i < (size_t)rt_ResourceNamespaceSize.i; ++i) {
 | 
					    for (size_t i = 0; i < rt_ResourceNamespaceSize.sz; ++i) {
 | 
				
			||||||
        if (_namespace.ids[i] != RT_INVALID_RESOURCE_ID)
 | 
					        if (_namespace.ids[i] != RT_INVALID_RESOURCE_ID)
 | 
				
			||||||
            ++entry_count;
 | 
					            ++entry_count;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@ -1108,7 +1108,7 @@ RT_DLLEXPORT void rtSaveResourceNamespace(void) {
 | 
				
			|||||||
    rt_namespace_file_header *header = buffer;
 | 
					    rt_namespace_file_header *header = buffer;
 | 
				
			||||||
    rt_namespace_file_entry *entries = (rt_namespace_file_entry *)(header + 1);
 | 
					    rt_namespace_file_entry *entries = (rt_namespace_file_entry *)(header + 1);
 | 
				
			||||||
    size_t at                        = 0;
 | 
					    size_t at                        = 0;
 | 
				
			||||||
    for (size_t i = 0; i < (size_t)rt_ResourceNamespaceSize.i; ++i) {
 | 
					    for (size_t i = 0; i < rt_ResourceNamespaceSize.sz; ++i) {
 | 
				
			||||||
        if (_namespace.ids[i] != RT_INVALID_RESOURCE_ID) {
 | 
					        if (_namespace.ids[i] != RT_INVALID_RESOURCE_ID) {
 | 
				
			||||||
            entries[at].id  = _namespace.ids[i];
 | 
					            entries[at].id  = _namespace.ids[i];
 | 
				
			||||||
            entries[at].ref = _namespace.refs[i];
 | 
					            entries[at].ref = _namespace.refs[i];
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										120
									
								
								src/runtime/string_storage.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										120
									
								
								src/runtime/string_storage.c
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,120 @@
 | 
				
			|||||||
 | 
					#include "string_storage.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <stdlib.h>
 | 
				
			||||||
 | 
					#include <string.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define STRING_STORAGE_BUDGET RT_MB(1)
 | 
				
			||||||
 | 
					/* Must be greater than sizeof(rt_free_range) */
 | 
				
			||||||
 | 
					#define MIN_SPLIT_LENGTH 64
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define HEADER_MAGIC 0x1234567812345678uLL
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					typedef struct rt_free_range {
 | 
				
			||||||
 | 
					    /* Begin is address of this struct */
 | 
				
			||||||
 | 
					    size_t length;
 | 
				
			||||||
 | 
					    struct rt_free_range *next;
 | 
				
			||||||
 | 
					} rt_free_range;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					typedef struct {
 | 
				
			||||||
 | 
					    size_t alloc_len;
 | 
				
			||||||
 | 
					    uint64_t magic;
 | 
				
			||||||
 | 
					} rt_string_header;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static char _mem[STRING_STORAGE_BUDGET];
 | 
				
			||||||
 | 
					static rt_free_range *_first_free;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					_Static_assert(sizeof(rt_free_range) < MIN_SPLIT_LENGTH, "Minimal split length must be greater than the size of a free list node.");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void InitStringStorage(void) {
 | 
				
			||||||
 | 
					    _first_free         = (rt_free_range *)& _mem[0];
 | 
				
			||||||
 | 
					    _first_free->length = STRING_STORAGE_BUDGET;
 | 
				
			||||||
 | 
					    _first_free->next   = NULL;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					RT_DLLEXPORT char *rtStoreString(const char *sz) {
 | 
				
			||||||
 | 
					    size_t len = strlen(sz) + 1;
 | 
				
			||||||
 | 
					    size_t alloc_len = len + sizeof(rt_string_header);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* Look for a free range that is large enough */
 | 
				
			||||||
 | 
					    rt_free_range *free_range = _first_free;
 | 
				
			||||||
 | 
					    rt_free_range *prev       = NULL;
 | 
				
			||||||
 | 
					    while (free_range && free_range->length < alloc_len) {
 | 
				
			||||||
 | 
					        prev       = free_range;
 | 
				
			||||||
 | 
					        free_range = free_range->next;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    if (!free_range)
 | 
				
			||||||
 | 
					        return NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* Should we split? */
 | 
				
			||||||
 | 
					    if ((free_range->length - alloc_len) >= MIN_SPLIT_LENGTH) {
 | 
				
			||||||
 | 
					        rt_free_range *split = (rt_free_range *)((char *)free_range + alloc_len);
 | 
				
			||||||
 | 
					        split->length        = free_range->length - alloc_len;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /* Enter into the linked list and remove the allocated range */
 | 
				
			||||||
 | 
					        split->next          = free_range->next;
 | 
				
			||||||
 | 
					        if (prev)
 | 
				
			||||||
 | 
					            prev->next = split;
 | 
				
			||||||
 | 
					        else
 | 
				
			||||||
 | 
					            _first_free = split;
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
 | 
					        /* Just remove us */
 | 
				
			||||||
 | 
					        alloc_len = free_range->length;
 | 
				
			||||||
 | 
					        if (prev)
 | 
				
			||||||
 | 
					            prev->next = free_range->next;
 | 
				
			||||||
 | 
					        else
 | 
				
			||||||
 | 
					            _first_free = free_range->next;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    char *ptr = (char *)free_range;
 | 
				
			||||||
 | 
					    memcpy(ptr + sizeof(rt_string_header), sz, len);
 | 
				
			||||||
 | 
					    rt_string_header *header = (rt_string_header*)ptr;
 | 
				
			||||||
 | 
					    header->alloc_len        = alloc_len;
 | 
				
			||||||
 | 
					    header->magic            = HEADER_MAGIC;
 | 
				
			||||||
 | 
					    return ptr + sizeof(rt_string_header);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					RT_DLLEXPORT void rtFreeString(char *storeStringRet) {
 | 
				
			||||||
 | 
					    if (!storeStringRet)
 | 
				
			||||||
 | 
					        return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    size_t len = strlen(storeStringRet) + 1;
 | 
				
			||||||
 | 
					    if (((uintptr_t)storeStringRet < (uintptr_t)&_mem[sizeof(rt_string_header)]) ||
 | 
				
			||||||
 | 
					        (((uintptr_t)storeStringRet + len) > (uintptr_t)&_mem[STRING_STORAGE_BUDGET - 1])) {
 | 
				
			||||||
 | 
					        rtReportError("STRSTORAGE",
 | 
				
			||||||
 | 
					                      "Tried to free a string that is not stored in the string storage.");
 | 
				
			||||||
 | 
					        return;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    rt_string_header *header = (rt_string_header *)(storeStringRet - sizeof(rt_string_header));
 | 
				
			||||||
 | 
					    if (header->magic != HEADER_MAGIC) {
 | 
				
			||||||
 | 
					        rtReportError("STRSTORAGE", "Invalid header in string storage!");
 | 
				
			||||||
 | 
					        return;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    size_t alloc_len          = header->alloc_len;
 | 
				
			||||||
 | 
					    rt_free_range *free_range = (rt_free_range *)header;
 | 
				
			||||||
 | 
					    free_range->length        = alloc_len;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* Search the place for inserting it */
 | 
				
			||||||
 | 
					    rt_free_range *prev = _first_free;
 | 
				
			||||||
 | 
					    if ((uintptr_t)prev < (uintptr_t)free_range) {
 | 
				
			||||||
 | 
					        while (prev->next) {
 | 
				
			||||||
 | 
					            if ((uintptr_t)prev->next > (uintptr_t)free_range)
 | 
				
			||||||
 | 
					                break;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        free_range->next = prev->next;
 | 
				
			||||||
 | 
					        prev->next       = free_range;
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
 | 
					        /* Swap */
 | 
				
			||||||
 | 
					        rt_free_range *t = _first_free;
 | 
				
			||||||
 | 
					        _first_free      = free_range;
 | 
				
			||||||
 | 
					        free_range       = t;
 | 
				
			||||||
 | 
					        prev             = _first_free;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* Check if we can merge */
 | 
				
			||||||
 | 
					    while (((uintptr_t)prev + prev->length) == (uintptr_t)free_range) {
 | 
				
			||||||
 | 
					        prev->length += alloc_len;
 | 
				
			||||||
 | 
					        prev->next = free_range->next;
 | 
				
			||||||
 | 
					        free_range = prev->next;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										23
									
								
								src/runtime/string_storage.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								src/runtime/string_storage.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,23 @@
 | 
				
			|||||||
 | 
					#ifndef RT_STRING_STORAGE_H
 | 
				
			||||||
 | 
					#define RT_STRING_STORAGE_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Memory management for strings.
 | 
				
			||||||
 | 
					 * This should only be used for relatively short strings (<256 bytes)
 | 
				
			||||||
 | 
					 * For large amounts of data, use the block allocator instead.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "runtime.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef __cplusplus
 | 
				
			||||||
 | 
					extern "C" {
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					RT_DLLEXPORT char *rtStoreString(const char *sz);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					RT_DLLEXPORT void rtFreeString(char *storeStringRet);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef __cplusplus
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
							
								
								
									
										11
									
								
								subprojects/inih.wrap
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								subprojects/inih.wrap
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,11 @@
 | 
				
			|||||||
 | 
					[wrap-file]
 | 
				
			||||||
 | 
					directory = inih-r57
 | 
				
			||||||
 | 
					source_url = https://github.com/benhoyt/inih/archive/r57.tar.gz
 | 
				
			||||||
 | 
					source_filename = inih-r57.tar.gz
 | 
				
			||||||
 | 
					source_hash = f03f98ca35c3adb56b2358573c8d3eda319ccd5287243d691e724b7eafa970b3
 | 
				
			||||||
 | 
					source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/inih_r57-1/inih-r57.tar.gz
 | 
				
			||||||
 | 
					wrapdb_version = r57-1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[provide]
 | 
				
			||||||
 | 
					inih = inih_dep
 | 
				
			||||||
 | 
					inireader = INIReader_dep
 | 
				
			||||||
							
								
								
									
										12
									
								
								subprojects/lz4.wrap
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								subprojects/lz4.wrap
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,12 @@
 | 
				
			|||||||
 | 
					[wrap-file]
 | 
				
			||||||
 | 
					directory = lz4-1.9.4
 | 
				
			||||||
 | 
					source_url = https://github.com/lz4/lz4/archive/v1.9.4.tar.gz
 | 
				
			||||||
 | 
					source_filename = lz4-1.9.4.tgz
 | 
				
			||||||
 | 
					source_hash = 0b0e3aa07c8c063ddf40b082bdf7e37a1562bda40a0ff5272957f3e987e0e54b
 | 
				
			||||||
 | 
					patch_filename = lz4_1.9.4-2_patch.zip
 | 
				
			||||||
 | 
					patch_url = https://wrapdb.mesonbuild.com/v2/lz4_1.9.4-2/get_patch
 | 
				
			||||||
 | 
					patch_hash = 4f33456cce986167d23faf5d28a128e773746c10789950475d2155a7914630fb
 | 
				
			||||||
 | 
					wrapdb_version = 1.9.4-2
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[provide]
 | 
				
			||||||
 | 
					liblz4 = liblz4_dep
 | 
				
			||||||
							
								
								
									
										13
									
								
								subprojects/xxhash.wrap
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								subprojects/xxhash.wrap
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,13 @@
 | 
				
			|||||||
 | 
					[wrap-file]
 | 
				
			||||||
 | 
					directory = xxHash-0.8.2
 | 
				
			||||||
 | 
					source_url = https://github.com/Cyan4973/xxHash/archive/v0.8.2.tar.gz
 | 
				
			||||||
 | 
					source_filename = xxHash-0.8.2.tar.gz
 | 
				
			||||||
 | 
					source_hash = baee0c6afd4f03165de7a4e67988d16f0f2b257b51d0e3cb91909302a26a79c4
 | 
				
			||||||
 | 
					patch_filename = xxhash_0.8.2-1_patch.zip
 | 
				
			||||||
 | 
					patch_url = https://wrapdb.mesonbuild.com/v2/xxhash_0.8.2-1/get_patch
 | 
				
			||||||
 | 
					patch_hash = e721ef7a4c4ee0ade8b8440f6f7cb9f935b68e825249d74cb1c2503c53e68d25
 | 
				
			||||||
 | 
					source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/xxhash_0.8.2-1/xxHash-0.8.2.tar.gz
 | 
				
			||||||
 | 
					wrapdb_version = 0.8.2-1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[provide]
 | 
				
			||||||
 | 
					libxxhash = xxhash_dep
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user