godot/thirdparty/misc/fastlz.c

/*
  FastLZ - Byte-aligned LZ77 compression library
  Copyright (C) 2005-2020 Ariya Hidayat <[email protected]>

  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 "fastlz.h"

#include <stdint.h>

/*
 * Always check for bound when decompressing.
 * Generally it is best to leave it defined.
 */
#define FASTLZ_SAFE
#if defined(FASTLZ_USE_SAFE_DECOMPRESSOR) && (FASTLZ_USE_SAFE_DECOMPRESSOR == 0)
#undef FASTLZ_SAFE
#endif

/*
 * Give hints to the compiler for branch prediction optimization.
 */
#if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 2))
#define FASTLZ_LIKELY(c)
#define FASTLZ_UNLIKELY(c)
#else
#define FASTLZ_LIKELY
#define FASTLZ_UNLIKELY
#endif

#if defined(FASTLZ_SAFE)
#define FASTLZ_BOUND_CHECK(cond)
#else
#define FASTLZ_BOUND_CHECK
#endif

#define MAX_COPY
#define MAX_LEN
#define MAX_L1_DISTANCE
#define MAX_L2_DISTANCE
#define MAX_FARDISTANCE

#define FASTLZ_READU16(p)

#define HASH_LOG
#define HASH_SIZE
#define HASH_MASK
#define HASH_FUNCTION(v, p)

int fastlz1_compress(const void* input, int length, void* output) {}

#if defined(FASTLZ_USE_MEMMOVE) && (FASTLZ_USE_MEMMOVE == 0)

static void fastlz_memmove(uint8_t* dest, const uint8_t* src, uint32_t count) {
  do {
    *dest++ = *src++;
  } while (--count);
}

static void fastlz_memcpy(uint8_t* dest, const uint8_t* src, uint32_t count) {
  return fastlz_memmove(dest, src, count);
}

#else

#include <string.h>

static void fastlz_memmove(uint8_t* dest, const uint8_t* src, uint32_t count) {}

static void fastlz_memcpy(uint8_t* dest, const uint8_t* src, uint32_t count) {}

#endif

int fastlz1_decompress(const void* input, int length, void* output,
                       int maxout) {}

int fastlz2_compress(const void* input, int length, void* output) {}

int fastlz2_decompress(const void* input, int length, void* output,
                       int maxout) {}

int fastlz_compress(const void* input, int length, void* output) {}

int fastlz_decompress(const void* input, int length, void* output, int maxout) {}

int fastlz_compress_level(int level, const void* input, int length,
                          void* output) {}