diff --git a/Makefile b/Makefile index d5eba45b3..4e0cb77c1 100644 --- a/Makefile +++ b/Makefile @@ -181,6 +181,7 @@ include third_party/maxmind/maxmind.mk include net/finger/finger.mk include third_party/double-conversion/test/test.mk include third_party/lua/lua.mk +include third_party/zstd/zstd.mk include third_party/tr/tr.mk include third_party/sed/sed.mk include third_party/awk/awk.mk diff --git a/third_party/third_party.mk b/third_party/third_party.mk index 29062ce2f..39c079157 100644 --- a/third_party/third_party.mk +++ b/third_party/third_party.mk @@ -39,4 +39,5 @@ o/$(MODE)/third_party: \ o/$(MODE)/third_party/vqsort \ o/$(MODE)/third_party/xed \ o/$(MODE)/third_party/zip \ + o/$(MODE)/third_party/zstd \ o/$(MODE)/third_party/zlib diff --git a/third_party/zstd/CHANGELOG b/third_party/zstd/CHANGELOG index c7a7506ee..ac84c32f8 100644 --- a/third_party/zstd/CHANGELOG +++ b/third_party/zstd/CHANGELOG @@ -1,3 +1,4 @@ +// clang-format off v1.5.5 (Apr 2023) fix: fix rare corruption bug affecting the high compression mode, reported by @danlark1 (#3517, @terrelln) perf: improve mid-level compression speed (#3529, #3533, #3543, @yoniko and #3552, @terrelln) diff --git a/third_party/zstd/CODE_OF_CONDUCT.md b/third_party/zstd/CODE_OF_CONDUCT.md index 0f7ad8bfc..29ab9b6e2 100644 --- a/third_party/zstd/CODE_OF_CONDUCT.md +++ b/third_party/zstd/CODE_OF_CONDUCT.md @@ -1,3 +1,4 @@ +// clang-format off # Code of Conduct Facebook has adopted a Code of Conduct that we expect project participants to adhere to. diff --git a/third_party/zstd/CONTRIBUTING.md b/third_party/zstd/CONTRIBUTING.md deleted file mode 100644 index f5e747ae1..000000000 --- a/third_party/zstd/CONTRIBUTING.md +++ /dev/null @@ -1,489 +0,0 @@ -# Contributing to Zstandard -We want to make contributing to this project as easy and transparent as -possible. - -## Our Development Process -New versions are being developed in the "dev" branch, -or in their own feature branch. -When they are deemed ready for a release, they are merged into "release". - -As a consequence, all contributions must stage first through "dev" -or their own feature branch. - -## Pull Requests -We actively welcome your pull requests. - -1. Fork the repo and create your branch from `dev`. -2. If you've added code that should be tested, add tests. -3. If you've changed APIs, update the documentation. -4. Ensure the test suite passes. -5. Make sure your code lints. -6. If you haven't already, complete the Contributor License Agreement ("CLA"). - -## Contributor License Agreement ("CLA") -In order to accept your pull request, we need you to submit a CLA. You only need -to do this once to work on any of Facebook's open source projects. - -Complete your CLA here: - -## Workflow -Zstd uses a branch-based workflow for making changes to the codebase. Typically, zstd -will use a new branch per sizable topic. For smaller changes, it is okay to lump multiple -related changes into a branch. - -Our contribution process works in three main stages: -1. Local development - * Update: - * Checkout your fork of zstd if you have not already - ``` - git checkout https://github.com//zstd - cd zstd - ``` - * Update your local dev branch - ``` - git pull https://github.com/facebook/zstd dev - git push origin dev - ``` - * Topic and development: - * Make a new branch on your fork about the topic you're developing for - ``` - # branch names should be concise but sufficiently informative - git checkout -b - git push origin - ``` - * Make commits and push - ``` - # make some changes = - git add -u && git commit -m - git push origin - ``` - * Note: run local tests to ensure that your changes didn't break existing functionality - * Quick check - ``` - make shortest - ``` - * Longer check - ``` - make test - ``` -2. Code Review and CI tests - * Ensure CI tests pass: - * Before sharing anything to the community, create a pull request in your own fork against the dev branch - and make sure that all GitHub Actions CI tests pass. See the Continuous Integration section below for more information. - * Ensure that static analysis passes on your development machine. See the Static Analysis section - below to see how to do this. - * Create a pull request: - * When you are ready to share you changes to the community, create a pull request from your branch - to facebook:dev. You can do this very easily by clicking 'Create Pull Request' on your fork's home - page. - * From there, select the branch where you made changes as your source branch and facebook:dev - as the destination. - * Examine the diff presented between the two branches to make sure there is nothing unexpected. - * Write a good pull request description: - * While there is no strict template that our contributors follow, we would like them to - sufficiently summarize and motivate the changes they are proposing. We recommend all pull requests, - at least indirectly, address the following points. - * Is this pull request important and why? - * Is it addressing an issue? If so, what issue? (provide links for convenience please) - * Is this a new feature? If so, why is it useful and/or necessary? - * Are there background references and documents that reviewers should be aware of to properly assess this change? - * Note: make sure to point out any design and architectural decisions that you made and the rationale behind them. - * Note: if you have been working with a specific user and would like them to review your work, make sure you mention them using (@) - * Submit the pull request and iterate with feedback. -3. Merge and Release - * Getting approval: - * You will have to iterate on your changes with feedback from other collaborators to reach a point - where your pull request can be safely merged. - * To avoid too many comments on style and convention, make sure that you have a - look at our style section below before creating a pull request. - * Eventually, someone from the zstd team will approve your pull request and not long after merge it into - the dev branch. - * Housekeeping: - * Most PRs are linked with one or more Github issues. If this is the case for your PR, make sure - the corresponding issue is mentioned. If your change 'fixes' or completely addresses the - issue at hand, then please indicate this by requesting that an issue be closed by commenting. - * Just because your changes have been merged does not mean the topic or larger issue is complete. Remember - that the change must make it to an official zstd release for it to be meaningful. We recommend - that contributors track the activity on their pull request and corresponding issue(s) page(s) until - their change makes it to the next release of zstd. Users will often discover bugs in your code or - suggest ways to refine and improve your initial changes even after the pull request is merged. - -## Static Analysis -Static analysis is a process for examining the correctness or validity of a program without actually -executing it. It usually helps us find many simple bugs. Zstd uses clang's `scan-build` tool for -static analysis. You can install it by following the instructions for your OS on https://clang-analyzer.llvm.org/scan-build. - -Once installed, you can ensure that our static analysis tests pass on your local development machine -by running: -``` -make staticAnalyze -``` - -In general, you can use `scan-build` to static analyze any build script. For example, to static analyze -just `contrib/largeNbDicts` and nothing else, you can run: - -``` -scan-build make -C contrib/largeNbDicts largeNbDicts -``` - -### Pitfalls of static analysis -`scan-build` is part of our regular CI suite. Other static analyzers are not. - -It can be useful to look at additional static analyzers once in a while (and we do), but it's not a good idea to multiply the nb of analyzers run continuously at each commit and PR. The reasons are : - -- Static analyzers are full of false positive. The signal to noise ratio is actually pretty low. -- A good CI policy is "zero-warning tolerance". That means that all issues must be solved, including false positives. This quickly becomes a tedious workload. -- Multiple static analyzers will feature multiple kind of false positives, sometimes applying to the same code but in different ways leading to : - + tortuous code, trying to please multiple constraints, hurting readability and therefore maintenance. Sometimes, such complexity introduce other more subtle bugs, that are just out of scope of the analyzers. - + sometimes, these constraints are mutually exclusive : if one try to solve one, the other static analyzer will complain, they can't be both happy at the same time. -- As if that was not enough, the list of false positives change with each version. It's hard enough to follow one static analyzer, but multiple ones with their own update agenda, this quickly becomes a massive velocity reducer. - -This is different from running a static analyzer once in a while, looking at the output, and __cherry picking__ a few warnings that seem helpful, either because they detected a genuine risk of bug, or because it helps expressing the code in a way which is more readable or more difficult to misuse. These kinds of reports can be useful, and are accepted. - -## Continuous Integration -CI tests run every time a pull request (PR) is created or updated. The exact tests -that get run will depend on the destination branch you specify. Some tests take -longer to run than others. Currently, our CI is set up to run a short -series of tests when creating a PR to the dev branch and a longer series of tests -when creating a PR to the release branch. You can look in the configuration files -of the respective CI platform for more information on what gets run when. - -Most people will just want to create a PR with the destination set to their local dev -branch of zstd. You can then find the status of the tests on the PR's page. You can also -re-run tests and cancel running tests from the PR page or from the respective CI's dashboard. - -Almost all of zstd's CI runs on GitHub Actions (configured at `.github/workflows`), which will automatically run on PRs to your -own fork. A small number of tests run on other services (e.g. Travis CI, Circle CI, Appveyor). -These require work to set up on your local fork, and (at least for Travis CI) cost money. -Therefore, if the PR on your local fork passes GitHub Actions, feel free to submit a PR -against the main repo. - -### Third-party CI -A small number of tests cannot run on GitHub Actions, or have yet to be migrated. -For these, we use a variety of third-party services (listed below). It is not necessary to set -these up on your fork in order to contribute to zstd; however, we do link to instructions for those -who want earlier signal. - -| Service | Purpose | Setup Links | Config Path | -|-----------|------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------| -| Travis CI | Used for testing on non-x86 architectures such as PowerPC | https://docs.travis-ci.com/user/tutorial/#to-get-started-with-travis-ci-using-github
https://github.com/marketplace/travis-ci | `.travis.yml` | -| AppVeyor | Used for some Windows testing (e.g. cygwin, mingw) | https://www.appveyor.com/blog/2018/10/02/github-apps-integration/
https://github.com/marketplace/appveyor | `appveyor.yml` | -| Cirrus CI | Used for testing on FreeBSD | https://github.com/marketplace/cirrus-ci/ | `.cirrus.yml` | -| Circle CI | Historically was used to provide faster signal,
but we may be able to migrate these to Github Actions | https://circleci.com/docs/2.0/getting-started/#setting-up-circleci
https://youtu.be/Js3hMUsSZ2c
https://circleci.com/docs/2.0/enable-checks/ | `.circleci/config.yml` | - -Note: the instructions linked above mostly cover how to set up a repository with CI from scratch. -The general idea should be the same for setting up CI on your fork of zstd, but you may have to -follow slightly different steps. In particular, please ignore any instructions related to setting up -config files (since zstd already has configs for each of these services). - -## Performance -Performance is extremely important for zstd and we only merge pull requests whose performance -landscape and corresponding trade-offs have been adequately analyzed, reproduced, and presented. -This high bar for performance means that every PR which has the potential to -impact performance takes a very long time for us to properly review. That being said, we -always welcome contributions to improve performance (or worsen performance for the trade-off of -something else). Please keep the following in mind before submitting a performance related PR: - -1. Zstd isn't as old as gzip but it has been around for time now and its evolution is -very well documented via past Github issues and pull requests. It may be the case that your -particular performance optimization has already been considered in the past. Please take some -time to search through old issues and pull requests using keywords specific to your -would-be PR. Of course, just because a topic has already been discussed (and perhaps rejected -on some grounds) in the past, doesn't mean it isn't worth bringing up again. But even in that case, -it will be helpful for you to have context from that topic's history before contributing. -2. The distinction between noise and actual performance gains can unfortunately be very subtle -especially when microbenchmarking extremely small wins or losses. The only remedy to getting -something subtle merged is extensive benchmarking. You will be doing us a great favor if you -take the time to run extensive, long-duration, and potentially cross-(os, platform, process, etc) -benchmarks on your end before submitting a PR. Of course, you will not be able to benchmark -your changes on every single processor and os out there (and neither will we) but do that best -you can:) We've added some things to think about when benchmarking below in the Benchmarking -Performance section which might be helpful for you. -3. Optimizing performance for a certain OS, processor vendor, compiler, or network system is a perfectly -legitimate thing to do as long as it does not harm the overall performance health of Zstd. -This is a hard balance to strike but please keep in mind other aspects of Zstd when -submitting changes that are clang-specific, windows-specific, etc. - -## Benchmarking Performance -Performance microbenchmarking is a tricky subject but also essential for Zstd. We value empirical -testing over theoretical speculation. This guide it not perfect but for most scenarios, it -is a good place to start. - -### Stability -Unfortunately, the most important aspect in being able to benchmark reliably is to have a stable -benchmarking machine. A virtual machine, a machine with shared resources, or your laptop -will typically not be stable enough to obtain reliable benchmark results. If you can get your -hands on a desktop, this is usually a better scenario. - -Of course, benchmarking can be done on non-hyper-stable machines as well. You will just have to -do a little more work to ensure that you are in fact measuring the changes you've made not and -noise. Here are some things you can do to make your benchmarks more stable: - -1. The most simple thing you can do to drastically improve the stability of your benchmark is -to run it multiple times and then aggregate the results of those runs. As a general rule of -thumb, the smaller the change you are trying to measure, the more samples of benchmark runs -you will have to aggregate over to get reliable results. Here are some additional things to keep in -mind when running multiple trials: - * How you aggregate your samples are important. You might be tempted to use the mean of your - results. While this is certainly going to be a more stable number than a raw single sample - benchmark number, you might have more luck by taking the median. The mean is not robust to - outliers whereas the median is. Better still, you could simply take the fastest speed your - benchmark achieved on each run since that is likely the fastest your process will be - capable of running your code. In our experience, this (aggregating by just taking the sample - with the fastest running time) has been the most stable approach. - * The more samples you have, the more stable your benchmarks should be. You can verify - your improved stability by looking at the size of your confidence intervals as you - increase your sample count. These should get smaller and smaller. Eventually hopefully - smaller than the performance win you are expecting. - * Most processors will take some time to get `hot` when running anything. The observations - you collect during that time period will very different from the true performance number. Having - a very large number of sample will help alleviate this problem slightly but you can also - address is directly by simply not including the first `n` iterations of your benchmark in - your aggregations. You can determine `n` by simply looking at the results from each iteration - and then hand picking a good threshold after which the variance in results seems to stabilize. -2. You cannot really get reliable benchmarks if your host machine is simultaneously running -another cpu/memory-intensive application in the background. If you are running benchmarks on your -personal laptop for instance, you should close all applications (including your code editor and -browser) before running your benchmarks. You might also have invisible background applications -running. You can see what these are by looking at either Activity Monitor on Mac or Task Manager -on Windows. You will get more stable benchmark results of you end those processes as well. - * If you have multiple cores, you can even run your benchmark on a reserved core to prevent - pollution from other OS and user processes. There are a number of ways to do this depending - on your OS: - * On linux boxes, you have use https://github.com/lpechacek/cpuset. - * On Windows, you can "Set Processor Affinity" using https://www.thewindowsclub.com/processor-affinity-windows - * On Mac, you can try to use their dedicated affinity API https://developer.apple.com/library/archive/releasenotes/Performance/RN-AffinityAPI/#//apple_ref/doc/uid/TP40006635-CH1-DontLinkElementID_2 -3. To benchmark, you will likely end up writing a separate c/c++ program that will link libzstd. -Dynamically linking your library will introduce some added variation (not a large amount but -definitely some). Statically linking libzstd will be more stable. Static libraries should -be enabled by default when building zstd. -4. Use a profiler with a good high resolution timer. See the section below on profiling for -details on this. -5. Disable frequency scaling, turbo boost and address space randomization (this will vary by OS) -6. Try to avoid storage. On some systems you can use tmpfs. Putting the program, inputs and outputs on -tmpfs avoids touching a real storage system, which can have a pretty big variability. - -Also check our LLVM's guide on benchmarking here: https://llvm.org/docs/Benchmarking.html - -### Zstd benchmark -The fastest signal you can get regarding your performance changes is via the in-build zstd cli -bench option. You can run Zstd as you typically would for your scenario using some set of options -and then additionally also specify the `-b#` option. Doing this will run our benchmarking pipeline -for that options you have just provided. If you want to look at the internals of how this -benchmarking script works, you can check out programs/benchzstd.c - -For example: say you have made a change that you believe improves the speed of zstd level 1. The -very first thing you should use to assess whether you actually achieved any sort of improvement -is `zstd -b`. You might try to do something like this. Note: you can use the `-i` option to -specify a running time for your benchmark in seconds (default is 3 seconds). -Usually, the longer the running time, the more stable your results will be. - -``` -$ git checkout -$ make && cp zstd zstd-old -$ git checkout -$ make && cp zstd zstd-new -$ zstd-old -i5 -b1 - 1 : 8990 -> 3992 (2.252), 302.6 MB/s , 626.4 MB/s -$ zstd-new -i5 -b1 - 1 : 8990 -> 3992 (2.252), 302.8 MB/s , 628.4 MB/s -``` - -Unless your performance win is large enough to be visible despite the intrinsic noise -on your computer, benchzstd alone will likely not be enough to validate the impact of your -changes. For example, the results of the example above indicate that effectively nothing -changed but there could be a small <3% improvement that the noise on the host machine -obscured. So unless you see a large performance win (10-15% consistently) using just -this method of evaluation will not be sufficient. - -### Profiling -There are a number of great profilers out there. We're going to briefly mention how you can -profile your code using `instruments` on mac, `perf` on linux and `visual studio profiler` -on Windows. - -Say you have an idea for a change that you think will provide some good performance gains -for level 1 compression on Zstd. Typically this means, you have identified a section of -code that you think can be made to run faster. - -The first thing you will want to do is make sure that the piece of code is actually taking up -a notable amount of time to run. It is usually not worth optimizing something which accounts for less than -0.0001% of the total running time. Luckily, there are tools to help with this. -Profilers will let you see how much time your code spends inside a particular function. -If your target code snippet is only part of a function, it might be worth trying to -isolate that snippet by moving it to its own function (this is usually not necessary but -might be). - -Most profilers (including the profilers discussed below) will generate a call graph of -functions for you. Your goal will be to find your function of interest in this call graph -and then inspect the time spent inside of it. You might also want to look at the annotated -assembly which most profilers will provide you with. - -#### Instruments -We will once again consider the scenario where you think you've identified a piece of code -whose performance can be improved upon. Follow these steps to profile your code using -Instruments. - -1. Open Instruments -2. Select `Time Profiler` from the list of standard templates -3. Close all other applications except for your instruments window and your terminal -4. Run your benchmarking script from your terminal window - * You will want a benchmark that runs for at least a few seconds (5 seconds will - usually be long enough). This way the profiler will have something to work with - and you will have ample time to attach your profiler to this process:) - * I will just use benchzstd as my benchmarmking script for this example: -``` -$ zstd -b1 -i5 # this will run for 5 seconds -``` -5. Once you run your benchmarking script, switch back over to instruments and attach your -process to the time profiler. You can do this by: - * Clicking on the `All Processes` drop down in the top left of the toolbar. - * Selecting your process from the dropdown. In my case, it is just going to be labeled - `zstd` - * Hitting the bright red record circle button on the top left of the toolbar -6. You profiler will now start collecting metrics from your benchmarking script. Once -you think you have collected enough samples (usually this is the case after 3 seconds of -recording), stop your profiler. -7. Make sure that in toolbar of the bottom window, `profile` is selected. -8. You should be able to see your call graph. - * If you don't see the call graph or an incomplete call graph, make sure you have compiled - zstd and your benchmarking script using debug flags. On mac and linux, this just means - you will have to supply the `-g` flag alone with your build script. You might also - have to provide the `-fno-omit-frame-pointer` flag -9. Dig down the graph to find your function call and then inspect it by double clicking -the list item. You will be able to see the annotated source code and the assembly side by -side. - -#### Perf - -This wiki has a pretty detailed tutorial on getting started working with perf so we'll -leave you to check that out of you're getting started: - -https://perf.wiki.kernel.org/index.php/Tutorial - -Some general notes on perf: -* Use `perf stat -r # ` to quickly get some relevant timing and -counter statistics. Perf uses a high resolution timer and this is likely one -of the first things your team will run when assessing your PR. -* Perf has a long list of hardware counters that can be viewed with `perf --list`. -When measuring optimizations, something worth trying is to make sure the hardware -counters you expect to be impacted by your change are in fact being so. For example, -if you expect the L1 cache misses to decrease with your change, you can look at the -counter `L1-dcache-load-misses` -* Perf hardware counters will not work on a virtual machine. - -#### Visual Studio - -TODO - -## Issues -We use GitHub issues to track public bugs. Please ensure your description is -clear and has sufficient instructions to be able to reproduce the issue. - -Facebook has a [bounty program](https://www.facebook.com/whitehat/) for the safe -disclosure of security bugs. In those cases, please go through the process -outlined on that page and do not file a public issue. - -## Coding Style -It's a pretty long topic, which is difficult to summarize in a single paragraph. -As a rule of thumbs, try to imitate the coding style of -similar lines of codes around your contribution. -The following is a non-exhaustive list of rules employed in zstd code base: - -### C90 -This code base is following strict C90 standard, -with 2 extensions : 64-bit `long long` types, and variadic macros. -This rule is applied strictly to code within `lib/` and `programs/`. -Sub-project in `contrib/` are allowed to use other conventions. - -### C++ direct compatibility : symbol mangling -All public symbol declarations must be wrapped in `extern “C” { … }`, -so that this project can be compiled as C++98 code, -and linked into C++ applications. - -### Minimal Frugal -This design requirement is fundamental to preserve the portability of the code base. -#### Dependencies -- Reduce dependencies to the minimum possible level. - Any dependency should be considered “bad” by default, - and only tolerated because it provides a service in a better way than can be achieved locally. - The only external dependencies this repository tolerates are - standard C libraries, and in rare cases, system level headers. -- Within `lib/`, this policy is even more drastic. - The only external dependencies allowed are ``, ``, ``, - and even then, not directly. - In particular, no function shall ever allocate on heap directly, - and must use instead `ZSTD_malloc()` and equivalent. - Other accepted non-symbol headers are `` and ``. -- Within the project, there is a strict hierarchy of dependencies that must be respected. - `programs/` is allowed to depend on `lib/`, but only its public API. - Within `lib/`, `lib/common` doesn't depend on any other directory. - `lib/compress` and `lib/decompress` shall not depend on each other. - `lib/dictBuilder` can depend on `lib/common` and `lib/compress`, but not `lib/decompress`. -#### Resources -- Functions in `lib/` must use very little stack space, - several dozens of bytes max. - Everything larger must use the heap allocator, - or require a scratch buffer to be emplaced manually. - -### Naming -* All public symbols are prefixed with `ZSTD_` - + private symbols, with a scope limited to their own unit, are free of this restriction. - However, since `libzstd` source code can be amalgamated, - each symbol name must attempt to be (and remain) unique. - Avoid too generic names that could become ground for future collisions. - This generally implies usage of some form of prefix. -* For symbols (functions and variables), naming convention is `PREFIX_camelCase`. - + In some advanced cases, one can also find : - - `PREFIX_prefix2_camelCase` - - `PREFIX_camelCase_extendedQualifier` -* Multi-words names generally consist of an action followed by object: - - for example : `ZSTD_createCCtx()` -* Prefer positive actions - - `goBackward` rather than `notGoForward` -* Type names (`struct`, etc.) follow similar convention, - except that they are allowed and even invited to start by an Uppercase letter. - Example : `ZSTD_CCtx`, `ZSTD_CDict` -* Macro names are all Capital letters. - The same composition rules (`PREFIX_NAME_QUALIFIER`) apply. -* File names are all lowercase letters. - The convention is `snake_case`. - File names **must** be unique across the entire code base, - even when they stand in clearly separated directories. - -### Qualifiers -* This code base is `const` friendly, if not `const` fanatical. - Any variable that can be `const` (aka. read-only) **must** be `const`. - Any pointer which content will not be modified must be `const`. - This property is then controlled at compiler level. - `const` variables are an important signal to readers that this variable isn't modified. - Conversely, non-const variables are a signal to readers to watch out for modifications later on in the function. -* If a function must be inlined, mention it explicitly, - using project's own portable macros, such as `FORCE_INLINE_ATTR`, - defined in `lib/common/compiler.h`. - -### Debugging -* **Assertions** are welcome, and should be used very liberally, - to control any condition the code expects for its correct execution. - These assertion checks will be run in debug builds, and disabled in production. -* For traces, this project provides its own debug macros, - in particular `DEBUGLOG(level, ...)`, defined in `lib/common/debug.h`. - -### Code documentation -* Avoid code documentation that merely repeats what the code is already stating. - Whenever applicable, prefer employing the code as the primary way to convey explanations. - Example 1 : `int nbTokens = n;` instead of `int i = n; /* i is a nb of tokens *./`. - Example 2 : `assert(size > 0);` instead of `/* here, size should be positive */`. -* At declaration level, the documentation explains how to use the function or variable - and when applicable why it's needed, of the scenarios where it can be useful. -* At implementation level, the documentation explains the general outline of the algorithm employed, - and when applicable why this specific choice was preferred. - -### General layout -* 4 spaces for indentation rather than tabs -* Code documentation shall directly precede function declaration or implementation -* Function implementations and its code documentation should be preceded and followed by an empty line - - -## License -By contributing to Zstandard, you agree that your contributions will be licensed -under both the [LICENSE](LICENSE) file and the [COPYING](COPYING) file in the root directory of this source tree. diff --git a/third_party/zstd/COPYING b/third_party/zstd/COPYING index ecbc05937..3540cee90 100644 --- a/third_party/zstd/COPYING +++ b/third_party/zstd/COPYING @@ -1,3 +1,4 @@ +// clang-format off GNU GENERAL PUBLIC LICENSE Version 2, June 1991 diff --git a/third_party/zstd/LICENSE b/third_party/zstd/LICENSE index 75800288c..4edf8c406 100644 --- a/third_party/zstd/LICENSE +++ b/third_party/zstd/LICENSE @@ -1,3 +1,4 @@ +// clang-format off BSD License For Zstandard software diff --git a/third_party/zstd/Makefile b/third_party/zstd/Makefile deleted file mode 100644 index 72a9480aa..000000000 --- a/third_party/zstd/Makefile +++ /dev/null @@ -1,452 +0,0 @@ -# ################################################################ -# Copyright (c) Meta Platforms, Inc. and affiliates. -# All rights reserved. -# -# This source code is licensed under both the BSD-style license (found in the -# LICENSE file in the root directory of this source tree) and the GPLv2 (found -# in the COPYING file in the root directory of this source tree). -# You may select, at your option, one of the above-listed licenses. -# ################################################################ - -# verbose mode (print commands) on V=1 or VERBOSE=1 -Q = $(if $(filter 1,$(V) $(VERBOSE)),,@) - -PRGDIR = programs -ZSTDDIR = lib -BUILDIR = build -ZWRAPDIR = zlibWrapper -TESTDIR = tests -FUZZDIR = $(TESTDIR)/fuzz - -# Define nul output -VOID = /dev/null - -# When cross-compiling from linux to windows, you might -# need to specify this as "Windows." Fedora build fails -# without it. -# -# Note: mingw-w64 build from linux to windows does not -# fail on other tested distros (ubuntu, debian) even -# without manually specifying the TARGET_SYSTEM. -TARGET_SYSTEM ?= $(OS) -CP ?= cp - -ifneq (,$(filter Windows%,$(TARGET_SYSTEM))) - EXT =.exe -else - EXT = -endif - -## default: Build lib-release and zstd-release -.PHONY: default -default: lib-release zstd-release - -.PHONY: all -all: allmost examples manual contrib - -.PHONY: allmost -allmost: allzstd zlibwrapper - -# skip zwrapper, can't build that on alternate architectures without the proper zlib installed -.PHONY: allzstd -allzstd: lib - $(Q)$(MAKE) -C $(PRGDIR) all - $(Q)$(MAKE) -C $(TESTDIR) all - -.PHONY: all32 -all32: - $(MAKE) -C $(PRGDIR) zstd32 - $(MAKE) -C $(TESTDIR) all32 - -.PHONY: lib lib-release lib-mt lib-nomt -lib lib-release lib-mt lib-nomt: - $(Q)$(MAKE) -C $(ZSTDDIR) $@ - -.PHONY: zstd zstd-release -zstd zstd-release: - $(Q)$(MAKE) -C $(PRGDIR) $@ - $(Q)ln -sf $(PRGDIR)/zstd$(EXT) zstd$(EXT) - -.PHONY: zstdmt -zstdmt: - $(Q)$(MAKE) -C $(PRGDIR) $@ - $(Q)$(CP) $(PRGDIR)/zstd$(EXT) ./zstdmt$(EXT) - -.PHONY: zlibwrapper -zlibwrapper: lib - $(MAKE) -C $(ZWRAPDIR) all - -## test: run long-duration tests -.PHONY: test -DEBUGLEVEL ?= 1 -test: MOREFLAGS += -g -Werror -test: - DEBUGLEVEL=$(DEBUGLEVEL) MOREFLAGS="$(MOREFLAGS)" $(MAKE) -j -C $(PRGDIR) allVariants - $(MAKE) -C $(TESTDIR) $@ - ZSTD=../../programs/zstd $(MAKE) -C doc/educational_decoder $@ - -## shortest: same as `make check` -.PHONY: shortest -shortest: - $(Q)$(MAKE) -C $(TESTDIR) $@ - -## check: run basic tests for `zstd` cli -.PHONY: check -check: shortest - -.PHONY: automated_benchmarking -automated_benchmarking: - $(MAKE) -C $(TESTDIR) $@ - -.PHONY: benchmarking -benchmarking: automated_benchmarking - -## examples: build all examples in `examples/` directory -.PHONY: examples -examples: lib - $(MAKE) -C examples all - -## manual: generate API documentation in html format -.PHONY: manual -manual: - $(MAKE) -C contrib/gen_html $@ - -## man: generate man page -.PHONY: man -man: - $(MAKE) -C programs $@ - -## contrib: build all supported projects in `/contrib` directory -.PHONY: contrib -contrib: lib - $(MAKE) -C contrib/pzstd all - $(MAKE) -C contrib/seekable_format/examples all - $(MAKE) -C contrib/seekable_format/tests test - $(MAKE) -C contrib/largeNbDicts all - $(MAKE) -C contrib/externalSequenceProducer all - cd build/single_file_libs/ ; ./build_decoder_test.sh - cd build/single_file_libs/ ; ./build_library_test.sh - -.PHONY: cleanTabs -cleanTabs: - cd contrib; ./cleanTabs - -.PHONY: clean -clean: - $(Q)$(MAKE) -C $(ZSTDDIR) $@ > $(VOID) - $(Q)$(MAKE) -C $(PRGDIR) $@ > $(VOID) - $(Q)$(MAKE) -C $(TESTDIR) $@ > $(VOID) - $(Q)$(MAKE) -C $(ZWRAPDIR) $@ > $(VOID) - $(Q)$(MAKE) -C examples/ $@ > $(VOID) - $(Q)$(MAKE) -C contrib/gen_html $@ > $(VOID) - $(Q)$(MAKE) -C contrib/pzstd $@ > $(VOID) - $(Q)$(MAKE) -C contrib/seekable_format/examples $@ > $(VOID) - $(Q)$(MAKE) -C contrib/seekable_format/tests $@ > $(VOID) - $(Q)$(MAKE) -C contrib/largeNbDicts $@ > $(VOID) - $(Q)$(MAKE) -C contrib/externalSequenceProducer $@ > $(VOID) - $(Q)$(RM) zstd$(EXT) zstdmt$(EXT) tmp* - $(Q)$(RM) -r lz4 - @echo Cleaning completed - -#------------------------------------------------------------------------------ -# make install is validated only for Linux, macOS, Hurd and some BSD targets -#------------------------------------------------------------------------------ -ifneq (,$(filter $(shell uname),Linux Darwin GNU/kFreeBSD GNU OpenBSD FreeBSD DragonFly NetBSD MSYS_NT Haiku AIX)) - -HOST_OS = POSIX - -MKDIR ?= mkdir -p - -HAVE_COLORNEVER = $(shell echo a | egrep --color=never a > /dev/null 2> /dev/null && echo 1 || echo 0) -EGREP_OPTIONS ?= -ifeq ($(HAVE_COLORNEVER), 1) -EGREP_OPTIONS += --color=never -endif -EGREP = egrep $(EGREP_OPTIONS) - -# Print a two column output of targets and their description. To add a target description, put a -# comment in the Makefile with the format "## : ". For example: -# -## list: Print all targets and their descriptions (if provided) -.PHONY: list -list: - $(Q)TARGETS=$$($(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null \ - | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' \ - | $(EGREP) -v -e '^[^[:alnum:]]' | sort); \ - { \ - printf "Target Name\tDescription\n"; \ - printf "%0.s-" {1..16}; printf "\t"; printf "%0.s-" {1..40}; printf "\n"; \ - for target in $$TARGETS; do \ - line=$$($(EGREP) "^##[[:space:]]+$$target:" $(lastword $(MAKEFILE_LIST))); \ - description=$$(echo $$line | awk '{i=index($$0,":"); print substr($$0,i+1)}' | xargs); \ - printf "$$target\t$$description\n"; \ - done \ - } | column -t -s $$'\t' - -.PHONY: install armtest usan asan uasan msan asan32 -install: - $(Q)$(MAKE) -C $(ZSTDDIR) $@ - $(Q)$(MAKE) -C $(PRGDIR) $@ - -.PHONY: uninstall -uninstall: - $(Q)$(MAKE) -C $(ZSTDDIR) $@ - $(Q)$(MAKE) -C $(PRGDIR) $@ - -.PHONY: travis-install -travis-install: - $(MAKE) install PREFIX=~/install_test_dir - -.PHONY: clangbuild-darwin-fat -clangbuild-darwin-fat: clean - clang -v - CXX=clang++ CC=clang CFLAGS="-Werror -Wconversion -Wno-sign-conversion -Wdocumentation -arch arm64" $(MAKE) zstd-release - mv programs/zstd programs/zstd_arm64 - CXX=clang++ CC=clang CFLAGS="-Werror -Wconversion -Wno-sign-conversion -Wdocumentation -arch x86_64" $(MAKE) zstd-release - mv programs/zstd programs/zstd_x64 - lipo -create programs/zstd_x64 programs/zstd_arm64 -output programs/zstd - -.PHONY: gcc5build gcc6build gcc7build clangbuild m32build armbuild aarch64build ppcbuild ppc64build -gcc5build: clean - gcc-5 -v - CC=gcc-5 $(MAKE) all MOREFLAGS="-Werror $(MOREFLAGS)" - -gcc6build: clean - gcc-6 -v - CC=gcc-6 $(MAKE) all MOREFLAGS="-Werror $(MOREFLAGS)" - -gcc7build: clean - gcc-7 -v - CC=gcc-7 $(MAKE) all MOREFLAGS="-Werror $(MOREFLAGS)" - -clangbuild: clean - clang -v - CXX=clang++ CC=clang CFLAGS="-Werror -Wconversion -Wno-sign-conversion -Wdocumentation" $(MAKE) all - -m32build: clean - gcc -v - $(MAKE) all32 - -armbuild: clean - CC=arm-linux-gnueabi-gcc CFLAGS="-Werror" $(MAKE) allzstd - -aarch64build: clean - CC=aarch64-linux-gnu-gcc CFLAGS="-Werror -O0" $(MAKE) allzstd - -ppcbuild: clean - CC=powerpc-linux-gnu-gcc CFLAGS="-m32 -Wno-attributes -Werror" $(MAKE) -j allzstd - -ppc64build: clean - CC=powerpc-linux-gnu-gcc CFLAGS="-m64 -Werror" $(MAKE) -j allzstd - -.PHONY: armfuzz aarch64fuzz ppcfuzz ppc64fuzz -armfuzz: clean - CC=arm-linux-gnueabi-gcc QEMU_SYS=qemu-arm-static MOREFLAGS="-static $(MOREFLAGS)" FUZZER_FLAGS="--no-big-tests $(FUZZER_FLAGS)" $(MAKE) -C $(TESTDIR) fuzztest - -aarch64fuzz: clean - ld -v - CC=aarch64-linux-gnu-gcc QEMU_SYS=qemu-aarch64-static MOREFLAGS="-static $(MOREFLAGS)" FUZZER_FLAGS="--no-big-tests $(FUZZER_FLAGS)" $(MAKE) -C $(TESTDIR) fuzztest - -ppcfuzz: clean - CC=powerpc-linux-gnu-gcc QEMU_SYS=qemu-ppc-static MOREFLAGS="-static $(MOREFLAGS)" FUZZER_FLAGS="--no-big-tests $(FUZZER_FLAGS)" $(MAKE) -C $(TESTDIR) fuzztest - -ppc64fuzz: clean - CC=powerpc-linux-gnu-gcc QEMU_SYS=qemu-ppc64-static MOREFLAGS="-m64 -static $(MOREFLAGS)" FUZZER_FLAGS="--no-big-tests $(FUZZER_FLAGS)" $(MAKE) -C $(TESTDIR) fuzztest - -.PHONY: cxxtest gcc5test gcc6test armtest aarch64test ppctest ppc64test -cxxtest: CXXFLAGS += -Wall -Wextra -Wundef -Wshadow -Wcast-align -Werror -cxxtest: clean - $(MAKE) -C $(PRGDIR) all CC="$(CXX) -Wno-deprecated" CFLAGS="$(CXXFLAGS)" # adding -Wno-deprecated to avoid clang++ warning on dealing with C files directly - -gcc5test: clean - gcc-5 -v - $(MAKE) all CC=gcc-5 MOREFLAGS="-Werror $(MOREFLAGS)" - -gcc6test: clean - gcc-6 -v - $(MAKE) all CC=gcc-6 MOREFLAGS="-Werror $(MOREFLAGS)" - -armtest: clean - $(MAKE) -C $(TESTDIR) datagen # use native, faster - $(MAKE) -C $(TESTDIR) test CC=arm-linux-gnueabi-gcc QEMU_SYS=qemu-arm-static ZSTDRTTEST= MOREFLAGS="-Werror -static $(MOREFLAGS)" FUZZER_FLAGS="--no-big-tests $(FUZZER_FLAGS)" - -aarch64test: - $(MAKE) -C $(TESTDIR) datagen # use native, faster - $(MAKE) -C $(TESTDIR) test CC=aarch64-linux-gnu-gcc QEMU_SYS=qemu-aarch64-static ZSTDRTTEST= MOREFLAGS="-Werror -static $(MOREFLAGS)" FUZZER_FLAGS="--no-big-tests $(FUZZER_FLAGS)" - -ppctest: clean - $(MAKE) -C $(TESTDIR) datagen # use native, faster - $(MAKE) -C $(TESTDIR) test CC=powerpc-linux-gnu-gcc QEMU_SYS=qemu-ppc-static ZSTDRTTEST= MOREFLAGS="-Werror -Wno-attributes -static $(MOREFLAGS)" FUZZER_FLAGS="--no-big-tests $(FUZZER_FLAGS)" - -ppc64test: clean - $(MAKE) -C $(TESTDIR) datagen # use native, faster - $(MAKE) -C $(TESTDIR) test CC=powerpc-linux-gnu-gcc QEMU_SYS=qemu-ppc64-static ZSTDRTTEST= MOREFLAGS="-m64 -static $(MOREFLAGS)" FUZZER_FLAGS="--no-big-tests $(FUZZER_FLAGS)" - -.PHONY: arm-ppc-compilation -arm-ppc-compilation: - $(MAKE) -C $(PRGDIR) clean zstd CC=arm-linux-gnueabi-gcc QEMU_SYS=qemu-arm-static ZSTDRTTEST= MOREFLAGS="-Werror -static $(MOREFLAGS)" - $(MAKE) -C $(PRGDIR) clean zstd CC=aarch64-linux-gnu-gcc QEMU_SYS=qemu-aarch64-static ZSTDRTTEST= MOREFLAGS="-Werror -static $(MOREFLAGS)" - $(MAKE) -C $(PRGDIR) clean zstd CC=powerpc-linux-gnu-gcc QEMU_SYS=qemu-ppc-static ZSTDRTTEST= MOREFLAGS="-Werror -Wno-attributes -static $(MOREFLAGS)" - $(MAKE) -C $(PRGDIR) clean zstd CC=powerpc-linux-gnu-gcc QEMU_SYS=qemu-ppc64-static ZSTDRTTEST= MOREFLAGS="-m64 -static $(MOREFLAGS)" - -regressiontest: - $(MAKE) -C $(FUZZDIR) regressiontest - -uasanregressiontest: - $(MAKE) -C $(FUZZDIR) regressiontest CC=clang CXX=clang++ CFLAGS="-O3 -fsanitize=address,undefined" CXXFLAGS="-O3 -fsanitize=address,undefined" - -msanregressiontest: - $(MAKE) -C $(FUZZDIR) regressiontest CC=clang CXX=clang++ CFLAGS="-O3 -fsanitize=memory" CXXFLAGS="-O3 -fsanitize=memory" - -update_regressionResults : REGRESS_RESULTS_DIR := /tmp/regress_results_dir/ -update_regressionResults: - $(MAKE) -C programs zstd - $(MAKE) -C tests/regression test - $(RM) -rf $(REGRESS_RESULTS_DIR) - $(MKDIR) $(REGRESS_RESULTS_DIR) - ./tests/regression/test \ - --cache tests/regression/cache \ - --output $(REGRESS_RESULTS_DIR)/results.csv \ - --zstd programs/zstd - echo "Showing results differences" - ! diff tests/regression/results.csv $(REGRESS_RESULTS_DIR)/results.csv - echo "Updating results.csv" - $(CP) $(REGRESS_RESULTS_DIR)/results.csv tests/regression/results.csv - - -# run UBsan with -fsanitize-recover=pointer-overflow -# this only works with recent compilers such as gcc 8+ -usan: clean - $(MAKE) test CC=clang MOREFLAGS="-g -fno-sanitize-recover=all -fsanitize-recover=pointer-overflow -fsanitize=undefined -Werror $(MOREFLAGS)" - -asan: clean - $(MAKE) test CC=clang MOREFLAGS="-g -fsanitize=address -Werror $(MOREFLAGS)" - -asan-%: clean - LDFLAGS=-fuse-ld=gold MOREFLAGS="-g -fno-sanitize-recover=all -fsanitize=address -Werror $(MOREFLAGS)" $(MAKE) -C $(TESTDIR) $* - -msan: clean - $(MAKE) test CC=clang MOREFLAGS="-g -fsanitize=memory -fno-omit-frame-pointer -Werror $(MOREFLAGS)" HAVE_LZMA=0 # datagen.c fails this test for no obvious reason - -msan-%: clean - LDFLAGS=-fuse-ld=gold MOREFLAGS="-g -fno-sanitize-recover=all -fsanitize=memory -fno-omit-frame-pointer -Werror $(MOREFLAGS)" FUZZER_FLAGS="--no-big-tests $(FUZZER_FLAGS)" $(MAKE) -C $(TESTDIR) HAVE_LZMA=0 $* - -asan32: clean - $(MAKE) -C $(TESTDIR) test32 CC=clang MOREFLAGS="-g -fsanitize=address $(MOREFLAGS)" - -uasan: clean - $(MAKE) test CC=clang MOREFLAGS="-g -fno-sanitize-recover=all -fsanitize-recover=pointer-overflow -fsanitize=address,undefined -Werror $(MOREFLAGS)" - -uasan-%: clean - LDFLAGS=-fuse-ld=gold MOREFLAGS="-g -fno-sanitize-recover=all -fsanitize-recover=pointer-overflow -fsanitize=address,undefined -Werror $(MOREFLAGS)" $(MAKE) -C $(TESTDIR) $* - -tsan-%: clean - LDFLAGS=-fuse-ld=gold MOREFLAGS="-g -fno-sanitize-recover=all -fsanitize=thread -Werror $(MOREFLAGS)" $(MAKE) -C $(TESTDIR) $* FUZZER_FLAGS="--no-big-tests $(FUZZER_FLAGS)" - -.PHONY: apt-install -apt-install: - # TODO: uncomment once issue 3011 is resolved and remove hack from Github Actions .yml - # sudo apt-get update - sudo apt-get -yq --no-install-suggests --no-install-recommends --force-yes install $(APT_PACKAGES) - -.PHONY: apt-add-repo -apt-add-repo: - sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test - sudo apt-get update -y -qq - -.PHONY: ppcinstall arminstall valgrindinstall libc6install gcc6install gcc7install gcc8install gpp6install clang38install lz4install -ppcinstall: - APT_PACKAGES="qemu-system-ppc qemu-user-static gcc-powerpc-linux-gnu" $(MAKE) apt-install - -arminstall: - APT_PACKAGES="qemu-system-arm qemu-user-static gcc-arm-linux-gnueabi libc6-dev-armel-cross gcc-aarch64-linux-gnu libc6-dev-arm64-cross" $(MAKE) apt-install - -valgrindinstall: - APT_PACKAGES="valgrind" $(MAKE) apt-install - -libc6install: - APT_PACKAGES="libc6-dev-i386 gcc-multilib" $(MAKE) apt-install - -gcc6install: apt-add-repo - APT_PACKAGES="libc6-dev-i386 gcc-multilib gcc-6 gcc-6-multilib" $(MAKE) apt-install - -gcc7install: apt-add-repo - APT_PACKAGES="libc6-dev-i386 gcc-multilib gcc-7 gcc-7-multilib" $(MAKE) apt-install - -gcc8install: apt-add-repo - APT_PACKAGES="libc6-dev-i386 gcc-multilib gcc-8 gcc-8-multilib" $(MAKE) apt-install - -gpp6install: apt-add-repo - APT_PACKAGES="libc6-dev-i386 g++-multilib gcc-6 g++-6 g++-6-multilib" $(MAKE) apt-install - -clang38install: - APT_PACKAGES="clang-3.8" $(MAKE) apt-install - -# Ubuntu 14.04 ships a too-old lz4 -lz4install: - [ -e lz4 ] || git clone https://github.com/lz4/lz4 && sudo $(MAKE) -C lz4 install - -endif - - -CMAKE_PARAMS = -DZSTD_BUILD_CONTRIB:BOOL=ON -DZSTD_BUILD_STATIC:BOOL=ON -DZSTD_BUILD_TESTS:BOOL=ON -DZSTD_ZLIB_SUPPORT:BOOL=ON -DZSTD_LZMA_SUPPORT:BOOL=ON -DCMAKE_BUILD_TYPE=Release - -ifneq (,$(filter MSYS%,$(shell uname))) -HOST_OS = MSYS -CMAKE_PARAMS = -G"MSYS Makefiles" -DCMAKE_BUILD_TYPE=Debug -DZSTD_MULTITHREAD_SUPPORT:BOOL=OFF -DZSTD_BUILD_STATIC:BOOL=ON -DZSTD_BUILD_TESTS:BOOL=ON -endif - -#------------------------------------------------------------------------ -# target specific tests -#------------------------------------------------------------------------ -ifneq (,$(filter $(HOST_OS),MSYS POSIX)) -.PHONY: cmakebuild c89build gnu90build c99build gnu99build c11build bmix64build bmix32build bmi32build staticAnalyze -cmakebuild: - cmake --version - $(RM) -r $(BUILDIR)/cmake/build - $(MKDIR) $(BUILDIR)/cmake/build - cd $(BUILDIR)/cmake/build; cmake -DCMAKE_INSTALL_PREFIX:PATH=~/install_test_dir $(CMAKE_PARAMS) .. - $(MAKE) -C $(BUILDIR)/cmake/build -j4; - $(MAKE) -C $(BUILDIR)/cmake/build install; - $(MAKE) -C $(BUILDIR)/cmake/build uninstall; - cd $(BUILDIR)/cmake/build; ctest -V -L Medium - -c89build: clean - $(CC) -v - CFLAGS="-std=c89 -Werror -Wno-attributes -Wpedantic -Wno-long-long -Wno-variadic-macros -O0" $(MAKE) lib zstd - -gnu90build: clean - $(CC) -v - CFLAGS="-std=gnu90 -Werror -O0" $(MAKE) allmost - -c99build: clean - $(CC) -v - CFLAGS="-std=c99 -Werror -O0" $(MAKE) allmost - -gnu99build: clean - $(CC) -v - CFLAGS="-std=gnu99 -Werror -O0" $(MAKE) allmost - -c11build: clean - $(CC) -v - CFLAGS="-std=c11 -Werror -O0" $(MAKE) allmost - -bmix64build: clean - $(CC) -v - CFLAGS="-O3 -mbmi -Werror" $(MAKE) -C $(TESTDIR) test - -bmix32build: clean - $(CC) -v - CFLAGS="-O3 -mbmi -mx32 -Werror" $(MAKE) -C $(TESTDIR) test - -bmi32build: clean - $(CC) -v - CFLAGS="-O3 -mbmi -m32 -Werror" $(MAKE) -C $(TESTDIR) test - -# static analyzer test uses clang's scan-build -# does not analyze zlibWrapper, due to detected issues in zlib source code -staticAnalyze: SCANBUILD ?= scan-build -staticAnalyze: - $(CC) -v - CC=$(CC) CPPFLAGS=-g $(SCANBUILD) --status-bugs -v $(MAKE) zstd -endif diff --git a/third_party/zstd/Package.swift b/third_party/zstd/Package.swift deleted file mode 100644 index 97f2c6a52..000000000 --- a/third_party/zstd/Package.swift +++ /dev/null @@ -1,36 +0,0 @@ -// swift-tools-version:5.0 -// The swift-tools-version declares the minimum version of Swift required to build this package. - -import PackageDescription - -let package = Package( - name: "zstd", - platforms: [ - .macOS(.v10_10), .iOS(.v9), .tvOS(.v9) - ], - products: [ - // Products define the executables and libraries a package produces, and make them visible to other packages. - .library( - name: "libzstd", - targets: [ "libzstd" ]) - ], - dependencies: [ - // Dependencies declare other packages that this package depends on. - // .package(url: /* package url */, from: "1.0.0"), - ], - targets: [ - // Targets are the basic building blocks of a package. A target can define a module or a test suite. - // Targets can depend on other targets in this package, and on products in packages this package depends on. - .target( - name: "libzstd", - path: "lib", - sources: [ "common", "compress", "decompress", "dictBuilder" ], - publicHeadersPath: ".", - cSettings: [ - .headerSearchPath(".") - ]) - ], - swiftLanguageVersions: [.v5], - cLanguageStandard: .gnu11, - cxxLanguageStandard: .gnucxx14 -) diff --git a/third_party/zstd/README.md b/third_party/zstd/README.md index f91e68fdb..8bcdcef87 100644 --- a/third_party/zstd/README.md +++ b/third_party/zstd/README.md @@ -1,3 +1,4 @@ +// clang-format off

Zstandard

__Zstandard__, or `zstd` as short version, is a fast lossless compression algorithm, diff --git a/third_party/zstd/TESTING.md b/third_party/zstd/TESTING.md deleted file mode 100644 index df842cc94..000000000 --- a/third_party/zstd/TESTING.md +++ /dev/null @@ -1,43 +0,0 @@ -Testing -======= - -Zstandard CI testing is split up into three sections: -short, medium, and long tests. - -Short Tests ------------ -Short tests run on CircleCI for new commits on every branch and pull request. -They consist of the following tests: -- Compilation on all supported targets (x86, x86_64, ARM, AArch64, PowerPC, and PowerPC64) -- Compilation on various versions of gcc, clang, and g++ -- `tests/playTests.sh` on x86_64, without the tests on long data (CLI tests) -- Small tests (`tests/legacy.c`, `tests/longmatch.c`) on x64_64 - -Medium Tests ------------- -Medium tests run on every commit and pull request to `dev` branch, on TravisCI. -They consist of the following tests: -- The following tests run with UBsan and Asan on x86_64 and x86, as well as with - Msan on x86_64 - - `tests/playTests.sh --test-large-data` - - Fuzzer tests: `tests/fuzzer.c`, `tests/zstreamtest.c`, and `tests/decodecorpus.c` -- `tests/zstreamtest.c` under Tsan (streaming mode, including multithreaded mode) -- Valgrind Test (`make -C tests test-valgrind`) (testing CLI and fuzzer under `valgrind`) -- Fuzzer tests (see above) on ARM, AArch64, PowerPC, and PowerPC64 - -Long Tests ----------- -Long tests run on all commits to `release` branch, -and once a day on the current version of `dev` branch, -on TravisCI. -They consist of the following tests: -- Entire test suite (including fuzzers and some other specialized tests) on: - - x86_64 and x86 with UBsan and Asan - - x86_64 with Msan - - ARM, AArch64, PowerPC, and PowerPC64 -- Streaming mode fuzzer with Tsan (for the `zstdmt` testing) -- ZlibWrapper tests, including under valgrind -- Versions test (ensuring `zstd` can decode files from all previous versions) -- `pzstd` with asan and tsan, as well as in 32-bits mode -- Testing `zstd` with legacy mode off -- Entire test suite and make install on macOS diff --git a/third_party/zstd/build/.gitignore b/third_party/zstd/build/.gitignore deleted file mode 100644 index 5a18b30a0..000000000 --- a/third_party/zstd/build/.gitignore +++ /dev/null @@ -1,33 +0,0 @@ -# Visual C++ -.vs/ -*Copy -*.db -*.opensdf -*.sdf -*.suo -*.user -*.opendb - -VS2008/bin/ -VS2010/bin/ -VS2010/zwrapbench/ -VS2012/ -VS2013/ -VS2015/ -Studio* - -# CMake -cmake/build/ -CMakeCache.txt -CMakeFiles -CMakeScripts -Testing -Makefile -cmake_install.cmake -install_manifest.txt -compile_commands.json -CTestTestfile.cmake -build -lib -!cmake/lib -!meson/lib diff --git a/third_party/zstd/build/LICENSE b/third_party/zstd/build/LICENSE deleted file mode 100644 index e69de29bb..000000000 diff --git a/third_party/zstd/build/README.md b/third_party/zstd/build/README.md deleted file mode 100644 index 23f92cef1..000000000 --- a/third_party/zstd/build/README.md +++ /dev/null @@ -1,56 +0,0 @@ -Projects for various integrated development environments (IDE) -============================================================== - -#### Included projects - -The following projects are included with the zstd distribution: -- `cmake` - CMake project contributed by Artyom Dymchenko -- `VS2005` - Visual Studio 2005 Project (this project has been moved to the contrib directory and will no longer be supported) -- `VS2008` - Visual Studio 2008 project -- `VS2010` - Visual Studio 2010 project (which also works well with Visual Studio 2012, 2013, 2015) -- `VS_scripts` - command line scripts prepared for Visual Studio compilation without IDE - - -#### How to compile zstd with Visual Studio - -1. Install Visual Studio e.g. VS 2015 Community Edition (it's free). -2. Download the latest version of zstd from https://github.com/facebook/zstd/releases -3. Decompress ZIP archive. -4. Go to decompressed directory then to `projects` then `VS2010` and open `zstd.sln` -5. Visual Studio will ask about converting VS2010 project to VS2015 and you should agree. -6. Change `Debug` to `Release` and if you have 64-bit Windows change also `Win32` to `x64`. -7. Press F7 on keyboard or select `BUILD` from the menu bar and choose `Build Solution`. -8. If compilation will be fine a compiled executable will be in `projects\VS2010\bin\x64\Release\zstd.exe` - - -#### Projects available within zstd.sln - -The Visual Studio solution file `visual\VS2010\zstd.sln` contains many projects that will be compiled to the -`visual\VS2010\bin\$(Platform)_$(Configuration)` directory. For example `zstd` set to `x64` and -`Release` will be compiled to `visual\VS2010\bin\x64_Release\zstd.exe`. The solution file contains the -following projects: - -- `zstd` : Command Line Utility, supporting gzip-like arguments -- `datagen` : Synthetic and parametrable data generator, for tests -- `fullbench` : Precisely measure speed for each zstd inner functions -- `fuzzer` : Test tool, to check zstd integrity on target platform -- `libzstd` : A static ZSTD library compiled to `libzstd_static.lib` -- `libzstd-dll` : A dynamic ZSTD library (DLL) compiled to `libzstd.dll` with the import library `libzstd.lib` -- `fullbench-dll` : The fullbench program compiled with the import library; the executable requires ZSTD DLL - - -#### Using ZSTD DLL with Microsoft Visual C++ project - -The header file `lib\zstd.h` and the import library -`visual\VS2010\bin\$(Platform)_$(Configuration)\libzstd.lib` are required to compile -a project using Visual C++. - -1. The path to header files should be added to `Additional Include Directories` that can - be found in Project Properties of Visual Studio IDE in the `C/C++` Property Pages on the `General` page. -2. The import library has to be added to `Additional Dependencies` that can - be found in Project Properties in the `Linker` Property Pages on the `Input` page. - If one will provide only the name `libzstd.lib` without a full path to the library - then the directory has to be added to `Linker\General\Additional Library Directories`. - -The compiled executable will require ZSTD DLL which is available at -`visual\VS2010\bin\$(Platform)_$(Configuration)\libzstd.dll`. diff --git a/third_party/zstd/build/VS2008/fullbench/fullbench.vcproj b/third_party/zstd/build/VS2008/fullbench/fullbench.vcproj deleted file mode 100644 index 82d5fba0f..000000000 --- a/third_party/zstd/build/VS2008/fullbench/fullbench.vcproj +++ /dev/null @@ -1,549 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/third_party/zstd/build/VS2008/fuzzer/fuzzer.vcproj b/third_party/zstd/build/VS2008/fuzzer/fuzzer.vcproj deleted file mode 100644 index d38e89150..000000000 --- a/third_party/zstd/build/VS2008/fuzzer/fuzzer.vcproj +++ /dev/null @@ -1,585 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/third_party/zstd/build/VS2008/zstd.sln b/third_party/zstd/build/VS2008/zstd.sln deleted file mode 100644 index 89b6993ba..000000000 --- a/third_party/zstd/build/VS2008/zstd.sln +++ /dev/null @@ -1,56 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zstd", "zstd\zstd.vcproj", "{1A2AB08E-5CE7-4C5B-BE55-458157C14051}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fuzzer", "fuzzer\fuzzer.vcproj", "{A62E89D2-9DDE-42BA-8F9B-9DA74889A6B0}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fullbench", "fullbench\fullbench.vcproj", "{CC8F1D1B-BA2F-43E3-A71F-FA415D81AAD3}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zstdlib", "zstdlib\zstdlib.vcproj", "{99DE2A79-7298-4004-A0ED-030D7A3796CA}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {1A2AB08E-5CE7-4C5B-BE55-458157C14051}.Debug|Win32.ActiveCfg = Debug|Win32 - {1A2AB08E-5CE7-4C5B-BE55-458157C14051}.Debug|Win32.Build.0 = Debug|Win32 - {1A2AB08E-5CE7-4C5B-BE55-458157C14051}.Debug|x64.ActiveCfg = Debug|x64 - {1A2AB08E-5CE7-4C5B-BE55-458157C14051}.Debug|x64.Build.0 = Debug|x64 - {1A2AB08E-5CE7-4C5B-BE55-458157C14051}.Release|Win32.ActiveCfg = Release|Win32 - {1A2AB08E-5CE7-4C5B-BE55-458157C14051}.Release|Win32.Build.0 = Release|Win32 - {1A2AB08E-5CE7-4C5B-BE55-458157C14051}.Release|x64.ActiveCfg = Release|x64 - {1A2AB08E-5CE7-4C5B-BE55-458157C14051}.Release|x64.Build.0 = Release|x64 - {A62E89D2-9DDE-42BA-8F9B-9DA74889A6B0}.Debug|Win32.ActiveCfg = Debug|Win32 - {A62E89D2-9DDE-42BA-8F9B-9DA74889A6B0}.Debug|Win32.Build.0 = Debug|Win32 - {A62E89D2-9DDE-42BA-8F9B-9DA74889A6B0}.Debug|x64.ActiveCfg = Debug|x64 - {A62E89D2-9DDE-42BA-8F9B-9DA74889A6B0}.Debug|x64.Build.0 = Debug|x64 - {A62E89D2-9DDE-42BA-8F9B-9DA74889A6B0}.Release|Win32.ActiveCfg = Release|Win32 - {A62E89D2-9DDE-42BA-8F9B-9DA74889A6B0}.Release|Win32.Build.0 = Release|Win32 - {A62E89D2-9DDE-42BA-8F9B-9DA74889A6B0}.Release|x64.ActiveCfg = Release|x64 - {A62E89D2-9DDE-42BA-8F9B-9DA74889A6B0}.Release|x64.Build.0 = Release|x64 - {CC8F1D1B-BA2F-43E3-A71F-FA415D81AAD3}.Debug|Win32.ActiveCfg = Debug|Win32 - {CC8F1D1B-BA2F-43E3-A71F-FA415D81AAD3}.Debug|Win32.Build.0 = Debug|Win32 - {CC8F1D1B-BA2F-43E3-A71F-FA415D81AAD3}.Debug|x64.ActiveCfg = Debug|x64 - {CC8F1D1B-BA2F-43E3-A71F-FA415D81AAD3}.Debug|x64.Build.0 = Debug|x64 - {CC8F1D1B-BA2F-43E3-A71F-FA415D81AAD3}.Release|Win32.ActiveCfg = Release|Win32 - {CC8F1D1B-BA2F-43E3-A71F-FA415D81AAD3}.Release|Win32.Build.0 = Release|Win32 - {CC8F1D1B-BA2F-43E3-A71F-FA415D81AAD3}.Release|x64.ActiveCfg = Release|x64 - {CC8F1D1B-BA2F-43E3-A71F-FA415D81AAD3}.Release|x64.Build.0 = Release|x64 - {99DE2A79-7298-4004-A0ED-030D7A3796CA}.Debug|Win32.ActiveCfg = Debug|Win32 - {99DE2A79-7298-4004-A0ED-030D7A3796CA}.Debug|Win32.Build.0 = Debug|Win32 - {99DE2A79-7298-4004-A0ED-030D7A3796CA}.Debug|x64.ActiveCfg = Debug|x64 - {99DE2A79-7298-4004-A0ED-030D7A3796CA}.Debug|x64.Build.0 = Debug|x64 - {99DE2A79-7298-4004-A0ED-030D7A3796CA}.Release|Win32.ActiveCfg = Release|Win32 - {99DE2A79-7298-4004-A0ED-030D7A3796CA}.Release|Win32.Build.0 = Release|Win32 - {99DE2A79-7298-4004-A0ED-030D7A3796CA}.Release|x64.ActiveCfg = Release|x64 - {99DE2A79-7298-4004-A0ED-030D7A3796CA}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/third_party/zstd/build/VS2008/zstd/zstd.vcproj b/third_party/zstd/build/VS2008/zstd/zstd.vcproj deleted file mode 100644 index 966b0ea9c..000000000 --- a/third_party/zstd/build/VS2008/zstd/zstd.vcproj +++ /dev/null @@ -1,673 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/third_party/zstd/build/VS2008/zstdlib/zstdlib.vcproj b/third_party/zstd/build/VS2008/zstdlib/zstdlib.vcproj deleted file mode 100644 index d1099eb5a..000000000 --- a/third_party/zstd/build/VS2008/zstdlib/zstdlib.vcproj +++ /dev/null @@ -1,635 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/third_party/zstd/build/VS2010/CompileAsCpp.props b/third_party/zstd/build/VS2010/CompileAsCpp.props deleted file mode 100644 index 372a94b1f..000000000 --- a/third_party/zstd/build/VS2010/CompileAsCpp.props +++ /dev/null @@ -1,8 +0,0 @@ - - - - - CompileAsCpp - - - diff --git a/third_party/zstd/build/VS2010/datagen/datagen.vcxproj b/third_party/zstd/build/VS2010/datagen/datagen.vcxproj deleted file mode 100644 index 38738df56..000000000 --- a/third_party/zstd/build/VS2010/datagen/datagen.vcxproj +++ /dev/null @@ -1,168 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {037E781E-81A6-494B-B1B3-438AB1200523} - Win32Proj - datagen - $(SolutionDir)bin\$(Platform)_$(Configuration)\ - $(SolutionDir)bin\obj\$(RootNamespace)_$(Platform)_$(Configuration)\ - - - - Application - true - MultiByte - - - Application - true - MultiByte - - - Application - false - true - MultiByte - - - Application - false - true - MultiByte - - - - - - - - - - - - - - - - - - - true - false - $(IncludePath);$(SolutionDir)..\..\programs;$(SolutionDir)..\..\lib\legacy;$(SolutionDir)..\..\lib\common;$(UniversalCRT_IncludePath); - - - true - false - $(IncludePath);$(SolutionDir)..\..\programs;$(SolutionDir)..\..\lib\legacy;$(SolutionDir)..\..\lib\common;$(UniversalCRT_IncludePath); - - - false - false - $(IncludePath);$(SolutionDir)..\..\programs;$(SolutionDir)..\..\lib\legacy;$(SolutionDir)..\..\lib\common;$(UniversalCRT_IncludePath); - - - false - false - $(IncludePath);$(SolutionDir)..\..\programs;$(SolutionDir)..\..\lib\legacy;$(SolutionDir)..\..\lib\common;$(UniversalCRT_IncludePath); - - - - - - Level4 - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - false - - - Console - true - - - - - - - Level4 - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - false - - - Console - true - - - - - Level4 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - false - false - MultiThreaded - - - Console - true - true - true - - - - - Level4 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - false - false - MultiThreaded - - - Console - true - true - true - - - - - - - - - - - - - - diff --git a/third_party/zstd/build/VS2010/fullbench-dll/fullbench-dll.vcxproj b/third_party/zstd/build/VS2010/fullbench-dll/fullbench-dll.vcxproj deleted file mode 100644 index 5a547d535..000000000 --- a/third_party/zstd/build/VS2010/fullbench-dll/fullbench-dll.vcxproj +++ /dev/null @@ -1,189 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {00000000-1CC8-4FD7-9281-6B8DBB9D3DF8} - Win32Proj - fullbench-dll - $(SolutionDir)bin\$(Platform)_$(Configuration)\ - $(SolutionDir)bin\obj\$(RootNamespace)_$(Platform)_$(Configuration)\ - - - - Application - true - MultiByte - - - Application - true - MultiByte - - - Application - false - true - MultiByte - - - Application - false - true - MultiByte - - - - - - - - - - - - - - - - - - - true - $(IncludePath);$(SolutionDir)..\..\lib;$(SolutionDir)..\..\programs;$(SolutionDir)..\..\lib\legacy;$(SolutionDir)..\..\lib\common;$(UniversalCRT_IncludePath); - false - - - true - $(IncludePath);$(SolutionDir)..\..\lib;$(SolutionDir)..\..\programs;$(SolutionDir)..\..\lib\legacy;$(SolutionDir)..\..\lib\common;$(UniversalCRT_IncludePath); - false - - - false - $(IncludePath);$(SolutionDir)..\..\lib;$(SolutionDir)..\..\programs;$(SolutionDir)..\..\lib\legacy;$(SolutionDir)..\..\lib\common;$(UniversalCRT_IncludePath); - false - - - false - $(IncludePath);$(SolutionDir)..\..\lib;$(SolutionDir)..\..\programs;$(SolutionDir)..\..\lib\legacy;$(SolutionDir)..\..\lib\common;$(UniversalCRT_IncludePath); - false - - - - - - Level4 - Disabled - WIN32;_DEBUG;_CONSOLE;ZSTD_DLL_IMPORT=1;%(PreprocessorDefinitions) - true - false - - - Console - true - $(SolutionDir)bin\$(Platform)_$(Configuration);%(AdditionalLibraryDirectories) - libzstd.lib;%(AdditionalDependencies) - false - - - - - - - Level4 - Disabled - WIN32;_DEBUG;_CONSOLE;ZSTD_DLL_IMPORT=1;%(PreprocessorDefinitions) - true - false - - - Console - true - $(SolutionDir)bin\$(Platform)_$(Configuration);%(AdditionalLibraryDirectories) - libzstd.lib;%(AdditionalDependencies) - - - - - Level4 - - - MaxSpeed - true - true - WIN32;_DEBUG;_CONSOLE;ZSTD_DLL_IMPORT=1;%(PreprocessorDefinitions) - false - false - MultiThreaded - - - Console - true - true - true - $(SolutionDir)bin\$(Platform)_$(Configuration);%(AdditionalLibraryDirectories) - libzstd.lib;%(AdditionalDependencies) - false - - - - - Level4 - - - MaxSpeed - true - true - WIN32;_DEBUG;_CONSOLE;ZSTD_DLL_IMPORT=1;%(PreprocessorDefinitions) - false - false - MultiThreaded - - - Console - true - true - true - $(SolutionDir)bin\$(Platform)_$(Configuration);%(AdditionalLibraryDirectories) - libzstd.lib;%(AdditionalDependencies) - - - - - - - - - - - - - - - - - - - {00000000-94d5-4bf9-8a50-7bd9929a0850} - - - - - - diff --git a/third_party/zstd/build/VS2010/fullbench/fullbench.vcxproj b/third_party/zstd/build/VS2010/fullbench/fullbench.vcxproj deleted file mode 100644 index fd3fdff18..000000000 --- a/third_party/zstd/build/VS2010/fullbench/fullbench.vcxproj +++ /dev/null @@ -1,218 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {61ABD629-1CC8-4FD7-9281-6B8DBB9D3DF8} - Win32Proj - fullbench - $(SolutionDir)bin\$(Platform)_$(Configuration)\ - $(SolutionDir)bin\obj\$(RootNamespace)_$(Platform)_$(Configuration)\ - - - - Application - true - MultiByte - - - Application - true - MultiByte - - - Application - false - true - MultiByte - - - Application - false - true - MultiByte - - - - - - - - - - - - - - - - - - - true - $(IncludePath);$(SolutionDir)..\..\lib;$(SolutionDir)..\..\programs;$(SolutionDir)..\..\lib\legacy;$(SolutionDir)..\..\lib\common;$(UniversalCRT_IncludePath); - false - - - true - $(IncludePath);$(SolutionDir)..\..\lib;$(SolutionDir)..\..\programs;$(SolutionDir)..\..\lib\legacy;$(SolutionDir)..\..\lib\common;$(UniversalCRT_IncludePath); - false - - - false - $(IncludePath);$(SolutionDir)..\..\lib;$(SolutionDir)..\..\programs;$(SolutionDir)..\..\lib\legacy;$(SolutionDir)..\..\lib\common;$(UniversalCRT_IncludePath); - false - - - false - $(IncludePath);$(SolutionDir)..\..\lib;$(SolutionDir)..\..\programs;$(SolutionDir)..\..\lib\legacy;$(SolutionDir)..\..\lib\common;$(UniversalCRT_IncludePath); - false - - - - - - Level4 - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - false - - - Console - true - - - - - - - Level4 - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - false - - - Console - true - - - - - Level4 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - false - false - MultiThreaded - - - Console - true - true - true - - - - - Level4 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - false - false - MultiThreaded - - - Console - true - true - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/third_party/zstd/build/VS2010/fuzzer/fuzzer.vcxproj b/third_party/zstd/build/VS2010/fuzzer/fuzzer.vcxproj deleted file mode 100644 index 473f20708..000000000 --- a/third_party/zstd/build/VS2010/fuzzer/fuzzer.vcxproj +++ /dev/null @@ -1,223 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {6FD4352B-346C-4703-96EA-D4A8B9A6976E} - Win32Proj - fuzzer - $(SolutionDir)bin\$(Platform)_$(Configuration)\ - $(SolutionDir)bin\obj\$(RootNamespace)_$(Platform)_$(Configuration)\ - - - - Application - true - MultiByte - - - Application - true - MultiByte - - - Application - false - true - MultiByte - - - Application - false - true - MultiByte - - - - - - - - - - - - - - - - - - - true - false - $(IncludePath);$(SolutionDir)..\..\lib;$(SolutionDir)..\..\programs;$(SolutionDir)..\..\lib\legacy;$(SolutionDir)..\..\lib\common;$(SolutionDir)..\..\lib\dictBuilder;$(SolutionDir)..\..\lib\compress;$(UniversalCRT_IncludePath); - - - true - false - $(IncludePath);$(SolutionDir)..\..\lib;$(SolutionDir)..\..\programs;$(SolutionDir)..\..\lib\legacy;$(SolutionDir)..\..\lib\common;$(SolutionDir)..\..\lib\dictBuilder;$(SolutionDir)..\..\lib\compress;$(UniversalCRT_IncludePath); - - - false - false - $(IncludePath);$(SolutionDir)..\..\lib;$(SolutionDir)..\..\programs;$(SolutionDir)..\..\lib\legacy;$(SolutionDir)..\..\lib\common;$(SolutionDir)..\..\lib\dictBuilder;$(SolutionDir)..\..\lib\compress;$(UniversalCRT_IncludePath); - - - false - false - $(IncludePath);$(SolutionDir)..\..\lib;$(SolutionDir)..\..\programs;$(SolutionDir)..\..\lib\legacy;$(SolutionDir)..\..\lib\common;$(SolutionDir)..\..\lib\dictBuilder;$(SolutionDir)..\..\lib\compress;$(UniversalCRT_IncludePath); - - - - - - Level4 - Disabled - ZSTD_MULTITHREAD=1;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - false - - - Console - true - - - - - - - Level4 - Disabled - ZSTD_MULTITHREAD=1;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - false - - - Console - true - - - - - Level4 - - - MaxSpeed - true - true - ZSTD_MULTITHREAD=1;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - false - false - MultiThreaded - - - Console - true - true - true - - - - - Level4 - - - MaxSpeed - true - true - ZSTD_MULTITHREAD=1;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - false - false - MultiThreaded - - - Console - true - true - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/third_party/zstd/build/VS2010/libzstd-dll/libzstd-dll.rc b/third_party/zstd/build/VS2010/libzstd-dll/libzstd-dll.rc deleted file mode 100644 index 63631037d..000000000 --- a/third_party/zstd/build/VS2010/libzstd-dll/libzstd-dll.rc +++ /dev/null @@ -1,51 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// - -#include "zstd.h" /* ZSTD_VERSION_STRING */ -#define APSTUDIO_READONLY_SYMBOLS -#include "verrsrc.h" -#undef APSTUDIO_READONLY_SYMBOLS - - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -LANGUAGE 9, 1 - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION ZSTD_VERSION_MAJOR,ZSTD_VERSION_MINOR,ZSTD_VERSION_RELEASE,0 - PRODUCTVERSION ZSTD_VERSION_MAJOR,ZSTD_VERSION_MINOR,ZSTD_VERSION_RELEASE,0 - FILEFLAGSMASK VS_FFI_FILEFLAGSMASK -#ifdef _DEBUG - FILEFLAGS VS_FF_DEBUG -#else - FILEFLAGS 0x0L -#endif - FILEOS VOS_NT_WINDOWS32 - FILETYPE VFT_DLL - FILESUBTYPE VFT2_UNKNOWN -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904B0" - BEGIN - VALUE "CompanyName", "Meta Platforms, Inc." - VALUE "FileDescription", "Zstandard - Fast and efficient compression algorithm" - VALUE "FileVersion", ZSTD_VERSION_STRING - VALUE "InternalName", "libzstd.dll" - VALUE "LegalCopyright", "Copyright (c) Meta Platforms, Inc. and affiliates." - VALUE "OriginalFilename", "libzstd.dll" - VALUE "ProductName", "Zstandard" - VALUE "ProductVersion", ZSTD_VERSION_STRING - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x0409, 1200 - END -END - -#endif diff --git a/third_party/zstd/build/VS2010/libzstd-dll/libzstd-dll.vcxproj b/third_party/zstd/build/VS2010/libzstd-dll/libzstd-dll.vcxproj deleted file mode 100644 index 03ebbaf9b..000000000 --- a/third_party/zstd/build/VS2010/libzstd-dll/libzstd-dll.vcxproj +++ /dev/null @@ -1,249 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {00000000-94D5-4BF9-8A50-7BD9929A0850} - Win32Proj - libzstd-dll - $(SolutionDir)bin\$(Platform)_$(Configuration)\ - $(SolutionDir)bin\obj\$(RootNamespace)_$(Platform)_$(Configuration)\ - - - - DynamicLibrary - true - MultiByte - - - DynamicLibrary - true - MultiByte - - - DynamicLibrary - false - true - MultiByte - - - DynamicLibrary - false - true - MultiByte - - - - - - - - - - - - - - - - - - - true - libzstd - $(IncludePath);$(SolutionDir)..\..\lib;$(SolutionDir)..\..\programs\legacy;$(SolutionDir)..\..\lib\legacy;$(SolutionDir)..\..\lib\common;$(SolutionDir)..\..\lib\dictBuilder;$(UniversalCRT_IncludePath); - false - - - true - libzstd - $(IncludePath);$(SolutionDir)..\..\lib;$(SolutionDir)..\..\programs\legacy;$(SolutionDir)..\..\lib\legacy;$(SolutionDir)..\..\lib\common;$(SolutionDir)..\..\lib\dictBuilder;$(UniversalCRT_IncludePath); - false - - - false - libzstd - $(IncludePath);$(SolutionDir)..\..\lib;$(SolutionDir)..\..\programs\legacy;$(SolutionDir)..\..\lib\legacy;$(SolutionDir)..\..\lib\common;$(SolutionDir)..\..\lib\dictBuilder;$(UniversalCRT_IncludePath); - false - - - false - libzstd - $(IncludePath);$(SolutionDir)..\..\lib;$(SolutionDir)..\..\programs\legacy;$(SolutionDir)..\..\lib\legacy;$(SolutionDir)..\..\lib\common;$(SolutionDir)..\..\lib\dictBuilder;$(UniversalCRT_IncludePath); - false - - - - - - Level4 - Disabled - ZSTD_DLL_EXPORT=1;ZSTD_MULTITHREAD=1;ZSTD_LEGACY_SUPPORT=5;WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - EnableFastChecks - MultiThreadedDebugDLL - EditAndContinue - true - false - - - Console - true - MachineX86 - - - - - - - Level4 - Disabled - ZSTD_DLL_EXPORT=1;ZSTD_MULTITHREAD=1;ZSTD_LEGACY_SUPPORT=5;WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - ProgramDatabase - false - - - Console - true - - - - - Level4 - - - MaxSpeed - true - true - ZSTD_DLL_EXPORT=1;ZSTD_MULTITHREAD=1;ZSTD_LEGACY_SUPPORT=5;WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - false - MultiThreaded - ProgramDatabase - - - Console - true - true - true - MachineX86 - - - - - Level4 - - - MaxSpeed - true - true - ZSTD_DLL_EXPORT=1;ZSTD_MULTITHREAD=1;ZSTD_LEGACY_SUPPORT=5;WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - false - false - MultiThreaded - ProgramDatabase - true - true - - - Console - true - true - true - - - - - - diff --git a/third_party/zstd/build/VS2010/libzstd/libzstd.vcxproj b/third_party/zstd/build/VS2010/libzstd/libzstd.vcxproj deleted file mode 100644 index 713c4b164..000000000 --- a/third_party/zstd/build/VS2010/libzstd/libzstd.vcxproj +++ /dev/null @@ -1,242 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {8BFD8150-94D5-4BF9-8A50-7BD9929A0850} - Win32Proj - libzstd - libzstd_static - MultiByte - StaticLibrary - $(SolutionDir)bin\$(Platform)_$(Configuration)\ - $(SolutionDir)bin\obj\$(RootNamespace)_$(Platform)_$(Configuration)\ - - - - true - - - true - - - false - true - - - false - true - - - - - - - - - - - - - - - - - - - true - $(IncludePath);$(SolutionDir)..\..\lib;$(SolutionDir)..\..\programs\legacy;$(SolutionDir)..\..\lib\legacy;$(SolutionDir)..\..\lib\common;$(SolutionDir)..\..\lib\dictBuilder;$(UniversalCRT_IncludePath); - false - - - true - $(IncludePath);$(SolutionDir)..\..\lib;$(SolutionDir)..\..\programs\legacy;$(SolutionDir)..\..\lib\legacy;$(SolutionDir)..\..\lib\common;$(SolutionDir)..\..\lib\dictBuilder;$(UniversalCRT_IncludePath); - false - - - false - $(IncludePath);$(SolutionDir)..\..\lib;$(SolutionDir)..\..\programs\legacy;$(SolutionDir)..\..\lib\legacy;$(SolutionDir)..\..\lib\common;$(SolutionDir)..\..\lib\dictBuilder;$(UniversalCRT_IncludePath); - false - - - false - $(IncludePath);$(SolutionDir)..\..\lib;$(SolutionDir)..\..\programs\legacy;$(SolutionDir)..\..\lib\legacy;$(SolutionDir)..\..\lib\common;$(SolutionDir)..\..\lib\dictBuilder;$(UniversalCRT_IncludePath); - false - - - - $(OutDir)$(TargetName).pdb - - - - - - - Level4 - Disabled - ZSTD_MULTITHREAD=1;ZSTD_LEGACY_SUPPORT=5;WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - EnableFastChecks - MultiThreadedDebugDLL - EditAndContinue - true - false - - - Console - true - MachineX86 - - - - - - - Level4 - Disabled - ZSTD_MULTITHREAD=1;ZSTD_LEGACY_SUPPORT=5;WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - ProgramDatabase - false - - - Console - true - - - - - Level4 - - - MaxSpeed - true - true - ZSTD_MULTITHREAD=1;ZSTD_LEGACY_SUPPORT=5;WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - false - MultiThreaded - ProgramDatabase - - - Console - true - true - true - MachineX86 - - - - - Level4 - - - MaxSpeed - true - true - ZSTD_MULTITHREAD=1;ZSTD_LEGACY_SUPPORT=5;WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - false - false - MultiThreaded - ProgramDatabase - true - true - - - Console - true - true - true - - - - - - diff --git a/third_party/zstd/build/VS2010/zstd.sln b/third_party/zstd/build/VS2010/zstd.sln deleted file mode 100644 index ddcf8401a..000000000 --- a/third_party/zstd/build/VS2010/zstd.sln +++ /dev/null @@ -1,89 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Express 2012 for Windows Desktop -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zstd", "zstd\zstd.vcxproj", "{4E52A41A-F33B-4C7A-8C36-A1A6B4F4277C}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fuzzer", "fuzzer\fuzzer.vcxproj", "{6FD4352B-346C-4703-96EA-D4A8B9A6976E}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fullbench", "fullbench\fullbench.vcxproj", "{61ABD629-1CC8-4FD7-9281-6B8DBB9D3DF8}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fullbench-dll", "fullbench-dll\fullbench-dll.vcxproj", "{00000000-1CC8-4FD7-9281-6B8DBB9D3DF8}" - ProjectSection(ProjectDependencies) = postProject - {00000000-94D5-4BF9-8A50-7BD9929A0850} = {00000000-94D5-4BF9-8A50-7BD9929A0850} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "datagen", "datagen\datagen.vcxproj", "{037E781E-81A6-494B-B1B3-438AB1200523}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libzstd", "libzstd\libzstd.vcxproj", "{8BFD8150-94D5-4BF9-8A50-7BD9929A0850}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libzstd-dll", "libzstd-dll\libzstd-dll.vcxproj", "{00000000-94D5-4BF9-8A50-7BD9929A0850}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {4E52A41A-F33B-4C7A-8C36-A1A6B4F4277C}.Debug|Win32.ActiveCfg = Debug|Win32 - {4E52A41A-F33B-4C7A-8C36-A1A6B4F4277C}.Debug|Win32.Build.0 = Debug|Win32 - {4E52A41A-F33B-4C7A-8C36-A1A6B4F4277C}.Debug|x64.ActiveCfg = Debug|x64 - {4E52A41A-F33B-4C7A-8C36-A1A6B4F4277C}.Debug|x64.Build.0 = Debug|x64 - {4E52A41A-F33B-4C7A-8C36-A1A6B4F4277C}.Release|Win32.ActiveCfg = Release|Win32 - {4E52A41A-F33B-4C7A-8C36-A1A6B4F4277C}.Release|Win32.Build.0 = Release|Win32 - {4E52A41A-F33B-4C7A-8C36-A1A6B4F4277C}.Release|x64.ActiveCfg = Release|x64 - {4E52A41A-F33B-4C7A-8C36-A1A6B4F4277C}.Release|x64.Build.0 = Release|x64 - {6FD4352B-346C-4703-96EA-D4A8B9A6976E}.Debug|Win32.ActiveCfg = Debug|Win32 - {6FD4352B-346C-4703-96EA-D4A8B9A6976E}.Debug|Win32.Build.0 = Debug|Win32 - {6FD4352B-346C-4703-96EA-D4A8B9A6976E}.Debug|x64.ActiveCfg = Debug|x64 - {6FD4352B-346C-4703-96EA-D4A8B9A6976E}.Debug|x64.Build.0 = Debug|x64 - {6FD4352B-346C-4703-96EA-D4A8B9A6976E}.Release|Win32.ActiveCfg = Release|Win32 - {6FD4352B-346C-4703-96EA-D4A8B9A6976E}.Release|Win32.Build.0 = Release|Win32 - {6FD4352B-346C-4703-96EA-D4A8B9A6976E}.Release|x64.ActiveCfg = Release|x64 - {6FD4352B-346C-4703-96EA-D4A8B9A6976E}.Release|x64.Build.0 = Release|x64 - {61ABD629-1CC8-4FD7-9281-6B8DBB9D3DF8}.Debug|Win32.ActiveCfg = Debug|Win32 - {61ABD629-1CC8-4FD7-9281-6B8DBB9D3DF8}.Debug|Win32.Build.0 = Debug|Win32 - {61ABD629-1CC8-4FD7-9281-6B8DBB9D3DF8}.Debug|x64.ActiveCfg = Debug|x64 - {61ABD629-1CC8-4FD7-9281-6B8DBB9D3DF8}.Debug|x64.Build.0 = Debug|x64 - {61ABD629-1CC8-4FD7-9281-6B8DBB9D3DF8}.Release|Win32.ActiveCfg = Release|Win32 - {61ABD629-1CC8-4FD7-9281-6B8DBB9D3DF8}.Release|Win32.Build.0 = Release|Win32 - {61ABD629-1CC8-4FD7-9281-6B8DBB9D3DF8}.Release|x64.ActiveCfg = Release|x64 - {61ABD629-1CC8-4FD7-9281-6B8DBB9D3DF8}.Release|x64.Build.0 = Release|x64 - {00000000-1CC8-4FD7-9281-6B8DBB9D3DF8}.Debug|Win32.ActiveCfg = Debug|Win32 - {00000000-1CC8-4FD7-9281-6B8DBB9D3DF8}.Debug|Win32.Build.0 = Debug|Win32 - {00000000-1CC8-4FD7-9281-6B8DBB9D3DF8}.Debug|x64.ActiveCfg = Debug|x64 - {00000000-1CC8-4FD7-9281-6B8DBB9D3DF8}.Debug|x64.Build.0 = Debug|x64 - {00000000-1CC8-4FD7-9281-6B8DBB9D3DF8}.Release|Win32.ActiveCfg = Release|Win32 - {00000000-1CC8-4FD7-9281-6B8DBB9D3DF8}.Release|Win32.Build.0 = Release|Win32 - {00000000-1CC8-4FD7-9281-6B8DBB9D3DF8}.Release|x64.ActiveCfg = Release|x64 - {00000000-1CC8-4FD7-9281-6B8DBB9D3DF8}.Release|x64.Build.0 = Release|x64 - {037E781E-81A6-494B-B1B3-438AB1200523}.Debug|Win32.ActiveCfg = Debug|Win32 - {037E781E-81A6-494B-B1B3-438AB1200523}.Debug|Win32.Build.0 = Debug|Win32 - {037E781E-81A6-494B-B1B3-438AB1200523}.Debug|x64.ActiveCfg = Debug|x64 - {037E781E-81A6-494B-B1B3-438AB1200523}.Debug|x64.Build.0 = Debug|x64 - {037E781E-81A6-494B-B1B3-438AB1200523}.Release|Win32.ActiveCfg = Release|Win32 - {037E781E-81A6-494B-B1B3-438AB1200523}.Release|Win32.Build.0 = Release|Win32 - {037E781E-81A6-494B-B1B3-438AB1200523}.Release|x64.ActiveCfg = Release|x64 - {037E781E-81A6-494B-B1B3-438AB1200523}.Release|x64.Build.0 = Release|x64 - {8BFD8150-94D5-4BF9-8A50-7BD9929A0850}.Debug|Win32.ActiveCfg = Debug|Win32 - {8BFD8150-94D5-4BF9-8A50-7BD9929A0850}.Debug|Win32.Build.0 = Debug|Win32 - {8BFD8150-94D5-4BF9-8A50-7BD9929A0850}.Debug|x64.ActiveCfg = Debug|x64 - {8BFD8150-94D5-4BF9-8A50-7BD9929A0850}.Debug|x64.Build.0 = Debug|x64 - {8BFD8150-94D5-4BF9-8A50-7BD9929A0850}.Release|Win32.ActiveCfg = Release|Win32 - {8BFD8150-94D5-4BF9-8A50-7BD9929A0850}.Release|Win32.Build.0 = Release|Win32 - {8BFD8150-94D5-4BF9-8A50-7BD9929A0850}.Release|x64.ActiveCfg = Release|x64 - {8BFD8150-94D5-4BF9-8A50-7BD9929A0850}.Release|x64.Build.0 = Release|x64 - {00000000-94D5-4BF9-8A50-7BD9929A0850}.Debug|Win32.ActiveCfg = Debug|Win32 - {00000000-94D5-4BF9-8A50-7BD9929A0850}.Debug|Win32.Build.0 = Debug|Win32 - {00000000-94D5-4BF9-8A50-7BD9929A0850}.Debug|x64.ActiveCfg = Debug|x64 - {00000000-94D5-4BF9-8A50-7BD9929A0850}.Debug|x64.Build.0 = Debug|x64 - {00000000-94D5-4BF9-8A50-7BD9929A0850}.Release|Win32.ActiveCfg = Release|Win32 - {00000000-94D5-4BF9-8A50-7BD9929A0850}.Release|Win32.Build.0 = Release|Win32 - {00000000-94D5-4BF9-8A50-7BD9929A0850}.Release|x64.ActiveCfg = Release|x64 - {00000000-94D5-4BF9-8A50-7BD9929A0850}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/third_party/zstd/build/VS2010/zstd/zstd.rc b/third_party/zstd/build/VS2010/zstd/zstd.rc deleted file mode 100644 index 99d491289..000000000 --- a/third_party/zstd/build/VS2010/zstd/zstd.rc +++ /dev/null @@ -1,51 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// - -#include "zstd.h" /* ZSTD_VERSION_STRING */ -#define APSTUDIO_READONLY_SYMBOLS -#include "verrsrc.h" -#undef APSTUDIO_READONLY_SYMBOLS - - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -LANGUAGE 9, 1 - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION ZSTD_VERSION_MAJOR,ZSTD_VERSION_MINOR,ZSTD_VERSION_RELEASE,0 - PRODUCTVERSION ZSTD_VERSION_MAJOR,ZSTD_VERSION_MINOR,ZSTD_VERSION_RELEASE,0 - FILEFLAGSMASK VS_FFI_FILEFLAGSMASK -#ifdef _DEBUG - FILEFLAGS VS_FF_DEBUG -#else - FILEFLAGS 0x0L -#endif - FILEOS VOS_NT_WINDOWS32 - FILETYPE VFT_DLL - FILESUBTYPE VFT2_UNKNOWN -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904B0" - BEGIN - VALUE "CompanyName", "Meta Platforms, Inc." - VALUE "FileDescription", "Zstandard - Fast and efficient compression algorithm" - VALUE "FileVersion", ZSTD_VERSION_STRING - VALUE "InternalName", "zstd.exe" - VALUE "LegalCopyright", "Copyright (c) Meta Platforms, Inc. and affiliates." - VALUE "OriginalFilename", "zstd.exe" - VALUE "ProductName", "Zstandard" - VALUE "ProductVersion", ZSTD_VERSION_STRING - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x0409, 1200 - END -END - -#endif diff --git a/third_party/zstd/build/VS2010/zstd/zstd.vcxproj b/third_party/zstd/build/VS2010/zstd/zstd.vcxproj deleted file mode 100644 index 919ac5a31..000000000 --- a/third_party/zstd/build/VS2010/zstd/zstd.vcxproj +++ /dev/null @@ -1,264 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {4E52A41A-F33B-4C7A-8C36-A1A6B4F4277C} - Win32Proj - zstd - $(SolutionDir)bin\$(Platform)_$(Configuration)\ - $(SolutionDir)bin\obj\$(RootNamespace)_$(Platform)_$(Configuration)\ - NotSet - - - - Application - true - MultiByte - - - Application - true - MultiByte - - - Application - false - true - MultiByte - - - Application - false - true - MultiByte - - - - - - - - - - - - - - - - - - - true - $(IncludePath);$(SolutionDir)..\..\lib;$(SolutionDir)..\..\lib\compress;$(SolutionDir)..\..\lib\legacy;$(SolutionDir)..\..\lib\common;$(SolutionDir)..\..\lib\dictBuilder;$(UniversalCRT_IncludePath); - false - $(LibraryPath) - - - true - $(IncludePath);$(SolutionDir)..\..\lib;$(SolutionDir)..\..\lib\compress;$(SolutionDir)..\..\lib\legacy;$(SolutionDir)..\..\lib\common;$(SolutionDir)..\..\lib\dictBuilder;$(UniversalCRT_IncludePath); - false - $(LibraryPath); - - - false - $(IncludePath);$(SolutionDir)..\..\lib;$(SolutionDir)..\..\lib\compress;$(SolutionDir)..\..\lib\legacy;$(SolutionDir)..\..\lib\common;$(SolutionDir)..\..\lib\dictBuilder;$(UniversalCRT_IncludePath); - false - $(LibraryPath) - - - false - $(IncludePath);$(SolutionDir)..\..\lib;$(SolutionDir)..\..\lib\compress;$(SolutionDir)..\..\lib\legacy;$(SolutionDir)..\..\lib\common;$(SolutionDir)..\..\lib\dictBuilder;$(UniversalCRT_IncludePath); - false - $(LibraryPath); - - - - - - Level4 - Disabled - ZSTD_MULTITHREAD=1;ZSTD_LEGACY_SUPPORT=5;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - false - $(InstructionSet) - - - Console - true - setargv.obj;%(AdditionalDependencies) - - - - - - - Level4 - Disabled - ZSTD_MULTITHREAD=1;ZSTD_LEGACY_SUPPORT=5;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - false - $(InstructionSet) - - - Console - true - setargv.obj;%(AdditionalDependencies) - - - - - Level4 - - - MaxSpeed - true - true - ZSTD_MULTITHREAD=1;ZSTD_LEGACY_SUPPORT=5;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - false - false - MultiThreaded - $(InstructionSet) - - - Console - true - true - true - setargv.obj;%(AdditionalDependencies) - - - - - Level4 - - - MaxSpeed - true - true - ZSTD_MULTITHREAD=1;ZSTD_LEGACY_SUPPORT=5;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - false - false - MultiThreaded - /DZSTD_MULTITHREAD %(AdditionalOptions) - $(InstructionSet) - - - Console - true - true - true - setargv.obj;%(AdditionalDependencies) - - - - - - diff --git a/third_party/zstd/build/VS_scripts/README.md b/third_party/zstd/build/VS_scripts/README.md deleted file mode 100644 index 6ccaca788..000000000 --- a/third_party/zstd/build/VS_scripts/README.md +++ /dev/null @@ -1,64 +0,0 @@ -Command line scripts for Visual Studio compilation without IDE -============================================================== - -Here are a few command lines for reference : - -### Build with Visual Studio 2013 for msvcr120.dll - -Running the following command will build both the `Release Win32` and `Release x64` versions: -```batch -build.VS2013.cmd -``` -The result of each build will be in the corresponding `bin\Release\{ARCH}\` folder. - -If you want to only need one architecture: -- Win32: `build.generic.cmd VS2013 Win32 Release v120` -- x64: `build.generic.cmd VS2013 x64 Release v120` - -If you want a Debug build: -- Win32: `build.generic.cmd VS2013 Win32 Debug v120` -- x64: `build.generic.cmd VS2013 x64 Debug v120` - -### Build with Visual Studio 2015 for msvcr140.dll - -Running the following command will build both the `Release Win32` and `Release x64` versions: -```batch -build.VS2015.cmd -``` -The result of each build will be in the corresponding `bin\Release\{ARCH}\` folder. - -If you want to only need one architecture: -- Win32: `build.generic.cmd VS2015 Win32 Release v140` -- x64: `build.generic.cmd VS2015 x64 Release v140` - -If you want a Debug build: -- Win32: `build.generic.cmd VS2015 Win32 Debug v140` -- x64: `build.generic.cmd VS2015 x64 Debug v140` - -### Build with Visual Studio 2015 for msvcr120.dll - -This capability is offered through `build.generic.cmd` using proper arguments: - -**For Win32** -```batch -build.generic.cmd VS2015 Win32 Release v120 -``` -The result of the build will be in the `bin\Release\Win32\` folder. - -**For x64** -```batch -build.generic.cmd VS2015 x64 Release v120 -``` -The result of the build will be in the `bin\Release\x64\` folder. - -If you want Debug builds, replace `Release` with `Debug`. - -### Build with Visual Studio 2017 - -`build.VS2017.cmd`, contributed by [@HaydnTrigg](https://github.com/HaydnTrigg), -will build both the `Release Win32` and `Release x64` versions -of the first VS2017 variant it finds, in this priority order : -Enterprise > Professional > Community - -Alternatively, it's possible to target a specific version, -using appropriate script, such as `build.VS2017Enterprise.cmd` for example. diff --git a/third_party/zstd/build/VS_scripts/build.VS2010.cmd b/third_party/zstd/build/VS_scripts/build.VS2010.cmd deleted file mode 100644 index 60fbbf69e..000000000 --- a/third_party/zstd/build/VS_scripts/build.VS2010.cmd +++ /dev/null @@ -1,7 +0,0 @@ -@echo off - -rem build 32-bit -call "%~p0%build.generic.cmd" VS2010 Win32 Release v100 - -rem build 64-bit -call "%~p0%build.generic.cmd" VS2010 x64 Release v100 \ No newline at end of file diff --git a/third_party/zstd/build/VS_scripts/build.VS2012.cmd b/third_party/zstd/build/VS_scripts/build.VS2012.cmd deleted file mode 100644 index 4328bae92..000000000 --- a/third_party/zstd/build/VS_scripts/build.VS2012.cmd +++ /dev/null @@ -1,6 +0,0 @@ -@echo off - -rem build 32-bit -call "%~p0%build.generic.cmd" VS2012 Win32 Release v110 -rem build 64-bit -call "%~p0%build.generic.cmd" VS2012 x64 Release v110 \ No newline at end of file diff --git a/third_party/zstd/build/VS_scripts/build.VS2013.cmd b/third_party/zstd/build/VS_scripts/build.VS2013.cmd deleted file mode 100644 index f906d9025..000000000 --- a/third_party/zstd/build/VS_scripts/build.VS2013.cmd +++ /dev/null @@ -1,7 +0,0 @@ -@echo off - -rem build 32-bit -call "%~p0%build.generic.cmd" VS2013 Win32 Release v120 - -rem build 64-bit -call "%~p0%build.generic.cmd" VS2013 x64 Release v120 \ No newline at end of file diff --git a/third_party/zstd/build/VS_scripts/build.VS2015.cmd b/third_party/zstd/build/VS_scripts/build.VS2015.cmd deleted file mode 100644 index 798e9dcb0..000000000 --- a/third_party/zstd/build/VS_scripts/build.VS2015.cmd +++ /dev/null @@ -1,7 +0,0 @@ -@echo off - -rem build 32-bit -call "%~p0%build.generic.cmd" VS2015 Win32 Release v140 - -rem build 64-bit -call "%~p0%build.generic.cmd" VS2015 x64 Release v140 \ No newline at end of file diff --git a/third_party/zstd/build/VS_scripts/build.VS2017.cmd b/third_party/zstd/build/VS_scripts/build.VS2017.cmd deleted file mode 100644 index aa2011671..000000000 --- a/third_party/zstd/build/VS_scripts/build.VS2017.cmd +++ /dev/null @@ -1,7 +0,0 @@ -@echo off - -rem build 32-bit -call "%~p0%build.generic.cmd" VS2017 Win32 Release v141 - -rem build 64-bit -call "%~p0%build.generic.cmd" VS2017 x64 Release v141 \ No newline at end of file diff --git a/third_party/zstd/build/VS_scripts/build.VS2017Community.cmd b/third_party/zstd/build/VS_scripts/build.VS2017Community.cmd deleted file mode 100644 index 90b69a80b..000000000 --- a/third_party/zstd/build/VS_scripts/build.VS2017Community.cmd +++ /dev/null @@ -1,7 +0,0 @@ -@echo off - -rem build 32-bit -call "%~p0%build.generic.cmd" VS2017Community Win32 Release v141 - -rem build 64-bit -call "%~p0%build.generic.cmd" VS2017Community x64 Release v141 \ No newline at end of file diff --git a/third_party/zstd/build/VS_scripts/build.VS2017Enterprise.cmd b/third_party/zstd/build/VS_scripts/build.VS2017Enterprise.cmd deleted file mode 100644 index 99863ff6c..000000000 --- a/third_party/zstd/build/VS_scripts/build.VS2017Enterprise.cmd +++ /dev/null @@ -1,7 +0,0 @@ -@echo off - -rem build 32-bit -call "%~p0%build.generic.cmd" VS2017Enterprise Win32 Release v141 - -rem build 64-bit -call "%~p0%build.generic.cmd" VS2017Enterprise x64 Release v141 \ No newline at end of file diff --git a/third_party/zstd/build/VS_scripts/build.VS2017Professional.cmd b/third_party/zstd/build/VS_scripts/build.VS2017Professional.cmd deleted file mode 100644 index d56ccabae..000000000 --- a/third_party/zstd/build/VS_scripts/build.VS2017Professional.cmd +++ /dev/null @@ -1,7 +0,0 @@ -@echo off - -rem build 32-bit -call "%~p0%build.generic.cmd" VS2017Professional Win32 Release v141 - -rem build 64-bit -call "%~p0%build.generic.cmd" VS2017Professional x64 Release v141 \ No newline at end of file diff --git a/third_party/zstd/build/VS_scripts/build.generic.cmd b/third_party/zstd/build/VS_scripts/build.generic.cmd deleted file mode 100644 index d43c134ed..000000000 --- a/third_party/zstd/build/VS_scripts/build.generic.cmd +++ /dev/null @@ -1,72 +0,0 @@ -@echo off - -IF "%1%" == "" GOTO display_help - -SETLOCAL - -SET msbuild_version=%1 - -SET msbuild_platform=%2 -IF "%msbuild_platform%" == "" SET msbuild_platform=x64 - -SET msbuild_configuration=%3 -IF "%msbuild_configuration%" == "" SET msbuild_configuration=Release - -SET msbuild_toolset=%4 - -GOTO build - -:display_help - -echo Syntax: build.generic.cmd msbuild_version msbuild_platform msbuild_configuration msbuild_toolset -echo msbuild_version: VS installed version (VS2012, VS2013, VS2015, VS2017, VS2019, ...) -echo msbuild_platform: Platform (x64 or Win32) -echo msbuild_configuration: VS configuration (Release or Debug) -echo msbuild_toolset: Platform Toolset (v100, v110, v120, v140, v141, v142, ...) - -EXIT /B 1 - -:build - -SET msbuild="%windir%\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe" -SET msbuild_vs2017community="%programfiles(x86)%\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\MSBuild.exe" -SET msbuild_vs2017professional="%programfiles(x86)%\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\MSBuild.exe" -SET msbuild_vs2017enterprise="%programfiles(x86)%\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\MSBuild.exe" -IF %msbuild_version% == VS2013 SET msbuild="%programfiles(x86)%\MSBuild\12.0\Bin\MSBuild.exe" -IF %msbuild_version% == VS2015 SET msbuild="%programfiles(x86)%\MSBuild\14.0\Bin\MSBuild.exe" -IF %msbuild_version% == VS2017Community SET msbuild=%msbuild_vs2017community% -IF %msbuild_version% == VS2017Professional SET msbuild=%msbuild_vs2017professional% -IF %msbuild_version% == VS2017Enterprise SET msbuild=%msbuild_vs2017enterprise% -IF %msbuild_version% == VS2017 ( - IF EXIST %msbuild_vs2017community% SET msbuild=%msbuild_vs2017community% - IF EXIST %msbuild_vs2017professional% SET msbuild=%msbuild_vs2017professional% - IF EXIST %msbuild_vs2017enterprise% SET msbuild=%msbuild_vs2017enterprise% -) - -:: VS2019 -SET msbuild_vs2019community="%programfiles(x86)%\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe" -SET msbuild_vs2019professional="%programfiles(x86)%\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\MSBuild.exe" -SET msbuild_vs2019enterprise="%programfiles(x86)%\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\MSBuild.exe" -IF %msbuild_version% == VS2019 ( - IF EXIST %msbuild_vs2019community% SET msbuild=%msbuild_vs2019community% - IF EXIST %msbuild_vs2019professional% SET msbuild=%msbuild_vs2019professional% - IF EXIST %msbuild_vs2019enterprise% SET msbuild=%msbuild_vs2019enterprise% -) - -SET project="%~p0\..\VS2010\zstd.sln" - -SET msbuild_params=/verbosity:minimal /nologo /t:Clean,Build /p:Platform=%msbuild_platform% /p:Configuration=%msbuild_configuration% -IF NOT "%msbuild_toolset%" == "" SET msbuild_params=%msbuild_params% /p:PlatformToolset=%msbuild_toolset% - -SET output=%~p0%bin -SET output="%output%/%msbuild_configuration%/%msbuild_platform%/" -SET msbuild_params=%msbuild_params% /p:OutDir=%output% - -echo ### Building %msbuild_version% project for %msbuild_configuration% %msbuild_platform% (%msbuild_toolset%)... -echo ### Build Params: %msbuild_params% - -%msbuild% %project% %msbuild_params% -IF ERRORLEVEL 1 EXIT /B 1 -echo # Success -echo # OutDir: %output% -echo # diff --git a/third_party/zstd/build/cmake/.gitignore b/third_party/zstd/build/cmake/.gitignore deleted file mode 100644 index 2e51e8954..000000000 --- a/third_party/zstd/build/cmake/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -# cmake working directory -cmakeBuild - -# cmake artefacts -CMakeCache.txt -CMakeFiles -Makefile -cmake_install.cmake -cmake_uninstall.cmake -*.1 diff --git a/third_party/zstd/build/cmake/CMakeLists.txt b/third_party/zstd/build/cmake/CMakeLists.txt deleted file mode 100644 index 0bffc87d9..000000000 --- a/third_party/zstd/build/cmake/CMakeLists.txt +++ /dev/null @@ -1,212 +0,0 @@ -# ################################################################ -# Copyright (c) Meta Platforms, Inc. and affiliates. -# All rights reserved. -# -# This source code is licensed under both the BSD-style license (found in the -# LICENSE file in the root directory of this source tree) and the GPLv2 (found -# in the COPYING file in the root directory of this source tree). -# ################################################################ - -cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR) - -# As of 2018-12-26 ZSTD has been validated to build with cmake version 3.13.2 new policies. -# Set and use the newest cmake policies that are validated to work -set(ZSTD_MAX_VALIDATED_CMAKE_MAJOR_VERSION "3") -set(ZSTD_MAX_VALIDATED_CMAKE_MINOR_VERSION "13") #Policies never changed at PATCH level -if("${CMAKE_MAJOR_VERSION}" LESS 3) - set(ZSTD_CMAKE_POLICY_VERSION "${CMAKE_VERSION}") -elseif( "${ZSTD_MAX_VALIDATED_CMAKE_MAJOR_VERSION}" EQUAL "${CMAKE_MAJOR_VERSION}" AND - "${ZSTD_MAX_VALIDATED_CMAKE_MINOR_VERSION}" GREATER "${CMAKE_MINOR_VERSION}") - set(ZSTD_CMAKE_POLICY_VERSION "${CMAKE_VERSION}") -else() - set(ZSTD_CMAKE_POLICY_VERSION "${ZSTD_MAX_VALIDATED_CMAKE_MAJOR_VERSION}.${ZSTD_MAX_VALIDATED_CMAKE_MINOR_VERSION}.0") -endif() -cmake_policy(VERSION ${ZSTD_CMAKE_POLICY_VERSION}) - -set(CMAKE_BUILD_WITH_INSTALL_RPATH on) - -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules") -set(ZSTD_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../..") -set(LIBRARY_DIR ${ZSTD_SOURCE_DIR}/lib) -# Parse version -include(GetZstdLibraryVersion) -GetZstdLibraryVersion(${LIBRARY_DIR}/zstd.h zstd_VERSION_MAJOR zstd_VERSION_MINOR zstd_VERSION_PATCH) - -if( CMAKE_MAJOR_VERSION LESS 3 ) - ## Provide cmake 3+ behavior for older versions of cmake - project(zstd) - set(PROJECT_VERSION_MAJOR ${zstd_VERSION_MAJOR}) - set(PROJECT_VERSION_MINOR ${zstd_VERSION_MINOR}) - set(PROJECT_VERSION_PATCH ${zstd_VERSION_PATCH}) - set(PROJECT_VERSION "${zstd_VERSION_MAJOR}.${zstd_VERSION_MINOR}.${zstd_VERSION_PATCH}") - enable_language(C) # Main library is in C - enable_language(ASM) # And ASM - enable_language(CXX) # Testing contributed code also utilizes CXX -else() - project(zstd - VERSION "${zstd_VERSION_MAJOR}.${zstd_VERSION_MINOR}.${zstd_VERSION_PATCH}" - LANGUAGES C # Main library is in C - ASM # And ASM - CXX # Testing contributed code also utilizes CXX - ) -endif() -message(STATUS "ZSTD VERSION: ${zstd_VERSION}") -set(zstd_HOMEPAGE_URL "https://facebook.github.io/zstd") -set(zstd_DESCRIPTION "Zstandard is a real-time compression algorithm, providing high compression ratios.") - -# Set a default build type if none was specified -if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) - message(STATUS "Setting build type to 'Release' as none was specified.") - set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE) - # Set the possible values of build type for cmake-gui - set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo") -endif() - -include(GNUInstallDirs) - -#----------------------------------------------------------------------------- -# Add extra compilation flags -#----------------------------------------------------------------------------- -include(AddZstdCompilationFlags) -ADD_ZSTD_COMPILATION_FLAGS() - -# Always hide XXHash symbols -add_definitions(-DXXH_NAMESPACE=ZSTD_) - -#----------------------------------------------------------------------------- -# Installation variables -#----------------------------------------------------------------------------- -message(STATUS "CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}") -message(STATUS "CMAKE_INSTALL_LIBDIR: ${CMAKE_INSTALL_LIBDIR}") - -#----------------------------------------------------------------------------- -# Options -#----------------------------------------------------------------------------- - -# Legacy support -option(ZSTD_LEGACY_SUPPORT "LEGACY SUPPORT" ON) - -if (ZSTD_LEGACY_SUPPORT) - message(STATUS "ZSTD_LEGACY_SUPPORT defined!") - set(ZSTD_LEGACY_LEVEL 5 CACHE STRING "") - add_definitions(-DZSTD_LEGACY_SUPPORT=${ZSTD_LEGACY_LEVEL}) -else () - message(STATUS "ZSTD_LEGACY_SUPPORT not defined!") - add_definitions(-DZSTD_LEGACY_SUPPORT=0) -endif () - -if (ANDROID) - set(ZSTD_MULTITHREAD_SUPPORT_DEFAULT OFF) -else() - set(ZSTD_MULTITHREAD_SUPPORT_DEFAULT ON) -endif() - -# Multi-threading support -option(ZSTD_MULTITHREAD_SUPPORT "MULTITHREADING SUPPORT" ${ZSTD_MULTITHREAD_SUPPORT_DEFAULT}) - -if (ZSTD_MULTITHREAD_SUPPORT) - message(STATUS "ZSTD_MULTITHREAD_SUPPORT is enabled") -else () - message(STATUS "ZSTD_MULTITHREAD_SUPPORT is disabled") -endif () - -option(ZSTD_BUILD_PROGRAMS "BUILD PROGRAMS" ON) -option(ZSTD_BUILD_CONTRIB "BUILD CONTRIB" OFF) - -# Respect the conventional CMake option for enabling tests if it was specified on the first configure -if (BUILD_TESTING) - set(ZSTD_BUILD_TESTS_default ON) -else() - set(ZSTD_BUILD_TESTS_default OFF) -endif() -option(ZSTD_BUILD_TESTS "BUILD TESTS" ${ZSTD_BUILD_TESTS_default}) -if (MSVC) - option(ZSTD_USE_STATIC_RUNTIME "LINK TO STATIC RUN-TIME LIBRARIES" OFF) -endif () - -#----------------------------------------------------------------------------- -# External dependencies -#----------------------------------------------------------------------------- -if (ZSTD_MULTITHREAD_SUPPORT AND UNIX) - set(THREADS_PREFER_PTHREAD_FLAG ON) - find_package(Threads REQUIRED) - if(CMAKE_USE_PTHREADS_INIT) - set(THREADS_LIBS "${CMAKE_THREAD_LIBS_INIT}") - else() - message(SEND_ERROR "ZSTD currently does not support thread libraries other than pthreads") - endif() -endif () - -#----------------------------------------------------------------------------- -# Add source directories -#----------------------------------------------------------------------------- -add_subdirectory(lib) - -option(ZSTD_PROGRAMS_LINK_SHARED "PROGRAMS LINK SHARED" OFF) - -if (ZSTD_BUILD_PROGRAMS) - if (NOT ZSTD_BUILD_STATIC AND NOT ZSTD_PROGRAMS_LINK_SHARED) - message(SEND_ERROR "You need to build static library to build zstd CLI") - elseif(NOT ZSTD_BUILD_SHARED AND ZSTD_PROGRAMS_LINK_SHARED) - message(SEND_ERROR "You need to build shared library to build zstd CLI") - endif () - - add_subdirectory(programs) -endif () - -if (ZSTD_BUILD_TESTS) - enable_testing() - if (NOT ZSTD_BUILD_STATIC) - message(SEND_ERROR "You need to build static library to build tests") - endif () - - add_subdirectory(tests) -endif () - -if (ZSTD_BUILD_CONTRIB) - add_subdirectory(contrib) -endif () - -#----------------------------------------------------------------------------- -# Add clean-all target -#----------------------------------------------------------------------------- -add_custom_target(clean-all - COMMAND ${CMAKE_BUILD_TOOL} clean - COMMAND rm -rf ${CMAKE_BINARY_DIR}/ -) - -#----------------------------------------------------------------------------- -# Generate Package Config files -# -# This section is based on the boiler plate code from: -# https://cmake.org/cmake/help/latest/manual/cmake-packages.7.html#creating-packages -#----------------------------------------------------------------------------- -include(CMakePackageConfigHelpers) -write_basic_package_version_file( - "${CMAKE_CURRENT_BINARY_DIR}/zstdConfigVersion.cmake" - VERSION ${zstd_VERSION} - COMPATIBILITY SameMajorVersion - ) - -# A Package Config file that works from the build directory -export(EXPORT zstdExports - FILE "${CMAKE_CURRENT_BINARY_DIR}/zstdTargets.cmake" - NAMESPACE zstd:: - ) -configure_file(zstdConfig.cmake - "${CMAKE_CURRENT_BINARY_DIR}/zstdConfig.cmake" - COPYONLY - ) - -# A Package Config file that works from the installation directory -set(ConfigPackageLocation ${CMAKE_INSTALL_LIBDIR}/cmake/zstd) -install(EXPORT zstdExports - FILE zstdTargets.cmake - NAMESPACE zstd:: - DESTINATION ${ConfigPackageLocation} - ) -install(FILES - zstdConfig.cmake - "${CMAKE_CURRENT_BINARY_DIR}/zstdConfigVersion.cmake" - DESTINATION ${ConfigPackageLocation} - ) diff --git a/third_party/zstd/build/cmake/CMakeModules/AddZstdCompilationFlags.cmake b/third_party/zstd/build/cmake/CMakeModules/AddZstdCompilationFlags.cmake deleted file mode 100644 index 5f179989b..000000000 --- a/third_party/zstd/build/cmake/CMakeModules/AddZstdCompilationFlags.cmake +++ /dev/null @@ -1,121 +0,0 @@ -include(CheckCXXCompilerFlag) -include(CheckCCompilerFlag) -# VERSION_GREATER_EQUAL requires CMake 3.7 or later. -# https://cmake.org/cmake/help/latest/command/if.html#version-greater-equal -if (CMAKE_VERSION VERSION_LESS 3.18) - set(ZSTD_HAVE_CHECK_LINKER_FLAG false) -else () - set(ZSTD_HAVE_CHECK_LINKER_FLAG true) -endif () -if (ZSTD_HAVE_CHECK_LINKER_FLAG) - include(CheckLinkerFlag) -endif() - -function(EnableCompilerFlag _flag _C _CXX _LD) - string(REGEX REPLACE "\\+" "PLUS" varname "${_flag}") - string(REGEX REPLACE "[^A-Za-z0-9]+" "_" varname "${varname}") - string(REGEX REPLACE "^_+" "" varname "${varname}") - string(TOUPPER "${varname}" varname) - if (_C) - CHECK_C_COMPILER_FLAG(${_flag} C_FLAG_${varname}) - if (C_FLAG_${varname}) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_flag}" PARENT_SCOPE) - endif () - endif () - if (_CXX) - CHECK_CXX_COMPILER_FLAG(${_flag} CXX_FLAG_${varname}) - if (CXX_FLAG_${varname}) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${_flag}" PARENT_SCOPE) - endif () - endif () - if (_LD) - # We never add a linker flag with CMake < 3.18. We will - # implement CHECK_LINKER_FLAG() like feature for CMake < 3.18 - # or require CMake >= 3.18 when we need to add a required - # linker flag in future. - # - # We also skip linker flags check for MSVC compilers (which includes - # clang-cl) since currently check_linker_flag() doesn't give correct - # results for this configuration, - # see: https://gitlab.kitware.com/cmake/cmake/-/issues/22023 - if (ZSTD_HAVE_CHECK_LINKER_FLAG AND NOT MSVC) - CHECK_LINKER_FLAG(C ${_flag} LD_FLAG_${varname}) - else () - set(LD_FLAG_${varname} false) - endif () - if (LD_FLAG_${varname}) - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${_flag}" PARENT_SCOPE) - set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${_flag}" PARENT_SCOPE) - endif () - endif () -endfunction() - -macro(ADD_ZSTD_COMPILATION_FLAGS) - if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang" OR MINGW) #Not only UNIX but also WIN32 for MinGW - # It's possible to select the exact standard used for compilation. - # It's not necessary, but can be employed for specific purposes. - # Note that zstd source code is compatible with both C++98 and above - # and C-gnu90 (c90 + long long + variadic macros ) and above - # EnableCompilerFlag("-std=c++11" false true) # Set C++ compilation to c++11 standard - # EnableCompilerFlag("-std=c99" true false) # Set C compiation to c99 standard - if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND MSVC) - # clang-cl normally maps -Wall to -Weverything. - EnableCompilerFlag("/clang:-Wall" true true false) - else () - EnableCompilerFlag("-Wall" true true false) - endif () - EnableCompilerFlag("-Wextra" true true false) - EnableCompilerFlag("-Wundef" true true false) - EnableCompilerFlag("-Wshadow" true true false) - EnableCompilerFlag("-Wcast-align" true true false) - EnableCompilerFlag("-Wcast-qual" true true false) - EnableCompilerFlag("-Wstrict-prototypes" true false false) - # Enable asserts in Debug mode - if (CMAKE_BUILD_TYPE MATCHES "Debug") - EnableCompilerFlag("-DDEBUGLEVEL=1" true true false) - endif () - # Add noexecstack flags - # LDFLAGS - EnableCompilerFlag("-z noexecstack" false false true) - # CFLAGS & CXXFLAGS - EnableCompilerFlag("-Qunused-arguments" true true false) - EnableCompilerFlag("-Wa,--noexecstack" true true false) - elseif (MSVC) # Add specific compilation flags for Windows Visual - - set(ACTIVATE_MULTITHREADED_COMPILATION "ON" CACHE BOOL "activate multi-threaded compilation (/MP flag)") - if (CMAKE_GENERATOR MATCHES "Visual Studio" AND ACTIVATE_MULTITHREADED_COMPILATION) - EnableCompilerFlag("/MP" true true false) - endif () - - # UNICODE SUPPORT - EnableCompilerFlag("/D_UNICODE" true true false) - EnableCompilerFlag("/DUNICODE" true true false) - # Enable asserts in Debug mode - if (CMAKE_BUILD_TYPE MATCHES "Debug") - EnableCompilerFlag("/DDEBUGLEVEL=1" true true false) - endif () - endif () - - # Remove duplicates compilation flags - foreach (flag_var CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE - CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO - CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE - CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO) - if( ${flag_var} ) - separate_arguments(${flag_var}) - string(REPLACE ";" " " ${flag_var} "${${flag_var}}") - endif() - endforeach () - - if (MSVC AND ZSTD_USE_STATIC_RUNTIME) - foreach (flag_var CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE - CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO - CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE - CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO) - if ( ${flag_var} ) - string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}") - endif() - endforeach () - endif () - -endmacro() diff --git a/third_party/zstd/build/cmake/CMakeModules/FindLibLZ4.cmake b/third_party/zstd/build/cmake/CMakeModules/FindLibLZ4.cmake deleted file mode 100644 index d0fac06da..000000000 --- a/third_party/zstd/build/cmake/CMakeModules/FindLibLZ4.cmake +++ /dev/null @@ -1,49 +0,0 @@ -# Find LibLZ4 -# -# Find LibLZ4 headers and library -# -# Result Variables -# -# LIBLZ4_FOUND - True if lz4 is found -# LIBLZ4_INCLUDE_DIRS - lz4 headers directories -# LIBLZ4_LIBRARIES - lz4 libraries -# LIBLZ4_VERSION_MAJOR - The major version of lz4 -# LIBLZ4_VERSION_MINOR - The minor version of lz4 -# LIBLZ4_VERSION_RELEASE - The release version of lz4 -# LIBLZ4_VERSION_STRING - version number string (e.g. 1.8.3) -# -# Hints -# -# Set ``LZ4_ROOT_DIR`` to the directory of lz4.h and lz4 library - -set(_LIBLZ4_ROOT_HINTS - ENV LZ4_ROOT_DIR) - -find_path( LIBLZ4_INCLUDE_DIR lz4.h - HINTS ${_LIBLZ4_ROOT_HINTS}) -find_library( LIBLZ4_LIBRARY NAMES lz4 liblz4 liblz4_static - HINTS ${_LIBLZ4_ROOT_HINTS}) - -if(LIBLZ4_INCLUDE_DIR) - file(STRINGS "${LIBLZ4_INCLUDE_DIR}/lz4.h" LIBLZ4_HEADER_CONTENT REGEX "#define LZ4_VERSION_[A-Z]+ +[0-9]+") - - string(REGEX REPLACE ".*#define LZ4_VERSION_MAJOR +([0-9]+).*" "\\1" LIBLZ4_VERSION_MAJOR "${LIBLZ4_HEADER_CONTENT}") - string(REGEX REPLACE ".*#define LZ4_VERSION_MINOR +([0-9]+).*" "\\1" LIBLZ4_VERSION_MINOR "${LIBLZ4_HEADER_CONTENT}") - string(REGEX REPLACE ".*#define LZ4_VERSION_RELEASE +([0-9]+).*" "\\1" LIBLZ4_VERSION_RELEASE "${LIBLZ4_HEADER_CONTENT}") - - set(LIBLZ4_VERSION_STRING "${LIBLZ4_VERSION_MAJOR}.${LIBLZ4_VERSION_MINOR}.${LIBLZ4_VERSION_RELEASE}") - unset(LIBLZ4_HEADER_CONTENT) -endif() - -include(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibLZ4 REQUIRED_VARS LIBLZ4_INCLUDE_DIR - LIBLZ4_LIBRARY - VERSION_VAR LIBLZ4_VERSION_STRING - FAIL_MESSAGE "Could NOT find LZ4, try to set the paths to lz4.h and lz4 library in environment variable LZ4_ROOT_DIR") - -if (LIBLZ4_FOUND) - set(LIBLZ4_LIBRARIES ${LIBLZ4_LIBRARY}) - set(LIBLZ4_INCLUDE_DIRS ${LIBLZ4_INCLUDE_DIR}) -endif () - -mark_as_advanced( LIBLZ4_INCLUDE_DIR LIBLZ4_LIBRARY ) diff --git a/third_party/zstd/build/cmake/CMakeModules/GetZstdLibraryVersion.cmake b/third_party/zstd/build/cmake/CMakeModules/GetZstdLibraryVersion.cmake deleted file mode 100644 index e8ed6064c..000000000 --- a/third_party/zstd/build/cmake/CMakeModules/GetZstdLibraryVersion.cmake +++ /dev/null @@ -1,10 +0,0 @@ -function(GetZstdLibraryVersion _header _major _minor _patch) - # Read file content - file(READ ${_header} CONTENT) - - string(REGEX MATCH ".*define ZSTD_VERSION_MAJOR *([0-9]+).*define ZSTD_VERSION_MINOR *([0-9]+).*define ZSTD_VERSION_RELEASE *([0-9]+)" VERSION_REGEX "${CONTENT}") - set(${_major} ${CMAKE_MATCH_1} PARENT_SCOPE) - set(${_minor} ${CMAKE_MATCH_2} PARENT_SCOPE) - set(${_patch} ${CMAKE_MATCH_3} PARENT_SCOPE) -endfunction() - diff --git a/third_party/zstd/build/cmake/CMakeModules/JoinPaths.cmake b/third_party/zstd/build/cmake/CMakeModules/JoinPaths.cmake deleted file mode 100644 index c68d91b84..000000000 --- a/third_party/zstd/build/cmake/CMakeModules/JoinPaths.cmake +++ /dev/null @@ -1,23 +0,0 @@ -# This module provides function for joining paths -# known from most languages -# -# SPDX-License-Identifier: (MIT OR CC0-1.0) -# Copyright 2020 Jan Tojnar -# https://github.com/jtojnar/cmake-snips -# -# Modelled after Python’s os.path.join -# https://docs.python.org/3.7/library/os.path.html#os.path.join -# Windows not supported -function(join_paths joined_path first_path_segment) - set(temp_path "${first_path_segment}") - foreach(current_segment IN LISTS ARGN) - if(NOT ("${current_segment}" STREQUAL "")) - if(IS_ABSOLUTE "${current_segment}") - set(temp_path "${current_segment}") - else() - set(temp_path "${temp_path}/${current_segment}") - endif() - endif() - endforeach() - set(${joined_path} "${temp_path}" PARENT_SCOPE) -endfunction() diff --git a/third_party/zstd/build/cmake/README.md b/third_party/zstd/build/cmake/README.md deleted file mode 100644 index a460dd161..000000000 --- a/third_party/zstd/build/cmake/README.md +++ /dev/null @@ -1,104 +0,0 @@ -# Cmake contributions - -Contributions to the cmake build configurations are welcome. Please -use case sensitivity that matches modern (i.e. cmake version 2.6 and above) -conventions of using lower-case for commands, and upper-case for -variables. - -## How to build - -As cmake doesn't support command like `cmake clean`, it's recommended to perform an "out of source build". -To do this, you can create a new directory and build in it: -```sh -cd build/cmake -mkdir builddir -cd builddir -cmake .. -make -``` -Then you can clean all cmake caches by simply delete the new directory: -```sh -rm -rf build/cmake/builddir -``` - -And of course, you can directly build in build/cmake: -```sh -cd build/cmake -cmake -make -``` - -To show cmake build options, you can: -```sh -cd build/cmake/builddir -cmake -LH .. -``` - -Bool options can be set to `ON/OFF` with `-D[option]=[ON/OFF]`. You can configure cmake options like this: -```sh -cd build/cmake/builddir -cmake -DZSTD_BUILD_TESTS=ON -DZSTD_LEGACY_SUPPORT=OFF .. -make -``` - -### referring -[Looking for a 'cmake clean' command to clear up CMake output](https://stackoverflow.com/questions/9680420/looking-for-a-cmake-clean-command-to-clear-up-cmake-output) - -## CMake Style Recommendations - -### Indent all code correctly, i.e. the body of - - * if/else/endif - * foreach/endforeach - * while/endwhile - * macro/endmacro - * function/endfunction - -Use spaces for indenting, 2, 3 or 4 spaces preferably. Use the same amount of -spaces for indenting as is used in the rest of the file. Do not use tabs. - -### Upper/lower casing - -Most important: use consistent upper- or lowercasing within one file ! - -In general, the all-lowercase style is preferred. - -So, this is recommended: - -``` -add_executable(foo foo.c) -``` - -These forms are discouraged - -``` -ADD_EXECUTABLE(bar bar.c) -Add_Executable(hello hello.c) -aDd_ExEcUtAbLe(blub blub.c) -``` - -### End commands -To make the code easier to read, use empty commands for endforeach(), endif(), -endfunction(), endmacro() and endwhile(). Also, use empty else() commands. - -For example, do this: - -``` -if(FOOVAR) - some_command(...) -else() - another_command(...) -endif() -``` - -and not this: - -``` -if(BARVAR) - some_other_command(...) -endif(BARVAR) -``` - -### Other resources for best practices - -https://cmake.org/cmake/help/latest/manual/cmake-developer.7.html#modules diff --git a/third_party/zstd/build/cmake/contrib/CMakeLists.txt b/third_party/zstd/build/cmake/contrib/CMakeLists.txt deleted file mode 100644 index 8df2a17b3..000000000 --- a/third_party/zstd/build/cmake/contrib/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -# ################################################################ -# Copyright (c) Meta Platforms, Inc. and affiliates. -# All rights reserved. -# -# This source code is licensed under both the BSD-style license (found in the -# LICENSE file in the root directory of this source tree) and the GPLv2 (found -# in the COPYING file in the root directory of this source tree). -# ################################################################ - -project(contrib) - -add_subdirectory(pzstd) -add_subdirectory(gen_html) diff --git a/third_party/zstd/build/cmake/contrib/gen_html/CMakeLists.txt b/third_party/zstd/build/cmake/contrib/gen_html/CMakeLists.txt deleted file mode 100644 index d1ff6c64b..000000000 --- a/third_party/zstd/build/cmake/contrib/gen_html/CMakeLists.txt +++ /dev/null @@ -1,30 +0,0 @@ -# ################################################################ -# Copyright (c) Meta Platforms, Inc. and affiliates. -# All rights reserved. -# -# This source code is licensed under both the BSD-style license (found in the -# LICENSE file in the root directory of this source tree) and the GPLv2 (found -# in the COPYING file in the root directory of this source tree). -# ################################################################ - -project(gen_html) -include(GetZstdLibraryVersion) - -set(CMAKE_INCLUDE_CURRENT_DIR TRUE) - -# Define programs directory, where sources and header files are located -set(LIBRARY_DIR ${ZSTD_SOURCE_DIR}/lib) -set(PROGRAMS_DIR ${ZSTD_SOURCE_DIR}/programs) -set(GENHTML_DIR ${ZSTD_SOURCE_DIR}/contrib/gen_html) -set(GENHTML_BINARY ${PROJECT_BINARY_DIR}/gen_html${CMAKE_EXECUTABLE_SUFFIX}) -include_directories(${PROGRAMS_DIR} ${LIBRARY_DIR} ${LIBRARY_DIR}/common ${GENHTML_DIR}) - -add_executable(gen_html ${GENHTML_DIR}/gen_html.cpp) - -GetZstdLibraryVersion(${LIBRARY_DIR}/zstd.h VMAJOR VMINOR VRELEASE) -set(LIBVERSION "${VMAJOR}.${VMINOR}.${VRELEASE}") -add_custom_target(zstd_manual.html ALL - ${GENHTML_BINARY} "${LIBVERSION}" "${LIBRARY_DIR}/zstd.h" "${PROJECT_BINARY_DIR}/zstd_manual.html" - DEPENDS gen_html COMMENT "Update zstd manual") - -install(FILES "${PROJECT_BINARY_DIR}/zstd_manual.html" DESTINATION "${CMAKE_INSTALL_DOCDIR}") diff --git a/third_party/zstd/build/cmake/contrib/pzstd/CMakeLists.txt b/third_party/zstd/build/cmake/contrib/pzstd/CMakeLists.txt deleted file mode 100644 index f7098fa0f..000000000 --- a/third_party/zstd/build/cmake/contrib/pzstd/CMakeLists.txt +++ /dev/null @@ -1,38 +0,0 @@ -# ################################################################ -# Copyright (c) Meta Platforms, Inc. and affiliates. -# All rights reserved. -# -# This source code is licensed under both the BSD-style license (found in the -# LICENSE file in the root directory of this source tree) and the GPLv2 (found -# in the COPYING file in the root directory of this source tree). -# ################################################################ - -project(pzstd) - -set(CMAKE_INCLUDE_CURRENT_DIR TRUE) - -# Define programs directory, where sources and header files are located -set(LIBRARY_DIR ${ZSTD_SOURCE_DIR}/lib) -set(PROGRAMS_DIR ${ZSTD_SOURCE_DIR}/programs) -set(PZSTD_DIR ${ZSTD_SOURCE_DIR}/contrib/pzstd) -include_directories(${PROGRAMS_DIR} ${LIBRARY_DIR} ${LIBRARY_DIR}/common ${PZSTD_DIR}) - -add_executable(pzstd ${PROGRAMS_DIR}/util.c ${PZSTD_DIR}/main.cpp ${PZSTD_DIR}/Options.cpp ${PZSTD_DIR}/Pzstd.cpp ${PZSTD_DIR}/SkippableFrame.cpp) -set_property(TARGET pzstd APPEND PROPERTY COMPILE_DEFINITIONS "NDEBUG") -set_property(TARGET pzstd APPEND PROPERTY COMPILE_OPTIONS "-Wno-shadow") - -if (ZSTD_BUILD_SHARED) - set(ZSTD_LIB libzstd_shared) -else() - set(ZSTD_LIB libzstd_static) -endif() - -set(THREADS_PREFER_PTHREAD_FLAG ON) -find_package(Threads REQUIRED) -if (CMAKE_USE_PTHREADS_INIT) - target_link_libraries(pzstd ${ZSTD_LIB} ${CMAKE_THREAD_LIBS_INIT}) -else() - message(SEND_ERROR "ZSTD currently does not support thread libraries other than pthreads") -endif() - -install(TARGETS pzstd RUNTIME DESTINATION "bin") diff --git a/third_party/zstd/build/cmake/lib/.gitignore b/third_party/zstd/build/cmake/lib/.gitignore deleted file mode 100644 index a4444c8d3..000000000 --- a/third_party/zstd/build/cmake/lib/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# cmake build artefact -libzstd.pc diff --git a/third_party/zstd/build/cmake/lib/CMakeLists.txt b/third_party/zstd/build/cmake/lib/CMakeLists.txt deleted file mode 100644 index 457b54797..000000000 --- a/third_party/zstd/build/cmake/lib/CMakeLists.txt +++ /dev/null @@ -1,219 +0,0 @@ -# ################################################################ -# Copyright (c) Meta Platforms, Inc. and affiliates. -# All rights reserved. -# -# This source code is licensed under both the BSD-style license (found in the -# LICENSE file in the root directory of this source tree) and the GPLv2 (found -# in the COPYING file in the root directory of this source tree). -# ################################################################ - -project(libzstd C ASM) - -set(CMAKE_INCLUDE_CURRENT_DIR TRUE) -option(ZSTD_BUILD_STATIC "BUILD STATIC LIBRARIES" ON) -option(ZSTD_BUILD_SHARED "BUILD SHARED LIBRARIES" ON) -option(ZSTD_BUILD_COMPRESSION "BUILD COMPRESSION MODULE" ON) -option(ZSTD_BUILD_DECOMPRESSION "BUILD DECOMPRESSION MODUEL" ON) -option(ZSTD_BUILD_DICTBUILDER "BUILD DICTBUILDER MODULE" ON) -option(ZSTD_BUILD_DEPRECATED "BUILD DEPRECATED MODULE" OFF) - -set(ZSTDLIB_VISIBLE "" CACHE STRING "Visiblity for ZSTDLIB API") -set(ZSTDERRORLIB_VISIBLE "" CACHE STRING "Visiblity for ZSTDERRORLIB_VISIBLE API") -set(ZDICTLIB_VISIBLE "" CACHE STRING "Visiblity for ZDICTLIB_VISIBLE API") -set(ZSTDLIB_STATIC_API "" CACHE STRING "Visiblity for ZSTDLIB_STATIC_API API") -set(ZDICTLIB_STATIC_API "" CACHE STRING "Visiblity for ZDICTLIB_STATIC_API API") - -set_property(CACHE ZSTDLIB_VISIBLE PROPERTY STRINGS "" "hidden" "default" "protected" "internal") -set_property(CACHE ZSTDERRORLIB_VISIBLE PROPERTY STRINGS "" "hidden" "default" "protected" "internal") -set_property(CACHE ZDICTLIB_VISIBLE PROPERTY STRINGS "" "hidden" "default" "protected" "internal") -set_property(CACHE ZSTDLIB_STATIC_API PROPERTY STRINGS "" "hidden" "default" "protected" "internal") -set_property(CACHE ZDICTLIB_STATIC_API PROPERTY STRINGS "" "hidden" "default" "protected" "internal") - -if(NOT ZSTD_BUILD_SHARED AND NOT ZSTD_BUILD_STATIC) - message(SEND_ERROR "You need to build at least one flavor of libzstd") -endif() - -# Define library directory, where sources and header files are located -include_directories(${LIBRARY_DIR} ${LIBRARY_DIR}/common) - -file(GLOB CommonSources ${LIBRARY_DIR}/common/*.c) -file(GLOB CompressSources ${LIBRARY_DIR}/compress/*.c) -if (MSVC) - file(GLOB DecompressSources ${LIBRARY_DIR}/decompress/*.c) - add_compile_options(-DZSTD_DISABLE_ASM) -else () - file(GLOB DecompressSources ${LIBRARY_DIR}/decompress/*.c ${LIBRARY_DIR}/decompress/*.S) -endif () -file(GLOB DictBuilderSources ${LIBRARY_DIR}/dictBuilder/*.c) -file(GLOB DeprecatedSources ${LIBRARY_DIR}/deprecated/*.c) - -file(GLOB CommonHeaders ${LIBRARY_DIR}/common/*.h) -file(GLOB CompressHeaders ${LIBRARY_DIR}/compress/*.h) -file(GLOB DecompressHeaders ${LIBRARY_DIR}/decompress/*.h) -file(GLOB DictBuilderHeaders ${LIBRARY_DIR}/dictBuilder/*.h) -file(GLOB DeprecatedHeaders ${LIBRARY_DIR}/deprecated/*.h) - -set(Sources ${CommonSources}) -set(Headers ${LIBRARY_DIR}/zstd.h ${CommonHeaders}) -if (ZSTD_BUILD_COMPRESSION) - set(Sources ${Sources} ${CompressSources}) - set(Headers ${Headers} ${CompressHeaders}) -endif() -if (ZSTD_BUILD_DECOMPRESSION) - set(Sources ${Sources} ${DecompressSources}) - set(Headers ${Headers} ${DecompressHeaders}) -endif() -if (ZSTD_BUILD_DICTBUILDER) - set(Sources ${Sources} ${DictBuilderSources}) - set(Headers ${Headers} ${DictBuilderHeaders}) -endif() -if (ZSTD_BUILD_DEPRECATED) - set(Sources ${Sources} ${DeprecatedSources}) - set(Headers ${Headers} ${DeprecatedHeaders}) -endif() - -if (ZSTD_LEGACY_SUPPORT) - set(LIBRARY_LEGACY_DIR ${LIBRARY_DIR}/legacy) - include_directories(${LIBRARY_LEGACY_DIR}) - - set(Sources ${Sources} - ${LIBRARY_LEGACY_DIR}/zstd_v01.c - ${LIBRARY_LEGACY_DIR}/zstd_v02.c - ${LIBRARY_LEGACY_DIR}/zstd_v03.c - ${LIBRARY_LEGACY_DIR}/zstd_v04.c - ${LIBRARY_LEGACY_DIR}/zstd_v05.c - ${LIBRARY_LEGACY_DIR}/zstd_v06.c - ${LIBRARY_LEGACY_DIR}/zstd_v07.c) - - set(Headers ${Headers} - ${LIBRARY_LEGACY_DIR}/zstd_legacy.h - ${LIBRARY_LEGACY_DIR}/zstd_v01.h - ${LIBRARY_LEGACY_DIR}/zstd_v02.h - ${LIBRARY_LEGACY_DIR}/zstd_v03.h - ${LIBRARY_LEGACY_DIR}/zstd_v04.h - ${LIBRARY_LEGACY_DIR}/zstd_v05.h - ${LIBRARY_LEGACY_DIR}/zstd_v06.h - ${LIBRARY_LEGACY_DIR}/zstd_v07.h) -endif () - -if (MSVC) - set(MSVC_RESOURCE_DIR ${ZSTD_SOURCE_DIR}/build/VS2010/libzstd-dll) - set(PlatformDependResources ${MSVC_RESOURCE_DIR}/libzstd-dll.rc) -endif () - -# Explicitly set the language to C for all files, including ASM files. -# Our assembly expects to be compiled by a C compiler, and is only enabled for -# __GNUC__ compatible compilers. Otherwise all the ASM code is disabled by -# macros. -set_source_files_properties(${Sources} PROPERTIES LANGUAGE C) - -macro (add_definition target var) - if (NOT ("${${var}}" STREQUAL "")) - set_property(TARGET ${target} APPEND PROPERTY COMPILE_DEFINITIONS "${var}=__attribute__((visibility(\"${${var}}\")))") - endif () -endmacro () - -# Split project to static and shared libraries build -set(library_targets) -if (ZSTD_BUILD_SHARED) - add_library(libzstd_shared SHARED ${Sources} ${Headers} ${PlatformDependResources}) - list(APPEND library_targets libzstd_shared) - if (ZSTD_MULTITHREAD_SUPPORT) - set_property(TARGET libzstd_shared APPEND PROPERTY COMPILE_DEFINITIONS "ZSTD_MULTITHREAD") - if (UNIX) - target_link_libraries(libzstd_shared ${THREADS_LIBS}) - endif () - endif () - add_definition(libzstd_shared ZSTDLIB_VISIBLE) - add_definition(libzstd_shared ZSTDERRORLIB_VISIBLE) - add_definition(libzstd_shared ZDICTLIB_VISIBLE) -endif () -if (ZSTD_BUILD_STATIC) - add_library(libzstd_static STATIC ${Sources} ${Headers}) - list(APPEND library_targets libzstd_static) - if (ZSTD_MULTITHREAD_SUPPORT) - set_property(TARGET libzstd_static APPEND PROPERTY COMPILE_DEFINITIONS "ZSTD_MULTITHREAD") - if (UNIX) - target_link_libraries(libzstd_static ${THREADS_LIBS}) - endif () - endif () - add_definition(libzstd_static ZSTDLIB_VISIBLE) - add_definition(libzstd_static ZSTDERRORLIB_VISIBLE) - add_definition(libzstd_static ZDICTLIB_VISIBLE) - add_definition(libzstd_static ZSTDLIB_STATIC_API) - add_definition(libzstd_static ZDICTLIB_STATIC_API) -endif () - -# Add specific compile definitions for MSVC project -if (MSVC) - if (ZSTD_BUILD_SHARED) - set_property(TARGET libzstd_shared APPEND PROPERTY COMPILE_DEFINITIONS "ZSTD_DLL_EXPORT=1;ZSTD_HEAPMODE=0;_CONSOLE;_CRT_SECURE_NO_WARNINGS") - endif () - if (ZSTD_BUILD_STATIC) - set_property(TARGET libzstd_static APPEND PROPERTY COMPILE_DEFINITIONS "ZSTD_HEAPMODE=0;_CRT_SECURE_NO_WARNINGS") - endif () -endif () - -# With MSVC static library needs to be renamed to avoid conflict with import library -if (MSVC OR (WIN32 AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND NOT MINGW)) - set(STATIC_LIBRARY_BASE_NAME zstd_static) -else () - set(STATIC_LIBRARY_BASE_NAME zstd) -endif () - -# Define static and shared library names -if (ZSTD_BUILD_SHARED) - set_target_properties( - libzstd_shared - PROPERTIES - OUTPUT_NAME zstd - VERSION ${zstd_VERSION_MAJOR}.${zstd_VERSION_MINOR}.${zstd_VERSION_PATCH} - SOVERSION ${zstd_VERSION_MAJOR}) -endif () - -if (ZSTD_BUILD_STATIC) - set_target_properties( - libzstd_static - PROPERTIES - POSITION_INDEPENDENT_CODE On - OUTPUT_NAME ${STATIC_LIBRARY_BASE_NAME}) -endif () - -# pkg-config -include(JoinPaths) # can be replaced by cmake_path(APPEND) in CMake 3.20 -set(PREFIX "${CMAKE_INSTALL_PREFIX}") -set(EXEC_PREFIX "\${prefix}") -join_paths(LIBDIR "\${exec_prefix}" "${CMAKE_INSTALL_LIBDIR}") -join_paths(INCLUDEDIR "\${prefix}" "${CMAKE_INSTALL_INCLUDEDIR}") -set(LIBS_PRIVATE "${THREADS_LIBS}") -set(VERSION "${zstd_VERSION}") - -configure_file("${LIBRARY_DIR}/libzstd.pc.in" "${CMAKE_CURRENT_BINARY_DIR}/libzstd.pc" @ONLY) -install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libzstd.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") - -# install target -install(FILES - "${LIBRARY_DIR}/zstd.h" - "${LIBRARY_DIR}/zdict.h" - "${LIBRARY_DIR}/zstd_errors.h" - DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") - -install(TARGETS ${library_targets} - EXPORT zstdExports - INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" - ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" - LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" - RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" - BUNDLE DESTINATION "${CMAKE_INSTALL_BINDIR}" - ) - -# uninstall target -if (NOT TARGET uninstall) - configure_file( - "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in" - "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" - IMMEDIATE @ONLY) - - add_custom_target(uninstall - COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake) -endif () diff --git a/third_party/zstd/build/cmake/lib/cmake_uninstall.cmake.in b/third_party/zstd/build/cmake/lib/cmake_uninstall.cmake.in deleted file mode 100644 index 9f1d045dd..000000000 --- a/third_party/zstd/build/cmake/lib/cmake_uninstall.cmake.in +++ /dev/null @@ -1,22 +0,0 @@ - -if(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt") - message(FATAL_ERROR "Cannot find install manifest: @CMAKE_BINARY_DIR@/install_manifest.txt") -endif() - -file(READ "@CMAKE_BINARY_DIR@/install_manifest.txt" files) -string(REGEX REPLACE "\n" ";" files "${files}") -foreach(file ${files}) - message(STATUS "Uninstalling $ENV{DESTDIR}${file}") - if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") - exec_program( - "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" - OUTPUT_VARIABLE rm_out - RETURN_VALUE rm_retval - ) - if(NOT "${rm_retval}" STREQUAL 0) - message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}") - endif() - else() - message(STATUS "File $ENV{DESTDIR}${file} does not exist.") - endif() -endforeach() diff --git a/third_party/zstd/build/cmake/programs/.gitignore b/third_party/zstd/build/cmake/programs/.gitignore deleted file mode 100644 index ae3a8a356..000000000 --- a/third_party/zstd/build/cmake/programs/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -# produced by make -zstd -zstd-frugal -unzstd -zstdcat diff --git a/third_party/zstd/build/cmake/programs/CMakeLists.txt b/third_party/zstd/build/cmake/programs/CMakeLists.txt deleted file mode 100644 index 58d998e42..000000000 --- a/third_party/zstd/build/cmake/programs/CMakeLists.txt +++ /dev/null @@ -1,137 +0,0 @@ -# ################################################################ -# Copyright (c) Meta Platforms, Inc. and affiliates. -# All rights reserved. -# -# This source code is licensed under both the BSD-style license (found in the -# LICENSE file in the root directory of this source tree) and the GPLv2 (found -# in the COPYING file in the root directory of this source tree). -# ################################################################ - -project(programs C) - -set(CMAKE_INCLUDE_CURRENT_DIR TRUE) - -# Define programs directory, where sources and header files are located -set(LIBRARY_DIR ${ZSTD_SOURCE_DIR}/lib) -set(PROGRAMS_DIR ${ZSTD_SOURCE_DIR}/programs) -include_directories(${PROGRAMS_DIR} ${LIBRARY_DIR} ${LIBRARY_DIR}/common ${LIBRARY_DIR}/compress ${LIBRARY_DIR}/dictBuilder) - -if (ZSTD_LEGACY_SUPPORT) - set(PROGRAMS_LEGACY_DIR ${PROGRAMS_DIR}/legacy) - include_directories(${PROGRAMS_LEGACY_DIR} ${LIBRARY_DIR}/legacy) -endif () - -if (ZSTD_PROGRAMS_LINK_SHARED) - set(PROGRAMS_ZSTD_LINK_TARGET libzstd_shared) -else () - set(PROGRAMS_ZSTD_LINK_TARGET libzstd_static) -endif () - -if (MSVC) - set(MSVC_RESOURCE_DIR ${ZSTD_SOURCE_DIR}/build/VS2010/zstd) - set(PlatformDependResources ${MSVC_RESOURCE_DIR}/zstd.rc) -endif () - -add_executable(zstd ${PROGRAMS_DIR}/zstdcli.c ${PROGRAMS_DIR}/util.c ${PROGRAMS_DIR}/timefn.c ${PROGRAMS_DIR}/fileio.c ${PROGRAMS_DIR}/fileio_asyncio.c ${PROGRAMS_DIR}/benchfn.c ${PROGRAMS_DIR}/benchzstd.c ${PROGRAMS_DIR}/datagen.c ${PROGRAMS_DIR}/dibio.c ${PROGRAMS_DIR}/zstdcli_trace.c ${PlatformDependResources}) -target_link_libraries(zstd ${PROGRAMS_ZSTD_LINK_TARGET}) -if (CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)") - target_link_libraries(zstd rt) -endif () -install(TARGETS zstd - RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" - BUNDLE DESTINATION "${CMAKE_INSTALL_BINDIR}") - -if (UNIX) - add_custom_target(zstdcat ALL ${CMAKE_COMMAND} -E create_symlink zstd zstdcat DEPENDS zstd COMMENT "Creating zstdcat symlink") - add_custom_target(unzstd ALL ${CMAKE_COMMAND} -E create_symlink zstd unzstd DEPENDS zstd COMMENT "Creating unzstd symlink") - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/zstdcat DESTINATION "${CMAKE_INSTALL_BINDIR}") - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/unzstd DESTINATION "${CMAKE_INSTALL_BINDIR}") - install(PROGRAMS ${PROGRAMS_DIR}/zstdgrep DESTINATION "${CMAKE_INSTALL_BINDIR}") - install(PROGRAMS ${PROGRAMS_DIR}/zstdless DESTINATION "${CMAKE_INSTALL_BINDIR}") - - add_custom_target(zstd.1 ALL - ${CMAKE_COMMAND} -E copy ${PROGRAMS_DIR}/zstd.1 . - COMMENT "Copying manpage zstd.1") - add_custom_target(zstdgrep.1 ALL - ${CMAKE_COMMAND} -E copy ${PROGRAMS_DIR}/zstdgrep.1 . - COMMENT "Copying manpage zstdgrep.1") - add_custom_target(zstdless.1 ALL - ${CMAKE_COMMAND} -E copy ${PROGRAMS_DIR}/zstdless.1 . - COMMENT "Copying manpage zstdless.1") - add_custom_target(zstdcat.1 ALL ${CMAKE_COMMAND} -E create_symlink zstd.1 zstdcat.1 DEPENDS zstd.1 COMMENT "Creating zstdcat.1 symlink") - add_custom_target(unzstd.1 ALL ${CMAKE_COMMAND} -E create_symlink zstd.1 unzstd.1 DEPENDS zstd.1 COMMENT "Creating unzstd.1 symlink") - - # Define MAN_INSTALL_DIR if necessary - if (MAN_INSTALL_DIR) - else () - set(MAN_INSTALL_DIR ${CMAKE_INSTALL_MANDIR}/man1) - endif () - - install(FILES - ${CMAKE_CURRENT_BINARY_DIR}/zstd.1 - ${CMAKE_CURRENT_BINARY_DIR}/zstdcat.1 - ${CMAKE_CURRENT_BINARY_DIR}/unzstd.1 - ${CMAKE_CURRENT_BINARY_DIR}/zstdgrep.1 - ${CMAKE_CURRENT_BINARY_DIR}/zstdless.1 - DESTINATION "${MAN_INSTALL_DIR}") - - add_executable(zstd-frugal ${PROGRAMS_DIR}/zstdcli.c ${PROGRAMS_DIR}/util.c ${PROGRAMS_DIR}/timefn.c ${PROGRAMS_DIR}/fileio.c ${PROGRAMS_DIR}/fileio_asyncio.c) - target_link_libraries(zstd-frugal ${PROGRAMS_ZSTD_LINK_TARGET}) - set_property(TARGET zstd-frugal APPEND PROPERTY COMPILE_DEFINITIONS "ZSTD_NOBENCH;ZSTD_NODICT;ZSTD_NOTRACE") -endif () - -# Add multi-threading support definitions - -if (ZSTD_MULTITHREAD_SUPPORT) - set_property(TARGET zstd APPEND PROPERTY COMPILE_DEFINITIONS "ZSTD_MULTITHREAD") - - if (UNIX) - target_link_libraries(zstd ${THREADS_LIBS}) - - add_custom_target(zstdmt ALL ${CMAKE_COMMAND} -E create_symlink zstd zstdmt DEPENDS zstd COMMENT "Creating zstdmt symlink") - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/zstdmt DESTINATION "${CMAKE_INSTALL_BINDIR}") - endif () -endif () - -option(ZSTD_ZLIB_SUPPORT "ZLIB SUPPORT" OFF) -option(ZSTD_LZMA_SUPPORT "LZMA SUPPORT" OFF) -option(ZSTD_LZ4_SUPPORT "LZ4 SUPPORT" OFF) - -# Add gzip support -if (ZSTD_ZLIB_SUPPORT) - find_package(ZLIB REQUIRED) - - if (ZLIB_FOUND) - include_directories(${ZLIB_INCLUDE_DIRS}) - target_link_libraries(zstd ${ZLIB_LIBRARIES}) - set_property(TARGET zstd APPEND PROPERTY COMPILE_DEFINITIONS "ZSTD_GZCOMPRESS;ZSTD_GZDECOMPRESS") - else () - message(SEND_ERROR "zlib library is missing") - endif () -endif () - -# Add lzma support -if (ZSTD_LZMA_SUPPORT) - find_package(LibLZMA REQUIRED) - - if (LIBLZMA_FOUND) - include_directories(${LIBLZMA_INCLUDE_DIRS}) - target_link_libraries(zstd ${LIBLZMA_LIBRARIES}) - set_property(TARGET zstd APPEND PROPERTY COMPILE_DEFINITIONS "ZSTD_LZMACOMPRESS;ZSTD_LZMADECOMPRESS") - else () - message(SEND_ERROR "lzma library is missing") - endif () -endif () - -# Add lz4 support -if (ZSTD_LZ4_SUPPORT) - find_package(LibLZ4 REQUIRED) - - if (LIBLZ4_FOUND) - include_directories(${LIBLZ4_INCLUDE_DIRS}) - target_link_libraries(zstd ${LIBLZ4_LIBRARIES}) - set_property(TARGET zstd APPEND PROPERTY COMPILE_DEFINITIONS "ZSTD_LZ4COMPRESS;ZSTD_LZ4DECOMPRESS") - else () - message(SEND_ERROR "lz4 library is missing") - endif () -endif () diff --git a/third_party/zstd/build/cmake/tests/.gitignore b/third_party/zstd/build/cmake/tests/.gitignore deleted file mode 100644 index ca2947f61..000000000 --- a/third_party/zstd/build/cmake/tests/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -# produced by make -datagen -fullbench -fuzzer -paramgrill - diff --git a/third_party/zstd/build/cmake/tests/CMakeLists.txt b/third_party/zstd/build/cmake/tests/CMakeLists.txt deleted file mode 100644 index 250f0508f..000000000 --- a/third_party/zstd/build/cmake/tests/CMakeLists.txt +++ /dev/null @@ -1,118 +0,0 @@ -# ################################################################ -# zstd - Makefile -# Copyright (c) Meta Platforms, Inc. and affiliates. -# All rights reserved. -# -# BSD license -# -# 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. -# -# You can contact the author at : -# - zstd homepage : https://facebook.github.io/zstd/ -# ################################################################ - -project(tests) - -# name: Cache variable name. The value is expected to be a semicolon-separated -# list of command line flags -# default_value: Value to initialize the option with. Can be space separated. -function(AddTestFlagsOption name default_value doc) - string(STRIP "${default_value}" default_value) - string(REGEX REPLACE " +" ";" default_value "${default_value}") - set(${name} ${default_value} CACHE STRING "${doc}") - mark_as_advanced(${name}) -endfunction() - -set(CMAKE_INCLUDE_CURRENT_DIR TRUE) - -# Define programs directory, where sources and header files are located -set(LIBRARY_DIR ${ZSTD_SOURCE_DIR}/lib) -set(PROGRAMS_DIR ${ZSTD_SOURCE_DIR}/programs) -set(TESTS_DIR ${ZSTD_SOURCE_DIR}/tests) -include_directories(${TESTS_DIR} ${PROGRAMS_DIR} ${LIBRARY_DIR} ${LIBRARY_DIR}/common ${LIBRARY_DIR}/compress ${LIBRARY_DIR}/dictBuilder) - -add_executable(datagen ${PROGRAMS_DIR}/datagen.c ${TESTS_DIR}/datagencli.c) -target_link_libraries(datagen libzstd_static) - -# -# fullbench -# -add_executable(fullbench ${PROGRAMS_DIR}/datagen.c ${PROGRAMS_DIR}/util.c ${PROGRAMS_DIR}/timefn.c ${PROGRAMS_DIR}/benchfn.c ${PROGRAMS_DIR}/benchzstd.c ${TESTS_DIR}/fullbench.c) -if (NOT MSVC) - target_compile_options(fullbench PRIVATE "-Wno-deprecated-declarations") -endif() -target_link_libraries(fullbench libzstd_static) -add_test(NAME fullbench COMMAND fullbench ${ZSTD_FULLBENCH_FLAGS}) - -# -# fuzzer -# -add_executable(fuzzer ${PROGRAMS_DIR}/datagen.c ${PROGRAMS_DIR}/util.c ${PROGRAMS_DIR}/timefn.c ${TESTS_DIR}/fuzzer.c) -if (NOT MSVC) - target_compile_options(fuzzer PRIVATE "-Wno-deprecated-declarations") -endif() -target_link_libraries(fuzzer libzstd_static) -AddTestFlagsOption(ZSTD_FUZZER_FLAGS "$ENV{FUZZERTEST} $ENV{FUZZER_FLAGS}" - "Semicolon-separated list of flags to pass to the fuzzer test (see `fuzzer -h` for usage)") -add_test(NAME fuzzer COMMAND fuzzer ${ZSTD_FUZZER_FLAGS}) -# Disable the timeout since the run time is too long for the default timeout of -# 1500 seconds and varies considerably between low-end and high-end CPUs. -# set_tests_properties(fuzzer PROPERTIES TIMEOUT 0) - -# -# zstreamtest -# -add_executable(zstreamtest ${PROGRAMS_DIR}/datagen.c ${PROGRAMS_DIR}/util.c ${PROGRAMS_DIR}/timefn.c ${TESTS_DIR}/seqgen.c ${TESTS_DIR}/zstreamtest.c ${TESTS_DIR}/external_matchfinder.c) -if (NOT MSVC) - target_compile_options(zstreamtest PRIVATE "-Wno-deprecated-declarations") -endif() -target_link_libraries(zstreamtest libzstd_static) -AddTestFlagsOption(ZSTD_ZSTREAM_FLAGS "$ENV{ZSTREAM_TESTTIME} $ENV{FUZZER_FLAGS}" - "Semicolon-separated list of flags to pass to the zstreamtest test (see `zstreamtest -h` for usage)") -add_test(NAME zstreamtest COMMAND zstreamtest ${ZSTD_ZSTREAM_FLAGS}) - -# -# playTests.sh -# -AddTestFlagsOption(ZSTD_PLAYTESTS_FLAGS "$ENV{PLAYTESTS_FLAGS}" - "Semicolon-separated list of flags to pass to the playTests.sh test") -add_test(NAME playTests COMMAND sh -c "\"${TESTS_DIR}/playTests.sh\" ${ZSTD_PLAYTESTS_FLAGS}") -find_program(UNAME uname) # Run script only in unix shell environments -if (ZSTD_BUILD_PROGRAMS AND UNAME) - set_property(TEST playTests APPEND PROPERTY ENVIRONMENT - "ZSTD_BIN=$" - "DATAGEN_BIN=$" - ) -else() - message(STATUS "Disabling playTests.sh test because requirements not met") - set_tests_properties(playTests PROPERTIES DISABLED YES) -endif() - -# Label the "Medium" set of tests (see TESTING.md) -set_property(TEST fuzzer zstreamtest playTests APPEND PROPERTY LABELS Medium) - -add_executable(paramgrill ${PROGRAMS_DIR}/benchfn.c ${PROGRAMS_DIR}/benchzstd.c ${PROGRAMS_DIR}/datagen.c ${PROGRAMS_DIR}/util.c ${PROGRAMS_DIR}/timefn.c ${TESTS_DIR}/paramgrill.c) -if (UNIX) - target_link_libraries(paramgrill libzstd_static m) #m is math library -else() - target_link_libraries(paramgrill libzstd_static) -endif () diff --git a/third_party/zstd/build/cmake/zstdConfig.cmake b/third_party/zstd/build/cmake/zstdConfig.cmake deleted file mode 100644 index ebbfcc38f..000000000 --- a/third_party/zstd/build/cmake/zstdConfig.cmake +++ /dev/null @@ -1 +0,0 @@ -include("${CMAKE_CURRENT_LIST_DIR}/zstdTargets.cmake") diff --git a/third_party/zstd/build/meson/GetZstdLibraryVersion.py b/third_party/zstd/build/meson/GetZstdLibraryVersion.py deleted file mode 100644 index 461af5f9c..000000000 --- a/third_party/zstd/build/meson/GetZstdLibraryVersion.py +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/env python3 -# ############################################################################# -# Copyright (c) 2018-present lzutao -# All rights reserved. -# -# This source code is licensed under both the BSD-style license (found in the -# LICENSE file in the root directory of this source tree) and the GPLv2 (found -# in the COPYING file in the root directory of this source tree). -# ############################################################################# -import re - - -def find_version_tuple(filepath): - version_file_data = None - with open(filepath) as fd: - version_file_data = fd.read() - - patterns = r"""#\s*define\s+ZSTD_VERSION_MAJOR\s+([0-9]+) -#\s*define\s+ZSTD_VERSION_MINOR\s+([0-9]+) -#\s*define\s+ZSTD_VERSION_RELEASE\s+([0-9]+) -""" - regex = re.compile(patterns, re.MULTILINE) - version_match = regex.search(version_file_data) - if version_match: - return version_match.groups() - raise Exception("Unable to find version string") - - -def main(): - import argparse - parser = argparse.ArgumentParser(description='Print zstd version from lib/zstd.h') - parser.add_argument('file', help='path to lib/zstd.h') - args = parser.parse_args() - version_tuple = find_version_tuple(args.file) - print('.'.join(version_tuple)) - - -if __name__ == '__main__': - main() diff --git a/third_party/zstd/build/meson/InstallSymlink.py b/third_party/zstd/build/meson/InstallSymlink.py deleted file mode 100644 index 3f2998c64..000000000 --- a/third_party/zstd/build/meson/InstallSymlink.py +++ /dev/null @@ -1,55 +0,0 @@ -#!/usr/bin/env python3 -# ############################################################################# -# Copyright (c) 2018-present lzutao -# All rights reserved. -# -# This source code is licensed under both the BSD-style license (found in the -# LICENSE file in the root directory of this source tree) and the GPLv2 (found -# in the COPYING file in the root directory of this source tree). -# ############################################################################# -# This file should be synced with https://github.com/lzutao/meson-symlink - -import os -import pathlib # since Python 3.4 - - -def install_symlink(src, dst, install_dir, dst_is_dir=False, dir_mode=0o777): - if not install_dir.exists(): - install_dir.mkdir(mode=dir_mode, parents=True, exist_ok=True) - if not install_dir.is_dir(): - raise NotADirectoryError(install_dir) - - new_dst = install_dir.joinpath(dst) - if new_dst.is_symlink() and os.readlink(new_dst) == src: - print('File exists: {!r} -> {!r}'.format(new_dst, src)) - return - print('Installing symlink {!r} -> {!r}'.format(new_dst, src)) - new_dst.symlink_to(src, target_is_directory=dst_is_dir) - - -def main(): - import argparse - parser = argparse.ArgumentParser(description='Install a symlink', - usage='{0} [-h] [-d] [-m MODE] source dest install_dir\n\n' - 'example:\n' - ' {0} dash sh /bin'.format(pathlib.Path(__file__).name)) - parser.add_argument('source', help='target to link') - parser.add_argument('dest', help='link name') - parser.add_argument('install_dir', help='installation directory') - parser.add_argument('-d', '--isdir', - action='store_true', - help='dest is a directory') - parser.add_argument('-m', '--mode', - help='directory mode on creating if not exist', - default='0o755') - args = parser.parse_args() - - dir_mode = int(args.mode, 8) - - meson_destdir = os.environ.get('MESON_INSTALL_DESTDIR_PREFIX', default='') - install_dir = pathlib.Path(meson_destdir, args.install_dir) - install_symlink(args.source, args.dest, install_dir, args.isdir, dir_mode) - - -if __name__ == '__main__': - main() diff --git a/third_party/zstd/build/meson/README.md b/third_party/zstd/build/meson/README.md deleted file mode 100644 index d393a063f..000000000 --- a/third_party/zstd/build/meson/README.md +++ /dev/null @@ -1,38 +0,0 @@ -Meson build system for zstandard -================================ - -Meson is a build system designed to optimize programmer productivity. -It aims to do this by providing simple, out-of-the-box support for -modern software development tools and practices, such as unit tests, -coverage reports, Valgrind, CCache and the like. - -This Meson build system is provided with no guarantee and maintained -by Dima Krasner \. - -It outputs one `libzstd`, either shared or static, depending on -`default_library` option. - -## How to build - -`cd` to this meson directory (`build/meson`) - -```sh -meson setup -Dbin_programs=true -Dbin_contrib=true builddir -cd builddir -ninja # to build -ninja install # to install -``` - -You might want to install it in staging directory: - -```sh -DESTDIR=./staging ninja install -``` - -To configure build options, use: - -```sh -meson configure -``` - -See [man meson(1)](https://manpages.debian.org/testing/meson/meson.1.en.html). diff --git a/third_party/zstd/build/meson/contrib/gen_html/meson.build b/third_party/zstd/build/meson/contrib/gen_html/meson.build deleted file mode 100644 index 3f302538d..000000000 --- a/third_party/zstd/build/meson/contrib/gen_html/meson.build +++ /dev/null @@ -1,30 +0,0 @@ -# ############################################################################# -# Copyright (c) 2018-present lzutao -# All rights reserved. -# -# This source code is licensed under both the BSD-style license (found in the -# LICENSE file in the root directory of this source tree) and the GPLv2 (found -# in the COPYING file in the root directory of this source tree). -# ############################################################################# - -zstd_rootdir = '../../../..' - -gen_html_includes = include_directories(join_paths(zstd_rootdir, 'programs'), - join_paths(zstd_rootdir, 'lib'), - join_paths(zstd_rootdir, 'lib/common'), - join_paths(zstd_rootdir, 'contrib/gen_html')) - -gen_html = executable('gen_html', - join_paths(zstd_rootdir, 'contrib/gen_html/gen_html.cpp'), - include_directories: gen_html_includes, - native: true, - install: false) - -# Update zstd manual -zstd_manual_html = custom_target('zstd_manual.html', - output : 'zstd_manual.html', - command : [gen_html, - zstd_version, - join_paths(meson.current_source_dir(), zstd_rootdir, 'lib/zstd.h'), - '@OUTPUT@'], - install : false) diff --git a/third_party/zstd/build/meson/contrib/meson.build b/third_party/zstd/build/meson/contrib/meson.build deleted file mode 100644 index 7f6d03a4c..000000000 --- a/third_party/zstd/build/meson/contrib/meson.build +++ /dev/null @@ -1,12 +0,0 @@ -# ############################################################################# -# Copyright (c) 2018-present Dima Krasner -# lzutao -# All rights reserved. -# -# This source code is licensed under both the BSD-style license (found in the -# LICENSE file in the root directory of this source tree) and the GPLv2 (found -# in the COPYING file in the root directory of this source tree). -# ############################################################################# - -subdir('pzstd') -subdir('gen_html') diff --git a/third_party/zstd/build/meson/contrib/pzstd/meson.build b/third_party/zstd/build/meson/contrib/pzstd/meson.build deleted file mode 100644 index b95dc7964..000000000 --- a/third_party/zstd/build/meson/contrib/pzstd/meson.build +++ /dev/null @@ -1,25 +0,0 @@ -# ############################################################################# -# Copyright (c) 2018-present lzutao -# All rights reserved. -# -# This source code is licensed under both the BSD-style license (found in the -# LICENSE file in the root directory of this source tree) and the GPLv2 (found -# in the COPYING file in the root directory of this source tree). -# ############################################################################# - -zstd_rootdir = '../../../..' - -pzstd_includes = include_directories(join_paths(zstd_rootdir, 'programs'), - join_paths(zstd_rootdir, 'contrib/pzstd')) -pzstd_sources = [join_paths(zstd_rootdir, 'programs/util.c'), - join_paths(zstd_rootdir, 'contrib/pzstd/main.cpp'), - join_paths(zstd_rootdir, 'contrib/pzstd/Options.cpp'), - join_paths(zstd_rootdir, 'contrib/pzstd/Pzstd.cpp'), - join_paths(zstd_rootdir, 'contrib/pzstd/SkippableFrame.cpp')] -pzstd = executable('pzstd', - pzstd_sources, - cpp_args: pzstd_warning_flags, - include_directories: pzstd_includes, - dependencies: [ libzstd_dep, thread_dep ], - override_options: ['b_ndebug=true'], - install: true) diff --git a/third_party/zstd/build/meson/lib/meson.build b/third_party/zstd/build/meson/lib/meson.build deleted file mode 100644 index 68db2ca6c..000000000 --- a/third_party/zstd/build/meson/lib/meson.build +++ /dev/null @@ -1,167 +0,0 @@ -# ############################################################################# -# Copyright (c) 2018-present Dima Krasner -# lzutao -# All rights reserved. -# -# This source code is licensed under both the BSD-style license (found in the -# LICENSE file in the root directory of this source tree) and the GPLv2 (found -# in the COPYING file in the root directory of this source tree). -# ############################################################################# - -zstd_rootdir = '../../..' - -libzstd_includes = [include_directories(join_paths(zstd_rootdir,'lib'), - join_paths(zstd_rootdir, 'lib/common'), - join_paths(zstd_rootdir, 'lib/compress'), - join_paths(zstd_rootdir, 'lib/decompress'), - join_paths(zstd_rootdir, 'lib/dictBuilder'))] - -libzstd_sources = [join_paths(zstd_rootdir, 'lib/common/entropy_common.c'), - join_paths(zstd_rootdir, 'lib/common/fse_decompress.c'), - join_paths(zstd_rootdir, 'lib/common/threading.c'), - join_paths(zstd_rootdir, 'lib/common/pool.c'), - join_paths(zstd_rootdir, 'lib/common/zstd_common.c'), - join_paths(zstd_rootdir, 'lib/common/error_private.c'), - join_paths(zstd_rootdir, 'lib/common/xxhash.c'), - join_paths(zstd_rootdir, 'lib/compress/hist.c'), - join_paths(zstd_rootdir, 'lib/compress/fse_compress.c'), - join_paths(zstd_rootdir, 'lib/compress/huf_compress.c'), - join_paths(zstd_rootdir, 'lib/compress/zstd_compress.c'), - join_paths(zstd_rootdir, 'lib/compress/zstd_compress_literals.c'), - join_paths(zstd_rootdir, 'lib/compress/zstd_compress_sequences.c'), - join_paths(zstd_rootdir, 'lib/compress/zstd_compress_superblock.c'), - join_paths(zstd_rootdir, 'lib/compress/zstdmt_compress.c'), - join_paths(zstd_rootdir, 'lib/compress/zstd_fast.c'), - join_paths(zstd_rootdir, 'lib/compress/zstd_double_fast.c'), - join_paths(zstd_rootdir, 'lib/compress/zstd_lazy.c'), - join_paths(zstd_rootdir, 'lib/compress/zstd_opt.c'), - join_paths(zstd_rootdir, 'lib/compress/zstd_ldm.c'), - join_paths(zstd_rootdir, 'lib/decompress/huf_decompress.c'), - join_paths(zstd_rootdir, 'lib/decompress/zstd_decompress.c'), - join_paths(zstd_rootdir, 'lib/decompress/zstd_decompress_block.c'), - join_paths(zstd_rootdir, 'lib/decompress/zstd_ddict.c'), - join_paths(zstd_rootdir, 'lib/dictBuilder/cover.c'), - join_paths(zstd_rootdir, 'lib/dictBuilder/fastcover.c'), - join_paths(zstd_rootdir, 'lib/dictBuilder/divsufsort.c'), - join_paths(zstd_rootdir, 'lib/dictBuilder/zdict.c')] - -# really we need anything that defines __GNUC__ as that is what ZSTD_ASM_SUPPORTED is gated on -# but these are the two compilers that are supported in tree and actually handle this correctly -# Otherwise, explicitly disable assembly. -if [compiler_gcc, compiler_clang].contains(cc_id) - libzstd_sources += join_paths(zstd_rootdir, 'lib/decompress/huf_decompress_amd64.S') -else - add_project_arguments('-DZSTD_DISABLE_ASM', language: 'c') -endif - -# Explicit define legacy support -add_project_arguments('-DZSTD_LEGACY_SUPPORT=@0@'.format(legacy_level), - language: 'c') - -if legacy_level == 0 - message('Legacy support: DISABLED') -else - # See ZSTD_LEGACY_SUPPORT of lib/README.md - message('Enable legacy support back to version 0.@0@'.format(legacy_level)) - - libzstd_includes += [ include_directories(join_paths(zstd_rootdir, 'lib/legacy')) ] - foreach i : [1, 2, 3, 4, 5, 6, 7] - if legacy_level <= i - libzstd_sources += join_paths(zstd_rootdir, 'lib/legacy/zstd_v0@0@.c'.format(i)) - endif - endforeach -endif - -libzstd_deps = [] -if use_multi_thread - message('Enable multi-threading support') - add_project_arguments('-DZSTD_MULTITHREAD', language: 'c') - libzstd_deps = [ thread_dep ] -endif - -libzstd_c_args = [] -if cc_id == compiler_msvc - if default_library_type != 'static' - libzstd_sources += [windows_mod.compile_resources( - join_paths(zstd_rootdir, 'build/VS2010/libzstd-dll/libzstd-dll.rc'), - include_directories: libzstd_includes)] - libzstd_c_args += ['-DZSTD_DLL_EXPORT=1', - '-DZSTD_HEAPMODE=0', - '-D_CONSOLE', - '-D_CRT_SECURE_NO_WARNINGS'] - else - libzstd_c_args += ['-DZSTD_HEAPMODE=0', - '-D_CRT_SECURE_NO_WARNINGS'] - endif -endif - -mingw_ansi_stdio_flags = [] -if host_machine_os == os_windows and cc_id == compiler_gcc - mingw_ansi_stdio_flags = [ '-D__USE_MINGW_ANSI_STDIO' ] -endif -libzstd_c_args += mingw_ansi_stdio_flags - -libzstd_debug_cflags = [] -if use_debug - libzstd_c_args += '-DDEBUGLEVEL=@0@'.format(debug_level) - if cc_id == compiler_gcc or cc_id == compiler_clang - libzstd_debug_cflags = ['-Wstrict-aliasing=1', '-Wswitch-enum', - '-Wdeclaration-after-statement', '-Wstrict-prototypes', - '-Wundef', '-Wpointer-arith', '-Wvla', - '-Wformat=2', '-Winit-self', '-Wfloat-equal', '-Wwrite-strings', - '-Wredundant-decls', '-Wmissing-prototypes', '-Wc++-compat'] - endif -endif -libzstd_c_args += cc.get_supported_arguments(libzstd_debug_cflags) - -libzstd = library('zstd', - libzstd_sources, - include_directories: libzstd_includes, - c_args: libzstd_c_args, - gnu_symbol_visibility: 'hidden', - dependencies: libzstd_deps, - install: true, - version: zstd_libversion) - -libzstd_dep = declare_dependency(link_with: libzstd, - include_directories: libzstd_includes) - -# we link to both: -# - the shared library (for public symbols) -# - the static library (for private symbols) -# -# this is needed because internally private symbols are used all the time, and -# -fvisibility=hidden means those cannot be found -if get_option('default_library') == 'static' - libzstd_static = libzstd - libzstd_internal_dep = libzstd_dep -else - if get_option('default_library') == 'shared' - libzstd_static = static_library('zstd_objlib', - objects: libzstd.extract_all_objects(recursive: true), - build_by_default: false) - else - libzstd_static = libzstd.get_static_lib() - endif - - if cc_id == compiler_msvc - # msvc does not actually support linking to both, but errors out with: - # error LNK2005: ZSTD_ already defined in zstd.lib(zstd-1.dll) - libzstd_internal_dep = declare_dependency(link_with: libzstd_static) - else - libzstd_internal_dep = declare_dependency(link_with: libzstd, - # the static library must be linked after the shared one - dependencies: declare_dependency(link_with: libzstd_static)) - endif -endif - -pkgconfig.generate(libzstd, - name: 'libzstd', - filebase: 'libzstd', - description: 'fast lossless compression algorithm library', - version: zstd_libversion, - url: 'https://facebook.github.io/zstd/') - -install_headers(join_paths(zstd_rootdir, 'lib/zstd.h'), - join_paths(zstd_rootdir, 'lib/zdict.h'), - join_paths(zstd_rootdir, 'lib/zstd_errors.h')) diff --git a/third_party/zstd/build/meson/meson.build b/third_party/zstd/build/meson/meson.build deleted file mode 100644 index 15c56c2b1..000000000 --- a/third_party/zstd/build/meson/meson.build +++ /dev/null @@ -1,145 +0,0 @@ -# ############################################################################# -# Copyright (c) 2018-present Dima Krasner -# lzutao -# All rights reserved. -# -# This source code is licensed under both the BSD-style license (found in the -# LICENSE file in the root directory of this source tree) and the GPLv2 (found -# in the COPYING file in the root directory of this source tree). -# ############################################################################# - -project('zstd', - ['c', 'cpp'], - license: ['BSD', 'GPLv2'], - default_options : [ - # There shouldn't be any need to force a C standard convention for zstd - # but in case one would want that anyway, this can be done here. - # 'c_std=gnu99', - # c++11 standard is useful for pzstd - 'cpp_std=c++11', - 'buildtype=release', - 'warning_level=3', - # -Wdocumentation does not actually pass, nor do the test binaries, - # so this isn't safe - #'werror=true' - ], - version: run_command( - find_program('GetZstdLibraryVersion.py'), '../../lib/zstd.h', - check: true).stdout().strip(), - meson_version: '>=0.50.0') - -cc = meson.get_compiler('c') -cxx = meson.get_compiler('cpp') -pkgconfig = import('pkgconfig') -windows_mod = import('windows') - -host_machine_os = host_machine.system() -os_windows = 'windows' -os_linux = 'linux' -os_darwin = 'darwin' -os_freebsd = 'freebsd' -os_sun = 'sunos' - -cc_id = cc.get_id() -compiler_gcc = 'gcc' -compiler_clang = 'clang' -compiler_msvc = 'msvc' - -zstd_version = meson.project_version() - -zstd_libversion = zstd_version - -# ============================================================================= -# Installation directories -# ============================================================================= - -zstd_prefix = get_option('prefix') -zstd_bindir = get_option('bindir') -zstd_datadir = get_option('datadir') -zstd_mandir = get_option('mandir') -zstd_docdir = join_paths(zstd_datadir, 'doc', meson.project_name()) - -# ============================================================================= -# Project options -# ============================================================================= - -# Built-in options -use_debug = get_option('debug') -buildtype = get_option('buildtype') -default_library_type = get_option('default_library') - -# Custom options -debug_level = get_option('debug_level') -legacy_level = get_option('legacy_level') -use_backtrace = get_option('backtrace') -use_static_runtime = get_option('static_runtime') - -bin_programs = get_option('bin_programs') -bin_contrib = get_option('bin_contrib') -bin_tests = get_option('bin_tests') - -feature_multi_thread = get_option('multi_thread') -feature_zlib = get_option('zlib') -feature_lzma = get_option('lzma') -feature_lz4 = get_option('lz4') - -# ============================================================================= -# Dependencies -# ============================================================================= - -libm_dep = cc.find_library('m', required: false) -thread_dep = dependency('threads', required: feature_multi_thread) -use_multi_thread = thread_dep.found() -# Arguments in dependency should be equivalent to those passed to pkg-config -zlib_dep = dependency('zlib', required: feature_zlib) -use_zlib = zlib_dep.found() -lzma_dep = dependency('liblzma', required: feature_lzma) -use_lzma = lzma_dep.found() -lz4_dep = dependency('liblz4', required: feature_lz4) -use_lz4 = lz4_dep.found() - -# ============================================================================= -# Compiler flags -# ============================================================================= - -add_project_arguments('-DXXH_NAMESPACE=ZSTD_', language: ['c']) - -pzstd_warning_flags = [] -if [compiler_gcc, compiler_clang].contains(cc_id) - common_warning_flags = [ '-Wundef', '-Wshadow', '-Wcast-align', '-Wcast-qual' ] - pzstd_warning_flags = ['-Wno-shadow', '-Wno-deprecated-declarations'] - if cc_id == compiler_clang - common_warning_flags += ['-Wconversion', '-Wno-sign-conversion', '-Wdocumentation'] - endif - cc_compile_flags = cc.get_supported_arguments(common_warning_flags + ['-Wstrict-prototypes']) - cxx_compile_flags = cxx.get_supported_arguments(common_warning_flags) - add_project_arguments(cc_compile_flags, language : 'c') - add_project_arguments(cxx_compile_flags, language : 'cpp') -elif cc_id == compiler_msvc - msvc_compile_flags = [ '/D_UNICODE', '/DUNICODE' ] - if use_multi_thread - msvc_compile_flags += '/MP' - endif - if use_static_runtime - msvc_compile_flags += '/MT' - endif - add_project_arguments(msvc_compile_flags, language: ['c', 'cpp']) -endif - -# ============================================================================= -# Subdirs -# ============================================================================= - -subdir('lib') - -if bin_programs or bin_tests - subdir('programs') -endif - -if bin_tests - subdir('tests') -endif - -if bin_contrib - subdir('contrib') -endif diff --git a/third_party/zstd/build/meson/meson_options.txt b/third_party/zstd/build/meson/meson_options.txt deleted file mode 100644 index f35cd5fc8..000000000 --- a/third_party/zstd/build/meson/meson_options.txt +++ /dev/null @@ -1,36 +0,0 @@ -# ############################################################################# -# Copyright (c) 2018-present Dima Krasner -# lzutao -# All rights reserved. -# -# This source code is licensed under both the BSD-style license (found in the -# LICENSE file in the root directory of this source tree) and the GPLv2 (found -# in the COPYING file in the root directory of this source tree). -# ############################################################################# - -# Read guidelines from https://wiki.gnome.org/Initiatives/GnomeGoals/MesonPorting - -option('legacy_level', type: 'integer', min: 0, max: 7, value: 5, - description: 'Support any legacy format: 7 to 1 for v0.7+ to v0.1+') -option('debug_level', type: 'integer', min: 0, max: 9, value: 1, - description: 'Enable run-time debug. See lib/common/debug.h') -option('backtrace', type: 'feature', value: 'disabled', - description: 'Display a stack backtrace when execution generates a runtime exception') -option('static_runtime', type: 'boolean', value: false, - description: 'Link to static run-time libraries on MSVC') - -option('bin_programs', type: 'boolean', value: true, - description: 'Enable programs build') -option('bin_tests', type: 'boolean', value: false, - description: 'Enable tests build') -option('bin_contrib', type: 'boolean', value: false, - description: 'Enable contrib build') - -option('multi_thread', type: 'feature', value: 'enabled', - description: 'Enable multi-threading when pthread is detected') -option('zlib', type: 'feature', value: 'auto', - description: 'Enable zlib support') -option('lzma', type: 'feature', value: 'auto', - description: 'Enable lzma support') -option('lz4', type: 'feature', value: 'auto', - description: 'Enable lz4 support') diff --git a/third_party/zstd/build/meson/programs/meson.build b/third_party/zstd/build/meson/programs/meson.build deleted file mode 100644 index 0b5a93056..000000000 --- a/third_party/zstd/build/meson/programs/meson.build +++ /dev/null @@ -1,123 +0,0 @@ -# ############################################################################# -# Copyright (c) 2018-present Dima Krasner -# lzutao -# All rights reserved. -# -# This source code is licensed under both the BSD-style license (found in the -# LICENSE file in the root directory of this source tree) and the GPLv2 (found -# in the COPYING file in the root directory of this source tree). -# ############################################################################# - -zstd_rootdir = '../../..' - -zstd_programs_sources = [join_paths(zstd_rootdir, 'programs/zstdcli.c'), - join_paths(zstd_rootdir, 'programs/util.c'), - join_paths(zstd_rootdir, 'programs/timefn.c'), - join_paths(zstd_rootdir, 'programs/fileio.c'), - join_paths(zstd_rootdir, 'programs/fileio_asyncio.c'), - join_paths(zstd_rootdir, 'programs/benchfn.c'), - join_paths(zstd_rootdir, 'programs/benchzstd.c'), - join_paths(zstd_rootdir, 'programs/datagen.c'), - join_paths(zstd_rootdir, 'programs/dibio.c'), - join_paths(zstd_rootdir, 'programs/zstdcli_trace.c')] - -zstd_deps = [ libzstd_internal_dep ] -zstd_c_args = libzstd_debug_cflags - -zstd_frugal_deps = [ libzstd_internal_dep ] -zstd_frugal_c_args = [ '-DZSTD_NOBENCH', '-DZSTD_NODICT', '-DZSTD_NOTRACE' ] - -if use_multi_thread - zstd_deps += [ thread_dep ] - zstd_c_args += [ '-DZSTD_MULTITHREAD' ] - zstd_frugal_deps += [ thread_dep ] - zstd_frugal_c_args += [ '-DZSTD_MULTITHREAD' ] -endif - -if use_zlib - zstd_deps += [ zlib_dep ] - zstd_c_args += [ '-DZSTD_GZCOMPRESS', '-DZSTD_GZDECOMPRESS' ] -endif - -if use_lzma - zstd_deps += [ lzma_dep ] - zstd_c_args += [ '-DZSTD_LZMACOMPRESS', '-DZSTD_LZMADECOMPRESS' ] -endif - -if use_lz4 - zstd_deps += [ lz4_dep ] - zstd_c_args += [ '-DZSTD_LZ4COMPRESS', '-DZSTD_LZ4DECOMPRESS' ] -endif - -export_dynamic_on_windows = false -# explicit backtrace enable/disable for Linux & Darwin -have_execinfo = cc.has_header('execinfo.h', required: use_backtrace) -if not have_execinfo - zstd_c_args += '-DBACKTRACE_ENABLE=0' -elif use_debug and host_machine_os == os_windows # MinGW target - zstd_c_args += '-DBACKTRACE_ENABLE=1' - export_dynamic_on_windows = true -endif - -if cc_id == compiler_msvc - if default_library_type != 'static' - zstd_programs_sources += [windows_mod.compile_resources( - join_paths(zstd_rootdir, 'build/VS2010/zstd/zstd.rc'), - include_directories: libzstd_includes)] - endif -endif - -zstd = executable('zstd', - zstd_programs_sources, - c_args: zstd_c_args, - dependencies: zstd_deps, - export_dynamic: export_dynamic_on_windows, # Since Meson 0.45.0 - build_by_default: bin_programs, - install: bin_programs) - -if not bin_programs - # we generate rules to build the programs, but don't install anything - # so do not continue to installing scripts and manpages - subdir_done() -endif - -zstd_frugal_sources = [join_paths(zstd_rootdir, 'programs/zstdcli.c'), - join_paths(zstd_rootdir, 'programs/timefn.c'), - join_paths(zstd_rootdir, 'programs/util.c'), - join_paths(zstd_rootdir, 'programs/fileio.c'), - join_paths(zstd_rootdir, 'programs/fileio_asyncio.c')] - -# Minimal target, with only zstd compression and decompression. -# No bench. No legacy. -executable('zstd-frugal', - zstd_frugal_sources, - dependencies: zstd_frugal_deps, - c_args: zstd_frugal_c_args, - install: true) - -install_data(join_paths(zstd_rootdir, 'programs/zstdgrep'), - join_paths(zstd_rootdir, 'programs/zstdless'), - install_dir: zstd_bindir) - -# ============================================================================= -# Programs and manpages installing -# ============================================================================= - -install_man(join_paths(zstd_rootdir, 'programs/zstd.1'), - join_paths(zstd_rootdir, 'programs/zstdgrep.1'), - join_paths(zstd_rootdir, 'programs/zstdless.1')) - -InstallSymlink_py = '../InstallSymlink.py' -zstd_man1_dir = join_paths(zstd_mandir, 'man1') -bin_EXT = host_machine_os == os_windows ? '.exe' : '' -man1_EXT = meson.version().version_compare('>=0.49.0') ? '.1' : '.1.gz' - -foreach f : ['zstdcat', 'unzstd'] - meson.add_install_script(InstallSymlink_py, 'zstd' + bin_EXT, f + bin_EXT, zstd_bindir) - meson.add_install_script(InstallSymlink_py, 'zstd' + man1_EXT, f + man1_EXT, zstd_man1_dir) -endforeach - -if use_multi_thread - meson.add_install_script(InstallSymlink_py, 'zstd' + bin_EXT, 'zstdmt' + bin_EXT, zstd_bindir) - meson.add_install_script(InstallSymlink_py, 'zstd' + man1_EXT, 'zstdmt' + man1_EXT, zstd_man1_dir) -endif diff --git a/third_party/zstd/build/meson/tests/meson.build b/third_party/zstd/build/meson/tests/meson.build deleted file mode 100644 index 2dd8d1067..000000000 --- a/third_party/zstd/build/meson/tests/meson.build +++ /dev/null @@ -1,215 +0,0 @@ -# ############################################################################# -# Copyright (c) 2018-present Dima Krasner -# lzutao -# All rights reserved. -# -# This source code is licensed under both the BSD-style license (found in the -# LICENSE file in the root directory of this source tree) and the GPLv2 (found -# in the COPYING file in the root directory of this source tree). -# ############################################################################# - -zstd_rootdir = '../../..' - -tests_supported_oses = [os_linux, 'gnu/kfreebsd', os_darwin, 'gnu', 'openbsd', - os_freebsd, 'netbsd', 'dragonfly', os_sun] - -# ============================================================================= -# Test flags -# ============================================================================= - -FUZZER_FLAGS = ['--no-big-tests'] -FUZZERTEST = '-T200s' -ZSTREAM_TESTTIME = '-T90s' -DECODECORPUS_TESTTIME = '-T30' - -# ============================================================================= -# Executables -# ============================================================================= - -test_includes = [ include_directories(join_paths(zstd_rootdir, 'programs')) ] - -testcommon_sources = [join_paths(zstd_rootdir, 'programs/datagen.c'), - join_paths(zstd_rootdir, 'programs/util.c'), - join_paths(zstd_rootdir, 'programs/timefn.c'), - join_paths(zstd_rootdir, 'programs/benchfn.c'), - join_paths(zstd_rootdir, 'programs/benchzstd.c')] - -testcommon = static_library('testcommon', - testcommon_sources, - # needed due to use of private symbol + -fvisibility=hidden - link_with: libzstd_static) - -testcommon_dep = declare_dependency(link_with: testcommon, - dependencies: libzstd_deps, - include_directories: libzstd_includes) - -datagen_sources = [join_paths(zstd_rootdir, 'tests/datagencli.c')] -datagen = executable('datagen', - datagen_sources, - c_args: [ '-DNDEBUG' ], - include_directories: test_includes, - dependencies: testcommon_dep, - install: false) - -fullbench_sources = [join_paths(zstd_rootdir, 'tests/fullbench.c')] -fullbench = executable('fullbench', - fullbench_sources, - include_directories: test_includes, - dependencies: testcommon_dep, - install: false) - -fuzzer_sources = [join_paths(zstd_rootdir, 'tests/fuzzer.c')] -fuzzer = executable('fuzzer', - fuzzer_sources, - include_directories: test_includes, - dependencies: [ testcommon_dep, thread_dep ], - install: false) - -zstreamtest_sources = [ - join_paths(zstd_rootdir, 'tests/seqgen.c'), - join_paths(zstd_rootdir, 'tests/zstreamtest.c'), - join_paths(zstd_rootdir, 'tests/external_matchfinder.c')] -zstreamtest = executable('zstreamtest', - zstreamtest_sources, - include_directories: test_includes, - dependencies: testcommon_dep, - install: false) - -paramgrill_sources = [join_paths(zstd_rootdir, 'tests/paramgrill.c')] -paramgrill = executable('paramgrill', - paramgrill_sources, - include_directories: test_includes, - dependencies: [ testcommon_dep, libm_dep ], - install: false) - -roundTripCrash_sources = [join_paths(zstd_rootdir, 'tests/roundTripCrash.c')] -roundTripCrash = executable('roundTripCrash', - roundTripCrash_sources, - dependencies: [ testcommon_dep ], - install: false) - -longmatch_sources = [join_paths(zstd_rootdir, 'tests/longmatch.c')] -longmatch = executable('longmatch', - longmatch_sources, - dependencies: [ libzstd_dep ], - install: false) - -invalidDictionaries_sources = [join_paths(zstd_rootdir, 'tests/invalidDictionaries.c')] -invalidDictionaries = executable('invalidDictionaries', - invalidDictionaries_sources, - dependencies: [ libzstd_dep ], - install: false) - -if 0 < legacy_level and legacy_level <= 4 - legacy_sources = [join_paths(zstd_rootdir, 'tests/legacy.c')] - legacy = executable('legacy', - legacy_sources, - # Use -Dlegacy_level build option to control it - #c_args: '-DZSTD_LEGACY_SUPPORT=4', - dependencies: [ libzstd_dep ], - install: false) -endif - -decodecorpus_sources = [join_paths(zstd_rootdir, 'tests/decodecorpus.c')] -decodecorpus = executable('decodecorpus', - decodecorpus_sources, - include_directories: test_includes, - dependencies: [ testcommon_dep, libm_dep ], - install: false) - -poolTests_sources = [join_paths(zstd_rootdir, 'tests/poolTests.c')] -poolTests = executable('poolTests', - poolTests_sources, - include_directories: test_includes, - dependencies: [ testcommon_dep, thread_dep ], - install: false) - -checkTag_sources = [join_paths(zstd_rootdir, 'tests/checkTag.c')] -checkTag = executable('checkTag', - checkTag_sources, - dependencies: [ libzstd_dep ], - install: false) - -# ============================================================================= -# Tests (Use "meson test --list" to list all tests) -# ============================================================================= - -if tests_supported_oses.contains(host_machine_os) - valgrind_prog = find_program('valgrind', ['/usr/bin/valgrind'], required: false) - valgrindTest_py = files('valgrindTest.py') - if valgrind_prog.found() - test('valgrindTest', - valgrindTest_py, - args: [valgrind_prog.path(), zstd, datagen, fuzzer, fullbench], - depends: [zstd, datagen, fuzzer, fullbench], - timeout: 600) # Timeout should work on HDD drive - endif -endif - -if host_machine_os != os_windows - playTests_sh = find_program(join_paths(zstd_rootdir, 'tests/playTests.sh'), required: true) - - # add slow tests only if the meson version is new enough to support - # test setups with default-excluded suites - if meson.version().version_compare('>=0.57.0') - matrix = {'fast': [], 'slow': ['--test-large-data']} - else - matrix = {'fast': []} - endif - - foreach suite, opt: matrix - test('test-zstd-'+suite, - playTests_sh, - args: opt, - env: ['ZSTD_BIN=' + zstd.full_path(), 'DATAGEN_BIN=./datagen'], - depends: [datagen, zstd], - suite: suite, - workdir: meson.current_build_dir(), - timeout: 2800) # Timeout should work on HDD drive - endforeach -endif - -test('test-fullbench-1', - fullbench, - args: ['-i1'], - depends: [datagen], - timeout: 60) -test('test-fullbench-2', - fullbench, - args: ['-i1', '-P0'], - depends: [datagen], - timeout: 60) - -if use_zlib - test('test-fuzzer', - fuzzer, - args: ['-v', FUZZERTEST] + FUZZER_FLAGS, - timeout: 480) -endif - -test('test-zstream-1', - zstreamtest, - args: ['-v', ZSTREAM_TESTTIME] + FUZZER_FLAGS, - timeout: 240) -test('test-zstream-3', - zstreamtest, - args: ['--newapi', '-t1', ZSTREAM_TESTTIME] + FUZZER_FLAGS, - timeout: 120) -test('test-longmatch', longmatch, timeout: 36) -test('test-invalidDictionaries', invalidDictionaries) # should be fast -if 0 < legacy_level and legacy_level <= 4 - test('test-legacy', legacy) # should be fast -endif -test('test-decodecorpus', - decodecorpus, - args: ['-t', DECODECORPUS_TESTTIME], - timeout: 60) -test('test-poolTests', poolTests) # should be fast - -if meson.version().version_compare('>=0.57.0') - add_test_setup('fast', - is_default: true, - exclude_suites: ['slow']) - add_test_setup('slow', - exclude_suites: ['fast']) -endif diff --git a/third_party/zstd/build/meson/tests/valgrindTest.py b/third_party/zstd/build/meson/tests/valgrindTest.py deleted file mode 100644 index 05d84878b..000000000 --- a/third_party/zstd/build/meson/tests/valgrindTest.py +++ /dev/null @@ -1,90 +0,0 @@ -#!/usr/bin/env python3 -# ############################################################################# -# Copyright (c) 2018-present lzutao -# All rights reserved. -# -# This source code is licensed under both the BSD-style license (found in the -# LICENSE file in the root directory of this source tree) and the GPLv2 (found -# in the COPYING file in the root directory of this source tree). -# ############################################################################# -import os -import subprocess -import tempfile - - -def valgrindTest(valgrind, datagen, fuzzer, zstd, fullbench): - VALGRIND_ARGS = [valgrind, '--leak-check=full', '--show-leak-kinds=all', '--error-exitcode=1'] - - print('\n ---- valgrind tests : memory analyzer ----') - - subprocess.check_call([*VALGRIND_ARGS, datagen, '-g50M'], stdout=subprocess.DEVNULL) - - if subprocess.call([*VALGRIND_ARGS, zstd], - stdout=subprocess.DEVNULL) == 0: - raise subprocess.SubprocessError('zstd without argument should have failed') - - with subprocess.Popen([datagen, '-g80'], stdout=subprocess.PIPE) as p1, \ - subprocess.Popen([*VALGRIND_ARGS, zstd, '-', '-c'], - stdin=p1.stdout, - stdout=subprocess.DEVNULL) as p2: - p1.stdout.close() # Allow p1 to receive a SIGPIPE if p2 exits. - p2.communicate() - if p2.returncode != 0: - raise subprocess.SubprocessError() - - with subprocess.Popen([datagen, '-g16KB'], stdout=subprocess.PIPE) as p1, \ - subprocess.Popen([*VALGRIND_ARGS, zstd, '-vf', '-', '-c'], - stdin=p1.stdout, - stdout=subprocess.DEVNULL) as p2: - p1.stdout.close() - p2.communicate() - if p2.returncode != 0: - raise subprocess.SubprocessError() - - with tempfile.NamedTemporaryFile() as tmp_fd: - with subprocess.Popen([datagen, '-g2930KB'], stdout=subprocess.PIPE) as p1, \ - subprocess.Popen([*VALGRIND_ARGS, zstd, '-5', '-vf', '-', '-o', tmp_fd.name], - stdin=p1.stdout) as p2: - p1.stdout.close() - p2.communicate() - if p2.returncode != 0: - raise subprocess.SubprocessError() - - subprocess.check_call([*VALGRIND_ARGS, zstd, '-vdf', tmp_fd.name, '-c'], - stdout=subprocess.DEVNULL) - - with subprocess.Popen([datagen, '-g64MB'], stdout=subprocess.PIPE) as p1, \ - subprocess.Popen([*VALGRIND_ARGS, zstd, '-vf', '-', '-c'], - stdin=p1.stdout, - stdout=subprocess.DEVNULL) as p2: - p1.stdout.close() - p2.communicate() - if p2.returncode != 0: - raise subprocess.SubprocessError() - - subprocess.check_call([*VALGRIND_ARGS, fuzzer, '-T1mn', '-t1']) - subprocess.check_call([*VALGRIND_ARGS, fullbench, '-i1']) - - -def main(): - import argparse - parser = argparse.ArgumentParser(description='Valgrind tests : memory analyzer') - parser.add_argument('valgrind', help='valgrind path') - parser.add_argument('zstd', help='zstd path') - parser.add_argument('datagen', help='datagen path') - parser.add_argument('fuzzer', help='fuzzer path') - parser.add_argument('fullbench', help='fullbench path') - - args = parser.parse_args() - - valgrind = args.valgrind - zstd = args.zstd - datagen = args.datagen - fuzzer = args.fuzzer - fullbench = args.fullbench - - valgrindTest(valgrind, datagen, fuzzer, zstd, fullbench) - - -if __name__ == '__main__': - main() diff --git a/third_party/zstd/build/single_file_libs/.gitignore b/third_party/zstd/build/single_file_libs/.gitignore deleted file mode 100644 index 8c1bc71ed..000000000 --- a/third_party/zstd/build/single_file_libs/.gitignore +++ /dev/null @@ -1,9 +0,0 @@ - -# build artifacts -zstddeclib.c -zstdenclib.c -zstd.c -zstd.h - -# test artifacts -temp* diff --git a/third_party/zstd/build/single_file_libs/README.md b/third_party/zstd/build/single_file_libs/README.md deleted file mode 100644 index 64c973a68..000000000 --- a/third_party/zstd/build/single_file_libs/README.md +++ /dev/null @@ -1,33 +0,0 @@ -# Single File Zstandard Libraries - -The script `combine.sh` creates an _amalgamated_ source file that can be used with or without `zstd.h`. This isn't a _header-only_ file but it does offer a similar level of simplicity when integrating into a project. - -All it now takes to support Zstd in your own projects is the addition of a single file, two if using the header, with no configuration or further build steps. - -Decompressor ------------- - -This is the most common use case. The decompression library is small, adding, for example, 26kB to an Emscripten compiled WebAssembly project. Native implementations add a little more, 40-70kB depending on the compiler and platform. - -Create `zstddeclib.c` from the Zstd source using: -``` -cd zstd/build/single_file_libs -python3 combine.py -r ../../lib -x legacy/zstd_legacy.h -o zstddeclib.c zstddeclib-in.c -``` -Then add the resulting file to your project (see the [example files](examples)). - -`create_single_file_decoder.sh` will run the above script, creating the file `zstddeclib.c` (`build_decoder_test.sh` will also create `zstddeclib.c`, then compile and test the result). - -Full Library ------------- - -The same tool can amalgamate the entire Zstd library for ease of adding both compression and decompression to a project. The [roundtrip example](examples/roundtrip.c) uses the original `zstd.h` with the remaining source files combined into `zstd.c` (currently just over 1.2MB) created from `zstd-in.c`. As with the standalone decoder the most useful compile flags have already been rolled-in and the resulting file can be added to a project as-is. - -Create `zstd.c` from the Zstd source using: -``` -cd zstd/build/single_file_libs -python3 combine.py -r ../../lib -x legacy/zstd_legacy.h -k zstd.h -o zstd.c zstd-in.c -``` -It's possible to create a compressor-only library but since the decompressor is so small in comparison this doesn't bring much of a gain (but for the curious, simply remove the files in the _decompress_ section at the end of `zstd-in.c`). - -`create_single_file_library.sh` will run the script to create `zstd.c` (`build_library_test.sh` will also create `zstd.c`, then compile and test the result). diff --git a/third_party/zstd/build/single_file_libs/build_decoder_test.sh b/third_party/zstd/build/single_file_libs/build_decoder_test.sh deleted file mode 100755 index c4ca55fa5..000000000 --- a/third_party/zstd/build/single_file_libs/build_decoder_test.sh +++ /dev/null @@ -1,91 +0,0 @@ -#!/bin/sh - -# Temporary compiled binary -OUT_FILE="tempbin" - -# Optional temporary compiled WebAssembly -OUT_WASM="temp.wasm" - -# Source files to compile using Emscripten. -IN_FILES="examples/emscripten.c" - -# Emscripten build using emcc. -emscripten_emcc_build() { - # Compile the same example as above - CC_FLAGS="-Wall -Wextra -Wshadow -Werror -Os -g0 -flto" - emcc $CC_FLAGS -s WASM=1 -I. -o $OUT_WASM $IN_FILES - # Did compilation work? - if [ $? -ne 0 ]; then - echo "Compiling ${IN_FILES}: FAILED" - exit 1 - fi - echo "Compiling ${IN_FILES}: PASSED" - rm -f $OUT_WASM -} - -# Emscripten build using docker. -emscripten_docker_build() { - docker container run --rm \ - --volume $PWD:/code \ - --workdir /code \ - emscripten/emsdk:latest \ - emcc $CC_FLAGS -s WASM=1 -I. -o $OUT_WASM $IN_FILES - # Did compilation work? - if [ $? -ne 0 ]; then - echo "Compiling ${IN_FILES} (using docker): FAILED" - exit 1 - fi - echo "Compiling ${IN_FILES} (using docker): PASSED" - rm -f $OUT_WASM -} - -# Try Emscripten build using emcc or docker. -try_emscripten_build() { - which emcc > /dev/null - if [ $? -eq 0 ]; then - emscripten_emcc_build - return $? - fi - - which docker > /dev/null - if [ $? -eq 0 ]; then - emscripten_docker_build - return $? - fi - - echo "(Skipping Emscripten test)" -} - -# Amalgamate the sources -./create_single_file_decoder.sh -# Did combining work? -if [ $? -ne 0 ]; then - echo "Single file decoder creation script: FAILED" - exit 1 -fi -echo "Single file decoder creation script: PASSED" - -# Compile the generated output -cc -Wall -Wextra -Wshadow -Werror -Os -g0 -o $OUT_FILE examples/simple.c -# Did compilation work? -if [ $? -ne 0 ]; then - echo "Compiling simple.c: FAILED" - exit 1 -fi -echo "Compiling simple.c: PASSED" - -# Run then delete the compiled output -./$OUT_FILE -retVal=$? -rm -f $OUT_FILE -# Did the test work? -if [ $retVal -ne 0 ]; then - echo "Running simple.c: FAILED" - exit 1 -fi -echo "Running simple.c: PASSED" - -# Try Emscripten build if emcc or docker command is available. -try_emscripten_build - -exit 0 diff --git a/third_party/zstd/build/single_file_libs/build_library_test.sh b/third_party/zstd/build/single_file_libs/build_library_test.sh deleted file mode 100755 index f4ba109ab..000000000 --- a/third_party/zstd/build/single_file_libs/build_library_test.sh +++ /dev/null @@ -1,97 +0,0 @@ -#!/bin/sh - -# Where to find the sources (only used to copy zstd.h) -ZSTD_SRC_ROOT="../../lib" - -# Temporary compiled binary -OUT_FILE="tempbin" - -# Optional temporary compiled WebAssembly -OUT_WASM="temp.wasm" - -# Source files to compile using Emscripten. -IN_FILES="zstd.c examples/roundtrip.c" - -# Emscripten build using emcc. -emscripten_emcc_build() { - # Compile the same example as above - CC_FLAGS="-Wall -Wextra -Wshadow -Werror -Os -g0 -flto" - emcc $CC_FLAGS -s WASM=1 -I. -o $OUT_WASM $IN_FILES - # Did compilation work? - if [ $? -ne 0 ]; then - echo "Compiling ${IN_FILES}: FAILED" - exit 1 - fi - echo "Compiling ${IN_FILES}: PASSED" - rm -f $OUT_WASM -} - -# Emscripten build using docker. -emscripten_docker_build() { - docker container run --rm \ - --volume $PWD:/code \ - --workdir /code \ - emscripten/emsdk:latest \ - emcc $CC_FLAGS -s WASM=1 -I. -o $OUT_WASM $IN_FILES - # Did compilation work? - if [ $? -ne 0 ]; then - echo "Compiling ${IN_FILES} (using docker): FAILED" - exit 1 - fi - echo "Compiling ${IN_FILES} (using docker): PASSED" - rm -f $OUT_WASM -} - -# Try Emscripten build using emcc or docker. -try_emscripten_build() { - which emcc > /dev/null - if [ $? -eq 0 ]; then - emscripten_emcc_build - return $? - fi - - which docker > /dev/null - if [ $? -eq 0 ]; then - emscripten_docker_build - return $? - fi - - echo "(Skipping Emscripten test)" -} - -# Amalgamate the sources -./create_single_file_library.sh -# Did combining work? -if [ $? -ne 0 ]; then - echo "Single file library creation script: FAILED" - exit 1 -fi -echo "Single file library creation script: PASSED" - -# Copy the header to here (for the tests) -cp "$ZSTD_SRC_ROOT/zstd.h" examples/zstd.h - -# Compile the generated output -cc -Wall -Wextra -Werror -Wshadow -pthread -I. -Os -g0 -o $OUT_FILE zstd.c examples/roundtrip.c -# Did compilation work? -if [ $? -ne 0 ]; then - echo "Compiling roundtrip.c: FAILED" - exit 1 -fi -echo "Compiling roundtrip.c: PASSED" - -# Run then delete the compiled output -./$OUT_FILE -retVal=$? -rm -f $OUT_FILE -# Did the test work? -if [ $retVal -ne 0 ]; then - echo "Running roundtrip.c: FAILED" - exit 1 -fi -echo "Running roundtrip.c: PASSED" - -# Try Emscripten build if emcc or docker command is available. -try_emscripten_build - -exit 0 diff --git a/third_party/zstd/build/single_file_libs/combine.py b/third_party/zstd/build/single_file_libs/combine.py deleted file mode 100755 index 771dd20bf..000000000 --- a/third_party/zstd/build/single_file_libs/combine.py +++ /dev/null @@ -1,234 +0,0 @@ -#!/usr/bin/env python3 - -# Tool to bundle multiple C/C++ source files, inlining any includes. -# -# Note: there are two types of exclusion options: the '-x' flag, which besides -# excluding a file also adds an #error directive in place of the #include, and -# the '-k' flag, which keeps the #include and doesn't inline the file. The -# intended use cases are: '-x' for files that would normally be #if'd out, so -# features that 100% won't be used in the amalgamated file, for which every -# occurrence adds the error, and '-k' for headers that we wish to manually -# include, such as a project's public API, for which occurrences after the first -# are removed. -# -# Todo: the error handling could be better, which currently throws and halts -# (which is functional just not very friendly). -# -# Author: Carl Woffenden, Numfum GmbH (this script is released under a CC0 license/Public Domain) - -import argparse, re, sys - -from pathlib import Path -from typing import Any, List, Optional, Pattern, Set, TextIO - -# Set of file roots when searching (equivalent to -I paths for the compiler). -roots: Set[Path] = set() - -# Set of (canonical) file Path objects to exclude from inlining (and not only -# exclude but to add a compiler error directive when they're encountered). -excludes: Set[Path] = set() - -# Set of (canonical) file Path objects to keep as include directives. -keeps: Set[Path] = set() - -# Whether to keep the #pragma once directives (unlikely, since this will result -# in a warning, but the option is there). -keep_pragma: bool = False - -# Destination file object (or stdout if no output file was supplied). -destn: TextIO = sys.stdout - -# Set of file Path objects previously inlined (and to ignore if reencountering). -found: Set[Path] = set() - -# Compiled regex Pattern to handle "#pragma once" in various formats: -# -# #pragma once -# #pragma once -# # pragma once -# #pragma once -# #pragma once // comment -# -# Ignoring commented versions, same as include_regex. -# -pragma_regex: Pattern = re.compile(r'^\s*#\s*pragma\s*once\s*') - -# Compiled regex Pattern to handle the following type of file includes: -# -# #include "file" -# #include "file" -# # include "file" -# #include "file" -# #include "file" // comment -# #include "file" // comment with quote " -# -# And all combinations of, as well as ignoring the following: -# -# #include -# //#include "file" -# /*#include "file"*/ -# -# We don't try to catch errors since the compiler will do this (and the code is -# expected to be valid before processing) and we don't care what follows the -# file (whether it's a valid comment or not, since anything after the quoted -# string is ignored) -# -include_regex: Pattern = re.compile(r'^\s*#\s*include\s*"(.+?)"') - -# Simple tests to prove include_regex's cases. -# -def test_match_include() -> bool: - if (include_regex.match('#include "file"') and - include_regex.match(' #include "file"') and - include_regex.match('# include "file"') and - include_regex.match('#include "file"') and - include_regex.match('#include "file" // comment')): - if (not include_regex.match('#include ') and - not include_regex.match('//#include "file"') and - not include_regex.match('/*#include "file"*/')): - found = include_regex.match('#include "file" // "') - if (found and found.group(1) == 'file'): - print('#include match valid') - return True - return False - -# Simple tests to prove pragma_regex's cases. -# -def test_match_pragma() -> bool: - if (pragma_regex.match('#pragma once') and - pragma_regex.match(' #pragma once') and - pragma_regex.match('# pragma once') and - pragma_regex.match('#pragma once') and - pragma_regex.match('#pragma once // comment')): - if (not pragma_regex.match('//#pragma once') and - not pragma_regex.match('/*#pragma once*/')): - print('#pragma once match valid') - return True - return False - -# Finds 'file'. First the list of 'root' paths are searched, followed by the -# currently processing file's 'parent' path, returning a valid Path in -# canonical form. If no match is found None is returned. -# -def resolve_include(file: str, parent: Optional[Path] = None) -> Optional[Path]: - for root in roots: - found = root.joinpath(file).resolve() - if (found.is_file()): - return found - if (parent): - found = parent.joinpath(file).resolve(); - else: - found = Path(file) - if (found.is_file()): - return found - return None - -# Helper to resolve lists of files. 'file_list' is passed in from the arguments -# and each entry resolved to its canonical path (like any include entry, either -# from the list of root paths or the owning file's 'parent', which in this case -# is case is the input file). The results are stored in 'resolved'. -# -def resolve_excluded_files(file_list: Optional[List[str]], resolved: Set[Path], parent: Optional[Path] = None) -> None: - if (file_list): - for filename in file_list: - found = resolve_include(filename, parent) - if (found): - resolved.add(found) - else: - error_line(f'Warning: excluded file not found: {filename}') - -# Writes 'line' to the open 'destn' (or stdout). -# -def write_line(line: str) -> None: - print(line, file=destn) - -# Logs 'line' to stderr. This is also used for general notifications that we -# don't want to go to stdout (so the source can be piped). -# -def error_line(line: Any) -> None: - print(line, file=sys.stderr) - -# Inline the contents of 'file' (with any of its includes also inlined, etc.). -# -# Note: text encoding errors are ignored and replaced with ? when reading the -# input files. This isn't ideal, but it's more than likely in the comments than -# code and a) the text editor has probably also failed to read the same content, -# and b) the compiler probably did too. -# -def add_file(file: Path, file_name: str = None) -> None: - if (file.is_file()): - if (not file_name): - file_name = file.name - error_line(f'Processing: {file_name}') - with file.open('r', errors='replace') as opened: - for line in opened: - line = line.rstrip('\n') - match_include = include_regex.match(line); - if (match_include): - # We have a quoted include directive so grab the file - inc_name = match_include.group(1) - resolved = resolve_include(inc_name, file.parent) - if (resolved): - if (resolved in excludes): - # The file was excluded so error if the compiler uses it - write_line(f'#error Using excluded file: {inc_name} (re-amalgamate source to fix)') - error_line(f'Excluding: {inc_name}') - else: - if (resolved not in found): - # The file was not previously encountered - found.add(resolved) - if (resolved in keeps): - # But the include was flagged to keep as included - write_line(f'/**** *NOT* inlining {inc_name} ****/') - write_line(line) - error_line(f'Not inlining: {inc_name}') - else: - # The file was neither excluded nor seen before so inline it - write_line(f'/**** start inlining {inc_name} ****/') - add_file(resolved, inc_name) - write_line(f'/**** ended inlining {inc_name} ****/') - else: - write_line(f'/**** skipping file: {inc_name} ****/') - else: - # The include file didn't resolve to a file - write_line(f'#error Unable to find: {inc_name}') - error_line(f'Error: Unable to find: {inc_name}') - else: - # Skip any 'pragma once' directives, otherwise write the source line - if (keep_pragma or not pragma_regex.match(line)): - write_line(line) - else: - error_line(f'Error: Invalid file: {file}') - -# Start here -parser = argparse.ArgumentParser(description='Amalgamate Tool', epilog=f'example: {sys.argv[0]} -r ../my/path -r ../other/path -o out.c in.c') -parser.add_argument('-r', '--root', action='append', type=Path, help='file root search path') -parser.add_argument('-x', '--exclude', action='append', help='file to completely exclude from inlining') -parser.add_argument('-k', '--keep', action='append', help='file to exclude from inlining but keep the include directive') -parser.add_argument('-p', '--pragma', action='store_true', default=False, help='keep any "#pragma once" directives (removed by default)') -parser.add_argument('-o', '--output', type=argparse.FileType('w'), help='output file (otherwise stdout)') -parser.add_argument('input', type=Path, help='input file') -args = parser.parse_args() - -# Fail early on an invalid input (and store it so we don't recurse) -args.input = args.input.resolve(strict=True) -found.add(args.input) - -# Resolve all of the root paths upfront (we'll halt here on invalid roots) -if (args.root): - for path in args.root: - roots.add(path.resolve(strict=True)) - -# The remaining params: so resolve the excluded files and #pragma once directive -resolve_excluded_files(args.exclude, excludes, args.input.parent) -resolve_excluded_files(args.keep, keeps, args.input.parent) -keep_pragma = args.pragma; - -# Then recursively process the input file -try: - if (args.output): - destn = args.output - add_file(args.input) -finally: - if (destn): - destn.close() diff --git a/third_party/zstd/build/single_file_libs/combine.sh b/third_party/zstd/build/single_file_libs/combine.sh deleted file mode 100755 index 222c2c32a..000000000 --- a/third_party/zstd/build/single_file_libs/combine.sh +++ /dev/null @@ -1,249 +0,0 @@ -#!/bin/sh -e - -# Tool to bundle multiple C/C++ source files, inlining any includes. -# -# TODO: ROOTS, FOUND, etc., as arrays (since they fail on paths with spaces) -# -# Author: Carl Woffenden, Numfum GmbH (this script is released under a CC0 license/Public Domain) - -# Common file roots -ROOTS="." - -# -x option excluded includes -XINCS="" - -# -k option includes to keep as include directives -KINCS="" - -# Files previously visited -FOUND="" - -# Optional destination file (empty string to write to stdout) -DESTN="" - -# Whether the "#pragma once" directives should be written to the output -PONCE=0 - -# Prints the script usage then exits -usage() { - echo "Usage: $0 [-r ] [-x
] [-k
] [-o ] infile" - echo " -r file root search path" - echo " -x file to completely exclude from inlining" - echo " -k file to exclude from inlining but keep the include directive" - echo " -p keep any '#pragma once' directives (removed by default)" - echo " -o output file (otherwise stdout)" - echo "Example: $0 -r ../my/path - r ../other/path -o out.c in.c" - exit 1 -} - -# Tests that the grep implementation works as expected (older OSX grep fails) -test_deps() { - if ! echo '#include "foo"' | grep -Eq '^\s*#\s*include\s*".+"'; then - echo "Aborting: the grep implementation fails to parse include lines" - exit 1 - fi - if ! echo '"foo.h"' | sed -E 's/"([^"]+)"/\1/' | grep -Eq '^foo\.h$'; then - echo "Aborting: sed is unavailable or non-functional" - exit 1 - fi -} - -# Test if glob pattern $1 matches subject $2 (see fnmatch(3)) -fnmatch() { - case "$2" in - $1) - return 0 - ;; - esac - return 1 -} - -# Test if line $1 is local include directive -is_include_line() { - fnmatch "*#*include*" "$1" || return 1 - printf "%s\n" "$1" | grep -Eq '^\s*#\s*include\s*".+"' -} - -# Test if line $1 is pragma once directive -is_pragma_once_line() { - fnmatch "*#*pragma*once*" "$1" || return 1 - printf "%s\n" "$1" | grep -Eq '^\s*#\s*pragma\s*once\s*' -} - -# Tests if list $1 has item $2 (returning zero on a match) -# (originally used grep -Eq "(^|\s*)$2(\$|\s*)) -readonly list_FS="$IFS" -list_has_item() { - # Re: escaping glob pattern special characters in item string: - # - # bash (tested 3.2.57, 5.1.4), dash (tested 0.5.10.2), NetBSD /bin/sh - # (tested 8.2), and Solaris /bin/sh (tested 11.4) require escaping - # backslashes in a bracket expression despite POSIX specifying that - # backslash loses significance in a bracket expression. - # - # Conversely, neither FreeBSD /bin/sh (tested 12.2) nor OpenBSD /bin/sh - # (tested 7.1) obey backslash-escaping in case statement patterns even - # outside bracket expressions, so escape special characters using bracket - # expressions. - # - # Solaris /bin/sh (tested 11.4) requires vertical bar (|) to be escaped. - # - # All accommodations should behave as expected under strict POSIX semantics. - if fnmatch "*[\\*?[|]*" "$2"; then - set -- "$1" "$(printf '%s\n' "$2" | sed -e 's/[*?[|]/[&]/g; s/[\]/[\\&]/g')" - fi - for item_P in "*[$list_FS]$2[$list_FS]*" "*[$list_FS]$2" "$2[$list_FS]*" "$2"; do - fnmatch "${item_P}" "$1" && return 0 - done - return 1 -} - -# Adds a new line with the supplied arguments to $DESTN (or stdout) -write_line() { - if [ -n "$DESTN" ]; then - printf '%s\n' "$@" >> "$DESTN" - else - printf '%s\n' "$@" - fi -} - -log_line() { - echo $@ >&2 -} - -# Find this file! -resolve_include() { - local srcdir=$1 - local inc=$2 - for root in $srcdir $ROOTS; do - if [ -f "$root/$inc" ]; then - # Try to reduce the file path into a canonical form (so that multiple) - # includes of the same file are successfully deduplicated, even if they - # are expressed differently. - local relpath="$(realpath --relative-to . "$root/$inc" 2>/dev/null)" - if [ "$relpath" != "" ]; then # not all realpaths support --relative-to - echo "$relpath" - return 0 - fi - local relpath="$(realpath "$root/$inc" 2>/dev/null)" - if [ "$relpath" != "" ]; then # not all distros have realpath... - echo "$relpath" - return 0 - fi - # Fallback on Python to reduce the path if the above fails. - local relpath=$(python -c "import os,sys; print os.path.relpath(sys.argv[1])" "$root/$inc" 2>/dev/null) - if [ "$relpath" != "" ]; then # not all distros have realpath... - echo "$relpath" - return 0 - fi - # Worst case, fall back to just the root + relative include path. The - # problem with this is that it is possible to emit multiple different - # resolved paths to the same file, depending on exactly how its included. - # Since the main loop below keeps a list of the resolved paths it's - # already included, in order to avoid repeated includes, this failure to - # produce a canonical/reduced path can lead to multiple inclusions of the - # same file. But it seems like the resulting single file library still - # works (hurray include guards!), so I guess it's ok. - echo "$root/$inc" - return 0 - fi - done - return 1 -} - -# Adds the contents of $1 with any of its includes inlined -add_file() { - local file=$1 - if [ -n "$file" ]; then - log_line "Processing: $file" - # Get directory of the current so we can resolve relative includes - local srcdir="$(dirname "$file")" - # Read the file - local line= - while IFS= read -r line; do - if is_include_line "$line"; then - # We have an include directive so strip the (first) file - local inc=$(echo "$line" | grep -Eo '".*"' | sed -E 's/"([^"]+)"/\1/' | head -1) - local res_inc="$(resolve_include "$srcdir" "$inc")" - if list_has_item "$XINCS" "$inc"; then - # The file was excluded so error if the source attempts to use it - write_line "#error Using excluded file: $inc (re-amalgamate source to fix)" - log_line "Excluding: $inc" - else - if ! list_has_item "$FOUND" "$res_inc"; then - # The file was not previously encountered - FOUND="$FOUND $res_inc" - if list_has_item "$KINCS" "$inc"; then - # But the include was flagged to keep as included - write_line "/**** *NOT* inlining $inc ****/" - write_line "$line" - log_line "Not Inlining: $inc" - else - # The file was neither excluded nor seen before so inline it - write_line "/**** start inlining $inc ****/" - add_file "$res_inc" - write_line "/**** ended inlining $inc ****/" - fi - else - write_line "/**** skipping file: $inc ****/" - fi - fi - else - # Skip any 'pragma once' directives, otherwise write the source line - local write=$PONCE - if [ $write -eq 0 ]; then - if ! is_pragma_once_line "$line"; then - write=1 - fi - fi - if [ $write -ne 0 ]; then - write_line "$line" - fi - fi - done < "$file" - else - write_line "#error Unable to find \"$1\"" - log_line "Error: Unable to find: \"$1\"" - fi -} - -while getopts ":r:x:k:po:" opts; do - case $opts in - r) - ROOTS="$ROOTS $OPTARG" - ;; - x) - XINCS="$XINCS $OPTARG" - ;; - k) - KINCS="$KINCS $OPTARG" - ;; - p) - PONCE=1 - ;; - o) - DESTN="$OPTARG" - ;; - *) - usage - ;; - esac -done -shift $((OPTIND-1)) - -if [ -n "$1" ]; then - if [ -f "$1" ]; then - if [ -n "$DESTN" ]; then - printf "" > "$DESTN" - fi - test_deps - log_line "Processing using the slower shell script; this might take a while" - add_file "$1" - else - echo "Input file not found: \"$1\"" - exit 1 - fi -else - usage -fi -exit 0 diff --git a/third_party/zstd/build/single_file_libs/create_single_file_decoder.sh b/third_party/zstd/build/single_file_libs/create_single_file_decoder.sh deleted file mode 100755 index 3c0c577df..000000000 --- a/third_party/zstd/build/single_file_libs/create_single_file_decoder.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh - -# Where to find the sources -ZSTD_SRC_ROOT="../../lib" - -# Amalgamate the sources -echo "Amalgamating files..." -# Using the faster Python script if we have 3.8 or higher -if python3 -c 'import sys; assert sys.version_info >= (3,8)' 2>/dev/null; then - ./combine.py -r "$ZSTD_SRC_ROOT" -x legacy/zstd_legacy.h -o zstddeclib.c zstddeclib-in.c -else - ./combine.sh -r "$ZSTD_SRC_ROOT" -x legacy/zstd_legacy.h -o zstddeclib.c zstddeclib-in.c -fi -# Did combining work? -if [ $? -ne 0 ]; then - echo "Combine script: FAILED" - exit 1 -fi -echo "Combine script: PASSED" diff --git a/third_party/zstd/build/single_file_libs/create_single_file_library.sh b/third_party/zstd/build/single_file_libs/create_single_file_library.sh deleted file mode 100755 index a6f71f0f0..000000000 --- a/third_party/zstd/build/single_file_libs/create_single_file_library.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh - -# Where to find the sources -ZSTD_SRC_ROOT="../../lib" - -# Amalgamate the sources -echo "Amalgamating files..." -# Using the faster Python script if we have 3.8 or higher -if python3 -c 'import sys; assert sys.version_info >= (3,8)' 2>/dev/null; then - ./combine.py -r "$ZSTD_SRC_ROOT" -x legacy/zstd_legacy.h -o zstd.c zstd-in.c -else - ./combine.sh -r "$ZSTD_SRC_ROOT" -x legacy/zstd_legacy.h -o zstd.c zstd-in.c -fi -# Did combining work? -if [ $? -ne 0 ]; then - echo "Combine script: FAILED" - exit 1 -fi -echo "Combine script: PASSED" diff --git a/third_party/zstd/build/single_file_libs/examples/README.md b/third_party/zstd/build/single_file_libs/examples/README.md deleted file mode 100644 index e93bee35f..000000000 --- a/third_party/zstd/build/single_file_libs/examples/README.md +++ /dev/null @@ -1,11 +0,0 @@ -# Single File ZStandard Examples - -The examples `#include` the generated `zstddeclib.c` directly but work equally as well when including `zstd.h` and compiling the amalgamated source separately. - -`simple.c` is the most basic example of decompressing content and verifying the result. - -`emscripten.c` is a bare-bones [Emscripten](https://github.com/emscripten-core/emscripten) compiled WebGL demo using Zstd to further compress a DXT1 texture (see the [original PNG image](testcard.png)). The 256x256 texture would normally be 32kB, but even when bundled with the Zstd decompressor the resulting WebAssembly weighs in at 41kB (`shell.html` is a support file to run the Wasm). - -`roundtrip.c` is an example to use with the optional [amalgamated library](../create_single_file_library.sh) showing compression the decompression. - -The example files in this directory are released under a [Creative Commons Zero license](https://creativecommons.org/publicdomain/zero/1.0/) (or Public Domain, whichever is applicable in your jurisdiction). diff --git a/third_party/zstd/build/single_file_libs/examples/emscripten.c b/third_party/zstd/build/single_file_libs/examples/emscripten.c deleted file mode 100644 index 10dae8689..000000000 --- a/third_party/zstd/build/single_file_libs/examples/emscripten.c +++ /dev/null @@ -1,340 +0,0 @@ -/** - * \file emscripten.c - * Emscripten example of using the single-file \c zstddeclib. Draws a rotating - * textured quad with data from the in-line Zstd compressed DXT1 texture (DXT1 - * being hardware compression, further compressed with Zstd). - * \n - * Compile using: - * \code - * export CC_FLAGS="-Wall -Wextra -Werror -Os -g0 -flto --llvm-lto 3 -lGL -DNDEBUG=1" - * export EM_FLAGS="-s WASM=1 -s ENVIRONMENT=web --shell-file shell.html --closure 1" - * emcc $CC_FLAGS $EM_FLAGS -o out.html emscripten.c - * \endcode - * - * \author Carl Woffenden, Numfum GmbH (released under a CC0 license) - */ - -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include "../zstddeclib.c" - -//************************* Test Data (DXT texture) **************************/ - -/** - * Zstd compressed DXT1 256x256 texture source. - * \n - * See \c testcard.png for the original. - */ -static uint8_t const srcZstd[] = { -#include "testcard-zstd.inl" -}; - -/** - * Uncompressed size of \c #srcZstd. - */ -#define DXT1_256x256 32768 - -/** - * Destination for decoding \c #srcZstd. - */ -static uint8_t dstDxt1[DXT1_256x256] = {}; - -#ifndef ZSTD_VERSION_MAJOR -/** - * For the case where the decompression library hasn't been included we add a - * dummy function to fake the process and stop the buffers being optimised out. - */ -size_t ZSTD_decompress(void* dst, size_t dstLen, const void* src, size_t srcLen) { - return (memcmp(dst, src, (srcLen < dstLen) ? srcLen : dstLen)) ? dstLen : 0; -} -#endif - -//*************************** Program and Shaders ***************************/ - -/** - * Program object ID. - */ -static GLuint progId = 0; - -/** - * Vertex shader ID. - */ -static GLuint vertId = 0; - -/** - * Fragment shader ID. - */ -static GLuint fragId = 0; - -//********************************* Uniforms *********************************/ - -/** - * Quad rotation angle ID. - */ -static GLint uRotId = -1; - -/** - * Draw colour ID. - */ -static GLint uTx0Id = -1; - -//******************************* Shader Source ******************************/ - -/** - * Vertex shader to draw texture mapped polys with an applied rotation. - */ -static GLchar const vertShader2D[] = -#if GL_ES_VERSION_2_0 - "#version 100\n" - "precision mediump float;\n" -#else - "#version 120\n" -#endif - "uniform float uRot;" // rotation - "attribute vec2 aPos;" // vertex position coords - "attribute vec2 aUV0;" // vertex texture UV0 - "varying vec2 vUV0;" // (passed to fragment shader) - "void main() {" - " float cosA = cos(radians(uRot));" - " float sinA = sin(radians(uRot));" - " mat3 rot = mat3(cosA, -sinA, 0.0," - " sinA, cosA, 0.0," - " 0.0, 0.0, 1.0);" - " gl_Position = vec4(rot * vec3(aPos, 1.0), 1.0);" - " vUV0 = aUV0;" - "}"; - -/** - * Fragment shader for the above polys. - */ -static GLchar const fragShader2D[] = -#if GL_ES_VERSION_2_0 - "#version 100\n" - "precision mediump float;\n" -#else - "#version 120\n" -#endif - "uniform sampler2D uTx0;" - "varying vec2 vUV0;" // (passed from fragment shader) - "void main() {" - " gl_FragColor = texture2D(uTx0, vUV0);" - "}"; - -/** - * Helper to compile a shader. - * - * \param type shader type - * \param text shader source - * \return the shader ID (or zero if compilation failed) - */ -static GLuint compileShader(GLenum const type, const GLchar* text) { - GLuint shader = glCreateShader(type); - if (shader) { - glShaderSource (shader, 1, &text, NULL); - glCompileShader(shader); - GLint compiled; - glGetShaderiv(shader, GL_COMPILE_STATUS, &compiled); - if (compiled) { - return shader; - } else { - GLint logLen; - glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &logLen); - if (logLen > 1) { - GLchar* logStr = malloc(logLen); - glGetShaderInfoLog(shader, logLen, NULL, logStr); - #ifndef NDEBUG - printf("Shader compilation error: %s\n", logStr); - #endif - free(logStr); - } - glDeleteShader(shader); - } - } - return 0; -} - -//********************************** Helpers *********************************/ - -/** - * Vertex position index. - */ -#define GL_VERT_POSXY_ID 0 - -/** - * Vertex UV0 index. - */ -#define GL_VERT_TXUV0_ID 1 - - /** - * \c GL vec2 storage type. - */ -struct vec2 { - float x; - float y; -}; - -/** - * Combined 2D vertex and 2D texture coordinates. - */ -struct posTex2d { - struct vec2 pos; - struct vec2 uv0; -}; - -//****************************************************************************/ - -/** - * Current quad rotation angle (in degrees, updated per frame). - */ -static float rotDeg = 0.0f; - -/** - * Emscripten (single) GL context. - */ -static EMSCRIPTEN_WEBGL_CONTEXT_HANDLE glCtx = 0; - -/** - * Emscripten resize handler. - */ -static EM_BOOL resize(int type, const EmscriptenUiEvent* e, void* data) { - double surfaceW; - double surfaceH; - if (emscripten_get_element_css_size ("#canvas", &surfaceW, &surfaceH) == EMSCRIPTEN_RESULT_SUCCESS) { - emscripten_set_canvas_element_size("#canvas", surfaceW, surfaceH); - if (glCtx) { - glViewport(0, 0, (int) surfaceW, (int) surfaceH); - } - } - (void) type; - (void) data; - (void) e; - return EM_FALSE; -} - -/** - * Boilerplate to create a WebGL context. - */ -static EM_BOOL initContext() { - // Default attributes - EmscriptenWebGLContextAttributes attr; - emscripten_webgl_init_context_attributes(&attr); - if ((glCtx = emscripten_webgl_create_context("#canvas", &attr))) { - // Bind the context and fire a resize to get the initial size - emscripten_webgl_make_context_current(glCtx); - emscripten_set_resize_callback(EMSCRIPTEN_EVENT_TARGET_DOCUMENT, NULL, EM_FALSE, resize); - resize(0, NULL, NULL); - return EM_TRUE; - } - return EM_FALSE; -} - -/** - * Called once per frame (clears the screen and draws the rotating quad). - */ -static void tick() { - glClearColor(1.0f, 0.0f, 1.0f, 1.0f); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - if (uRotId >= 0) { - glUniform1f(uRotId, rotDeg); - rotDeg += 0.1f; - if (rotDeg >= 360.0f) { - rotDeg -= 360.0f; - } - } - - glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0); - glFlush(); -} - -/** - * Creates the GL context, shaders and quad data, decompresses the Zstd data - * and 'uploads' the resulting texture. - * - * As a (naive) comparison, removing Zstd and building with "-Os -g0 s WASM=1 - * -lGL emscripten.c" results in a 15kB WebAssembly file; re-adding Zstd - * increases the Wasm by 26kB. - */ -int main() { - if (initContext()) { - // Compile shaders and set the initial GL state - if ((progId = glCreateProgram())) { - vertId = compileShader(GL_VERTEX_SHADER, vertShader2D); - fragId = compileShader(GL_FRAGMENT_SHADER, fragShader2D); - - glBindAttribLocation(progId, GL_VERT_POSXY_ID, "aPos"); - glBindAttribLocation(progId, GL_VERT_TXUV0_ID, "aUV0"); - - glAttachShader(progId, vertId); - glAttachShader(progId, fragId); - glLinkProgram (progId); - glUseProgram (progId); - uRotId = glGetUniformLocation(progId, "uRot"); - uTx0Id = glGetUniformLocation(progId, "uTx0"); - if (uTx0Id >= 0) { - glUniform1i(uTx0Id, 0); - } - - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_BLEND); - glDisable(GL_DITHER); - - glCullFace(GL_BACK); - glEnable(GL_CULL_FACE); - } - - GLuint vertsBuf = 0; - GLuint indexBuf = 0; - GLuint txName = 0; - // Create the textured quad (vert positions then UVs) - struct posTex2d verts2d[] = { - {{-0.85f, -0.85f}, {0.0f, 0.0f}}, // BL - {{ 0.85f, -0.85f}, {1.0f, 0.0f}}, // BR - {{-0.85f, 0.85f}, {0.0f, 1.0f}}, // TL - {{ 0.85f, 0.85f}, {1.0f, 1.0f}}, // TR - }; - uint16_t index2d[] = { - 0, 1, 2, - 2, 1, 3, - }; - glGenBuffers(1, &vertsBuf); - glBindBuffer(GL_ARRAY_BUFFER, vertsBuf); - glBufferData(GL_ARRAY_BUFFER, - sizeof(verts2d), verts2d, GL_STATIC_DRAW); - glVertexAttribPointer(GL_VERT_POSXY_ID, 2, - GL_FLOAT, GL_FALSE, sizeof(struct posTex2d), 0); - glVertexAttribPointer(GL_VERT_TXUV0_ID, 2, - GL_FLOAT, GL_FALSE, sizeof(struct posTex2d), - (void*) offsetof(struct posTex2d, uv0)); - glGenBuffers(1, &indexBuf); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuf); - glBufferData(GL_ELEMENT_ARRAY_BUFFER, - sizeof(index2d), index2d, GL_STATIC_DRAW); - glEnableVertexAttribArray(GL_VERT_POSXY_ID); - glEnableVertexAttribArray(GL_VERT_TXUV0_ID); - - // Decode the Zstd data and create the texture - if (ZSTD_decompress(dstDxt1, DXT1_256x256, srcZstd, sizeof srcZstd) == DXT1_256x256) { - glGenTextures(1, &txName); - glBindTexture(GL_TEXTURE_2D, txName); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glCompressedTexImage2D(GL_TEXTURE_2D, 0, - GL_COMPRESSED_RGB_S3TC_DXT1_EXT, - 256, 256, 0, DXT1_256x256, dstDxt1); - } else { - printf("Failed to decode Zstd data\n"); - } - emscripten_set_main_loop(tick, 0, EM_FALSE); - emscripten_exit_with_live_runtime(); - } - return EXIT_FAILURE; -} diff --git a/third_party/zstd/build/single_file_libs/examples/roundtrip.c b/third_party/zstd/build/single_file_libs/examples/roundtrip.c deleted file mode 100644 index b228de88e..000000000 --- a/third_party/zstd/build/single_file_libs/examples/roundtrip.c +++ /dev/null @@ -1,83 +0,0 @@ -/* - * \file roundtrip.c - * In this example we include \c zstd.h and compile separately the amalgamated - * \c zstd.c: - * \code - * cc -Wall -Wextra -Werror -I. -Os -g0 zstd.c examples/roundtrip.c - * \endcode - * - * \author Carl Woffenden, Numfum GmbH (released under a CC0 license) - */ - -#include -#include -#include -#include -#include - -#include "zstd.h" - -//************************** Test Data (DXT texture) **************************/ - -/** - * Raw test data (borrowed from the Emscripten example). - * \n - * See \c testcard.png for the original. - */ -static uint8_t const rawData[] = { -#include "testcard-dxt1.inl" -}; - -#ifndef ZSTD_VERSION_MAJOR -/* - * For the case where the decompression library hasn't been included we add - * dummy functions to fake the process and stop the buffers being optimised out. - */ -size_t ZSTD_compressBound(size_t maxSrc) { - return maxSrc + 32; -} -int ZSTD_maxCLevel(void) { - return 20; -} -size_t ZSTD_compress(void* dst, size_t dstLen, const void* src, size_t srcLen, int level) { - return (memcmp(dst, src, (srcLen < dstLen) ? srcLen : dstLen)) ? level : dstLen; -} -unsigned ZSTD_isError(size_t code) { - return ((int) code) < 0; -} -size_t ZSTD_decompress(void* dst, size_t dstLen, const void* src, size_t srcLen) { - return (memcmp(dst, src, (srcLen < dstLen) ? srcLen : dstLen)) ? 0 : dstLen; -} -#endif - -//*****************************************************************************/ - -/** - * Simple single-file test to compress \c rawData, decompress the result, then - * compare the decompressed version with the original. - */ -int main() { - size_t bounds = ZSTD_compressBound(sizeof rawData); - void* compBuf = malloc(bounds); - void* testBuf = malloc(sizeof rawData); - int compare = -1; - if (compBuf && testBuf) { - size_t compSize = ZSTD_compress(compBuf, bounds, rawData, sizeof rawData, ZSTD_maxCLevel()); - if (!ZSTD_isError(compSize)) { - printf("Compression: PASSED (size: %lu, uncompressed: %lu)\n", (unsigned long) compSize, (unsigned long) (sizeof rawData)); - size_t decSize = ZSTD_decompress(testBuf, sizeof rawData, compBuf, compSize); - if (!ZSTD_isError(decSize)) { - printf("Decompression: PASSED\n"); - compare = memcmp(rawData, testBuf, decSize); - printf("Byte comparison: %s\n", (compare == 0) ? "PASSED" : "FAILED"); - } else { - printf("Decompression: FAILED\n"); - } - } else { - printf("Compression: FAILED\n"); - } - free(compBuf); - free(testBuf); - } - return (compare == 0) ? EXIT_SUCCESS : EXIT_FAILURE; -} diff --git a/third_party/zstd/build/single_file_libs/examples/shell.html b/third_party/zstd/build/single_file_libs/examples/shell.html deleted file mode 100644 index 5beb0e6d5..000000000 --- a/third_party/zstd/build/single_file_libs/examples/shell.html +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - Emscripten Shell - - - - - -{{{ SCRIPT }}} - - diff --git a/third_party/zstd/build/single_file_libs/examples/simple.c b/third_party/zstd/build/single_file_libs/examples/simple.c deleted file mode 100644 index ee63416a6..000000000 --- a/third_party/zstd/build/single_file_libs/examples/simple.c +++ /dev/null @@ -1,75 +0,0 @@ -/** - * \file simple.c - * Simple standalone example of using the single-file \c zstddeclib. - * - * \note In this simple example we include the amalgamated source and compile - * just this single file, but we could equally (and more conventionally) - * include \c zstd.h and compile both this file and \c zstddeclib.c (the - * resulting binaries differ slightly in size but perform the same). - * - * \author Carl Woffenden, Numfum GmbH (released under a CC0 license) - */ - -#include -#include -#include -#include -#include - -#include "../zstddeclib.c" - -//************************* Test Data (DXT texture) **************************/ - -/** - * Raw 256x256 DXT1 data (used to compare the result). - * \n - * See \c testcard.png for the original. - */ -static uint8_t const rawDxt1[] = { -#include "testcard-dxt1.inl" -}; - -/** - * Zstd compressed version of \c #rawDxt1. - * \n - * See \c testcard.png for the original. - */ -static uint8_t const srcZstd[] = { -#include "testcard-zstd.inl" -}; - -/** - * Destination for decoding \c #srcZstd. - */ -static uint8_t dstDxt1[sizeof rawDxt1] = {}; - -#ifndef ZSTD_VERSION_MAJOR -/** - * For the case where the decompression library hasn't been included we add a - * dummy function to fake the process and stop the buffers being optimised out. - */ -size_t ZSTD_decompress(void* dst, size_t dstLen, const void* src, size_t srcLen) { - return (memcmp(dst, src, (srcLen < dstLen) ? srcLen : dstLen)) ? 0 : dstLen; -} -#endif - -//****************************************************************************/ - -/** - * Simple single-file test to decompress \c #srcZstd into \c # dstDxt1 then - * compare the resulting bytes with \c #rawDxt1. - * \n - * As a (naive) comparison, removing Zstd and building with "-Os -g0 simple.c" - * results in a 44kB binary (macOS 10.14, Clang 10); re-adding Zstd increases - * the binary by 56kB (after calling \c strip). - */ -int main() { - size_t size = ZSTD_decompress(dstDxt1, sizeof dstDxt1, srcZstd, sizeof srcZstd); - int compare = memcmp(rawDxt1, dstDxt1, sizeof dstDxt1); - printf("Decompressed size: %s\n", (size == sizeof dstDxt1) ? "PASSED" : "FAILED"); - printf("Byte comparison: %s\n", (compare == 0) ? "PASSED" : "FAILED"); - if (size == sizeof dstDxt1 && compare == 0) { - return EXIT_SUCCESS; - } - return EXIT_FAILURE; -} diff --git a/third_party/zstd/build/single_file_libs/examples/testcard-dxt1.inl b/third_party/zstd/build/single_file_libs/examples/testcard-dxt1.inl deleted file mode 100644 index e099e66fc..000000000 --- a/third_party/zstd/build/single_file_libs/examples/testcard-dxt1.inl +++ /dev/null @@ -1,2731 +0,0 @@ -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, -0x55, 0xa9, 0xa9, 0xa9, 0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, -0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, -0x55, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, 0x55, 0xa9, 0xa9, 0xa9, -0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, -0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, 0x55, 0x6a, 0x6a, 0x6a, -0x00, 0x00, 0xff, 0xff, 0x55, 0xa9, 0xa9, 0xa9, 0x00, 0x00, 0xff, 0xff, -0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, -0x00, 0x00, 0xff, 0xff, 0x55, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, -0x55, 0xa9, 0xa9, 0xa9, 0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, -0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, -0x55, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, 0x55, 0xa9, 0xa9, 0xa9, -0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, -0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, 0x55, 0x6a, 0x6a, 0x6a, -0x00, 0x00, 0xff, 0xff, 0x55, 0xa9, 0xa9, 0xa9, 0x00, 0x00, 0xff, 0xff, -0x55, 0xaa, 0xaa, 0xaa, 0xff, 0xff, 0x30, 0x84, 0x00, 0x55, 0x55, 0xb5, -0xde, 0xf7, 0x30, 0x84, 0x00, 0x15, 0x35, 0x20, 0xdf, 0xff, 0x30, 0x84, -0x00, 0xd4, 0x80, 0x54, 0xde, 0xf7, 0x30, 0x84, 0x00, 0x2b, 0x7e, 0x55, -0xde, 0xf7, 0x10, 0x84, 0x00, 0xa0, 0x55, 0x55, 0xdf, 0xff, 0xe7, 0x39, -0x00, 0x2a, 0x3f, 0x3f, 0x82, 0x10, 0xff, 0xff, 0x55, 0xa9, 0xa9, 0xa9, -0xff, 0xff, 0x28, 0x42, 0x00, 0xff, 0xff, 0xff, 0x41, 0x08, 0xff, 0xff, -0x55, 0xaa, 0xaa, 0xaa, 0xff, 0xff, 0x8a, 0x52, 0x00, 0x3f, 0x3f, 0x3f, -0xff, 0xff, 0x08, 0x42, 0x00, 0xa8, 0xfc, 0xfc, 0xde, 0xf7, 0x30, 0x84, -0x00, 0x02, 0x55, 0x55, 0xff, 0xff, 0x10, 0x84, 0x00, 0xfa, 0xaf, 0x55, -0xdf, 0xff, 0x30, 0x84, 0x00, 0x15, 0x20, 0x35, 0xde, 0xf7, 0x30, 0x84, -0x00, 0x54, 0x54, 0x80, 0xff, 0xff, 0x30, 0x84, 0x00, 0x55, 0x55, 0x57, -0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, -0x55, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, 0x55, 0xa9, 0xa9, 0xa9, -0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, -0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, 0x55, 0x6a, 0x6a, 0x6a, -0x00, 0x00, 0xff, 0xff, 0x55, 0xa9, 0xa9, 0xa9, 0x00, 0x00, 0xff, 0xff, -0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, -0x00, 0x00, 0xff, 0xff, 0x55, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, -0x55, 0xa9, 0xa9, 0xa9, 0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, -0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, -0x55, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, 0x55, 0xa9, 0xa9, 0xa9, -0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, -0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, 0x55, 0x6a, 0x6a, 0x6a, -0x00, 0x00, 0xff, 0xff, 0x55, 0xa9, 0xa9, 0xa9, 0x00, 0x00, 0xff, 0xff, -0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, -0x00, 0x00, 0xff, 0xff, 0x55, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, -0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, -0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0xff, 0xff, 0x10, 0x84, 0x15, 0x15, 0x15, 0x2d, 0xff, 0xff, 0x30, 0x84, -0x54, 0xd4, 0x88, 0x5c, 0xff, 0xff, 0x10, 0x84, 0xb5, 0xe2, 0x57, 0x55, -0x7d, 0xef, 0x30, 0x84, 0xe0, 0x55, 0x55, 0x55, 0x41, 0x08, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, -0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x6a, 0xff, 0xff, 0x30, 0x84, 0xd4, 0x54, 0x54, 0x54, -0x9d, 0xef, 0x30, 0x84, 0x82, 0xd5, 0x55, 0x55, 0xff, 0xff, 0x10, 0x84, -0x57, 0xe2, 0xb5, 0x55, 0xff, 0xff, 0x30, 0x84, 0x15, 0x15, 0x38, 0x2d, -0xff, 0xff, 0x10, 0x84, 0x54, 0x54, 0x54, 0x5c, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, -0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, -0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, 0x41, 0x08, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0xa9, 0x9e, 0xf7, 0x10, 0x84, 0x55, 0x55, 0x35, 0xe2, -0x5c, 0xe7, 0x10, 0x84, 0xb5, 0x83, 0x5c, 0x55, 0xff, 0xff, 0x30, 0x84, -0x38, 0x15, 0x15, 0x15, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, -0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, -0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, 0xde, 0xf7, 0x30, 0x84, -0x88, 0x94, 0x54, 0x54, 0x5c, 0xe7, 0x10, 0x84, 0x57, 0x70, 0x0d, 0xd5, -0xbe, 0xf7, 0x30, 0x84, 0x55, 0x55, 0x57, 0x62, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, -0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0x55, 0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, -0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x55, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0x55, -0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, -0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x55, -0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0x55, 0x00, 0x00, 0xff, 0xff, -0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x55, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0x55, 0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, -0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, 0xff, 0xff, 0x08, 0x42, -0x3f, 0x3f, 0x2f, 0x00, 0x51, 0x8c, 0xdf, 0xff, 0x61, 0x25, 0x01, 0x55, -0xff, 0xff, 0x49, 0x4a, 0xfe, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, -0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x55, -0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0x55, 0x00, 0x00, 0xff, 0xff, -0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x55, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0x55, 0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, -0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x55, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0x55, -0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, -0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x55, -0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0x55, 0x00, 0x00, 0xff, 0xff, -0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x55, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0x55, 0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, -0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x55, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0x55, -0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, 0xff, 0xff, 0x69, 0x4a, -0x2f, 0xff, 0xff, 0x00, 0x51, 0x8c, 0xff, 0xff, 0x42, 0x66, 0x60, 0x55, -0xff, 0xff, 0x28, 0x42, 0xfc, 0xfc, 0xfc, 0x00, 0x00, 0x00, 0xff, 0xff, -0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x55, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0x55, 0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, -0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x55, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0x55, -0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, -0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x55, -0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0x55, 0x00, 0x00, 0xff, 0xff, -0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x55, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0xa9, 0xa9, 0xa9, -0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, -0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, 0x55, 0x6a, 0x6a, 0x6a, -0xde, 0xff, 0xc8, 0x88, 0xff, 0xff, 0xff, 0xff, 0xde, 0xff, 0xc8, 0x88, -0xff, 0xff, 0xff, 0xff, 0xde, 0xff, 0xc8, 0x88, 0xff, 0xff, 0xff, 0xff, -0xde, 0xff, 0xc8, 0x88, 0xff, 0xff, 0xff, 0xff, 0x99, 0xff, 0x00, 0x5a, -0xff, 0xff, 0xff, 0xff, 0x99, 0xff, 0x00, 0x5a, 0xff, 0xff, 0xff, 0xff, -0x99, 0xff, 0x00, 0x5a, 0xff, 0xff, 0xff, 0xff, 0x99, 0xff, 0x00, 0x5a, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x55, 0xa9, 0xa9, 0xa9, -0xde, 0xf7, 0x10, 0x84, 0x00, 0x55, 0xd5, 0x25, 0xbe, 0xf7, 0x30, 0x84, -0x00, 0xc9, 0x58, 0x57, 0xff, 0xff, 0x08, 0x42, 0x00, 0x3f, 0x3f, 0x3f, -0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, -0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, -0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, -0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, -0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, -0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, -0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, -0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, -0x76, 0xfe, 0x01, 0xd8, 0xff, 0xff, 0xff, 0xff, 0x76, 0xfe, 0x01, 0xd8, -0xff, 0xff, 0xff, 0xff, 0x76, 0xfe, 0x01, 0xd8, 0xff, 0xff, 0xff, 0xff, -0x76, 0xfe, 0x01, 0xd8, 0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, -0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, -0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, -0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, -0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, -0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, -0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, -0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, -0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x08, 0x42, -0x00, 0xbc, 0xfc, 0xfc, 0xbe, 0xf7, 0x10, 0x84, 0x00, 0x58, 0xc9, 0x35, -0xff, 0xff, 0x10, 0x84, 0x00, 0x55, 0x55, 0x56, 0x00, 0x00, 0xff, 0xff, -0x55, 0x6a, 0x6a, 0x6a, 0xf6, 0xff, 0xc1, 0x59, 0xff, 0xff, 0xff, 0xff, -0xf6, 0xff, 0xc1, 0x59, 0xff, 0xff, 0xff, 0xff, 0xf6, 0xff, 0xc1, 0x59, -0xff, 0xff, 0xff, 0xff, 0xf6, 0xff, 0xc1, 0x59, 0xff, 0xff, 0xff, 0xff, -0xff, 0xff, 0x71, 0x39, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x71, 0x39, -0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x71, 0x39, 0xff, 0xff, 0xff, 0xff, -0xff, 0xff, 0x71, 0x39, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0x55, 0xa9, 0xa9, 0xa9, 0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, -0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, -0x55, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, 0xde, 0xff, 0xc8, 0x88, -0xff, 0xff, 0xff, 0xff, 0xde, 0xff, 0xc8, 0x88, 0xff, 0xff, 0xff, 0xff, -0xde, 0xff, 0xc8, 0x88, 0xff, 0xff, 0xff, 0xff, 0xde, 0xff, 0xc8, 0x88, -0xff, 0xff, 0xff, 0xff, 0x99, 0xff, 0x00, 0x5a, 0xff, 0xff, 0xff, 0xff, -0x99, 0xff, 0x00, 0x5a, 0xff, 0xff, 0xff, 0xff, 0x99, 0xff, 0x00, 0x5a, -0xff, 0xff, 0xff, 0xff, 0xe9, 0x93, 0xc7, 0x8b, 0xaa, 0xaa, 0xaa, 0x2a, -0xbe, 0xf7, 0x10, 0x84, 0x54, 0x94, 0x8c, 0x70, 0x7d, 0xef, 0x10, 0x84, -0x63, 0x5c, 0x55, 0x55, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, 0xda, 0xf7, 0x81, 0xf7, -0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, -0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, -0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, -0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, -0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, -0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, -0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, -0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, 0x76, 0xfe, 0x01, 0xd8, -0xff, 0xff, 0xff, 0xff, 0x76, 0xfe, 0x01, 0xd8, 0xff, 0xff, 0xff, 0xff, -0x76, 0xfe, 0x01, 0xd8, 0xff, 0xff, 0xff, 0xff, 0x76, 0xfe, 0x01, 0xd8, -0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, -0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, -0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, -0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, -0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, -0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, -0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, -0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, -0x71, 0x8c, 0xcf, 0x7b, 0xbf, 0xff, 0xff, 0xff, 0x9d, 0xef, 0x10, 0x84, -0x72, 0x8d, 0x95, 0x55, 0xbe, 0xf7, 0x10, 0x84, 0x15, 0x15, 0x1c, 0x23, -0xf6, 0xff, 0xc1, 0x59, 0xff, 0xff, 0xff, 0xff, 0xf6, 0xff, 0xc1, 0x59, -0xff, 0xff, 0xff, 0xff, 0xf6, 0xff, 0xc1, 0x59, 0xff, 0xff, 0xff, 0xff, -0xf6, 0xff, 0xc1, 0x59, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x71, 0x39, -0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x71, 0x39, 0xff, 0xff, 0xff, 0xff, -0xff, 0xff, 0x71, 0x39, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x71, 0x39, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x6a, 0xde, 0xff, 0xc8, 0x88, 0xff, 0xff, 0xff, 0xff, -0xde, 0xff, 0xc8, 0x88, 0xff, 0xff, 0xff, 0xff, 0xde, 0xff, 0xc8, 0x88, -0xff, 0xff, 0xff, 0xff, 0xde, 0xff, 0xc8, 0x88, 0xff, 0xff, 0xff, 0xff, -0x99, 0xff, 0x00, 0x5a, 0xff, 0xff, 0xff, 0xff, 0x99, 0xff, 0x00, 0x5a, -0xff, 0xff, 0xff, 0xff, 0x56, 0xd6, 0xa1, 0x72, 0xff, 0xff, 0xff, 0x3f, -0x5c, 0xef, 0x2a, 0x94, 0x15, 0x8d, 0x73, 0x54, 0x41, 0x08, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x6a, 0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, -0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, -0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, -0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, -0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, -0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, -0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, -0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, -0xff, 0xff, 0xff, 0xff, 0x76, 0xfe, 0x01, 0xd8, 0xff, 0xff, 0xff, 0xff, -0x76, 0xfe, 0x01, 0xd8, 0xff, 0xff, 0xff, 0xff, 0x76, 0xfe, 0x01, 0xd8, -0xff, 0xff, 0xff, 0xff, 0x76, 0xfe, 0x01, 0xd8, 0xff, 0xff, 0xff, 0xff, -0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, -0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, -0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, -0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, -0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, -0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, -0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, -0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0xff, 0xff, 0x30, 0x84, 0x25, 0x15, 0x15, 0x15, 0x7c, 0xf7, 0x09, 0x94, -0x55, 0x5c, 0x73, 0x85, 0x09, 0x94, 0xa7, 0x8b, 0xff, 0xff, 0xff, 0xfe, -0xf6, 0xff, 0xc1, 0x59, 0xff, 0xff, 0xff, 0xff, 0xf6, 0xff, 0xc1, 0x59, -0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x71, 0x39, 0xff, 0xff, 0xff, 0xff, -0xff, 0xff, 0x71, 0x39, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x71, 0x39, -0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x71, 0x39, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0x55, -0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, -0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x55, -0xde, 0xff, 0xc8, 0x88, 0xff, 0xff, 0xff, 0xff, 0xde, 0xff, 0xc8, 0x88, -0xff, 0xff, 0xff, 0xff, 0xde, 0xff, 0xc8, 0x88, 0xff, 0xff, 0xff, 0xff, -0xde, 0xff, 0xc8, 0x88, 0xff, 0xff, 0xff, 0xff, 0x99, 0xff, 0x00, 0x5a, -0xff, 0xff, 0xff, 0xff, 0x7c, 0xf7, 0xc8, 0x8b, 0x55, 0x55, 0xd5, 0x35, -0x3b, 0xef, 0x09, 0x94, 0x05, 0x61, 0x58, 0x57, 0x2a, 0x9c, 0xc7, 0x8b, -0xfc, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0x55, -0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, -0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x55, -0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, -0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, -0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, -0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, -0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, -0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, -0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, -0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, -0x76, 0xfe, 0x01, 0xd8, 0xff, 0xff, 0xff, 0xff, 0x76, 0xfe, 0x01, 0xd8, -0xff, 0xff, 0xff, 0xff, 0x76, 0xfe, 0x01, 0xd8, 0xff, 0xff, 0xff, 0xff, -0x76, 0xfe, 0x01, 0xd8, 0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, -0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, -0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, -0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, -0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, -0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, -0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, -0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, -0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0x55, 0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, -0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x55, 0xf9, 0xe6, 0x60, 0x6a, 0x3f, 0xff, 0xff, 0xff, -0x9d, 0xf7, 0x09, 0x94, 0x56, 0x52, 0x49, 0x35, 0xc2, 0x72, 0xce, 0xac, -0xaa, 0xaa, 0xaa, 0xa9, 0xf6, 0xff, 0xc1, 0x59, 0xff, 0xff, 0xff, 0xff, -0xff, 0xff, 0x71, 0x39, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x71, 0x39, -0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x71, 0x39, 0xff, 0xff, 0xff, 0xff, -0xff, 0xff, 0x71, 0x39, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0x55, 0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, -0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xff, 0xff, 0x55, 0xa9, 0xa9, 0xa9, 0x00, 0x00, 0xff, 0xff, -0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, -0x00, 0x00, 0xff, 0xff, 0x55, 0x6a, 0x6a, 0x6a, 0xde, 0xff, 0xc8, 0x88, -0xff, 0xff, 0xff, 0xff, 0xde, 0xff, 0xc8, 0x88, 0xff, 0xff, 0xff, 0xff, -0xde, 0xff, 0xc8, 0x88, 0xff, 0xff, 0xff, 0xff, 0xde, 0xff, 0xc8, 0x88, -0xff, 0xff, 0xff, 0xff, 0xdf, 0xff, 0x10, 0x84, 0x00, 0x54, 0xd4, 0x34, -0xde, 0xf7, 0xef, 0x7b, 0x00, 0x73, 0x5c, 0x57, 0x00, 0x00, 0xff, 0xff, -0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, 0x55, 0x6a, 0x6a, 0x6a, -0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, -0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, -0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, -0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, -0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, -0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, -0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, -0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, -0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, -0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, -0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, 0x76, 0xfe, 0x01, 0xd8, -0xff, 0xff, 0xff, 0xff, 0x76, 0xfe, 0x01, 0xd8, 0xff, 0xff, 0xff, 0xff, -0x76, 0xfe, 0x01, 0xd8, 0xff, 0xff, 0xff, 0xff, 0x76, 0xfe, 0x01, 0xd8, -0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, -0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, -0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, -0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, -0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, -0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, -0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, -0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, -0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, -0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, -0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0x55, 0xa9, 0xa9, 0xa9, 0x00, 0x00, 0xff, 0xff, -0x55, 0xaa, 0xaa, 0xaa, 0xde, 0xf7, 0xef, 0x7b, 0x00, 0x73, 0xcd, 0x35, -0xff, 0xff, 0x10, 0x84, 0x00, 0x15, 0x15, 0x17, 0xff, 0xff, 0x71, 0x39, -0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x71, 0x39, 0xff, 0xff, 0xff, 0xff, -0xff, 0xff, 0x71, 0x39, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x71, 0x39, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x55, 0xa9, 0xa9, 0xa9, -0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, -0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, 0x55, 0x6a, 0x6a, 0x6a, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x6a, 0xde, 0xff, 0xc8, 0x88, 0xff, 0xff, 0xff, 0xff, -0xde, 0xff, 0xc8, 0x88, 0xff, 0xff, 0xff, 0xff, 0xde, 0xff, 0xc8, 0x88, -0xff, 0xff, 0xff, 0xff, 0x5d, 0xf7, 0xef, 0xaa, 0x55, 0x55, 0xd5, 0x35, -0xde, 0xf7, 0xef, 0x7b, 0xcc, 0x70, 0x5c, 0x54, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, 0xda, 0xf7, 0x81, 0xf7, -0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, -0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, -0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, -0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, -0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, -0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, -0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, -0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, -0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, -0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, -0xff, 0xff, 0xff, 0xff, 0x76, 0xfe, 0x01, 0xd8, 0xff, 0xff, 0xff, 0xff, -0x76, 0xfe, 0x01, 0xd8, 0xff, 0xff, 0xff, 0xff, 0x76, 0xfe, 0x01, 0xd8, -0xff, 0xff, 0xff, 0xff, 0x76, 0xfe, 0x01, 0xd8, 0xff, 0xff, 0xff, 0xff, -0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, -0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, -0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, -0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, -0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, -0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, -0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, -0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, -0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, -0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, -0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0x2c, 0x63, 0xd3, 0x9c, 0x6a, 0xaa, 0xaa, 0xaa, 0xde, 0xf7, 0xef, 0x7b, -0x1c, 0x33, 0x0d, 0x35, 0xd4, 0x62, 0x57, 0x94, 0xaa, 0xaa, 0xaa, 0xa9, -0xff, 0xff, 0x71, 0x39, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x71, 0x39, -0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x71, 0x39, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, -0xde, 0xff, 0xc8, 0x88, 0xff, 0xff, 0xff, 0xff, 0xde, 0xff, 0xc8, 0x88, -0xff, 0xff, 0xff, 0xff, 0xd8, 0xdd, 0xcb, 0x99, 0xff, 0xff, 0xff, 0x3f, -0xdb, 0xee, 0x30, 0xb3, 0x85, 0x61, 0x50, 0x54, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x6a, 0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, -0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, -0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, -0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, -0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, -0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, -0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, -0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, -0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, -0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, -0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, -0x76, 0xfe, 0x01, 0xd8, 0xff, 0xff, 0xff, 0xff, 0x76, 0xfe, 0x01, 0xd8, -0xff, 0xff, 0xff, 0xff, 0x76, 0xfe, 0x01, 0xd8, 0xff, 0xff, 0xff, 0xff, -0x76, 0xfe, 0x01, 0xd8, 0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, -0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, -0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, -0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, -0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, -0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, -0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, -0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, -0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, -0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, -0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, -0x1d, 0xe7, 0xb6, 0x83, 0x54, 0x52, 0x41, 0x85, 0xff, 0xff, 0x71, 0x39, -0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x71, 0x39, 0xff, 0xff, 0xff, 0xff, -0xff, 0xff, 0x71, 0x39, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0x55, 0x00, 0x00, 0xff, 0xff, -0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x55, 0xde, 0xff, 0xc8, 0x88, -0xff, 0xff, 0xff, 0xff, 0x30, 0xb3, 0x0f, 0xb3, 0xff, 0xff, 0xff, 0xbf, -0x9e, 0xf7, 0x30, 0xb3, 0x35, 0xcd, 0x71, 0x5a, 0xf2, 0xbb, 0xae, 0xaa, -0xfe, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0x55, -0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, -0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x55, -0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, -0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, -0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, -0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, -0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, -0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, -0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, -0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, -0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, -0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, -0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, 0x76, 0xfe, 0x01, 0xd8, -0xff, 0xff, 0xff, 0xff, 0x76, 0xfe, 0x01, 0xd8, 0xff, 0xff, 0xff, 0xff, -0x76, 0xfe, 0x01, 0xd8, 0xff, 0xff, 0xff, 0xff, 0x76, 0xfe, 0x01, 0xd8, -0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, -0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, -0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, -0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, -0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, -0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, -0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, -0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, -0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, -0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, -0xff, 0xff, 0xff, 0xff, 0xda, 0xf7, 0x81, 0xf7, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0x55, 0x00, 0x00, 0xff, 0xff, -0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x55, 0x5e, 0xef, 0x96, 0x7b, -0x15, 0xd5, 0x55, 0x55, 0x9e, 0xf7, 0xb6, 0x7b, 0x57, 0x5c, 0x53, 0x69, -0xff, 0xff, 0x71, 0x39, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x71, 0x39, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0x55, -0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, -0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x55, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0xa9, 0xa9, 0xa9, 0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, -0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, -0x55, 0x6a, 0x6a, 0x6a, 0xde, 0xff, 0xc8, 0x88, 0xff, 0xff, 0xff, 0xff, -0x7d, 0xf7, 0x2f, 0xb3, 0x95, 0x35, 0xc5, 0x69, 0xdb, 0xee, 0x0f, 0xb3, -0x54, 0x57, 0x55, 0x55, 0xde, 0xff, 0xc8, 0x88, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0x55, 0xa9, 0xa9, 0xa9, 0x00, 0x00, 0xff, 0xff, -0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, -0x00, 0x00, 0xff, 0xff, 0x55, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x41, 0x08, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x41, 0x08, 0x00, 0x00, -0xff, 0xff, 0xff, 0xff, 0x41, 0x08, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, -0x41, 0x08, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x41, 0x08, 0x00, 0x00, -0xff, 0xff, 0xff, 0xff, 0x41, 0x08, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, -0x41, 0x08, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x41, 0x08, 0x00, 0x00, -0xff, 0xff, 0xff, 0xff, 0x41, 0x08, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, -0x41, 0x08, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x41, 0x08, 0x00, 0x00, -0xff, 0xff, 0xff, 0xff, 0x41, 0x08, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, -0x41, 0x08, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x41, 0x08, 0x00, 0x00, -0xff, 0xff, 0xff, 0xff, 0x41, 0x08, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, -0x41, 0x08, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x41, 0x08, 0x00, 0x00, -0xff, 0xff, 0xff, 0xff, 0x41, 0x08, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, -0x41, 0x08, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x41, 0x08, 0x00, 0x00, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0xa9, 0xa9, 0xa9, 0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, -0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, -0x55, 0x6a, 0x6a, 0x6a, 0xff, 0xff, 0x71, 0x39, 0xff, 0xff, 0xff, 0xff, -0x5e, 0xef, 0xf2, 0x49, 0x8f, 0x3f, 0xbf, 0xff, 0x7e, 0xef, 0x96, 0x7b, -0x55, 0x57, 0x54, 0x5a, 0xff, 0xff, 0x71, 0x39, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0x55, 0xa9, 0xa9, 0xa9, 0x00, 0x00, 0xff, 0xff, -0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, -0x00, 0x00, 0xff, 0xff, 0x55, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, -0x7d, 0xf7, 0x2f, 0xb3, 0x55, 0x55, 0x95, 0x35, 0x7d, 0xf7, 0x30, 0xb3, -0x53, 0x5c, 0x56, 0x55, 0xde, 0xff, 0xc8, 0x88, 0xff, 0xff, 0xff, 0xff, -0xde, 0xff, 0xc8, 0x88, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x41, 0x08, 0x00, 0x00, -0xff, 0xff, 0xff, 0xff, 0x41, 0x08, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, -0x41, 0x08, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x41, 0x08, 0x00, 0x00, -0xff, 0xff, 0xff, 0xff, 0x41, 0x08, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, -0x41, 0x08, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x41, 0x08, 0x00, 0x00, -0xff, 0xff, 0xff, 0xff, 0x41, 0x08, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, -0x41, 0x08, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x41, 0x08, 0x00, 0x00, -0xff, 0xff, 0xff, 0xff, 0x41, 0x08, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, -0x41, 0x08, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x41, 0x08, 0x00, 0x00, -0xff, 0xff, 0xff, 0xff, 0x41, 0x08, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, -0x41, 0x08, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x41, 0x08, 0x00, 0x00, -0xff, 0xff, 0xff, 0xff, 0x41, 0x08, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, -0x41, 0x08, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x41, 0x08, 0x00, 0x00, -0xff, 0xff, 0xff, 0xff, 0x41, 0x08, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, -0xff, 0xff, 0x71, 0x39, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x71, 0x39, -0xff, 0xff, 0xff, 0xff, 0x7e, 0xef, 0xb6, 0x83, 0x71, 0x4d, 0xa5, 0x15, -0x73, 0x5a, 0xb8, 0x9c, 0xaa, 0xaa, 0xaa, 0xa9, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, 0xfc, 0xee, 0x70, 0xb3, -0xc5, 0x49, 0x51, 0x58, 0xde, 0xff, 0xc8, 0x88, 0xff, 0xff, 0xff, 0xff, -0xde, 0xff, 0xc8, 0x88, 0xff, 0xff, 0xff, 0xff, 0xde, 0xff, 0xc8, 0x88, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x41, 0x08, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, -0x41, 0x08, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x41, 0x08, 0x00, 0x00, -0xff, 0xff, 0xff, 0xff, 0x41, 0x08, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, -0x41, 0x08, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x41, 0x08, 0x00, 0x00, -0xff, 0xff, 0xff, 0xff, 0x41, 0x08, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, -0x41, 0x08, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x41, 0x08, 0x00, 0x00, -0xff, 0xff, 0xff, 0xff, 0x41, 0x08, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, -0x41, 0x08, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x41, 0x08, 0x00, 0x00, -0xff, 0xff, 0xff, 0xff, 0x41, 0x08, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, -0x41, 0x08, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x41, 0x08, 0x00, 0x00, -0xff, 0xff, 0xff, 0xff, 0x41, 0x08, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, -0x41, 0x08, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x41, 0x08, 0x00, 0x00, -0xff, 0xff, 0xff, 0xff, 0x41, 0x08, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, -0x41, 0x08, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, 0xff, 0xff, 0x71, 0x39, -0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x71, 0x39, 0xff, 0xff, 0xff, 0xff, -0x19, 0xa5, 0xaf, 0x28, 0x2a, 0xaa, 0xaa, 0xaa, 0x1d, 0xe7, 0xd6, 0x83, -0x54, 0x58, 0x51, 0x49, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0x55, 0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, -0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, 0xff, 0xff, 0x10, 0x84, -0x15, 0x15, 0x35, 0x00, 0x9e, 0xf7, 0x30, 0xb3, 0x54, 0x57, 0x55, 0x55, -0xde, 0xff, 0xc8, 0x88, 0xff, 0xff, 0xff, 0xff, 0xde, 0xff, 0xc8, 0x88, -0xff, 0xff, 0xff, 0xff, 0xde, 0xff, 0xc8, 0x88, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0x55, 0x00, 0x00, 0xff, 0xff, -0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x41, 0x08, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x41, 0x08, 0x00, 0x00, -0xff, 0xff, 0xff, 0xff, 0x41, 0x08, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, -0x41, 0x08, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x41, 0x08, 0x00, 0x00, -0xff, 0xff, 0xff, 0xff, 0x41, 0x08, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, -0x41, 0x08, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x41, 0x08, 0x00, 0x00, -0xff, 0xff, 0xff, 0xff, 0x41, 0x08, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, -0x41, 0x08, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x41, 0x08, 0x00, 0x00, -0xff, 0xff, 0xff, 0xff, 0x41, 0x08, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, -0x41, 0x08, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x41, 0x08, 0x00, 0x00, -0xff, 0xff, 0xff, 0xff, 0x41, 0x08, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, -0x41, 0x08, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x41, 0x08, 0x00, 0x00, -0xff, 0xff, 0xff, 0xff, 0x41, 0x08, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, -0x41, 0x08, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x41, 0x08, 0x00, 0x00, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0x55, 0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, -0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x55, 0xff, 0xff, 0x71, 0x39, 0xff, 0xff, 0xff, 0xff, -0xff, 0xff, 0x71, 0x39, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x71, 0x39, -0xff, 0xff, 0xff, 0xff, 0x3d, 0xe7, 0xb6, 0x7b, 0xc5, 0x35, 0x15, 0xd5, -0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0x55, 0x00, 0x00, 0xff, 0xff, -0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x55, 0xa9, 0xa9, 0xa9, -0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, 0xff, 0xff, 0x08, 0x42, -0x00, 0xff, 0xff, 0xff, 0xdf, 0xff, 0x71, 0x8c, 0x00, 0x11, 0x1b, 0x14, -0xde, 0xff, 0xc8, 0x88, 0xff, 0xff, 0xff, 0xff, 0xde, 0xff, 0xc8, 0x88, -0xff, 0xff, 0xff, 0xff, 0xde, 0xff, 0xc8, 0x88, 0xff, 0xff, 0xff, 0xff, -0xde, 0xff, 0xc8, 0x88, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0x55, 0xa9, 0xa9, 0xa9, 0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, -0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, -0x55, 0x6a, 0x6a, 0x6a, 0x1f, 0x62, 0x1e, 0x5a, 0xea, 0xaa, 0xaa, 0xea, -0x1f, 0x62, 0xfd, 0x59, 0xfe, 0xfa, 0xfe, 0xfe, 0x1e, 0x5a, 0xfd, 0x59, -0x5f, 0x57, 0x57, 0x57, 0xfd, 0x59, 0xdb, 0x51, 0xfa, 0xfa, 0xfa, 0xfa, -0xfc, 0x51, 0xba, 0x51, 0xfe, 0xfe, 0xfa, 0xfe, 0xda, 0x51, 0x99, 0x49, -0xea, 0xea, 0xe8, 0xea, 0xb9, 0x51, 0x98, 0x49, 0x7e, 0x7e, 0x7e, 0x7e, -0x97, 0x49, 0x76, 0x41, 0xe8, 0xe8, 0xe8, 0xe8, 0x97, 0x49, 0x75, 0x41, -0x5f, 0x5f, 0x5f, 0x5f, 0x75, 0x41, 0x32, 0x39, 0xea, 0xea, 0xea, 0xea, -0x53, 0x39, 0x32, 0x39, 0x7e, 0x7e, 0x5e, 0x7e, 0x31, 0x39, 0x10, 0x31, -0xfa, 0xfa, 0x78, 0x7a, 0x0f, 0x31, 0xcd, 0x28, 0xa0, 0x80, 0x80, 0x80, -0xee, 0x30, 0xed, 0x28, 0x5e, 0x7e, 0x5e, 0x5e, 0xcc, 0x28, 0xaa, 0x20, -0xa0, 0xa0, 0xa0, 0xa0, 0xcc, 0x28, 0xaa, 0x20, 0x5f, 0x5f, 0x5f, 0x5f, -0xaa, 0x20, 0x88, 0x18, 0xfa, 0xfa, 0xfa, 0xfa, 0x88, 0x18, 0x66, 0x18, -0xe8, 0xe8, 0xe8, 0xe8, 0x87, 0x18, 0x45, 0x10, 0xfa, 0xfa, 0xfa, 0xfa, -0x66, 0x10, 0x44, 0x10, 0x7e, 0x7e, 0x7e, 0x7e, 0x44, 0x10, 0x22, 0x08, -0xa8, 0xe8, 0xa8, 0xe8, 0x44, 0x10, 0x22, 0x08, 0x5f, 0x7f, 0x7f, 0x7f, -0x22, 0x08, 0x01, 0x08, 0xea, 0xfa, 0xfa, 0xea, 0x01, 0x08, 0x00, 0x00, -0xaa, 0xea, 0xaa, 0xaa, 0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, -0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, -0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, -0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, -0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, -0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, -0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, -0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x55, 0xa9, 0xa9, 0xa9, -0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, -0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, 0x55, 0x6a, 0x6a, 0x6a, -0xff, 0xff, 0x71, 0x39, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x71, 0x39, -0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x71, 0x39, 0xff, 0xff, 0xff, 0xff, -0xff, 0xff, 0x71, 0x39, 0xff, 0xff, 0xff, 0xff, 0xdf, 0xff, 0x51, 0x8c, -0x00, 0x50, 0x78, 0x44, 0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, -0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, -0x55, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0x3c, 0xe7, 0x69, 0x4a, 0xbf, 0x3f, 0x2f, 0x8f, -0xff, 0xff, 0xef, 0x7b, 0x16, 0x17, 0x15, 0x15, 0xde, 0xff, 0xc8, 0x88, -0xff, 0xff, 0xff, 0xff, 0xde, 0xff, 0xc8, 0x88, 0xff, 0xff, 0xff, 0xff, -0xde, 0xff, 0xc8, 0x88, 0xff, 0xff, 0xff, 0xff, 0xde, 0xff, 0xc8, 0x88, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, -0x1f, 0x62, 0x1e, 0x5a, 0xaa, 0xea, 0xaa, 0xea, 0x1f, 0x62, 0xfd, 0x59, -0xfe, 0xfe, 0xfe, 0xfe, 0x1e, 0x5a, 0xfd, 0x59, 0x57, 0x57, 0x57, 0x57, -0xfd, 0x59, 0xdb, 0x51, 0xfa, 0xfa, 0xfa, 0xfa, 0xdb, 0x51, 0xb9, 0x51, -0xa0, 0xa0, 0xa0, 0x80, 0xba, 0x51, 0xb9, 0x49, 0xe8, 0xe8, 0xe8, 0xe8, -0xda, 0x51, 0x98, 0x49, 0x5f, 0x7f, 0x7f, 0x5f, 0x97, 0x49, 0x76, 0x41, -0xe8, 0xe8, 0xe8, 0xe0, 0x97, 0x49, 0x75, 0x41, 0x57, 0x57, 0x5f, 0x5f, -0x75, 0x41, 0x32, 0x39, 0xea, 0xea, 0xea, 0xea, 0x53, 0x39, 0x32, 0x39, -0x5c, 0x5e, 0x7e, 0x5e, 0x32, 0x39, 0x0f, 0x31, 0xfa, 0xfa, 0xfa, 0xfa, -0x0f, 0x31, 0xee, 0x28, 0xe0, 0xe0, 0xa0, 0xa0, 0x10, 0x31, 0xed, 0x28, -0x5f, 0x5f, 0x5f, 0x5f, 0xcc, 0x28, 0xcb, 0x20, 0xe0, 0xe8, 0xe8, 0xe0, -0xcc, 0x28, 0xaa, 0x20, 0x5f, 0x5f, 0x5f, 0x5f, 0xa9, 0x20, 0x88, 0x18, -0xe8, 0xe8, 0xe8, 0xe8, 0x88, 0x18, 0x66, 0x18, 0xe8, 0xe8, 0xe8, 0xe8, -0x67, 0x18, 0x65, 0x10, 0xfe, 0xfa, 0xfe, 0xfa, 0x66, 0x10, 0x44, 0x10, -0x7e, 0x7e, 0x7e, 0x7e, 0x44, 0x10, 0x22, 0x08, 0xa8, 0xa8, 0xa8, 0xa8, -0x44, 0x10, 0x22, 0x08, 0x5f, 0x7f, 0x7f, 0x7f, 0x22, 0x08, 0x01, 0x08, -0xf8, 0xe8, 0xea, 0xea, 0x01, 0x08, 0x00, 0x00, 0xaa, 0xe8, 0xea, 0xe8, -0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, -0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, -0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, -0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, -0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, -0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, -0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, -0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, 0xff, 0xff, 0x71, 0x39, -0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x71, 0x39, 0xff, 0xff, 0xff, 0xff, -0xff, 0xff, 0x71, 0x39, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x71, 0x39, -0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x10, 0x84, 0xe4, 0x34, 0x94, 0xd4, -0x3c, 0xe7, 0x69, 0x4a, 0xff, 0xff, 0xfe, 0xfc, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0x9d, 0xef, 0x30, 0x84, 0x4d, 0x79, 0x51, 0x5a, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x6a, 0xde, 0xff, 0xc8, 0x88, 0xff, 0xff, 0xff, 0xff, -0xde, 0xff, 0xc8, 0x88, 0xff, 0xff, 0xff, 0xff, 0xde, 0xff, 0xc8, 0x88, -0xff, 0xff, 0xff, 0xff, 0xde, 0xff, 0xc8, 0x88, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, 0x1f, 0x62, 0x1e, 0x5a, -0xea, 0xea, 0xea, 0xea, 0x1f, 0x62, 0xfd, 0x59, 0xfe, 0xfe, 0xfa, 0xfe, -0x1e, 0x5a, 0xfd, 0x59, 0x57, 0x5f, 0x57, 0x57, 0xfd, 0x59, 0xdb, 0x51, -0xfa, 0xfa, 0xfa, 0xfa, 0xdb, 0x51, 0xba, 0x51, 0xe0, 0xe0, 0xe0, 0xe0, -0xba, 0x51, 0xb9, 0x49, 0xe8, 0xe8, 0xe8, 0xe8, 0xda, 0x51, 0x98, 0x49, -0x5f, 0x5f, 0x5f, 0x5f, 0x97, 0x49, 0x76, 0x41, 0xe8, 0xe0, 0xe8, 0xe0, -0x97, 0x49, 0x75, 0x41, 0x5f, 0x5f, 0x5f, 0x5f, 0x75, 0x41, 0x32, 0x39, -0xea, 0xea, 0xea, 0xea, 0x53, 0x39, 0x32, 0x39, 0x7e, 0x7a, 0x7a, 0x7e, -0x31, 0x39, 0x10, 0x31, 0x78, 0xf8, 0xf8, 0x78, 0x0f, 0x31, 0xee, 0x28, -0xa0, 0xe0, 0xa0, 0xe0, 0x10, 0x31, 0xed, 0x28, 0x5f, 0x5f, 0x5f, 0x5f, -0xed, 0x28, 0xaa, 0x20, 0xea, 0xea, 0xea, 0xea, 0xcc, 0x28, 0xaa, 0x20, -0x5f, 0x5f, 0x5f, 0x5f, 0xaa, 0x20, 0x88, 0x18, 0xfa, 0xfa, 0xfa, 0xfa, -0x88, 0x18, 0x66, 0x18, 0xe8, 0xe8, 0xe8, 0xe8, 0x67, 0x18, 0x65, 0x10, -0xfa, 0xfa, 0xf8, 0xfa, 0x66, 0x10, 0x44, 0x10, 0x7e, 0x7e, 0x7e, 0x7e, -0x44, 0x10, 0x22, 0x08, 0xa8, 0xa8, 0xa8, 0xa8, 0x44, 0x10, 0x22, 0x08, -0x5f, 0x5f, 0x7f, 0x5f, 0x22, 0x08, 0x01, 0x08, 0xea, 0xea, 0xea, 0xe8, -0x01, 0x08, 0x00, 0x00, 0xea, 0xea, 0xe8, 0xea, 0xd3, 0x9d, 0x02, 0x10, -0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, -0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, -0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, -0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, -0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, -0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, -0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, -0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x6a, 0xff, 0xff, 0x71, 0x39, 0xff, 0xff, 0xff, 0xff, -0xff, 0xff, 0x71, 0x39, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x71, 0x39, -0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x71, 0x39, 0xff, 0xff, 0xff, 0xff, -0xff, 0xff, 0x08, 0x42, 0xfc, 0xfc, 0xfc, 0xfc, 0x9e, 0xf7, 0x30, 0x84, -0x5c, 0x5b, 0x51, 0x69, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0x55, -0xff, 0xff, 0xef, 0x7b, 0x55, 0xd5, 0x95, 0x00, 0xbe, 0xf7, 0x10, 0x84, -0x5c, 0x54, 0x57, 0x00, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x55, -0xde, 0xff, 0xc8, 0x88, 0xff, 0xff, 0xff, 0xff, 0xde, 0xff, 0xc8, 0x88, -0xff, 0xff, 0xff, 0xff, 0xde, 0xff, 0xc8, 0x88, 0xff, 0xff, 0xff, 0xff, -0xde, 0xff, 0xc8, 0x88, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0x55, 0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, -0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x55, 0x1f, 0x62, 0x1e, 0x5a, 0xea, 0xaa, 0xea, 0xea, -0x1f, 0x62, 0xfd, 0x59, 0xfe, 0xfe, 0xfe, 0xfe, 0x1e, 0x5a, 0xfd, 0x59, -0x57, 0x57, 0x57, 0x57, 0xfd, 0x59, 0xdb, 0x51, 0xea, 0xfa, 0xfa, 0xea, -0xdb, 0x51, 0xb9, 0x51, 0x80, 0x80, 0xa0, 0x80, 0xba, 0x51, 0xb8, 0x49, -0xa8, 0xa8, 0xa8, 0xa0, 0xb9, 0x51, 0x98, 0x49, 0x7e, 0x7e, 0x7e, 0x7e, -0x97, 0x49, 0x76, 0x41, 0xa8, 0xe8, 0xe8, 0xe0, 0x97, 0x49, 0x75, 0x41, -0x5f, 0x5f, 0x57, 0x5f, 0x75, 0x41, 0x32, 0x39, 0xea, 0xea, 0xea, 0xea, -0x53, 0x39, 0x32, 0x39, 0x58, 0x7e, 0x7a, 0x7a, 0x32, 0x39, 0x0f, 0x31, -0xfa, 0xfa, 0xfa, 0xfa, 0x0f, 0x31, 0xee, 0x28, 0xa0, 0xe0, 0xe0, 0xe0, -0xef, 0x30, 0xed, 0x28, 0x5e, 0x7f, 0x5e, 0x7f, 0xed, 0x28, 0xaa, 0x20, -0xea, 0xea, 0xea, 0xea, 0xcc, 0x28, 0xaa, 0x20, 0x5f, 0x5f, 0x5f, 0x5f, -0xa9, 0x20, 0x88, 0x18, 0xf8, 0xe8, 0xe8, 0xe8, 0x88, 0x18, 0x66, 0x18, -0xe8, 0xe8, 0xe8, 0xe8, 0x67, 0x18, 0x65, 0x10, 0xfa, 0xfa, 0xfa, 0xfa, -0x66, 0x10, 0x44, 0x10, 0x7e, 0x7e, 0x7e, 0x7e, 0x44, 0x10, 0x22, 0x08, -0xa8, 0xa8, 0xa8, 0xe0, 0x44, 0x10, 0x22, 0x08, 0x7f, 0x7f, 0x5f, 0x5f, -0x22, 0x08, 0x01, 0x08, 0xfa, 0xf8, 0xfa, 0xf8, 0x01, 0x08, 0x00, 0x00, -0xa8, 0xa8, 0xa8, 0xa8, 0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, -0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, -0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, -0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, -0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, -0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, -0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, -0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0x55, -0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, -0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x55, -0xff, 0xff, 0x71, 0x39, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x71, 0x39, -0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x71, 0x39, 0xff, 0xff, 0xff, 0xff, -0xff, 0xff, 0x71, 0x39, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0x55, 0xbe, 0xf7, 0x10, 0x84, 0x4d, 0xc5, 0xb5, 0x00, -0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0xa9, 0xa9, 0xa9, 0xff, 0xff, 0x30, 0x84, -0x00, 0xe5, 0x45, 0x6d, 0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, -0x00, 0x00, 0xff, 0xff, 0x55, 0x6a, 0x6a, 0x6a, 0xde, 0xff, 0xc8, 0x88, -0xff, 0xff, 0xff, 0xff, 0xde, 0xff, 0xc8, 0x88, 0xff, 0xff, 0xff, 0xff, -0xde, 0xff, 0xc8, 0x88, 0xff, 0xff, 0xff, 0xff, 0xde, 0xff, 0xc8, 0x88, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x55, 0xa9, 0xa9, 0xa9, -0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, -0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, 0x55, 0x6a, 0x6a, 0x6a, -0x8c, 0xf8, 0x6b, 0xf0, 0xaa, 0xaa, 0xaa, 0xea, 0x8c, 0xf0, 0x6b, 0xf0, -0xff, 0xdf, 0xff, 0xff, 0x8b, 0xf0, 0x6b, 0xe8, 0x5f, 0x5f, 0x7f, 0x5f, -0x6b, 0xe8, 0x6a, 0xd8, 0xfa, 0xfa, 0xfa, 0xfa, 0x6a, 0xd8, 0x6a, 0xd0, -0xe0, 0xa0, 0xe0, 0xe0, 0x6a, 0xd0, 0x69, 0xc8, 0xf8, 0xf8, 0x78, 0xf8, -0x69, 0xc8, 0x49, 0xb8, 0xa8, 0xe8, 0xe8, 0xe8, 0x69, 0xc0, 0x48, 0xb0, -0xfa, 0xfa, 0xfa, 0xfe, 0x69, 0xb8, 0x48, 0xa8, 0x5f, 0x5f, 0x5f, 0x5f, -0x48, 0xa8, 0x47, 0x98, 0x7a, 0xfa, 0xfa, 0xfa, 0x47, 0x98, 0x47, 0x90, -0x7c, 0x5c, 0x58, 0x5c, 0x47, 0x90, 0x46, 0x80, 0x7a, 0x7e, 0x7a, 0x7e, -0x46, 0x80, 0x45, 0x70, 0xf8, 0xf8, 0xf8, 0xf8, 0x45, 0x70, 0x25, 0x68, -0x78, 0x78, 0x78, 0x78, 0x25, 0x68, 0x24, 0x58, 0xfa, 0xfa, 0xfa, 0xfa, -0x24, 0x58, 0x24, 0x50, 0x78, 0x78, 0x78, 0x78, 0x24, 0x50, 0x23, 0x40, -0xfa, 0xfa, 0xfa, 0xfa, 0x23, 0x40, 0x23, 0x38, 0x78, 0x78, 0x78, 0x78, -0x23, 0x38, 0x02, 0x28, 0xea, 0xea, 0xea, 0xea, 0x22, 0x30, 0x02, 0x20, -0xfa, 0xfe, 0xfa, 0xfa, 0x02, 0x20, 0x01, 0x18, 0xe8, 0xe8, 0xe8, 0xf8, -0x01, 0x18, 0x01, 0x10, 0xf8, 0xf8, 0xf8, 0xe8, 0x01, 0x10, 0x00, 0x08, -0xe8, 0xe8, 0xe8, 0xe0, 0x01, 0x10, 0x00, 0x00, 0xfe, 0xfe, 0xfe, 0xfe, -0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, -0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, -0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, -0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, -0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, -0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, -0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, -0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0x55, 0xa9, 0xa9, 0xa9, 0x00, 0x00, 0xff, 0xff, -0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, -0x00, 0x00, 0xff, 0xff, 0x55, 0x6a, 0x6a, 0x6a, 0xff, 0xff, 0x71, 0x39, -0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x71, 0x39, 0xff, 0xff, 0xff, 0xff, -0xff, 0xff, 0x71, 0x39, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x71, 0x39, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x55, 0xa9, 0xa9, 0xa9, -0xff, 0xff, 0x10, 0x84, 0x00, 0xd5, 0x55, 0x55, 0xff, 0xff, 0x10, 0x84, -0x00, 0x56, 0x54, 0x5e, 0x00, 0x00, 0xff, 0xff, 0x55, 0x6a, 0x6a, 0x6a, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0xa9, 0x7d, 0xef, 0x10, 0x84, 0x79, 0x51, 0x53, 0x5a, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x6a, 0xde, 0xff, 0xc8, 0x88, 0xff, 0xff, 0xff, 0xff, -0xde, 0xff, 0xc8, 0x88, 0xff, 0xff, 0xff, 0xff, 0xde, 0xff, 0xc8, 0x88, -0xff, 0xff, 0xff, 0xff, 0xde, 0xff, 0xc8, 0x88, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, 0x6c, 0xf8, 0x6b, 0xf0, -0xe8, 0xa8, 0xe8, 0xa8, 0x8b, 0xf8, 0x6b, 0xe8, 0xea, 0xfa, 0xfa, 0xea, -0x8b, 0xf0, 0x6b, 0xe8, 0x57, 0x57, 0x57, 0x57, 0x6b, 0xe8, 0x6a, 0xd8, -0xfa, 0xfa, 0xfa, 0xfa, 0x6a, 0xd8, 0x6a, 0xd0, 0xa0, 0xa0, 0xa0, 0xe0, -0x6a, 0xd0, 0x69, 0xc8, 0x60, 0x68, 0xf8, 0xe8, 0x6a, 0xd0, 0x69, 0xc0, -0x5f, 0x5f, 0x5f, 0x5f, 0x69, 0xc0, 0x48, 0xb0, 0xfa, 0xfa, 0xfa, 0xfa, -0x68, 0xb0, 0x48, 0xa8, 0x7e, 0x7a, 0x7e, 0x7a, 0x48, 0xa8, 0x47, 0x98, -0x7a, 0xfa, 0x7a, 0xfa, 0x47, 0x90, 0x47, 0x98, 0x09, 0x09, 0x09, 0x09, -0x47, 0x90, 0x46, 0x80, 0x7e, 0x7e, 0x7e, 0x7e, 0x46, 0x80, 0x25, 0x70, -0xe8, 0xe8, 0xe8, 0xf8, 0x46, 0x78, 0x25, 0x68, 0x7e, 0x7e, 0x7e, 0x7e, -0x45, 0x68, 0x24, 0x58, 0xfa, 0xfe, 0xfa, 0xfa, 0x24, 0x58, 0x24, 0x50, -0x78, 0x78, 0x78, 0x78, 0x24, 0x50, 0x23, 0x40, 0xfa, 0xfa, 0xfa, 0xfa, -0x23, 0x40, 0x23, 0x38, 0x78, 0x78, 0x78, 0x78, 0x23, 0x38, 0x02, 0x28, -0xea, 0xea, 0xfa, 0xea, 0x02, 0x30, 0x22, 0x20, 0xfe, 0xfe, 0xfa, 0xfa, -0x22, 0x28, 0x01, 0x18, 0x7e, 0x7e, 0xfe, 0xfe, 0x01, 0x18, 0x01, 0x10, -0xe8, 0xe8, 0xe8, 0xe8, 0x01, 0x10, 0x00, 0x08, 0xe8, 0xe8, 0xe8, 0xe0, -0x01, 0x08, 0x00, 0x08, 0xff, 0xff, 0xfb, 0xff, 0xd3, 0x9d, 0x02, 0x10, -0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, -0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, -0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, -0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, -0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, -0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, -0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, -0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x6a, 0xff, 0xff, 0x71, 0x39, 0xff, 0xff, 0xff, 0xff, -0xff, 0xff, 0x71, 0x39, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x71, 0x39, -0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x71, 0x39, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0x7d, 0xef, 0x10, 0x84, 0x5b, 0x51, 0x71, 0x69, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0xdf, 0xff, 0x10, 0x84, 0x54, 0x54, 0xd4, 0x94, -0x1c, 0xe7, 0xef, 0x7b, 0x5c, 0x54, 0x54, 0x56, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, -0xde, 0xff, 0xc8, 0x88, 0xff, 0xff, 0xff, 0xff, 0xde, 0xff, 0xc8, 0x88, -0xff, 0xff, 0xff, 0xff, 0xde, 0xff, 0xc8, 0x88, 0xff, 0xff, 0xff, 0xff, -0xde, 0xff, 0xc8, 0x88, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x6a, 0x8c, 0xf8, 0x6b, 0xf0, 0xfa, 0xea, 0xea, 0xea, -0x8c, 0xf0, 0x6b, 0xf0, 0xfa, 0xfe, 0xfa, 0xff, 0x8b, 0xf0, 0x6b, 0xe8, -0x5f, 0x5f, 0x5e, 0x5f, 0x6b, 0xe8, 0x6a, 0xd8, 0xfa, 0xfa, 0xfa, 0xfa, -0x6a, 0xd8, 0x6a, 0xd0, 0xe0, 0xa0, 0xa0, 0xe0, 0x6a, 0xd0, 0x69, 0xc8, -0xf8, 0xe8, 0xf8, 0xf8, 0x6a, 0xc8, 0x69, 0xc0, 0x7e, 0x7e, 0x5e, 0x5e, -0x69, 0xc0, 0x48, 0xb0, 0xfa, 0xfa, 0xfa, 0xfa, 0x68, 0xb0, 0x48, 0xa8, -0x7e, 0x5e, 0x7a, 0x7e, 0x48, 0xa8, 0x47, 0x98, 0x7a, 0x7a, 0x7a, 0xfa, -0x47, 0x90, 0x47, 0x98, 0x09, 0x09, 0x09, 0x09, 0x47, 0x90, 0x46, 0x80, -0x7e, 0x7e, 0x7a, 0x7e, 0x46, 0x80, 0x25, 0x70, 0xfa, 0xea, 0xea, 0xea, -0x46, 0x78, 0x25, 0x68, 0x7e, 0x7e, 0x7e, 0x7e, 0x45, 0x68, 0x24, 0x58, -0xfe, 0xfa, 0xfe, 0xfe, 0x24, 0x58, 0x24, 0x50, 0x78, 0x78, 0x78, 0x78, -0x24, 0x50, 0x23, 0x40, 0xfa, 0xfa, 0xfa, 0xfa, 0x23, 0x40, 0x23, 0x38, -0x78, 0x78, 0x78, 0x78, 0x23, 0x38, 0x22, 0x28, 0xea, 0xfa, 0xfa, 0xfa, -0x22, 0x30, 0x02, 0x20, 0xfa, 0xfe, 0xfa, 0xfa, 0x22, 0x28, 0x01, 0x18, -0xfe, 0xfe, 0xfe, 0xfe, 0x01, 0x18, 0x01, 0x10, 0xe8, 0xe8, 0xe8, 0xf8, -0x01, 0x10, 0x00, 0x08, 0xe8, 0xe8, 0xe0, 0xe8, 0x01, 0x10, 0x00, 0x00, -0xfe, 0xfa, 0xfa, 0xfe, 0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, -0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, -0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, -0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, -0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, -0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, -0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, -0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, -0xff, 0xff, 0x71, 0x39, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x71, 0x39, -0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x71, 0x39, 0xff, 0xff, 0xff, 0xff, -0xff, 0xff, 0x71, 0x39, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0x7d, 0xef, 0x10, 0x84, 0x4d, 0x45, 0xe5, 0xa5, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0xff, 0xff, 0x10, 0x84, 0x94, 0x14, 0xb4, 0x00, 0xdf, 0xff, 0xef, 0x7b, -0x57, 0x55, 0x55, 0x00, 0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x55, 0xde, 0xff, 0xc8, 0x88, -0xff, 0xff, 0xff, 0xff, 0xde, 0xff, 0xc8, 0x88, 0xff, 0xff, 0xff, 0xff, -0xde, 0xff, 0xc8, 0x88, 0xff, 0xff, 0xff, 0xff, 0xde, 0xff, 0xc8, 0x88, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0x55, -0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, -0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x55, -0x8c, 0xf8, 0x6b, 0xf0, 0xea, 0xea, 0xea, 0xea, 0x8c, 0xf0, 0x6b, 0xf0, -0xff, 0xff, 0xff, 0xfb, 0x6b, 0xf0, 0x6b, 0xe0, 0xea, 0xfa, 0xea, 0xfa, -0x6b, 0xe8, 0x6a, 0xd8, 0xfa, 0xfa, 0xfa, 0xfa, 0x6a, 0xd8, 0x6a, 0xd0, -0xe0, 0xe0, 0xa0, 0xe0, 0x6a, 0xd0, 0x69, 0xc8, 0x70, 0xe8, 0x78, 0xe8, -0x6a, 0xd0, 0x69, 0xc0, 0x5f, 0x5f, 0x5f, 0x5f, 0x69, 0xc0, 0x48, 0xb0, -0xfe, 0xfe, 0xfa, 0x7a, 0x68, 0xb0, 0x48, 0xa8, 0x7a, 0x7a, 0x7e, 0x7a, -0x48, 0xa8, 0x47, 0x98, 0xfa, 0xfa, 0xfa, 0xfa, 0x47, 0x90, 0x47, 0x98, -0x09, 0x09, 0x09, 0x09, 0x47, 0x90, 0x46, 0x80, 0x7a, 0x7a, 0x7e, 0x7e, -0x46, 0x80, 0x25, 0x70, 0xe8, 0xe8, 0xe8, 0xe8, 0x45, 0x70, 0x25, 0x68, -0x78, 0x78, 0x78, 0x78, 0x25, 0x68, 0x24, 0x58, 0xfa, 0xfa, 0xfa, 0xfa, -0x24, 0x58, 0x24, 0x50, 0x78, 0x78, 0x78, 0x78, 0x24, 0x50, 0x23, 0x40, -0xfa, 0xfa, 0xfa, 0xfa, 0x23, 0x40, 0x23, 0x38, 0x78, 0x78, 0x78, 0x78, -0x23, 0x38, 0x02, 0x28, 0xea, 0xfa, 0xea, 0xea, 0x22, 0x30, 0x02, 0x20, -0xfa, 0xfa, 0xfa, 0xfe, 0x22, 0x28, 0x01, 0x18, 0xfe, 0xfe, 0xfe, 0x7e, -0x01, 0x18, 0x01, 0x10, 0xe8, 0xe8, 0xf8, 0xe8, 0x01, 0x10, 0x00, 0x08, -0xa8, 0xe8, 0xa0, 0xa8, 0x01, 0x10, 0x00, 0x00, 0xfe, 0xfe, 0xfe, 0xfe, -0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, -0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, -0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, -0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, -0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, -0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, -0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, -0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0x55, 0x00, 0x00, 0xff, 0xff, -0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x55, 0xff, 0xff, 0x71, 0x39, -0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x71, 0x39, 0xff, 0xff, 0xff, 0xff, -0xff, 0xff, 0x71, 0x39, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x71, 0x39, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0x55, -0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, 0xff, 0xff, 0x10, 0x84, -0xb5, 0x15, 0x95, 0x00, 0xff, 0xff, 0x10, 0x84, 0x15, 0x15, 0x17, 0x00, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xde, 0xf7, 0x30, 0x84, -0x00, 0x44, 0x44, 0x6c, 0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, -0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, -0x55, 0x6a, 0x6a, 0x6a, 0xde, 0xff, 0xc8, 0x88, 0xff, 0xff, 0xff, 0xff, -0xde, 0xff, 0xc8, 0x88, 0xff, 0xff, 0xff, 0xff, 0xde, 0xff, 0xc8, 0x88, -0xff, 0xff, 0xff, 0xff, 0xde, 0xff, 0xc8, 0x88, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0x55, 0xa9, 0xa9, 0xa9, 0x00, 0x00, 0xff, 0xff, -0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, -0x00, 0x00, 0xff, 0xff, 0x55, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0xa9, 0xa9, 0xa9, 0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, -0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, -0x55, 0x6a, 0x6a, 0x6a, 0xff, 0xff, 0x71, 0x39, 0xff, 0xff, 0xff, 0xff, -0xff, 0xff, 0x71, 0x39, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x71, 0x39, -0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x71, 0x39, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0x55, 0xa9, 0xa9, 0xa9, 0x00, 0x00, 0xff, 0xff, -0x55, 0xaa, 0xaa, 0xaa, 0x41, 0x08, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, -0xbe, 0xf7, 0x10, 0x84, 0x00, 0x14, 0x14, 0x1c, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0xde, 0xf7, 0x30, 0x84, 0x6c, 0x78, 0x78, 0x50, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, -0xde, 0xff, 0xc8, 0x88, 0xff, 0xff, 0xff, 0xff, 0xde, 0xff, 0xc8, 0x88, -0xff, 0xff, 0xff, 0xff, 0xde, 0xff, 0xc8, 0x88, 0xff, 0xff, 0xff, 0xff, -0xde, 0xff, 0xc8, 0x88, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, -0xff, 0xff, 0x71, 0x39, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x71, 0x39, -0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x71, 0x39, 0xff, 0xff, 0xff, 0xff, -0xff, 0xff, 0x71, 0x39, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0xde, 0xf7, 0x30, 0x84, -0x1e, 0x1b, 0x1b, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0xdf, 0xff, 0x10, 0x84, 0x50, 0x50, 0x58, 0x58, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, 0xde, 0xff, 0xc8, 0x88, -0xff, 0xff, 0xff, 0xff, 0xde, 0xff, 0xc8, 0x88, 0xff, 0xff, 0xff, 0xff, -0xde, 0xff, 0xc8, 0x88, 0xff, 0xff, 0xff, 0xff, 0xde, 0xff, 0xc8, 0x88, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, 0xff, 0xff, 0x71, 0x39, -0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x71, 0x39, 0xff, 0xff, 0xff, 0xff, -0xff, 0xff, 0x71, 0x39, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x71, 0x39, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0xdf, 0xff, 0x30, 0x84, 0x11, 0x11, 0x39, 0x39, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x08, 0x42, -0xf8, 0xf8, 0xf8, 0x00, 0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, -0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x55, 0xde, 0xff, 0xc8, 0x88, 0xff, 0xff, 0xff, 0xff, -0xde, 0xff, 0xc8, 0x88, 0xff, 0xff, 0xff, 0xff, 0xde, 0xff, 0xc8, 0x88, -0xff, 0xff, 0xff, 0xff, 0xde, 0xff, 0xc8, 0x88, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0x55, 0x00, 0x00, 0xff, 0xff, -0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x55, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0x55, 0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, -0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x55, 0xff, 0xff, 0x71, 0x39, 0xff, 0xff, 0xff, 0xff, -0xff, 0xff, 0x71, 0x39, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x71, 0x39, -0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x71, 0x39, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0x55, 0x00, 0x00, 0xff, 0xff, -0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, -0xff, 0xff, 0x08, 0x42, 0x2b, 0x2b, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0xa2, 0x10, 0xff, 0xff, 0x55, 0xa9, 0xa9, 0xa9, -0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, -0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, 0x55, 0x6a, 0x6a, 0x6a, -0xde, 0xff, 0xc8, 0x88, 0xff, 0xff, 0xff, 0xff, 0xde, 0xff, 0xc8, 0x88, -0xff, 0xff, 0xff, 0xff, 0xde, 0xff, 0xc8, 0x88, 0xff, 0xff, 0xff, 0xff, -0xde, 0xff, 0xc8, 0x88, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0x55, 0xa9, 0xa9, 0xa9, 0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, -0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, -0x55, 0x6a, 0x6a, 0x6a, 0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, -0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0xd3, 0x9d, 0x02, 0x10, -0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, -0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0xd3, 0x9d, 0x02, 0x10, -0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, -0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0xd3, 0x9d, 0x02, 0x10, -0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0xa9, 0xa9, 0xa9, -0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, -0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, 0x55, 0x6a, 0x6a, 0x6a, -0xff, 0xff, 0x71, 0x39, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x71, 0x39, -0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x71, 0x39, 0xff, 0xff, 0xff, 0xff, -0xff, 0xff, 0x71, 0x39, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0x55, 0xa9, 0xa9, 0xa9, 0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, -0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, 0x04, 0x21, 0xbe, 0xf7, -0x55, 0x5a, 0x5a, 0x5a, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0xff, 0xff, 0x28, 0x42, 0xfc, 0xfc, 0xfc, 0xfc, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, 0xde, 0xff, 0xc8, 0x88, -0xff, 0xff, 0xff, 0xff, 0xde, 0xff, 0xc8, 0x88, 0xff, 0xff, 0xff, 0xff, -0xde, 0xff, 0xc8, 0x88, 0xff, 0xff, 0xff, 0xff, 0xde, 0xff, 0xc8, 0x88, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, -0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0xd3, 0x9d, 0x02, 0x10, -0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, -0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0xd3, 0x9d, 0x02, 0x10, -0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, -0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0xd3, 0x9d, 0x02, 0x10, -0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, -0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, 0xff, 0xff, 0x71, 0x39, -0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x71, 0x39, 0xff, 0xff, 0xff, 0xff, -0xff, 0xff, 0x71, 0x39, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x71, 0x39, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0xde, 0xf7, 0x49, 0x4a, 0x0f, 0x0f, 0x0f, 0x0f, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0xff, 0xff, 0x28, 0x42, -0xfc, 0xfc, 0xfc, 0xfc, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x6a, 0xfb, 0xd5, 0x0a, 0x04, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xd5, 0x0a, 0x04, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xd5, 0x0a, 0x04, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xd5, 0x0a, 0x04, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, 0xd3, 0x9d, 0x02, 0x10, -0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, -0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0xd3, 0x9d, 0x02, 0x10, -0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, -0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0xd3, 0x9d, 0x02, 0x10, -0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, -0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x6a, 0xda, 0xfd, 0x60, 0x3b, 0xff, 0xff, 0xff, 0xff, -0xda, 0xfd, 0x60, 0x3b, 0xff, 0xff, 0xff, 0xff, 0xda, 0xfd, 0x60, 0x3b, -0xff, 0xff, 0xff, 0xff, 0xda, 0xfd, 0x60, 0x3b, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0x10, 0x84, 0xdf, 0xff, 0x50, 0x50, 0x50, 0x50, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0xa2, 0x10, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0x55, -0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, -0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x55, -0xfb, 0xd5, 0x0a, 0x04, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xd5, 0x0a, 0x04, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xd5, 0x0a, 0x04, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xd5, 0x0a, 0x04, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0x55, 0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, -0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x55, 0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, -0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0xd3, 0x9d, 0x02, 0x10, -0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, -0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0xd3, 0x9d, 0x02, 0x10, -0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, -0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0xd3, 0x9d, 0x02, 0x10, -0xff, 0xff, 0xff, 0xff, 0xd3, 0x9d, 0x02, 0x10, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0x55, -0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, -0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x55, -0xda, 0xfd, 0x60, 0x3b, 0xff, 0xff, 0xff, 0xff, 0xda, 0xfd, 0x60, 0x3b, -0xff, 0xff, 0xff, 0xff, 0xda, 0xfd, 0x60, 0x3b, 0xff, 0xff, 0xff, 0xff, -0xda, 0xfd, 0x60, 0x3b, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0x55, 0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, -0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, 0xbe, 0xf7, 0xaa, 0x52, -0x0f, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0xff, 0xff, 0x08, 0x42, 0x00, 0xf8, 0xf8, 0xf8, 0x00, 0x00, 0xff, 0xff, -0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, -0x00, 0x00, 0xff, 0xff, 0x55, 0x6a, 0x6a, 0x6a, 0xfb, 0xd5, 0x0a, 0x04, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xd5, 0x0a, 0x04, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xd5, 0x0a, 0x04, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xd5, 0x0a, 0x04, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x55, 0xa9, 0xa9, 0xa9, -0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, -0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, 0x55, 0x6a, 0x6a, 0x6a, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0xd6, 0xb5, 0x21, 0x08, 0xff, 0xff, 0xff, 0xff, -0xd6, 0xb5, 0x21, 0x08, 0xff, 0xff, 0xff, 0xff, 0xd6, 0xb5, 0x21, 0x08, -0xff, 0xff, 0xff, 0xff, 0xd6, 0xb5, 0x21, 0x08, 0xff, 0xff, 0xff, 0xff, -0xd6, 0xb5, 0x21, 0x08, 0xff, 0xff, 0xff, 0xff, 0xd6, 0xb5, 0x21, 0x08, -0xff, 0xff, 0xff, 0xff, 0xd6, 0xb5, 0x21, 0x08, 0xff, 0xff, 0xff, 0xff, -0xd6, 0xb5, 0x21, 0x08, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0xde, 0xf5, 0x14, 0xa6, 0xff, 0xff, 0xff, 0xff, 0xde, 0xf5, 0x14, 0xa6, -0xff, 0xff, 0xff, 0xff, 0xde, 0xf5, 0x14, 0xa6, 0xff, 0xff, 0xff, 0xff, -0xde, 0xf5, 0x14, 0xa6, 0xff, 0xff, 0xff, 0xff, 0xde, 0xf5, 0x14, 0xa6, -0xff, 0xff, 0xff, 0xff, 0xde, 0xf5, 0x14, 0xa6, 0xff, 0xff, 0xff, 0xff, -0xde, 0xf5, 0x14, 0xa6, 0xff, 0xff, 0xff, 0xff, 0xde, 0xf5, 0x14, 0xa6, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0xa9, 0xa9, 0xa9, 0x00, 0x00, 0xff, 0xff, -0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, -0x00, 0x00, 0xff, 0xff, 0x55, 0x6a, 0x6a, 0x6a, 0xda, 0xfd, 0x60, 0x3b, -0xff, 0xff, 0xff, 0xff, 0xda, 0xfd, 0x60, 0x3b, 0xff, 0xff, 0xff, 0xff, -0xda, 0xfd, 0x60, 0x3b, 0xff, 0xff, 0xff, 0xff, 0xda, 0xfd, 0x60, 0x3b, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x55, 0xa9, 0xa9, 0xa9, -0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, -0x55, 0xaa, 0xaa, 0xaa, 0xff, 0xff, 0x08, 0x42, 0x00, 0x2b, 0x2b, 0x2b, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xdf, 0xff, 0x10, 0x84, -0x58, 0x58, 0x50, 0x50, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x6a, 0xfb, 0xd5, 0x0a, 0x04, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xd5, 0x0a, 0x04, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xd5, 0x0a, 0x04, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xd5, 0x0a, 0x04, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0xd6, 0xb5, 0x21, 0x08, 0xff, 0xff, 0xff, 0xff, 0xd6, 0xb5, 0x21, 0x08, -0xff, 0xff, 0xff, 0xff, 0xd6, 0xb5, 0x21, 0x08, 0xff, 0xff, 0xff, 0xff, -0xd6, 0xb5, 0x21, 0x08, 0xff, 0xff, 0xff, 0xff, 0xd6, 0xb5, 0x21, 0x08, -0xff, 0xff, 0xff, 0xff, 0xd6, 0xb5, 0x21, 0x08, 0xff, 0xff, 0xff, 0xff, -0xd6, 0xb5, 0x21, 0x08, 0xff, 0xff, 0xff, 0xff, 0xd6, 0xb5, 0x21, 0x08, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0xde, 0xf5, 0x14, 0xa6, -0xff, 0xff, 0xff, 0xff, 0xde, 0xf5, 0x14, 0xa6, 0xff, 0xff, 0xff, 0xff, -0xde, 0xf5, 0x14, 0xa6, 0xff, 0xff, 0xff, 0xff, 0xde, 0xf5, 0x14, 0xa6, -0xff, 0xff, 0xff, 0xff, 0xde, 0xf5, 0x14, 0xa6, 0xff, 0xff, 0xff, 0xff, -0xde, 0xf5, 0x14, 0xa6, 0xff, 0xff, 0xff, 0xff, 0xde, 0xf5, 0x14, 0xa6, -0xff, 0xff, 0xff, 0xff, 0xde, 0xf5, 0x14, 0xa6, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x6a, 0xda, 0xfd, 0x60, 0x3b, 0xff, 0xff, 0xff, 0xff, -0xda, 0xfd, 0x60, 0x3b, 0xff, 0xff, 0xff, 0xff, 0xda, 0xfd, 0x60, 0x3b, -0xff, 0xff, 0xff, 0xff, 0xda, 0xfd, 0x60, 0x3b, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0xdf, 0xff, 0x30, 0x84, 0x39, 0x39, 0x11, 0x11, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0xde, 0xf7, 0x30, 0x84, 0x50, 0x78, 0x78, 0x6c, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, -0xfb, 0xd5, 0x0a, 0x04, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xd5, 0x0a, 0x04, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xd5, 0x0a, 0x04, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xd5, 0x0a, 0x04, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd6, 0xb5, 0x21, 0x08, -0xff, 0xff, 0xff, 0xff, 0xd6, 0xb5, 0x21, 0x08, 0xff, 0xff, 0xff, 0xff, -0xd6, 0xb5, 0x21, 0x08, 0xff, 0xff, 0xff, 0xff, 0xd6, 0xb5, 0x21, 0x08, -0xff, 0xff, 0xff, 0xff, 0xd6, 0xb5, 0x21, 0x08, 0xff, 0xff, 0xff, 0xff, -0xd6, 0xb5, 0x21, 0x08, 0xff, 0xff, 0xff, 0xff, 0xd6, 0xb5, 0x21, 0x08, -0xff, 0xff, 0xff, 0xff, 0xd6, 0xb5, 0x21, 0x08, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0xde, 0xf5, 0x14, 0xa6, 0xff, 0xff, 0xff, 0xff, -0xde, 0xf5, 0x14, 0xa6, 0xff, 0xff, 0xff, 0xff, 0xde, 0xf5, 0x14, 0xa6, -0xff, 0xff, 0xff, 0xff, 0xde, 0xf5, 0x14, 0xa6, 0xff, 0xff, 0xff, 0xff, -0xde, 0xf5, 0x14, 0xa6, 0xff, 0xff, 0xff, 0xff, 0xde, 0xf5, 0x14, 0xa6, -0xff, 0xff, 0xff, 0xff, 0xde, 0xf5, 0x14, 0xa6, 0xff, 0xff, 0xff, 0xff, -0xde, 0xf5, 0x14, 0xa6, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, -0xda, 0xfd, 0x60, 0x3b, 0xff, 0xff, 0xff, 0xff, 0xda, 0xfd, 0x60, 0x3b, -0xff, 0xff, 0xff, 0xff, 0xda, 0xfd, 0x60, 0x3b, 0xff, 0xff, 0xff, 0xff, -0xda, 0xfd, 0x60, 0x3b, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0xde, 0xf7, 0x30, 0x84, -0x11, 0x1b, 0x1b, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0xbe, 0xf7, 0x30, 0x84, 0x4c, 0x44, 0x44, 0x00, 0x00, 0x00, 0xff, 0xff, -0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x55, 0xfb, 0xd5, 0x0a, 0x04, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xd5, 0x0a, 0x04, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xd5, 0x0a, 0x04, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xd5, 0x0a, 0x04, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0x55, -0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, -0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x55, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0xd6, 0xb5, 0x21, 0x08, 0xff, 0xff, 0xff, 0xff, -0xd6, 0xb5, 0x21, 0x08, 0xff, 0xff, 0xff, 0xff, 0xd6, 0xb5, 0x21, 0x08, -0xff, 0xff, 0xff, 0xff, 0xd6, 0xb5, 0x21, 0x08, 0xff, 0xff, 0xff, 0xff, -0xd6, 0xb5, 0x21, 0x08, 0xff, 0xff, 0xff, 0xff, 0xd6, 0xb5, 0x21, 0x08, -0xff, 0xff, 0xff, 0xff, 0xd6, 0xb5, 0x21, 0x08, 0xff, 0xff, 0xff, 0xff, -0xd6, 0xb5, 0x21, 0x08, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0xde, 0xf5, 0x14, 0xa6, 0xff, 0xff, 0xff, 0xff, 0xde, 0xf5, 0x14, 0xa6, -0xff, 0xff, 0xff, 0xff, 0xde, 0xf5, 0x14, 0xa6, 0xff, 0xff, 0xff, 0xff, -0xde, 0xf5, 0x14, 0xa6, 0xff, 0xff, 0xff, 0xff, 0xde, 0xf5, 0x14, 0xa6, -0xff, 0xff, 0xff, 0xff, 0xde, 0xf5, 0x14, 0xa6, 0xff, 0xff, 0xff, 0xff, -0xde, 0xf5, 0x14, 0xa6, 0xff, 0xff, 0xff, 0xff, 0xde, 0xf5, 0x14, 0xa6, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0x55, 0x00, 0x00, 0xff, 0xff, -0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x55, 0xda, 0xfd, 0x60, 0x3b, -0xff, 0xff, 0xff, 0xff, 0xda, 0xfd, 0x60, 0x3b, 0xff, 0xff, 0xff, 0xff, -0xda, 0xfd, 0x60, 0x3b, 0xff, 0xff, 0xff, 0xff, 0xda, 0xfd, 0x60, 0x3b, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0x55, -0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, 0x41, 0x08, 0xff, 0xff, -0xaa, 0xaa, 0xaa, 0x55, 0xbe, 0xf7, 0x10, 0x84, 0x1c, 0x14, 0x14, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0xff, 0xff, 0x10, 0x84, -0x00, 0xb4, 0x14, 0x94, 0xdf, 0xff, 0xef, 0x7b, 0x00, 0x55, 0x55, 0x57, -0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, -0x55, 0x6a, 0x6a, 0x6a, 0xfb, 0xd5, 0x0a, 0x04, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xd5, 0x0a, 0x04, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xd5, 0x0a, 0x04, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xd5, 0x0a, 0x04, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0x55, 0xa9, 0xa9, 0xa9, 0x00, 0x00, 0xff, 0xff, -0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, -0x00, 0x00, 0xff, 0xff, 0x55, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0xd6, 0xb5, 0x21, 0x08, 0xff, 0xff, 0xff, 0xff, 0xd6, 0xb5, 0x21, 0x08, -0xff, 0xff, 0xff, 0xff, 0xd6, 0xb5, 0x21, 0x08, 0xff, 0xff, 0xff, 0xff, -0xd6, 0xb5, 0x21, 0x08, 0xff, 0xff, 0xff, 0xff, 0xd6, 0xb5, 0x21, 0x08, -0xff, 0xff, 0xff, 0xff, 0xd6, 0xb5, 0x21, 0x08, 0xff, 0xff, 0xff, 0xff, -0xd6, 0xb5, 0x21, 0x08, 0xff, 0xff, 0xff, 0xff, 0xd6, 0xb5, 0x21, 0x08, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0xde, 0xf5, 0x14, 0xa6, -0xff, 0xff, 0xff, 0xff, 0xde, 0xf5, 0x14, 0xa6, 0xff, 0xff, 0xff, 0xff, -0xde, 0xf5, 0x14, 0xa6, 0xff, 0xff, 0xff, 0xff, 0xde, 0xf5, 0x14, 0xa6, -0xff, 0xff, 0xff, 0xff, 0xde, 0xf5, 0x14, 0xa6, 0xff, 0xff, 0xff, 0xff, -0xde, 0xf5, 0x14, 0xa6, 0xff, 0xff, 0xff, 0xff, 0xde, 0xf5, 0x14, 0xa6, -0xff, 0xff, 0xff, 0xff, 0xde, 0xf5, 0x14, 0xa6, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0xa9, 0xa9, 0xa9, 0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, -0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, -0x55, 0x6a, 0x6a, 0x6a, 0xda, 0xfd, 0x60, 0x3b, 0xff, 0xff, 0xff, 0xff, -0xda, 0xfd, 0x60, 0x3b, 0xff, 0xff, 0xff, 0xff, 0xda, 0xfd, 0x60, 0x3b, -0xff, 0xff, 0xff, 0xff, 0xda, 0xfd, 0x60, 0x3b, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0x55, 0xa9, 0xa9, 0xa9, 0x00, 0x00, 0xff, 0xff, -0x55, 0xaa, 0xaa, 0xaa, 0xff, 0xff, 0x10, 0x84, 0x00, 0x95, 0x15, 0xb5, -0xff, 0xff, 0x10, 0x84, 0x00, 0x17, 0x15, 0x15, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0xdf, 0xff, 0x10, 0x84, 0x94, 0xd4, 0x54, 0x54, -0x3c, 0xe7, 0xef, 0x7b, 0x56, 0x54, 0x54, 0x5c, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, -0xfb, 0xd5, 0x0a, 0x04, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xd5, 0x0a, 0x04, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xd5, 0x0a, 0x04, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xd5, 0x0a, 0x04, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd6, 0xb5, 0x21, 0x08, -0xff, 0xff, 0xff, 0xff, 0xd6, 0xb5, 0x21, 0x08, 0xff, 0xff, 0xff, 0xff, -0xd6, 0xb5, 0x21, 0x08, 0xff, 0xff, 0xff, 0xff, 0xd6, 0xb5, 0x21, 0x08, -0xff, 0xff, 0xff, 0xff, 0xd6, 0xb5, 0x21, 0x08, 0xff, 0xff, 0xff, 0xff, -0xd6, 0xb5, 0x21, 0x08, 0xff, 0xff, 0xff, 0xff, 0xd6, 0xb5, 0x21, 0x08, -0xff, 0xff, 0xff, 0xff, 0xd6, 0xb5, 0x21, 0x08, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0xde, 0xf5, 0x14, 0xa6, 0xff, 0xff, 0xff, 0xff, -0xde, 0xf5, 0x14, 0xa6, 0xff, 0xff, 0xff, 0xff, 0xde, 0xf5, 0x14, 0xa6, -0xff, 0xff, 0xff, 0xff, 0xde, 0xf5, 0x14, 0xa6, 0xff, 0xff, 0xff, 0xff, -0xde, 0xf5, 0x14, 0xa6, 0xff, 0xff, 0xff, 0xff, 0xde, 0xf5, 0x14, 0xa6, -0xff, 0xff, 0xff, 0xff, 0xde, 0xf5, 0x14, 0xa6, 0xff, 0xff, 0xff, 0xff, -0xde, 0xf5, 0x14, 0xa6, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, -0xda, 0xfd, 0x60, 0x3b, 0xff, 0xff, 0xff, 0xff, 0xda, 0xfd, 0x60, 0x3b, -0xff, 0xff, 0xff, 0xff, 0xda, 0xfd, 0x60, 0x3b, 0xff, 0xff, 0xff, 0xff, -0xda, 0xfd, 0x60, 0x3b, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0x7d, 0xef, 0x10, 0x84, 0xa5, 0xe5, 0x45, 0x4d, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, 0x5d, 0xef, 0x10, 0x84, -0x5a, 0x53, 0x51, 0x79, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, 0xfb, 0xd5, 0x0a, 0x04, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xd5, 0x0a, 0x04, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xd5, 0x0a, 0x04, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xd5, 0x0a, 0x04, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0xd6, 0xb5, 0x21, 0x08, 0xff, 0xff, 0xff, 0xff, -0xd6, 0xb5, 0x21, 0x08, 0xff, 0xff, 0xff, 0xff, 0xd6, 0xb5, 0x21, 0x08, -0xff, 0xff, 0xff, 0xff, 0xd6, 0xb5, 0x21, 0x08, 0xff, 0xff, 0xff, 0xff, -0xd6, 0xb5, 0x21, 0x08, 0xff, 0xff, 0xff, 0xff, 0xd6, 0xb5, 0x21, 0x08, -0xff, 0xff, 0xff, 0xff, 0xd6, 0xb5, 0x21, 0x08, 0xff, 0xff, 0xff, 0xff, -0xd6, 0xb5, 0x21, 0x08, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0xde, 0xf5, 0x14, 0xa6, 0xff, 0xff, 0xff, 0xff, 0xde, 0xf5, 0x14, 0xa6, -0xff, 0xff, 0xff, 0xff, 0xde, 0xf5, 0x14, 0xa6, 0xff, 0xff, 0xff, 0xff, -0xde, 0xf5, 0x14, 0xa6, 0xff, 0xff, 0xff, 0xff, 0xde, 0xf5, 0x14, 0xa6, -0xff, 0xff, 0xff, 0xff, 0xde, 0xf5, 0x14, 0xa6, 0xff, 0xff, 0xff, 0xff, -0xde, 0xf5, 0x14, 0xa6, 0xff, 0xff, 0xff, 0xff, 0xde, 0xf5, 0x14, 0xa6, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, 0xda, 0xfd, 0x60, 0x3b, -0xff, 0xff, 0xff, 0xff, 0xda, 0xfd, 0x60, 0x3b, 0xff, 0xff, 0xff, 0xff, -0xda, 0xfd, 0x60, 0x3b, 0xff, 0xff, 0xff, 0xff, 0xda, 0xfd, 0x60, 0x3b, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0x7d, 0xef, 0x10, 0x84, -0x69, 0x71, 0x51, 0x5b, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0x55, 0xff, 0xff, 0x30, 0x84, 0x6d, 0x45, 0xe5, 0x00, -0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x55, 0xfb, 0xd5, 0x0a, 0x04, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xd5, 0x0a, 0x04, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xd5, 0x0a, 0x04, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xd5, 0x0a, 0x04, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0x55, 0x00, 0x00, 0xff, 0xff, -0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x55, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0xd6, 0xb5, 0x21, 0x08, 0xff, 0xff, 0xff, 0xff, 0xd6, 0xb5, 0x21, 0x08, -0xff, 0xff, 0xff, 0xff, 0xd6, 0xb5, 0x21, 0x08, 0xff, 0xff, 0xff, 0xff, -0xd6, 0xb5, 0x21, 0x08, 0xff, 0xff, 0xff, 0xff, 0xd6, 0xb5, 0x21, 0x08, -0xff, 0xff, 0xff, 0xff, 0xd6, 0xb5, 0x21, 0x08, 0xff, 0xff, 0xff, 0xff, -0xd6, 0xb5, 0x21, 0x08, 0xff, 0xff, 0xff, 0xff, 0xd6, 0xb5, 0x21, 0x08, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0xde, 0xf5, 0x14, 0xa6, -0xff, 0xff, 0xff, 0xff, 0xde, 0xf5, 0x14, 0xa6, 0xff, 0xff, 0xff, 0xff, -0xde, 0xf5, 0x14, 0xa6, 0xff, 0xff, 0xff, 0xff, 0xde, 0xf5, 0x14, 0xa6, -0xff, 0xff, 0xff, 0xff, 0xde, 0xf5, 0x14, 0xa6, 0xff, 0xff, 0xff, 0xff, -0xde, 0xf5, 0x14, 0xa6, 0xff, 0xff, 0xff, 0xff, 0xde, 0xf5, 0x14, 0xa6, -0xff, 0xff, 0xff, 0xff, 0xde, 0xf5, 0x14, 0xa6, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0x55, 0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, -0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x55, 0xda, 0xfd, 0x60, 0x3b, 0xff, 0xff, 0xff, 0xff, -0xda, 0xfd, 0x60, 0x3b, 0xff, 0xff, 0xff, 0xff, 0xda, 0xfd, 0x60, 0x3b, -0xff, 0xff, 0xff, 0xff, 0xda, 0xfd, 0x60, 0x3b, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0x55, 0xff, 0xff, 0x10, 0x84, -0x55, 0x55, 0xd5, 0x00, 0xff, 0xff, 0x10, 0x84, 0x5e, 0x54, 0x56, 0x00, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x55, 0xa9, 0xa9, 0xa9, -0xff, 0xff, 0xef, 0x7b, 0x00, 0x95, 0xd5, 0x55, 0xbe, 0xf7, 0x10, 0x84, -0x00, 0x57, 0x54, 0x5c, 0x00, 0x00, 0xff, 0xff, 0x55, 0x6a, 0x6a, 0x6a, -0xfb, 0xd5, 0x0a, 0x04, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xd5, 0x0a, 0x04, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xd5, 0x0a, 0x04, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xd5, 0x0a, 0x04, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0x55, 0xa9, 0xa9, 0xa9, 0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, -0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, -0x55, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0xde, 0xf5, 0x14, 0xa6, 0xff, 0xff, 0xff, 0xff, 0xde, 0xf5, 0x14, 0xa6, -0xff, 0xff, 0xff, 0xff, 0xde, 0xf5, 0x14, 0xa6, 0xff, 0xff, 0xff, 0xff, -0xde, 0xf5, 0x14, 0xa6, 0xff, 0xff, 0xff, 0xff, 0xc0, 0xf5, 0x00, 0xa6, -0xff, 0xff, 0xff, 0xff, 0xc0, 0xf5, 0x00, 0xa6, 0xff, 0xff, 0xff, 0xff, -0xc0, 0xf5, 0x00, 0xa6, 0xff, 0xff, 0xff, 0xff, 0xc0, 0xf5, 0x00, 0xa6, -0xff, 0xff, 0xff, 0xff, 0x14, 0x06, 0xde, 0x05, 0xaa, 0xaa, 0xaa, 0xaa, -0x14, 0x06, 0xde, 0x05, 0xaa, 0xaa, 0xaa, 0xaa, 0x14, 0x06, 0xde, 0x05, -0xaa, 0xaa, 0xaa, 0xaa, 0x14, 0x06, 0xde, 0x05, 0xaa, 0xaa, 0xaa, 0xaa, -0x00, 0x06, 0xc0, 0x05, 0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x06, 0xc0, 0x05, -0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x06, 0xc0, 0x05, 0xaa, 0xaa, 0xaa, 0xaa, -0x00, 0x06, 0xc0, 0x05, 0xaa, 0xaa, 0xaa, 0xaa, 0x1e, 0xf0, 0x14, 0xa0, -0xff, 0xff, 0xff, 0xff, 0x1e, 0xf0, 0x14, 0xa0, 0xff, 0xff, 0xff, 0xff, -0x1e, 0xf0, 0x14, 0xa0, 0xff, 0xff, 0xff, 0xff, 0x1e, 0xf0, 0x14, 0xa0, -0xff, 0xff, 0xff, 0xff, 0x00, 0xf0, 0x00, 0xa0, 0xff, 0xff, 0xff, 0xff, -0x00, 0xf0, 0x00, 0xa0, 0xff, 0xff, 0xff, 0xff, 0x00, 0xf0, 0x00, 0xa0, -0xff, 0xff, 0xff, 0xff, 0x00, 0xf0, 0x00, 0xa0, 0xff, 0xff, 0xff, 0xff, -0x1e, 0x00, 0x14, 0x00, 0xff, 0xff, 0xff, 0xff, 0x1e, 0x00, 0x14, 0x00, -0xff, 0xff, 0xff, 0xff, 0x1e, 0x00, 0x14, 0x00, 0xff, 0xff, 0xff, 0xff, -0x1e, 0x00, 0x14, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x55, 0xa9, 0xa9, 0xa9, -0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, -0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, 0x55, 0x6a, 0x6a, 0x6a, -0xda, 0xfd, 0x60, 0x3b, 0xff, 0xff, 0xff, 0xff, 0xda, 0xfd, 0x60, 0x3b, -0xff, 0xff, 0xff, 0xff, 0xda, 0xfd, 0x60, 0x3b, 0xff, 0xff, 0xff, 0xff, -0xda, 0xfd, 0x60, 0x3b, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0x55, 0xa9, 0xa9, 0xa9, 0xbe, 0xf7, 0x10, 0x84, 0x00, 0xb5, 0xc5, 0x4d, -0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, -0x55, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0x9e, 0xf7, 0x30, 0x84, 0x5a, 0x51, 0x79, 0x4d, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, 0xfb, 0xd5, 0x0a, 0x04, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xd5, 0x0a, 0x04, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xd5, 0x0a, 0x04, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xd5, 0x0a, 0x04, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0xde, 0xf5, 0x14, 0xa6, -0xff, 0xff, 0xff, 0xff, 0xde, 0xf5, 0x14, 0xa6, 0xff, 0xff, 0xff, 0xff, -0xde, 0xf5, 0x14, 0xa6, 0xff, 0xff, 0xff, 0xff, 0xde, 0xf5, 0x14, 0xa6, -0xff, 0xff, 0xff, 0xff, 0xc0, 0xf5, 0x00, 0xa6, 0xff, 0xff, 0xff, 0xff, -0xc0, 0xf5, 0x00, 0xa6, 0xff, 0xff, 0xff, 0xff, 0xc0, 0xf5, 0x00, 0xa6, -0xff, 0xff, 0xff, 0xff, 0xc0, 0xf5, 0x00, 0xa6, 0xff, 0xff, 0xff, 0xff, -0x14, 0x06, 0xde, 0x05, 0xaa, 0xaa, 0xaa, 0xaa, 0x14, 0x06, 0xde, 0x05, -0xaa, 0xaa, 0xaa, 0xaa, 0x14, 0x06, 0xde, 0x05, 0xaa, 0xaa, 0xaa, 0xaa, -0x14, 0x06, 0xde, 0x05, 0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x06, 0xc0, 0x05, -0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x06, 0xc0, 0x05, 0xaa, 0xaa, 0xaa, 0xaa, -0x00, 0x06, 0xc0, 0x05, 0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x06, 0xc0, 0x05, -0xaa, 0xaa, 0xaa, 0xaa, 0x1e, 0xf0, 0x14, 0xa0, 0xff, 0xff, 0xff, 0xff, -0x1e, 0xf0, 0x14, 0xa0, 0xff, 0xff, 0xff, 0xff, 0x1e, 0xf0, 0x14, 0xa0, -0xff, 0xff, 0xff, 0xff, 0x1e, 0xf0, 0x14, 0xa0, 0xff, 0xff, 0xff, 0xff, -0x00, 0xf0, 0x00, 0xa0, 0xff, 0xff, 0xff, 0xff, 0x00, 0xf0, 0x00, 0xa0, -0xff, 0xff, 0xff, 0xff, 0x00, 0xf0, 0x00, 0xa0, 0xff, 0xff, 0xff, 0xff, -0x00, 0xf0, 0x00, 0xa0, 0xff, 0xff, 0xff, 0xff, 0x1e, 0x00, 0x14, 0x00, -0xff, 0xff, 0xff, 0xff, 0x1e, 0x00, 0x14, 0x00, 0xff, 0xff, 0xff, 0xff, -0x1e, 0x00, 0x14, 0x00, 0xff, 0xff, 0xff, 0xff, 0x1e, 0x00, 0x14, 0x00, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, 0xda, 0xfd, 0x60, 0x3b, -0xff, 0xff, 0xff, 0xff, 0xda, 0xfd, 0x60, 0x3b, 0xff, 0xff, 0xff, 0xff, -0xda, 0xfd, 0x60, 0x3b, 0xff, 0xff, 0xff, 0xff, 0xda, 0xfd, 0x60, 0x3b, -0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x08, 0x42, 0xfc, 0xfc, 0xfc, 0xfc, -0x9e, 0xf7, 0x30, 0x84, 0x69, 0x51, 0x5b, 0x5c, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0x3c, 0xe7, 0x69, 0x4a, 0x8f, 0x2f, 0x3f, 0xbf, 0xff, 0xff, 0xef, 0x7b, -0x15, 0x15, 0x17, 0x16, 0xfb, 0xd5, 0x0a, 0x04, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xd5, 0x0a, 0x04, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xd5, 0x0a, 0x04, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xd5, 0x0a, 0x04, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0xde, 0xf5, 0x14, 0xa6, 0xff, 0xff, 0xff, 0xff, -0xde, 0xf5, 0x14, 0xa6, 0xff, 0xff, 0xff, 0xff, 0xde, 0xf5, 0x14, 0xa6, -0xff, 0xff, 0xff, 0xff, 0xde, 0xf5, 0x14, 0xa6, 0xff, 0xff, 0xff, 0xff, -0xc0, 0xf5, 0x00, 0xa6, 0xff, 0xff, 0xff, 0xff, 0xc0, 0xf5, 0x00, 0xa6, -0xff, 0xff, 0xff, 0xff, 0xc0, 0xf5, 0x00, 0xa6, 0xff, 0xff, 0xff, 0xff, -0xc0, 0xf5, 0x00, 0xa6, 0xff, 0xff, 0xff, 0xff, 0x14, 0x06, 0xde, 0x05, -0xaa, 0xaa, 0xaa, 0xaa, 0x14, 0x06, 0xde, 0x05, 0xaa, 0xaa, 0xaa, 0xaa, -0x14, 0x06, 0xde, 0x05, 0xaa, 0xaa, 0xaa, 0xaa, 0x14, 0x06, 0xde, 0x05, -0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x06, 0xc0, 0x05, 0xaa, 0xaa, 0xaa, 0xaa, -0x00, 0x06, 0xc0, 0x05, 0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x06, 0xc0, 0x05, -0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x06, 0xc0, 0x05, 0xaa, 0xaa, 0xaa, 0xaa, -0x1e, 0xf0, 0x14, 0xa0, 0xff, 0xff, 0xff, 0xff, 0x1e, 0xf0, 0x14, 0xa0, -0xff, 0xff, 0xff, 0xff, 0x1e, 0xf0, 0x14, 0xa0, 0xff, 0xff, 0xff, 0xff, -0x1e, 0xf0, 0x14, 0xa0, 0xff, 0xff, 0xff, 0xff, 0x00, 0xf0, 0x00, 0xa0, -0xff, 0xff, 0xff, 0xff, 0x00, 0xf0, 0x00, 0xa0, 0xff, 0xff, 0xff, 0xff, -0x00, 0xf0, 0x00, 0xa0, 0xff, 0xff, 0xff, 0xff, 0x00, 0xf0, 0x00, 0xa0, -0xff, 0xff, 0xff, 0xff, 0x1e, 0x00, 0x14, 0x00, 0xff, 0xff, 0xff, 0xff, -0x1e, 0x00, 0x14, 0x00, 0xff, 0xff, 0xff, 0xff, 0x1e, 0x00, 0x14, 0x00, -0xff, 0xff, 0xff, 0xff, 0x1e, 0x00, 0x14, 0x00, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x6a, 0xda, 0xfd, 0x60, 0x3b, 0xff, 0xff, 0xff, 0xff, -0xda, 0xfd, 0x60, 0x3b, 0xff, 0xff, 0xff, 0xff, 0xda, 0xfd, 0x60, 0x3b, -0xff, 0xff, 0xff, 0xff, 0xda, 0xfd, 0x60, 0x3b, 0xff, 0xff, 0xff, 0xff, -0xff, 0xff, 0x10, 0x84, 0xd4, 0x94, 0x34, 0xe4, 0x1c, 0xe7, 0x69, 0x4a, -0xfc, 0xfe, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0x55, -0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, 0xff, 0xff, 0x08, 0x42, -0xff, 0xff, 0xff, 0x00, 0xdf, 0xff, 0x71, 0x8c, 0x14, 0x1b, 0x11, 0x00, -0xfb, 0xd5, 0x0a, 0x04, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xd5, 0x0a, 0x04, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xd5, 0x0a, 0x04, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xd5, 0x0a, 0x04, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0x55, 0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, -0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0xde, 0xf5, 0x14, 0xa6, 0xff, 0xff, 0xff, 0xff, 0xde, 0xf5, 0x14, 0xa6, -0xff, 0xff, 0xff, 0xff, 0xde, 0xf5, 0x14, 0xa6, 0xff, 0xff, 0xff, 0xff, -0xde, 0xf5, 0x14, 0xa6, 0xff, 0xff, 0xff, 0xff, 0xc0, 0xf5, 0x00, 0xa6, -0xff, 0xff, 0xff, 0xff, 0xc0, 0xf5, 0x00, 0xa6, 0xff, 0xff, 0xff, 0xff, -0xc0, 0xf5, 0x00, 0xa6, 0xff, 0xff, 0xff, 0xff, 0xc0, 0xf5, 0x00, 0xa6, -0xff, 0xff, 0xff, 0xff, 0x14, 0x06, 0xde, 0x05, 0xaa, 0xaa, 0xaa, 0xaa, -0x14, 0x06, 0xde, 0x05, 0xaa, 0xaa, 0xaa, 0xaa, 0x14, 0x06, 0xde, 0x05, -0xaa, 0xaa, 0xaa, 0xaa, 0x14, 0x06, 0xde, 0x05, 0xaa, 0xaa, 0xaa, 0xaa, -0x00, 0x06, 0xc0, 0x05, 0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x06, 0xc0, 0x05, -0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x06, 0xc0, 0x05, 0xaa, 0xaa, 0xaa, 0xaa, -0x00, 0x06, 0xc0, 0x05, 0xaa, 0xaa, 0xaa, 0xaa, 0x1e, 0xf0, 0x14, 0xa0, -0xff, 0xff, 0xff, 0xff, 0x1e, 0xf0, 0x14, 0xa0, 0xff, 0xff, 0xff, 0xff, -0x1e, 0xf0, 0x14, 0xa0, 0xff, 0xff, 0xff, 0xff, 0x1e, 0xf0, 0x14, 0xa0, -0xff, 0xff, 0xff, 0xff, 0x00, 0xf0, 0x00, 0xa0, 0xff, 0xff, 0xff, 0xff, -0x00, 0xf0, 0x00, 0xa0, 0xff, 0xff, 0xff, 0xff, 0x00, 0xf0, 0x00, 0xa0, -0xff, 0xff, 0xff, 0xff, 0x00, 0xf0, 0x00, 0xa0, 0xff, 0xff, 0xff, 0xff, -0x1e, 0x00, 0x14, 0x00, 0xff, 0xff, 0xff, 0xff, 0x1e, 0x00, 0x14, 0x00, -0xff, 0xff, 0xff, 0xff, 0x1e, 0x00, 0x14, 0x00, 0xff, 0xff, 0xff, 0xff, -0x1e, 0x00, 0x14, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0x55, -0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, -0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x55, -0xda, 0xfd, 0x60, 0x3b, 0xff, 0xff, 0xff, 0xff, 0xda, 0xfd, 0x60, 0x3b, -0xff, 0xff, 0xff, 0xff, 0xda, 0xfd, 0x60, 0x3b, 0xff, 0xff, 0xff, 0xff, -0xda, 0xfd, 0x60, 0x3b, 0xff, 0xff, 0xff, 0xff, 0xdf, 0xff, 0x51, 0x8c, -0x44, 0x78, 0x50, 0x00, 0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, -0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0xa9, 0xa9, 0xa9, 0x00, 0x00, 0xff, 0xff, -0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, -0xff, 0xff, 0x10, 0x84, 0x00, 0x35, 0x15, 0x15, 0xbe, 0xef, 0xb0, 0x4c, -0x55, 0x55, 0x57, 0x54, 0xfb, 0xd5, 0x0a, 0x04, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xd5, 0x0a, 0x04, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xd5, 0x0a, 0x04, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x55, 0xa9, 0xa9, 0xa9, -0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, -0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, 0x55, 0x6a, 0x6a, 0x6a, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0xde, 0xf5, 0x14, 0xa6, -0xff, 0xff, 0xff, 0xff, 0xde, 0xf5, 0x14, 0xa6, 0xff, 0xff, 0xff, 0xff, -0xde, 0xf5, 0x14, 0xa6, 0xff, 0xff, 0xff, 0xff, 0xde, 0xf5, 0x14, 0xa6, -0xff, 0xff, 0xff, 0xff, 0xc0, 0xf5, 0x00, 0xa6, 0xff, 0xff, 0xff, 0xff, -0xc0, 0xf5, 0x00, 0xa6, 0xff, 0xff, 0xff, 0xff, 0xc0, 0xf5, 0x00, 0xa6, -0xff, 0xff, 0xff, 0xff, 0xc0, 0xf5, 0x00, 0xa6, 0xff, 0xff, 0xff, 0xff, -0x14, 0x06, 0xde, 0x05, 0xaa, 0xaa, 0xaa, 0xaa, 0x14, 0x06, 0xde, 0x05, -0xaa, 0xaa, 0xaa, 0xaa, 0x14, 0x06, 0xde, 0x05, 0xaa, 0xaa, 0xaa, 0xaa, -0x14, 0x06, 0xde, 0x05, 0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x06, 0xc0, 0x05, -0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x06, 0xc0, 0x05, 0xaa, 0xaa, 0xaa, 0xaa, -0x00, 0x06, 0xc0, 0x05, 0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x06, 0xc0, 0x05, -0xaa, 0xaa, 0xaa, 0xaa, 0x1e, 0xf0, 0x14, 0xa0, 0xff, 0xff, 0xff, 0xff, -0x1e, 0xf0, 0x14, 0xa0, 0xff, 0xff, 0xff, 0xff, 0x1e, 0xf0, 0x14, 0xa0, -0xff, 0xff, 0xff, 0xff, 0x1e, 0xf0, 0x14, 0xa0, 0xff, 0xff, 0xff, 0xff, -0x00, 0xf0, 0x00, 0xa0, 0xff, 0xff, 0xff, 0xff, 0x00, 0xf0, 0x00, 0xa0, -0xff, 0xff, 0xff, 0xff, 0x00, 0xf0, 0x00, 0xa0, 0xff, 0xff, 0xff, 0xff, -0x00, 0xf0, 0x00, 0xa0, 0xff, 0xff, 0xff, 0xff, 0x1e, 0x00, 0x14, 0x00, -0xff, 0xff, 0xff, 0xff, 0x1e, 0x00, 0x14, 0x00, 0xff, 0xff, 0xff, 0xff, -0x1e, 0x00, 0x14, 0x00, 0xff, 0xff, 0xff, 0xff, 0x1e, 0x00, 0x14, 0x00, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xff, 0xff, 0x55, 0xa9, 0xa9, 0xa9, 0x00, 0x00, 0xff, 0xff, -0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, -0x00, 0x00, 0xff, 0xff, 0x55, 0x6a, 0x6a, 0x6a, 0xda, 0xfd, 0x60, 0x3b, -0xff, 0xff, 0xff, 0xff, 0xda, 0xfd, 0x60, 0x3b, 0xff, 0xff, 0xff, 0xff, -0xda, 0xfd, 0x60, 0x3b, 0xff, 0xff, 0xff, 0xff, 0x5b, 0xe7, 0x29, 0x7c, -0xd5, 0x15, 0x35, 0xc5, 0x00, 0x00, 0xff, 0xff, 0x55, 0xa9, 0xa9, 0xa9, -0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, -0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, 0x55, 0x6a, 0x6a, 0x6a, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x6a, 0x9d, 0xe7, 0xd0, 0x54, 0x5a, 0x51, 0x69, 0xc5, -0xfb, 0xd5, 0x0a, 0x04, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xd5, 0x0a, 0x04, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xd5, 0x0a, 0x04, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0xde, 0xf5, 0x14, 0xa6, 0xff, 0xff, 0xff, 0xff, -0xde, 0xf5, 0x14, 0xa6, 0xff, 0xff, 0xff, 0xff, 0xde, 0xf5, 0x14, 0xa6, -0xff, 0xff, 0xff, 0xff, 0xde, 0xf5, 0x14, 0xa6, 0xff, 0xff, 0xff, 0xff, -0xc0, 0xf5, 0x00, 0xa6, 0xff, 0xff, 0xff, 0xff, 0xc0, 0xf5, 0x00, 0xa6, -0xff, 0xff, 0xff, 0xff, 0xc0, 0xf5, 0x00, 0xa6, 0xff, 0xff, 0xff, 0xff, -0xc0, 0xf5, 0x00, 0xa6, 0xff, 0xff, 0xff, 0xff, 0x14, 0x06, 0xde, 0x05, -0xaa, 0xaa, 0xaa, 0xaa, 0x14, 0x06, 0xde, 0x05, 0xaa, 0xaa, 0xaa, 0xaa, -0x14, 0x06, 0xde, 0x05, 0xaa, 0xaa, 0xaa, 0xaa, 0x14, 0x06, 0xde, 0x05, -0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x06, 0xc0, 0x05, 0xaa, 0xaa, 0xaa, 0xaa, -0x00, 0x06, 0xc0, 0x05, 0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x06, 0xc0, 0x05, -0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x06, 0xc0, 0x05, 0xaa, 0xaa, 0xaa, 0xaa, -0x1e, 0xf0, 0x14, 0xa0, 0xff, 0xff, 0xff, 0xff, 0x1e, 0xf0, 0x14, 0xa0, -0xff, 0xff, 0xff, 0xff, 0x1e, 0xf0, 0x14, 0xa0, 0xff, 0xff, 0xff, 0xff, -0x1e, 0xf0, 0x14, 0xa0, 0xff, 0xff, 0xff, 0xff, 0x00, 0xf0, 0x00, 0xa0, -0xff, 0xff, 0xff, 0xff, 0x00, 0xf0, 0x00, 0xa0, 0xff, 0xff, 0xff, 0xff, -0x00, 0xf0, 0x00, 0xa0, 0xff, 0xff, 0xff, 0xff, 0x00, 0xf0, 0x00, 0xa0, -0xff, 0xff, 0xff, 0xff, 0x1e, 0x00, 0x14, 0x00, 0xff, 0xff, 0xff, 0xff, -0x1e, 0x00, 0x14, 0x00, 0xff, 0xff, 0xff, 0xff, 0x1e, 0x00, 0x14, 0x00, -0xff, 0xff, 0xff, 0xff, 0x1e, 0x00, 0x14, 0x00, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x6a, 0xda, 0xfd, 0x60, 0x3b, 0xff, 0xff, 0xff, 0xff, -0xda, 0xfd, 0x60, 0x3b, 0xff, 0xff, 0xff, 0xff, 0xe1, 0x52, 0x70, 0xa5, -0xaa, 0xaa, 0xaa, 0x6a, 0x3a, 0xe7, 0x6a, 0x84, 0x49, 0x51, 0x58, 0x54, -0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, -0x9d, 0xef, 0xb0, 0x4c, 0x35, 0x95, 0x55, 0x55, 0x9d, 0xef, 0xd0, 0x4c, -0x55, 0x56, 0x5c, 0x53, 0xfb, 0xd5, 0x0a, 0x04, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xd5, 0x0a, 0x04, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0xde, 0xf5, 0x14, 0xa6, 0xff, 0xff, 0xff, 0xff, 0xde, 0xf5, 0x14, 0xa6, -0xff, 0xff, 0xff, 0xff, 0xde, 0xf5, 0x14, 0xa6, 0xff, 0xff, 0xff, 0xff, -0xde, 0xf5, 0x14, 0xa6, 0xff, 0xff, 0xff, 0xff, 0xc0, 0xf5, 0x00, 0xa6, -0xff, 0xff, 0xff, 0xff, 0xc0, 0xf5, 0x00, 0xa6, 0xff, 0xff, 0xff, 0xff, -0xc0, 0xf5, 0x00, 0xa6, 0xff, 0xff, 0xff, 0xff, 0xc0, 0xf5, 0x00, 0xa6, -0xff, 0xff, 0xff, 0xff, 0x14, 0x06, 0xde, 0x05, 0xaa, 0xaa, 0xaa, 0xaa, -0x14, 0x06, 0xde, 0x05, 0xaa, 0xaa, 0xaa, 0xaa, 0x14, 0x06, 0xde, 0x05, -0xaa, 0xaa, 0xaa, 0xaa, 0x14, 0x06, 0xde, 0x05, 0xaa, 0xaa, 0xaa, 0xaa, -0x00, 0x06, 0xc0, 0x05, 0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x06, 0xc0, 0x05, -0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x06, 0xc0, 0x05, 0xaa, 0xaa, 0xaa, 0xaa, -0x00, 0x06, 0xc0, 0x05, 0xaa, 0xaa, 0xaa, 0xaa, 0x1e, 0xf0, 0x14, 0xa0, -0xff, 0xff, 0xff, 0xff, 0x1e, 0xf0, 0x14, 0xa0, 0xff, 0xff, 0xff, 0xff, -0x1e, 0xf0, 0x14, 0xa0, 0xff, 0xff, 0xff, 0xff, 0x1e, 0xf0, 0x14, 0xa0, -0xff, 0xff, 0xff, 0xff, 0x00, 0xf0, 0x00, 0xa0, 0xff, 0xff, 0xff, 0xff, -0x00, 0xf0, 0x00, 0xa0, 0xff, 0xff, 0xff, 0xff, 0x00, 0xf0, 0x00, 0xa0, -0xff, 0xff, 0xff, 0xff, 0x00, 0xf0, 0x00, 0xa0, 0xff, 0xff, 0xff, 0xff, -0x1e, 0x00, 0x14, 0x00, 0xff, 0xff, 0xff, 0xff, 0x1e, 0x00, 0x14, 0x00, -0xff, 0xff, 0xff, 0xff, 0x1e, 0x00, 0x14, 0x00, 0xff, 0xff, 0xff, 0xff, -0x1e, 0x00, 0x14, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, -0xda, 0xfd, 0x60, 0x3b, 0xff, 0xff, 0xff, 0xff, 0xda, 0xfd, 0x60, 0x3b, -0xff, 0xff, 0xff, 0xff, 0x9d, 0xef, 0x49, 0x84, 0x15, 0xa5, 0x4d, 0x71, -0x2e, 0x9d, 0xa6, 0x6b, 0xfc, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0x55, 0x00, 0x00, 0xff, 0xff, -0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x55, 0xfb, 0xd5, 0x0a, 0x04, -0xff, 0xff, 0xff, 0xff, 0x9d, 0xe7, 0xb0, 0x4c, 0x69, 0xc5, 0x35, 0x95, -0x3c, 0xd7, 0xaf, 0x4c, 0x55, 0x55, 0x57, 0x54, 0xfb, 0xd5, 0x0a, 0x04, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0x55, -0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, -0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0xde, 0xf5, 0x14, 0xa6, -0xff, 0xff, 0xff, 0xff, 0xde, 0xf5, 0x14, 0xa6, 0xff, 0xff, 0xff, 0xff, -0xde, 0xf5, 0x14, 0xa6, 0xff, 0xff, 0xff, 0xff, 0xde, 0xf5, 0x14, 0xa6, -0xff, 0xff, 0xff, 0xff, 0xc0, 0xf5, 0x00, 0xa6, 0xff, 0xff, 0xff, 0xff, -0xc0, 0xf5, 0x00, 0xa6, 0xff, 0xff, 0xff, 0xff, 0xc0, 0xf5, 0x00, 0xa6, -0xff, 0xff, 0xff, 0xff, 0xc0, 0xf5, 0x00, 0xa6, 0xff, 0xff, 0xff, 0xff, -0x14, 0x06, 0xde, 0x05, 0xaa, 0xaa, 0xaa, 0xaa, 0x14, 0x06, 0xde, 0x05, -0xaa, 0xaa, 0xaa, 0xaa, 0x14, 0x06, 0xde, 0x05, 0xaa, 0xaa, 0xaa, 0xaa, -0x14, 0x06, 0xde, 0x05, 0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x06, 0xc0, 0x05, -0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x06, 0xc0, 0x05, 0xaa, 0xaa, 0xaa, 0xaa, -0x00, 0x06, 0xc0, 0x05, 0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x06, 0xc0, 0x05, -0xaa, 0xaa, 0xaa, 0xaa, 0x1e, 0xf0, 0x14, 0xa0, 0xff, 0xff, 0xff, 0xff, -0x1e, 0xf0, 0x14, 0xa0, 0xff, 0xff, 0xff, 0xff, 0x1e, 0xf0, 0x14, 0xa0, -0xff, 0xff, 0xff, 0xff, 0x1e, 0xf0, 0x14, 0xa0, 0xff, 0xff, 0xff, 0xff, -0x00, 0xf0, 0x00, 0xa0, 0xff, 0xff, 0xff, 0xff, 0x00, 0xf0, 0x00, 0xa0, -0xff, 0xff, 0xff, 0xff, 0x00, 0xf0, 0x00, 0xa0, 0xff, 0xff, 0xff, 0xff, -0x00, 0xf0, 0x00, 0xa0, 0xff, 0xff, 0xff, 0xff, 0x1e, 0x00, 0x14, 0x00, -0xff, 0xff, 0xff, 0xff, 0x1e, 0x00, 0x14, 0x00, 0xff, 0xff, 0xff, 0xff, -0x1e, 0x00, 0x14, 0x00, 0xff, 0xff, 0xff, 0xff, 0x1e, 0x00, 0x14, 0x00, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0x55, 0x00, 0x00, 0xff, 0xff, -0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x55, 0xda, 0xfd, 0x60, 0x3b, -0xff, 0xff, 0xff, 0xff, 0x7c, 0xef, 0xc0, 0x4a, 0xff, 0xbf, 0x3f, 0x8f, -0x9c, 0xef, 0x29, 0x7c, 0x5a, 0x54, 0x57, 0x55, 0xda, 0xfd, 0x60, 0x3b, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0x55, -0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, -0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, -0x55, 0xa9, 0xa9, 0xa9, 0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, -0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, -0x55, 0x6a, 0x6a, 0x6a, 0xfb, 0xd5, 0x0a, 0x04, 0xff, 0xff, 0xff, 0xff, -0xb0, 0x4c, 0xb0, 0x44, 0x2a, 0xaa, 0xaa, 0xaa, 0xbe, 0xef, 0xb0, 0x4c, -0x5a, 0x71, 0xcd, 0x35, 0x6e, 0x3c, 0xf1, 0x5c, 0xaa, 0xaa, 0xaa, 0xa9, -0x00, 0x00, 0xff, 0xff, 0x55, 0xa9, 0xa9, 0xa9, 0x00, 0x00, 0xff, 0xff, -0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, -0x00, 0x00, 0xff, 0xff, 0x55, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0xde, 0xf5, 0x14, 0xa6, 0xff, 0xff, 0xff, 0xff, -0xde, 0xf5, 0x14, 0xa6, 0xff, 0xff, 0xff, 0xff, 0xde, 0xf5, 0x14, 0xa6, -0xff, 0xff, 0xff, 0xff, 0xde, 0xf5, 0x14, 0xa6, 0xff, 0xff, 0xff, 0xff, -0xc0, 0xf5, 0x00, 0xa6, 0xff, 0xff, 0xff, 0xff, 0xc0, 0xf5, 0x00, 0xa6, -0xff, 0xff, 0xff, 0xff, 0xc0, 0xf5, 0x00, 0xa6, 0xff, 0xff, 0xff, 0xff, -0xc0, 0xf5, 0x00, 0xa6, 0xff, 0xff, 0xff, 0xff, 0x14, 0x06, 0xde, 0x05, -0xaa, 0xaa, 0xaa, 0xaa, 0x14, 0x06, 0xde, 0x05, 0xaa, 0xaa, 0xaa, 0xaa, -0x14, 0x06, 0xde, 0x05, 0xaa, 0xaa, 0xaa, 0xaa, 0x14, 0x06, 0xde, 0x05, -0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x06, 0xc0, 0x05, 0xaa, 0xaa, 0xaa, 0xaa, -0x00, 0x06, 0xc0, 0x05, 0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x06, 0xc0, 0x05, -0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x06, 0xc0, 0x05, 0xaa, 0xaa, 0xaa, 0xaa, -0x1e, 0xf0, 0x14, 0xa0, 0xff, 0xff, 0xff, 0xff, 0x1e, 0xf0, 0x14, 0xa0, -0xff, 0xff, 0xff, 0xff, 0x1e, 0xf0, 0x14, 0xa0, 0xff, 0xff, 0xff, 0xff, -0x1e, 0xf0, 0x14, 0xa0, 0xff, 0xff, 0xff, 0xff, 0x00, 0xf0, 0x00, 0xa0, -0xff, 0xff, 0xff, 0xff, 0x00, 0xf0, 0x00, 0xa0, 0xff, 0xff, 0xff, 0xff, -0x00, 0xf0, 0x00, 0xa0, 0xff, 0xff, 0xff, 0xff, 0x00, 0xf0, 0x00, 0xa0, -0xff, 0xff, 0xff, 0xff, 0x1e, 0x00, 0x14, 0x00, 0xff, 0xff, 0xff, 0xff, -0x1e, 0x00, 0x14, 0x00, 0xff, 0xff, 0xff, 0xff, 0x1e, 0x00, 0x14, 0x00, -0xff, 0xff, 0xff, 0xff, 0x1e, 0x00, 0x14, 0x00, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, -0x55, 0xa9, 0xa9, 0xa9, 0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, -0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, -0x55, 0x6a, 0x6a, 0x6a, 0x7c, 0xef, 0x29, 0x7c, 0x55, 0x55, 0xd5, 0x15, -0xbd, 0xf7, 0x49, 0x7c, 0x69, 0x53, 0x5c, 0x57, 0xda, 0xfd, 0x60, 0x3b, -0xff, 0xff, 0xff, 0xff, 0xda, 0xfd, 0x60, 0x3b, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0x55, 0xa9, 0xa9, 0xa9, 0x00, 0x00, 0xff, 0xff, -0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, -0x00, 0x00, 0xff, 0xff, 0x55, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, -0xfb, 0xd5, 0x0a, 0x04, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xd5, 0x0a, 0x04, -0xff, 0xff, 0xff, 0xff, 0x7d, 0xe7, 0xb0, 0x4c, 0x95, 0x55, 0x55, 0x55, -0x3b, 0xd7, 0xd0, 0x4c, 0x54, 0x50, 0x61, 0x85, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0xde, 0xf5, 0x14, 0xa6, 0xff, 0xff, 0xff, 0xff, 0xde, 0xf5, 0x14, 0xa6, -0xff, 0xff, 0xff, 0xff, 0xde, 0xf5, 0x14, 0xa6, 0xff, 0xff, 0xff, 0xff, -0xde, 0xf5, 0x14, 0xa6, 0xff, 0xff, 0xff, 0xff, 0xc0, 0xf5, 0x00, 0xa6, -0xff, 0xff, 0xff, 0xff, 0xc0, 0xf5, 0x00, 0xa6, 0xff, 0xff, 0xff, 0xff, -0xc0, 0xf5, 0x00, 0xa6, 0xff, 0xff, 0xff, 0xff, 0xc0, 0xf5, 0x00, 0xa6, -0xff, 0xff, 0xff, 0xff, 0x14, 0x06, 0xde, 0x05, 0xaa, 0xaa, 0xaa, 0xaa, -0x14, 0x06, 0xde, 0x05, 0xaa, 0xaa, 0xaa, 0xaa, 0x14, 0x06, 0xde, 0x05, -0xaa, 0xaa, 0xaa, 0xaa, 0x14, 0x06, 0xde, 0x05, 0xaa, 0xaa, 0xaa, 0xaa, -0x00, 0x06, 0xc0, 0x05, 0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x06, 0xc0, 0x05, -0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x06, 0xc0, 0x05, 0xaa, 0xaa, 0xaa, 0xaa, -0x00, 0x06, 0xc0, 0x05, 0xaa, 0xaa, 0xaa, 0xaa, 0x1e, 0xf0, 0x14, 0xa0, -0xff, 0xff, 0xff, 0xff, 0x1e, 0xf0, 0x14, 0xa0, 0xff, 0xff, 0xff, 0xff, -0x1e, 0xf0, 0x14, 0xa0, 0xff, 0xff, 0xff, 0xff, 0x1e, 0xf0, 0x14, 0xa0, -0xff, 0xff, 0xff, 0xff, 0x00, 0xf0, 0x00, 0xa0, 0xff, 0xff, 0xff, 0xff, -0x00, 0xf0, 0x00, 0xa0, 0xff, 0xff, 0xff, 0xff, 0x00, 0xf0, 0x00, 0xa0, -0xff, 0xff, 0xff, 0xff, 0x00, 0xf0, 0x00, 0xa0, 0xff, 0xff, 0xff, 0xff, -0x1e, 0x00, 0x14, 0x00, 0xff, 0xff, 0xff, 0xff, 0x1e, 0x00, 0x14, 0x00, -0xff, 0xff, 0xff, 0xff, 0x1e, 0x00, 0x14, 0x00, 0xff, 0xff, 0xff, 0xff, -0x1e, 0x00, 0x14, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, -0x3a, 0xe7, 0x49, 0x84, 0x85, 0x41, 0x52, 0x54, 0xda, 0xfd, 0x60, 0x3b, -0xff, 0xff, 0xff, 0xff, 0xda, 0xfd, 0x60, 0x3b, 0xff, 0xff, 0xff, 0xff, -0xda, 0xfd, 0x60, 0x3b, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, 0xfb, 0xd5, 0x0a, 0x04, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xd5, 0x0a, 0x04, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xd5, 0x0a, 0x04, 0xff, 0xff, 0xff, 0xff, 0x9d, 0xe7, 0x8f, 0x44, -0x35, 0xd5, 0x55, 0x55, 0xde, 0xf7, 0xef, 0x7b, 0x54, 0x5c, 0x70, 0xcc, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0xde, 0xf5, 0x14, 0xa6, -0xff, 0xff, 0xff, 0xff, 0xde, 0xf5, 0x14, 0xa6, 0xff, 0xff, 0xff, 0xff, -0xde, 0xf5, 0x14, 0xa6, 0xff, 0xff, 0xff, 0xff, 0xde, 0xf5, 0x14, 0xa6, -0xff, 0xff, 0xff, 0xff, 0xc0, 0xf5, 0x00, 0xa6, 0xff, 0xff, 0xff, 0xff, -0xc0, 0xf5, 0x00, 0xa6, 0xff, 0xff, 0xff, 0xff, 0xc0, 0xf5, 0x00, 0xa6, -0xff, 0xff, 0xff, 0xff, 0xc0, 0xf5, 0x00, 0xa6, 0xff, 0xff, 0xff, 0xff, -0x14, 0x06, 0xde, 0x05, 0xaa, 0xaa, 0xaa, 0xaa, 0x14, 0x06, 0xde, 0x05, -0xaa, 0xaa, 0xaa, 0xaa, 0x14, 0x06, 0xde, 0x05, 0xaa, 0xaa, 0xaa, 0xaa, -0x14, 0x06, 0xde, 0x05, 0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x06, 0xc0, 0x05, -0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x06, 0xc0, 0x05, 0xaa, 0xaa, 0xaa, 0xaa, -0x00, 0x06, 0xc0, 0x05, 0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x06, 0xc0, 0x05, -0xaa, 0xaa, 0xaa, 0xaa, 0x1e, 0xf0, 0x14, 0xa0, 0xff, 0xff, 0xff, 0xff, -0x1e, 0xf0, 0x14, 0xa0, 0xff, 0xff, 0xff, 0xff, 0x1e, 0xf0, 0x14, 0xa0, -0xff, 0xff, 0xff, 0xff, 0x1e, 0xf0, 0x14, 0xa0, 0xff, 0xff, 0xff, 0xff, -0x00, 0xf0, 0x00, 0xa0, 0xff, 0xff, 0xff, 0xff, 0x00, 0xf0, 0x00, 0xa0, -0xff, 0xff, 0xff, 0xff, 0x00, 0xf0, 0x00, 0xa0, 0xff, 0xff, 0xff, 0xff, -0x00, 0xf0, 0x00, 0xa0, 0xff, 0xff, 0xff, 0xff, 0x1e, 0x00, 0x14, 0x00, -0xff, 0xff, 0xff, 0xff, 0x1e, 0x00, 0x14, 0x00, 0xff, 0xff, 0xff, 0xff, -0x1e, 0x00, 0x14, 0x00, 0xff, 0xff, 0xff, 0xff, 0x1e, 0x00, 0x14, 0x00, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0x2c, 0x63, 0xd3, 0x9c, 0xaa, 0xaa, 0xaa, 0x6a, -0xde, 0xf7, 0xef, 0x7b, 0x35, 0x0d, 0x33, 0x1c, 0x70, 0xad, 0x85, 0x63, -0xfe, 0xff, 0xff, 0xff, 0xda, 0xfd, 0x60, 0x3b, 0xff, 0xff, 0xff, 0xff, -0xda, 0xfd, 0x60, 0x3b, 0xff, 0xff, 0xff, 0xff, 0xda, 0xfd, 0x60, 0x3b, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0x55, 0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, -0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x55, 0xfb, 0xd5, 0x0a, 0x04, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xd5, 0x0a, 0x04, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xd5, 0x0a, 0x04, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xd5, 0x0a, 0x04, 0xff, 0xff, 0xff, 0xff, -0xdf, 0xff, 0x10, 0x84, 0x34, 0xd4, 0x54, 0x00, 0xde, 0xf7, 0xef, 0x7b, -0x57, 0x5c, 0x73, 0x00, 0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0xde, 0xf5, 0x14, 0xa6, 0xff, 0xff, 0xff, 0xff, -0xde, 0xf5, 0x14, 0xa6, 0xff, 0xff, 0xff, 0xff, 0xde, 0xf5, 0x14, 0xa6, -0xff, 0xff, 0xff, 0xff, 0xde, 0xf5, 0x14, 0xa6, 0xff, 0xff, 0xff, 0xff, -0xc0, 0xf5, 0x00, 0xa6, 0xff, 0xff, 0xff, 0xff, 0xc0, 0xf5, 0x00, 0xa6, -0xff, 0xff, 0xff, 0xff, 0xc0, 0xf5, 0x00, 0xa6, 0xff, 0xff, 0xff, 0xff, -0xc0, 0xf5, 0x00, 0xa6, 0xff, 0xff, 0xff, 0xff, 0x14, 0x06, 0xde, 0x05, -0xaa, 0xaa, 0xaa, 0xaa, 0x14, 0x06, 0xde, 0x05, 0xaa, 0xaa, 0xaa, 0xaa, -0x14, 0x06, 0xde, 0x05, 0xaa, 0xaa, 0xaa, 0xaa, 0x14, 0x06, 0xde, 0x05, -0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x06, 0xc0, 0x05, 0xaa, 0xaa, 0xaa, 0xaa, -0x00, 0x06, 0xc0, 0x05, 0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x06, 0xc0, 0x05, -0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x06, 0xc0, 0x05, 0xaa, 0xaa, 0xaa, 0xaa, -0x1e, 0xf0, 0x14, 0xa0, 0xff, 0xff, 0xff, 0xff, 0x1e, 0xf0, 0x14, 0xa0, -0xff, 0xff, 0xff, 0xff, 0x1e, 0xf0, 0x14, 0xa0, 0xff, 0xff, 0xff, 0xff, -0x1e, 0xf0, 0x14, 0xa0, 0xff, 0xff, 0xff, 0xff, 0x00, 0xf0, 0x00, 0xa0, -0xff, 0xff, 0xff, 0xff, 0x00, 0xf0, 0x00, 0xa0, 0xff, 0xff, 0xff, 0xff, -0x00, 0xf0, 0x00, 0xa0, 0xff, 0xff, 0xff, 0xff, 0x00, 0xf0, 0x00, 0xa0, -0xff, 0xff, 0xff, 0xff, 0x1e, 0x00, 0x14, 0x00, 0xff, 0xff, 0xff, 0xff, -0x1e, 0x00, 0x14, 0x00, 0xff, 0xff, 0xff, 0xff, 0x1e, 0x00, 0x14, 0x00, -0xff, 0xff, 0xff, 0xff, 0x1e, 0x00, 0x14, 0x00, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0x55, 0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, -0xde, 0xf7, 0xef, 0x7b, 0x35, 0xcd, 0x73, 0x00, 0xff, 0xff, 0x10, 0x84, -0x17, 0x15, 0x15, 0x00, 0xda, 0xfd, 0x60, 0x3b, 0xff, 0xff, 0xff, 0xff, -0xda, 0xfd, 0x60, 0x3b, 0xff, 0xff, 0xff, 0xff, 0xda, 0xfd, 0x60, 0x3b, -0xff, 0xff, 0xff, 0xff, 0xda, 0xfd, 0x60, 0x3b, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0x55, 0x00, 0x00, 0xff, 0xff, -0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x55, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0xa9, 0xa9, 0xa9, -0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, -0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, 0x55, 0x6a, 0x6a, 0x6a, -0xfb, 0xd5, 0x0a, 0x04, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xd5, 0x0a, 0x04, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xd5, 0x0a, 0x04, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xd5, 0x0a, 0x04, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xf6, 0x63, -0x55, 0x55, 0x55, 0x55, 0x7e, 0xef, 0xd6, 0x63, 0x35, 0xd5, 0x55, 0x55, -0x3d, 0xe7, 0x17, 0x6c, 0x57, 0x58, 0x61, 0x05, 0xd8, 0x8c, 0xf6, 0x63, -0x55, 0x55, 0x55, 0x57, 0x00, 0x00, 0xff, 0xff, 0x55, 0xa9, 0xa9, 0xa9, -0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, -0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, 0x55, 0x6a, 0x6a, 0x6a, -0x00, 0x00, 0xff, 0xff, 0x55, 0xa9, 0xa9, 0xa9, 0x00, 0x00, 0xff, 0xff, -0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, -0x00, 0x00, 0xff, 0xff, 0x55, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, -0x55, 0xa9, 0xa9, 0xa9, 0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, -0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, -0x55, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, 0x55, 0xa9, 0xa9, 0xa9, -0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, -0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, 0x55, 0x6a, 0x6a, 0x6a, -0x00, 0x00, 0xff, 0xff, 0x55, 0xa9, 0xa9, 0xa9, 0x00, 0x00, 0xff, 0xff, -0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, -0x00, 0x00, 0xff, 0xff, 0x55, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, -0x55, 0xa9, 0xa9, 0xa9, 0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, -0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, -0x55, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, 0x55, 0xa9, 0xa9, 0xa9, -0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, -0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, 0x55, 0x6a, 0x6a, 0x6a, -0x00, 0x00, 0xff, 0xff, 0x55, 0xa9, 0xa9, 0xa9, 0x00, 0x00, 0xff, 0xff, -0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, -0x00, 0x00, 0xff, 0xff, 0x55, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, -0x55, 0xa9, 0xa9, 0xa9, 0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, -0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, -0x55, 0x6a, 0x6a, 0x6a, 0xfd, 0xde, 0x93, 0x32, 0xff, 0xff, 0xff, 0x3f, -0x9e, 0xef, 0x37, 0x6c, 0x35, 0x49, 0x52, 0x56, 0xf6, 0x63, 0xfb, 0xb5, -0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf6, 0x63, 0x55, 0x55, 0x55, 0x55, -0xda, 0xfd, 0x60, 0x3b, 0xff, 0xff, 0xff, 0xff, 0xda, 0xfd, 0x60, 0x3b, -0xff, 0xff, 0xff, 0xff, 0xda, 0xfd, 0x60, 0x3b, 0xff, 0xff, 0xff, 0xff, -0xda, 0xfd, 0x60, 0x3b, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0x55, 0xa9, 0xa9, 0xa9, 0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, -0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, -0x55, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, 0xfb, 0xd5, 0x0a, 0x04, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xd5, 0x0a, 0x04, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xd5, 0x0a, 0x04, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xd5, 0x0a, 0x04, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xf6, 0x63, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xf6, 0x63, 0x55, 0x55, 0x55, 0x55, 0x9e, 0xef, 0xf6, 0x63, -0x95, 0x55, 0x55, 0x55, 0x5e, 0xe7, 0x16, 0x6c, 0x5c, 0x73, 0x8d, 0x15, -0x41, 0x08, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, -0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, -0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x30, 0x84, 0x15, 0x15, 0x15, 0x25, -0x9e, 0xef, 0x36, 0x6c, 0x85, 0x73, 0x5c, 0x55, 0x16, 0x6c, 0xf6, 0x63, -0x57, 0x55, 0x55, 0x55, 0x00, 0x00, 0xf6, 0x63, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xf6, 0x63, 0x55, 0x55, 0x55, 0x55, 0xda, 0xfd, 0x60, 0x3b, -0xff, 0xff, 0xff, 0xff, 0xda, 0xfd, 0x60, 0x3b, 0xff, 0xff, 0xff, 0xff, -0xda, 0xfd, 0x60, 0x3b, 0xff, 0xff, 0xff, 0xff, 0xda, 0xfd, 0x60, 0x3b, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x6a, 0xfb, 0xd5, 0x0a, 0x04, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xd5, 0x0a, 0x04, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xd5, 0x0a, 0x04, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xd5, 0x0a, 0x04, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xf6, 0x63, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xf6, 0x63, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xf6, 0x63, 0x55, 0x55, 0x55, 0x55, -0x16, 0x6c, 0xf6, 0x63, 0xd5, 0x55, 0x55, 0x55, 0xbe, 0xf7, 0x10, 0x84, -0x70, 0x8c, 0x94, 0x54, 0x7d, 0xef, 0x10, 0x84, 0x55, 0x55, 0x5c, 0x63, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, -0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, -0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, -0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, 0x71, 0x8c, 0xcf, 0x7b, -0xff, 0xff, 0xff, 0xbf, 0x9d, 0xef, 0x10, 0x84, 0x55, 0x95, 0x8d, 0x72, -0xbe, 0xf7, 0x10, 0x84, 0x23, 0x1c, 0x15, 0x15, 0x00, 0x00, 0xf6, 0x63, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xf6, 0x63, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xf6, 0x63, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xf6, 0x63, -0x55, 0x55, 0x55, 0x55, 0xda, 0xfd, 0x60, 0x3b, 0xff, 0xff, 0xff, 0xff, -0xda, 0xfd, 0x60, 0x3b, 0xff, 0xff, 0xff, 0xff, 0xda, 0xfd, 0x60, 0x3b, -0xff, 0xff, 0xff, 0xff, 0xda, 0xfd, 0x60, 0x3b, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0x55, -0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, -0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x55, -0xfb, 0xd5, 0x0a, 0x04, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xd5, 0x0a, 0x04, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xd5, 0x0a, 0x04, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xd5, 0x0a, 0x04, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xf6, 0x63, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xf6, 0x63, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xf6, 0x63, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xf6, 0x63, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0x55, -0xde, 0xf7, 0x10, 0x84, 0x25, 0xd5, 0x55, 0x00, 0xbe, 0xf7, 0x30, 0x84, -0x57, 0x58, 0xc9, 0x00, 0xff, 0xff, 0x08, 0x42, 0x3f, 0x3f, 0x3f, 0x00, -0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0x55, 0x00, 0x00, 0xff, 0xff, -0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x55, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0x55, 0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, -0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x55, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0x55, -0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, -0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x55, -0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0x55, 0x00, 0x00, 0xff, 0xff, -0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x55, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0x55, 0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, -0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x55, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0x55, -0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, -0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x55, -0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0x55, 0x00, 0x00, 0xff, 0xff, -0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x55, 0xff, 0xff, 0x08, 0x42, -0xfc, 0xfc, 0xbc, 0x00, 0xbe, 0xf7, 0x10, 0x84, 0x35, 0xc9, 0x58, 0x00, -0xff, 0xff, 0x10, 0x84, 0x56, 0x55, 0x55, 0x00, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x55, 0x00, 0x00, 0xf6, 0x63, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xf6, 0x63, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xf6, 0x63, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xf6, 0x63, 0x55, 0x55, 0x55, 0x55, -0xda, 0xfd, 0x60, 0x3b, 0xff, 0xff, 0xff, 0xff, 0xda, 0xfd, 0x60, 0x3b, -0xff, 0xff, 0xff, 0xff, 0xda, 0xfd, 0x60, 0x3b, 0xff, 0xff, 0xff, 0xff, -0xda, 0xfd, 0x60, 0x3b, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0x55, 0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, -0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xff, 0xff, 0x55, 0xa9, 0xa9, 0xa9, 0x00, 0x00, 0xff, 0xff, -0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, -0x00, 0x00, 0xff, 0xff, 0x55, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, -0x55, 0xa9, 0xa9, 0xa9, 0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, -0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, -0x55, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, 0x55, 0xa9, 0xa9, 0xa9, -0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, -0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, 0x55, 0x6a, 0x6a, 0x6a, -0x00, 0x00, 0xff, 0xff, 0x55, 0xa9, 0xa9, 0xa9, 0x00, 0x00, 0xff, 0xff, -0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, -0xff, 0xff, 0x08, 0x42, 0x00, 0x2f, 0x3f, 0x3f, 0xff, 0xff, 0x8a, 0x52, -0x00, 0xfc, 0xe0, 0x2c, 0xdf, 0xff, 0x30, 0x84, 0x00, 0x55, 0x55, 0x56, -0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, -0x55, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, 0x55, 0xa9, 0xa9, 0xa9, -0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, -0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, 0x55, 0x6a, 0x6a, 0x6a, -0x00, 0x00, 0xff, 0xff, 0x55, 0xa9, 0xa9, 0xa9, 0x00, 0x00, 0xff, 0xff, -0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, -0x00, 0x00, 0xff, 0xff, 0x55, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, -0x55, 0xa9, 0xa9, 0xa9, 0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, -0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, -0x55, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, 0x55, 0xa9, 0xa9, 0xa9, -0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, -0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, 0x55, 0x6a, 0x6a, 0x6a, -0x00, 0x00, 0xff, 0xff, 0x55, 0xa9, 0xa9, 0xa9, 0x00, 0x00, 0xff, 0xff, -0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, -0x00, 0x00, 0xff, 0xff, 0x55, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, -0x55, 0xa9, 0xa9, 0xa9, 0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, -0xdf, 0xff, 0x30, 0x84, 0x00, 0x55, 0x55, 0x25, 0xff, 0xff, 0x8a, 0x52, -0x00, 0x2f, 0x22, 0x3e, 0xff, 0xff, 0x08, 0x42, 0x00, 0xfc, 0xfc, 0xfc, -0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, -0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, 0x55, 0x6a, 0x6a, 0x6a, -0x00, 0x00, 0xff, 0xff, 0x55, 0xa9, 0xa9, 0xa9, 0x00, 0x00, 0xff, 0xff, -0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, -0x00, 0x00, 0xff, 0xff, 0x55, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, -0x55, 0xa9, 0xa9, 0xa9, 0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, -0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, -0x55, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, 0x55, 0xa9, 0xa9, 0xa9, -0x00, 0x00, 0xff, 0xff, 0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, -0x55, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0xff, 0xff, 0x55, 0x6a, 0x6a, 0x6a, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, -0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x6a, 0x41, 0x08, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, -0x9e, 0xf7, 0x10, 0x84, 0xe2, 0x35, 0x55, 0x55, 0x3c, 0xe7, 0x10, 0x84, -0x55, 0x5c, 0x83, 0xb5, 0xff, 0xff, 0x30, 0x84, 0x15, 0x15, 0x15, 0x38, -0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, -0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x6a, 0xde, 0xf7, 0x30, 0x84, 0x54, 0x54, 0x94, 0x88, -0x5c, 0xe7, 0x10, 0x84, 0xd5, 0x0d, 0x70, 0x57, 0xbe, 0xf7, 0x30, 0x84, -0x62, 0x57, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, -0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, -0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, -0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, -0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0xff, 0xff, 0x10, 0x84, 0x2d, 0x15, 0x15, 0x15, 0xff, 0xff, 0x30, 0x84, -0x5c, 0x88, 0xd4, 0x54, 0xff, 0xff, 0x10, 0x84, 0x55, 0x57, 0xe2, 0xb5, -0x9d, 0xef, 0x30, 0x84, 0x55, 0x55, 0x55, 0xe0, 0x41, 0x08, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, -0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x6a, 0xff, 0xff, 0x30, 0x84, 0x54, 0x54, 0x54, 0xd4, -0x9d, 0xef, 0x30, 0x84, 0x55, 0x55, 0xd5, 0x82, 0xff, 0xff, 0x10, 0x84, -0x55, 0xb5, 0xe2, 0x57, 0xff, 0xff, 0x30, 0x84, 0x2d, 0x38, 0x15, 0x15, -0xff, 0xff, 0x10, 0x84, 0x5c, 0x54, 0x54, 0x54, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, -0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, -0xff, 0xff, 0xff, 0xff, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0xa9, 0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, -0xfb, 0xdf, 0x0a, 0x52, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0x55, 0x00, 0x00, 0xff, 0xff, -0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x55, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0x55, 0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, -0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x55, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0x55, -0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, -0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x55, -0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0x55, 0x00, 0x00, 0xff, 0xff, -0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x55, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0x55, 0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, -0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x55, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0x55, -0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, 0xff, 0xff, 0x30, 0x84, -0xb5, 0x55, 0x55, 0x00, 0xde, 0xf7, 0x30, 0x84, 0x20, 0x35, 0x15, 0x00, -0xdf, 0xff, 0x30, 0x84, 0x54, 0x80, 0xd4, 0x00, 0xde, 0xf7, 0x30, 0x84, -0x55, 0x7e, 0x2b, 0x00, 0xdf, 0xff, 0x10, 0x84, 0x55, 0x55, 0xa0, 0x00, -0xef, 0x7b, 0xdf, 0xff, 0x40, 0x40, 0x6a, 0x55, 0x82, 0x10, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0x55, 0xff, 0xff, 0x28, 0x42, 0xff, 0xff, 0xff, 0x00, -0x21, 0x08, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, 0xc3, 0x18, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x55, 0xff, 0xff, 0x08, 0x42, 0xfc, 0xfc, 0xa8, 0x00, -0xde, 0xf7, 0x30, 0x84, 0x55, 0x55, 0x02, 0x00, 0xff, 0xff, 0x10, 0x84, -0x55, 0xaf, 0xfa, 0x00, 0xdf, 0xff, 0x30, 0x84, 0x35, 0x20, 0x15, 0x00, -0xde, 0xf7, 0x30, 0x84, 0x80, 0x54, 0x54, 0x00, 0xff, 0xff, 0x30, 0x84, -0x57, 0x55, 0x55, 0x00, 0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x55, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0x55, 0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, -0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x55, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0x55, -0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, -0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x55, -0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0x55, 0x00, 0x00, 0xff, 0xff, -0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, -0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x55, 0x00, 0x00, 0xff, 0xff, -0xa9, 0xa9, 0xa9, 0x55, 0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, -0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, -0x6a, 0x6a, 0x6a, 0x55, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xa9, 0xa9, 0x55, -0x00, 0x00, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, -0xaa, 0xaa, 0xaa, 0x55, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x55, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, -0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55, -0x00, 0x00, 0xff, 0xff, 0x55, 0x55, 0x55, 0x55 \ No newline at end of file diff --git a/third_party/zstd/build/single_file_libs/examples/testcard-zstd.inl b/third_party/zstd/build/single_file_libs/examples/testcard-zstd.inl deleted file mode 100644 index 9e4388365..000000000 --- a/third_party/zstd/build/single_file_libs/examples/testcard-zstd.inl +++ /dev/null @@ -1,261 +0,0 @@ -0x28, 0xb5, 0x2f, 0xfd, 0x60, 0x00, 0x7f, 0x6d, 0x61, 0x00, 0x0a, 0x66, -0xec, 0x17, 0x48, 0x60, 0x1c, 0x5a, 0xc9, 0x5d, 0x1a, 0x38, 0x07, 0xe8, -0xc5, 0x82, 0x99, 0x68, 0xe6, 0x95, 0x45, 0x58, 0x0d, 0x0c, 0xf3, 0x36, -0xc8, 0xd9, 0x0f, 0x46, 0x2d, 0x68, 0x11, 0xf8, 0x31, 0x10, 0xa1, 0x1a, -0x2f, 0x99, 0x5c, 0x84, 0xfd, 0x92, 0x02, 0xe6, 0x3b, 0x44, 0x9b, 0x01, -0x5d, 0x92, 0xff, 0x38, 0x26, 0x00, 0x6a, 0x6b, 0xc3, 0x53, 0xb2, 0x0c, -0x25, 0xf3, 0xd8, 0x59, 0x68, 0x9b, 0x14, 0x8a, 0x89, 0x75, 0x18, 0x03, -0x1d, 0xc9, 0x0f, 0x63, 0x01, 0x73, 0x01, 0x72, 0x01, 0x4f, 0x66, 0x31, -0x58, 0x0f, 0x97, 0x4b, 0x0c, 0x4c, 0x06, 0xac, 0x07, 0x0b, 0x68, 0xd4, -0xad, 0x80, 0x64, 0x13, 0x74, 0xa1, 0x12, 0x16, 0x58, 0xcf, 0x1a, 0x95, -0x5f, 0x0d, 0x26, 0x55, 0xd0, 0x9c, 0xf4, 0x52, 0x35, 0x2e, 0x20, 0xc1, -0x06, 0x69, 0x03, 0x0a, 0x93, 0x83, 0x5e, 0x27, 0x9b, 0x4c, 0x6d, 0xee, -0x87, 0x03, 0x30, 0x6c, 0x46, 0xd7, 0x50, 0x5c, 0xca, 0xe6, 0xa6, 0x4d, -0xa8, 0xf6, 0xab, 0xd7, 0x0e, 0x27, 0x27, 0x90, 0xc4, 0xb2, 0xd1, 0x10, -0xfa, 0x43, 0x82, 0xc8, 0xf2, 0xe5, 0xff, 0xff, 0xd5, 0x52, 0x62, 0x43, -0x87, 0x26, 0x2a, 0x05, 0x70, 0x0e, 0xb0, 0x2f, 0xc4, 0x56, 0xef, 0xb5, -0xca, 0xb8, 0x53, 0xb7, 0x96, 0x0e, 0xe7, 0x00, 0x2c, 0xa8, 0xda, 0x3b, -0x07, 0x70, 0xa7, 0x78, 0x38, 0x60, 0x87, 0x7a, 0x01, 0x3b, 0x75, 0xec, -0xfa, 0x77, 0xe2, 0x46, 0x94, 0x61, 0x8e, 0x0d, 0x0c, 0xfb, 0xe7, 0x8b, -0x13, 0x50, 0x31, 0xa9, 0x27, 0xcd, 0x27, 0xef, 0x6b, 0xa6, 0xab, 0x9c, -0x4d, 0x95, 0x6c, 0x3a, 0xbb, 0x8e, 0x96, 0x92, 0x18, 0x5a, 0x7c, 0x4f, -0xff, 0x7b, 0x38, 0xf2, 0xdb, 0x86, 0xde, 0xff, 0x1f, 0x2f, 0x21, 0x86, -0x7d, 0xbf, 0x45, 0xd0, 0x6e, 0x77, 0x0a, 0xee, 0x0a, 0xee, 0x14, 0x9a, -0xb8, 0x84, 0xf3, 0xac, 0xbe, 0xc8, 0x7f, 0x8d, 0xff, 0xff, 0xcf, 0x2a, -0xfb, 0x69, 0xfc, 0xfb, 0xfd, 0x7a, 0x10, 0x22, 0x36, 0xfc, 0xff, 0x3f, -0xcf, 0xd0, 0xf1, 0x7f, 0xfe, 0xff, 0x3d, 0x24, 0xdf, 0x78, 0x4a, 0xff, -0xda, 0x9c, 0x39, 0xcf, 0xef, 0xe7, 0xfd, 0x52, 0x98, 0xb5, 0x40, 0x92, -0xee, 0xdd, 0x99, 0xf5, 0x53, 0x5b, 0x65, 0x6b, 0xb5, 0xd8, 0x7b, 0xae, -0xfa, 0xc1, 0x0f, 0x0c, 0x7f, 0x4f, 0x55, 0xa3, 0xad, 0x2c, 0xa0, 0xbd, -0xf7, 0x2a, 0x0e, 0xe8, 0xbd, 0xc7, 0x5e, 0xf5, 0xd8, 0x54, 0x9e, 0x56, -0xa3, 0xd6, 0x59, 0xd5, 0xfe, 0x1f, 0xc0, 0x30, 0x8c, 0xfc, 0x46, 0x04, -0xae, 0x60, 0xbc, 0xe8, 0xcf, 0xec, 0x3d, 0xde, 0xf9, 0xf0, 0xfe, 0xef, -0x7d, 0xcc, 0xf7, 0x2b, 0xe5, 0x1b, 0x70, 0xff, 0xff, 0x7e, 0x3f, 0x6e, -0xe4, 0x02, 0x07, 0xfc, 0x1b, 0x7a, 0xff, 0xe7, 0x58, 0xfc, 0x7e, 0x3a, -0xdc, 0x97, 0xfd, 0x57, 0xef, 0xa3, 0xfc, 0x2a, 0xc7, 0x4d, 0xf3, 0xcb, -0x9d, 0xce, 0xac, 0xfe, 0xeb, 0x2e, 0x86, 0xb9, 0x69, 0x54, 0xef, 0xf9, -0x55, 0xcf, 0xff, 0x48, 0x24, 0x72, 0x3a, 0x9d, 0x72, 0x2f, 0x2f, 0x2f, -0xff, 0x3f, 0xe7, 0x01, 0x6c, 0x4d, 0x6c, 0xcd, 0x2d, 0x5b, 0x53, 0xb7, -0x59, 0x22, 0x08, 0x0b, 0xa7, 0x92, 0x15, 0x75, 0x93, 0xb0, 0x5d, 0xaf, -0x2a, 0x63, 0x95, 0x1d, 0x25, 0xd2, 0xd2, 0xa8, 0x1c, 0x84, 0xc9, 0xdc, -0x72, 0xba, 0xd7, 0xfc, 0x69, 0xf5, 0xc7, 0x19, 0xa9, 0xbe, 0xfa, 0x26, -0x55, 0x25, 0x75, 0xb7, 0x60, 0xa3, 0xd8, 0x68, 0x54, 0xb7, 0x1b, 0xa5, -0x54, 0x62, 0xb1, 0x49, 0xde, 0xe2, 0xac, 0xa2, 0xe8, 0x7b, 0xff, 0x5f, -0x75, 0x4e, 0xb8, 0xa2, 0xdd, 0x6a, 0xb7, 0xda, 0x6e, 0x2e, 0x04, 0xcd, -0x08, 0x2f, 0xec, 0x8e, 0x49, 0xaf, 0x49, 0x6f, 0x8b, 0x4f, 0x2e, 0x1a, -0xc5, 0x62, 0x7b, 0x6b, 0x3e, 0x32, 0x3e, 0x32, 0xbe, 0x08, 0x35, 0x4d, -0x63, 0x93, 0xa6, 0xc8, 0x42, 0xe6, 0x21, 0xcc, 0x59, 0xc8, 0x4c, 0xe5, -0x86, 0xe1, 0x03, 0x06, 0xa4, 0xec, 0xff, 0xb7, 0x78, 0x7e, 0x62, 0x43, -0xc7, 0x2c, 0x50, 0x30, 0x4a, 0xc8, 0x9b, 0xf3, 0xbf, 0xe6, 0x62, 0xa0, -0x50, 0xa6, 0x9c, 0xe3, 0x6e, 0x5b, 0xaf, 0x77, 0x8b, 0xbb, 0xe1, 0x70, -0xaa, 0xaa, 0xaa, 0x92, 0xb4, 0x52, 0xad, 0x14, 0x87, 0x93, 0x0b, 0xe6, -0x82, 0x39, 0x11, 0xb9, 0x20, 0x9a, 0x16, 0x34, 0x22, 0x68, 0xb2, 0x68, -0xb2, 0x76, 0xd3, 0xe8, 0x6e, 0xda, 0x6b, 0x62, 0x34, 0x2e, 0x8d, 0xbd, -0x2d, 0x3d, 0x6b, 0x4c, 0x26, 0x33, 0xda, 0x33, 0xf3, 0x91, 0x51, 0x46, -0x79, 0xbd, 0x3e, 0x39, 0x9f, 0xcf, 0xd2, 0xb8, 0x5c, 0xfa, 0x22, 0xf8, -0x8e, 0xb6, 0xbe, 0x08, 0x40, 0x14, 0x49, 0x40, 0x14, 0xf2, 0x0c, 0x2d, -0x30, 0x85, 0x3c, 0x63, 0x29, 0xd3, 0x98, 0x85, 0x6c, 0xb5, 0xdb, 0xad, -0x5c, 0x63, 0x9e, 0x72, 0xcf, 0x43, 0xe6, 0xaf, 0x77, 0xa6, 0xe2, 0x21, -0x0c, 0x4d, 0xd3, 0x49, 0x1e, 0xc2, 0x14, 0x6f, 0xee, 0xdb, 0x7b, 0x7b, -0x08, 0xb3, 0xa4, 0x60, 0x3b, 0x9d, 0x6e, 0x8b, 0x37, 0x4b, 0x0a, 0x74, -0x35, 0x33, 0xbc, 0xf9, 0x64, 0x85, 0x63, 0x32, 0x29, 0x20, 0x59, 0x0c, -0x3c, 0x96, 0x67, 0x62, 0xb7, 0x8a, 0x92, 0x4d, 0xa0, 0xd3, 0xf3, 0xd1, -0x85, 0x80, 0x38, 0xcb, 0x64, 0x60, 0xc9, 0xb5, 0xaf, 0x97, 0x8d, 0x20, -0x45, 0x28, 0xb8, 0xab, 0xe8, 0xc9, 0x0a, 0x88, 0x1f, 0xd6, 0x47, 0x54, -0xf1, 0xd3, 0xfb, 0x62, 0xa7, 0xfd, 0xf2, 0x8b, 0xfd, 0xb6, 0xe4, 0x2e, -0xb6, 0x91, 0x73, 0x1c, 0xd0, 0x7b, 0xba, 0x83, 0xc9, 0xac, 0x51, 0x39, -0x92, 0xc5, 0x4f, 0x30, 0x1e, 0x2e, 0xd5, 0xf1, 0xa8, 0xa6, 0xa5, 0x80, -0x70, 0xb9, 0xbc, 0xb7, 0xc2, 0x52, 0x32, 0x6c, 0xe3, 0x3d, 0xed, 0x41, -0xa4, 0x4b, 0x31, 0x2a, 0xe6, 0x62, 0x11, 0x19, 0x95, 0x73, 0x1d, 0xbf, -0xe1, 0x6c, 0xfc, 0x47, 0x75, 0x6c, 0x37, 0x63, 0x02, 0xf8, 0x34, 0x40, -0x9a, 0x00, 0x1d, 0xf7, 0x32, 0x56, 0x77, 0xda, 0x5b, 0x9f, 0x9f, 0x0f, -0xbb, 0x91, 0x5b, 0xbd, 0xe7, 0x58, 0x82, 0x4a, 0x20, 0xcd, 0x4f, 0x47, -0x15, 0xf3, 0x51, 0xf1, 0x43, 0x51, 0x10, 0x96, 0xae, 0xba, 0xf7, 0x21, -0x50, 0xef, 0x55, 0x27, 0x0c, 0x1f, 0xe0, 0x54, 0xf8, 0xc9, 0x69, 0xef, -0xb9, 0x53, 0xf7, 0x83, 0x73, 0x9d, 0xce, 0x86, 0x07, 0x83, 0x44, 0x61, -0x37, 0x35, 0x35, 0x33, 0x4e, 0x33, 0x33, 0x3e, 0x9f, 0x50, 0x48, 0x24, -0xe6, 0xd0, 0x79, 0x49, 0xc3, 0x2d, 0xa0, 0x46, 0x31, 0x9a, 0x72, 0xc3, -0x84, 0xff, 0x7a, 0x95, 0xbb, 0x00, 0x22, 0xcc, 0x14, 0x00, 0x04, 0xac, -0x60, 0x64, 0x86, 0xe4, 0x6f, 0xb1, 0x58, 0xf4, 0xdc, 0xb0, 0x05, 0x00, -0x72, 0x38, 0xf8, 0xce, 0xce, 0x8e, 0xcf, 0x37, 0x33, 0x43, 0x24, 0x0a, -0x85, 0x33, 0x35, 0x35, 0x37, 0xc2, 0xa8, 0x28, 0x27, 0x1b, 0x9d, 0xce, -0x29, 0x18, 0xe4, 0xfc, 0x09, 0x53, 0xa5, 0x51, 0xad, 0x74, 0x79, 0x7b, -0xb5, 0x4a, 0x65, 0x94, 0x36, 0x89, 0xf5, 0x62, 0x9b, 0xd8, 0x9a, 0xe8, -0x2b, 0xff, 0xa1, 0x73, 0xfe, 0x2e, 0x2c, 0x41, 0x45, 0x37, 0xef, 0x6e, -0x7b, 0x38, 0xca, 0xa5, 0xd2, 0xb8, 0x1c, 0x3b, 0x96, 0x21, 0xbb, 0x5d, -0xad, 0xd1, 0xdb, 0x1c, 0xf6, 0x5e, 0x4b, 0xd9, 0x59, 0x1b, 0x67, 0xf5, -0x7a, 0x7c, 0x9a, 0x91, 0x3e, 0x8e, 0xe3, 0xee, 0x7b, 0xb9, 0xa4, 0xb9, -0xf5, 0x70, 0xee, 0x1d, 0x4e, 0x4f, 0xcc, 0xd6, 0x7b, 0x07, 0x71, 0x48, -0xf2, 0x06, 0xd0, 0x10, 0x82, 0x21, 0xe4, 0x55, 0x2e, 0xa5, 0x1d, 0xbe, -0x48, 0x8c, 0x69, 0xbb, 0x24, 0x40, 0x68, 0x9b, 0xba, 0x5a, 0x5a, 0xa7, -0xe2, 0xd1, 0xac, 0xc2, 0xd8, 0x87, 0x9c, 0xe3, 0x78, 0xee, 0xa6, 0xcd, -0xdd, 0x68, 0x6e, 0xdd, 0xdb, 0x2e, 0xc6, 0xbb, 0x8b, 0xe9, 0xc1, 0xd9, -0xf6, 0x62, 0x7e, 0x72, 0x7e, 0x72, 0x34, 0xe4, 0x68, 0xc8, 0x11, 0x32, -0x10, 0x32, 0x20, 0x32, 0xf0, 0x12, 0x19, 0x90, 0xe0, 0x45, 0x91, 0xe0, -0x25, 0x83, 0xba, 0xc9, 0x20, 0x26, 0x87, 0xa5, 0x72, 0xa9, 0x64, 0x72, -0x80, 0x21, 0x54, 0x13, 0xeb, 0x29, 0x18, 0x42, 0x34, 0x84, 0x94, 0x34, -0x84, 0xa4, 0x1d, 0xa4, 0x1d, 0x82, 0x1c, 0xef, 0xaf, 0x0e, 0x63, 0x47, -0x6d, 0x10, 0xb9, 0xec, 0xd8, 0x2d, 0x3b, 0x9e, 0x21, 0xb1, 0x67, 0x48, -0x34, 0x24, 0x1a, 0x52, 0xdb, 0xa4, 0x6d, 0x62, 0xd3, 0xfa, 0xff, 0xfa, -0x03, 0x34, 0xef, 0x9d, 0xc9, 0xe1, 0x5d, 0xec, 0xf5, 0xf1, 0x79, 0x8c, -0x97, 0xd2, 0x24, 0xc1, 0x2d, 0xe0, 0x39, 0x16, 0x1e, 0xa9, 0x41, 0xc3, -0xbf, 0x4a, 0xd9, 0x3c, 0xea, 0x77, 0x96, 0x55, 0xe6, 0x95, 0xc3, 0xf1, -0x8e, 0x7b, 0x4f, 0xad, 0x61, 0xf8, 0xe7, 0x01, 0xad, 0x46, 0xf5, 0x2c, -0xac, 0x55, 0x2c, 0x94, 0xaa, 0x46, 0xfb, 0x5e, 0xcd, 0xaa, 0x1f, 0x78, -0x4f, 0x2f, 0xd1, 0xc9, 0x02, 0xd6, 0x2c, 0x67, 0xef, 0x3f, 0x54, 0xab, -0xda, 0x03, 0x79, 0x1f, 0xab, 0xfd, 0x0c, 0x38, 0x3c, 0xbc, 0xe1, 0xd5, -0x01, 0xf6, 0xfb, 0xfb, 0xf1, 0x70, 0xee, 0xfd, 0x90, 0x13, 0x97, 0xc4, -0xbc, 0x08, 0xe7, 0x4b, 0x88, 0x34, 0xf7, 0x56, 0x1e, 0x0c, 0xdb, 0xe4, -0x9c, 0x78, 0xf1, 0xf4, 0x62, 0x4c, 0xb5, 0xf7, 0xdd, 0xd9, 0x4c, 0x5a, -0x69, 0xa6, 0x36, 0x27, 0x03, 0xbe, 0x86, 0xc2, 0x72, 0xa2, 0x60, 0x73, -0xf1, 0xe0, 0x17, 0x50, 0xb5, 0x93, 0x81, 0xac, 0xf1, 0xc9, 0xd4, 0x66, -0x73, 0x71, 0xce, 0x63, 0xa8, 0x60, 0x98, 0xda, 0x86, 0x46, 0x72, 0xec, -0x54, 0xc1, 0xe6, 0x8a, 0x10, 0x23, 0x2d, 0x0c, 0xdd, 0x44, 0x0b, 0xa0, -0x44, 0xa4, 0x9d, 0x0e, 0x64, 0x31, 0x30, 0x45, 0xb1, 0x97, 0x4c, 0x6d, -0x9f, 0x43, 0x99, 0x71, 0xa8, 0x9a, 0xe6, 0xbd, 0x3a, 0xe1, 0xff, 0x7f, -0x33, 0x61, 0xf1, 0x48, 0xda, 0x48, 0x28, 0x10, 0x23, 0x9b, 0x24, 0xeb, -0xee, 0xbd, 0x35, 0x0e, 0x6e, 0x75, 0x23, 0x20, 0xd6, 0x95, 0x8c, 0xa5, -0x24, 0xec, 0x44, 0x67, 0x52, 0x2e, 0x78, 0x2a, 0xba, 0x3e, 0x3a, 0x4e, -0xc9, 0x5c, 0x23, 0xb0, 0xd5, 0xfb, 0x29, 0xaf, 0x9a, 0x0b, 0x90, 0x89, -0xd8, 0xec, 0xa9, 0xa8, 0x13, 0xfc, 0x22, 0xfa, 0xf2, 0x74, 0x2f, 0x4e, -0x35, 0xb0, 0x6d, 0x6c, 0xfd, 0xc4, 0xfe, 0xd0, 0x98, 0x3d, 0xe5, 0x43, -0x0a, 0xd0, 0x33, 0x26, 0x3b, 0x12, 0x7d, 0x65, 0xa1, 0xff, 0xff, 0x6f, -0x53, 0x0e, 0x28, 0x84, 0xa7, 0xa2, 0x2e, 0xf8, 0x4a, 0xb6, 0xa1, 0x47, -0xf5, 0xd0, 0x13, 0x9d, 0xd9, 0x50, 0xef, 0x9f, 0x31, 0xb4, 0x13, 0x67, -0xf9, 0x0a, 0x99, 0xb5, 0x80, 0xec, 0x4a, 0x1a, 0x59, 0x21, 0x3b, 0xce, -0xc5, 0x7e, 0x96, 0x85, 0x92, 0xc5, 0xb0, 0x75, 0xaa, 0x41, 0x16, 0xa9, -0xd3, 0xde, 0x13, 0x7d, 0xd9, 0x61, 0x30, 0x1c, 0x73, 0x61, 0x54, 0x90, -0xcf, 0xd4, 0xe8, 0xfe, 0xbf, 0xbf, 0x36, 0x57, 0x26, 0x38, 0xab, 0x06, -0xc4, 0x7e, 0x3c, 0x5b, 0x35, 0xd2, 0x7c, 0x2c, 0x0a, 0x82, 0xf2, 0xa8, -0xf2, 0x8b, 0x48, 0xa9, 0x90, 0x00, 0x01, 0x10, 0x10, 0x14, 0x04, 0x00, -0x32, 0xa2, 0x06, 0x82, 0x28, 0x90, 0xc2, 0xb4, 0x85, 0xda, 0x01, 0x52, -0xe9, 0x18, 0x85, 0x60, 0x00, 0x00, 0x20, 0x0c, 0x00, 0x14, 0x41, 0x00, -0x40, 0xa0, 0x04, 0x40, 0x00, 0x80, 0x50, 0x03, 0x01, 0x10, 0x18, 0x01, -0x80, 0xd4, 0x14, 0x99, 0x01, 0xfd, 0x07, 0xf8, 0x16, 0x0e, 0xd9, 0x5d, -0xa3, 0x70, 0xfe, 0xda, 0x17, 0xfa, 0xce, 0x46, 0x9a, 0x99, 0x81, 0x1a, -0x39, 0xba, 0x63, 0xb1, 0x18, 0x11, 0x58, 0xd7, 0xc7, 0xba, 0x03, 0x3e, -0x01, 0xf2, 0xf9, 0x4e, 0x12, 0xa3, 0x50, 0x7b, 0xaf, 0x7b, 0x60, 0x5c, -0x83, 0x23, 0xd2, 0x60, 0x27, 0x84, 0xad, 0xb8, 0x02, 0xed, 0xfe, 0xb4, -0x9c, 0x08, 0x9f, 0x49, 0xae, 0x55, 0x02, 0x94, 0xc0, 0x1b, 0x90, 0x75, -0x0b, 0x90, 0xc4, 0xc7, 0x43, 0x9e, 0x67, 0x25, 0x70, 0x61, 0x0d, 0xb8, -0x7a, 0x97, 0x43, 0xfc, 0xd1, 0x7e, 0x68, 0xed, 0x03, 0xb7, 0x1e, 0x75, -0xe9, 0x4d, 0x7a, 0x23, 0x18, 0x37, 0x63, 0x6f, 0xab, 0x5f, 0x7c, 0x5b, -0x1c, 0x05, 0xdf, 0x3f, 0x00, 0x86, 0x37, 0xa0, 0xfa, 0x0c, 0xe0, 0xed, -0x35, 0x35, 0x2f, 0xd8, 0xd1, 0x75, 0xba, 0x37, 0x34, 0x7e, 0xb0, 0x84, -0x2a, 0x01, 0x0c, 0x98, 0xed, 0x47, 0xf9, 0x86, 0x81, 0x74, 0x00, 0x5d, -0x8b, 0x4c, 0x18, 0x8a, 0x31, 0xcd, 0xae, 0x07, 0x44, 0xb5, 0xd5, 0x07, -0xa0, 0xdf, 0xf4, 0xfa, 0xa6, 0x42, 0xd0, 0x4f, 0x17, 0xd8, 0xdf, 0xb6, -0x34, 0x44, 0xe3, 0x01, 0xc4, 0xb6, 0x2d, 0xb5, 0x56, 0xc6, 0x2a, 0x1f, -0x05, 0x6c, 0x35, 0xe0, 0x09, 0x31, 0xef, 0x60, 0xfe, 0xaf, 0x07, 0x80, -0x32, 0xa0, 0xe9, 0xd3, 0x96, 0x45, 0xa7, 0xaa, 0xb6, 0xfb, 0x03, 0x10, -0xe3, 0x97, 0x96, 0x8d, 0x3a, 0x01, 0xdd, 0x58, 0x58, 0x78, 0x00, 0xab, -0xff, 0x06, 0xa0, 0xd6, 0x01, 0x58, 0x08, 0xb7, 0xdc, 0x2d, 0xa7, 0xfb, -0x22, 0xa8, 0x67, 0x00, 0xe3, 0xcf, 0x82, 0x43, 0xfc, 0x96, 0x1b, 0x40, -0x63, 0xcf, 0x9d, 0x42, 0x5d, 0x66, 0x40, 0xaa, 0xaf, 0x28, 0x94, 0xd3, -0x2a, 0xd4, 0x02, 0x13, 0xd2, 0xdf, 0x03, 0x9c, 0x60, 0x6b, 0x16, 0x94, -0xb4, 0xbe, 0x62, 0xc2, 0x35, 0x60, 0x45, 0x09, 0x23, 0x5a, 0xe0, 0x85, -0xb3, 0x03, 0x50, 0x68, 0x0c, 0x20, 0xa5, 0xf9, 0x94, 0xd2, 0x35, 0x80, -0xad, 0x4c, 0x4e, 0x40, 0x41, 0x97, 0x92, 0x75, 0xbe, 0x0c, 0x03, 0x50, -0x85, 0x08, 0xaf, 0x36, 0x00, 0x68, 0xaf, 0x09, 0xb3, 0x0c, 0x20, 0x4f, -0x81, 0x6a, 0x6a, 0xf5, 0x0d, 0x70, 0x69, 0x00, 0x4c, 0xb4, 0x0f, 0x59, -0xe7, 0x31, 0x0a, 0x45, 0x9f, 0xde, 0x90, 0xd6, 0x38, 0x80, 0x6b, 0x2c, -0xb9, 0x2f, 0xd4, 0x01, 0x40, 0x14, 0xd5, 0xed, 0x8e, 0x01, 0x53, 0xbf, -0x03, 0x18, 0x1e, 0xb0, 0xc1, 0x85, 0x32, 0xec, 0x78, 0x2b, 0xf0, 0xbb, -0xbb, 0x6c, 0xf3, 0x4d, 0xdc, 0x73, 0x40, 0xfd, 0x10, 0x09, 0x9e, 0x20, -0xe2, 0x12, 0x8c, 0xe0, 0xd2, 0xed, 0x80, 0x6b, 0xcc, 0x78, 0x20, 0x03, -0xd0, 0x5e, 0x06, 0xf4, 0xb0, 0xc4, 0x0e, 0x15, 0x1d, 0x80, 0xb4, 0x76, -0xdf, 0x49, 0x03, 0x50, 0x82, 0xad, 0xda, 0x8b, 0x5a, 0x61, 0xc2, 0x5e, -0xb5, 0x1e, 0x46, 0xc0, 0xde, 0xaa, 0x0e, 0x15, 0x06, 0xd2, 0xf4, 0xb2, -0xd1, 0xed, 0x38, 0x0a, 0x03, 0x18, 0x33, 0x1a, 0x80, 0x61, 0x3e, 0xec, -0x7c, 0x74, 0xa8, 0x1d, 0x80, 0x1a, 0xce, 0x25, 0x1d, 0x41, 0xd1, 0xc1, -0x03, 0x28, 0xb5, 0xaf, 0x72, 0x9c, 0x59, 0x7a, 0xe1, 0x7d, 0xc0, 0xa5, -0x08, 0x1e, 0x18, 0x24, 0xfa, 0xbd, 0x99, 0x4a, 0x31, 0xa0, 0xea, 0xee, -0xf8, 0x36, 0x60, 0x98, 0xc9, 0x10, 0xd1, 0xa7, 0x35, 0x00, 0x8d, 0x40, -0x8e, 0x5a, 0x35, 0x0f, 0x80, 0xb1, 0xd4, 0x32, 0x79, 0x40, 0x34, 0x05, -0x7e, 0x98, 0xc6, 0x80, 0x3e, 0x90, 0x01, 0x65, 0xf4, 0x80, 0x73, 0x08, -0x64, 0xd7, 0x36, 0xc1, 0x7c, 0xc0, 0x5c, 0x75, 0x00, 0xc5, 0x09, 0x58, -0x9c, 0x13, 0x01, 0x72, 0x37, 0x9b, 0x79, 0xe4, 0x05, 0xd1, 0x01, 0x04, -0x98, 0x08, 0x74, 0xfd, 0xfc, 0x3f, 0x1c, 0x00, 0x73, 0x01, 0xfc, 0x1c, -0xcc, 0x16, 0x43, 0x19, 0x1d, 0xac, 0x61, 0x4b, 0x11, 0xc2, 0xa0, 0xf2, -0x01, 0x0b, 0x7b, 0x3b, 0xf4, 0xfc, 0x58, 0x5d, 0x2d, 0x5c, 0x01, 0x8c, -0x62, 0x17, 0x78, 0xbe, 0x60, 0x8c, 0x01, 0x6f, 0x91, 0x49, 0x65, 0x54, -0x92, 0xe9, 0x01, 0x1e, 0x10, 0x77, 0x35, 0x00, 0xa8, 0xd4, 0xc7, 0x71, -0x07, 0xd8, 0xcd, 0xa3, 0x7d, 0x69, 0x20, 0xac, 0x07, 0x00, 0x35, 0xc7, -0x62, 0xee, 0x8c, 0x7d, 0x0c, 0xb8, 0x43, 0x0e, 0x00, 0x08, 0xfb, 0xe7, -0xec, 0x33, 0x37, 0x04, 0x80, 0x2d, 0x1d, 0xa6, 0x13, 0x34, 0x1b, 0x1d, -0xc0, 0xca, 0x00, 0x92, 0xed, 0x2e, 0x56, 0xbe, 0x91, 0x80, 0x0c, 0x88, -0xa6, 0x01, 0xdf, 0x7f, 0x90, 0x49, 0xed, 0x0c, 0xe0, 0x08, 0x73, 0x28, -0x74, 0xc7, 0xe1, 0xb1, 0x03, 0x5d, 0xc5, 0xab, 0x61, 0x42, 0xdf, 0x03, -0x43, 0xf3, 0x35, 0x04, 0xcf, 0xc6, 0x1d, 0x79, 0x07, 0x40, 0x22, 0xe4, -0x68, 0x0d, 0x01, 0x95, 0xad, 0x72, 0x69, 0x00, 0x39, 0x9d, 0x53, 0x8f, -0x13, 0x0d, 0xb0, 0x29, 0x79, 0x1a, 0x39, 0x20, 0x12, 0x28, 0x9b, 0x02, -0x8f, 0x74, 0x90, 0x4c, 0xe8, 0xd1, 0x57, 0xf4, 0x01, 0x44, 0x04, 0xe0, -0x0c, 0x82, 0x91, 0xc5, 0x4f, 0x8f, 0xc6, 0x00, 0x43, 0x85, 0x65, 0xc8, -0xe6, 0x34, 0x1d, 0x80, 0xc0, 0xca, 0xdb, 0x57, 0x6c, 0x00, 0x72, 0x42, -0x5f, 0xd0, 0x49, 0x57, 0x47, 0xd4, 0x97, 0x18, 0x18, 0x80, 0x68, 0x8e, -0x0a, 0xf1, 0x6b, 0x34, 0xf1, 0x60, 0x2c, 0x41, 0x29, 0xd3, 0x3d, 0x55, -0x95, 0xb1, 0x3c, 0xd4, 0x95, 0x42, 0xef, 0xe7, 0xca, 0x00, 0x2e, 0xce, -0x25, 0xc2, 0xca, 0xf5, 0x00, 0x17, 0x3b, 0x8c, 0x42, 0x88, 0x03, 0xde, -0x97, 0xe1, 0x3a, 0x74, 0xb0, 0x33, 0xe0, 0x8f, 0x47, 0xeb, 0x2a, 0x5f, -0x36, 0x3e, 0x5a, 0xff, 0xc5, 0x80, 0xb9, 0x13, 0xa9, 0x1f, 0xf8, 0x86, -0xc9, 0x51, 0xf8, 0x4c, 0xaa, 0xe1, 0x65, 0x80, 0xb0, 0x8b, 0x91, 0xec, -0xcc, 0xbf, 0x70, 0x19, 0x98, 0x03, 0x10, 0xf0, 0x38, 0x40, 0xc4, 0x65, -0xbe, 0x41, 0xb2, 0x58, 0x3f, 0xe0, 0xcc, 0x0e, 0x08, 0x2b, 0x73, 0xf4, -0xdd, 0x86, 0x06, 0xa0, 0xc6, 0x8f, 0x1a, 0x32, 0x66, 0x50, 0x8e, 0xe1, -0x59, 0x67, 0x00, 0xed, 0x66, 0x1d, 0xdd, 0xfa, 0x7b, 0xe2, 0x56, 0x89, -0xd9, 0xa0, 0x4f, 0x41, 0x94, 0x28, 0xb8, 0xc6, 0xc7, 0x64, 0xde, 0x9b, -0x64, 0x44, 0x33, 0x39, 0xb5, 0x6c, 0xb9, 0x42, 0xe7, 0x7e, 0x16, 0xd2, -0x01, 0x12, 0x03, 0xb3, 0x48, 0x47, 0x6b, 0x75, 0x26, 0x19, 0x8c, 0xac, -0x6f, 0xb1, 0x6f, 0xdc, 0x04, 0x27, 0x3a, 0x00, 0xd6, 0xae, 0xfa, 0xe1, -0xf7, 0x30, 0xa4, 0xdb, 0xd5, 0x86, 0x5a, 0x07, 0x11, 0xde, 0xea, 0xf4, -0xb0, 0x83, 0x16, 0xbb, 0xc6, 0x00, 0x6e, 0xf2, 0x6b, 0x40, 0x81, 0x01, -0x67, 0x0e, 0xa9, 0x82, 0x23, 0x04, 0x34, 0xed, 0x02, 0xf5, 0xe4, 0x0e, -0x58, 0xe8, 0x8a, 0x58, 0x57, 0xb0, 0x56, 0x65, 0x3d, 0x40, 0x64, 0x03, -0x6e, 0x7b, 0x07, 0x20, 0x99, 0x90, 0x36, 0x95, 0x9f, 0xdf, 0x3d, 0xe8, -0x00, 0xa0, 0x57, 0x8f, 0x6d, 0xa4, 0xb3, 0x1d, 0x7a, 0x06, 0xa8, 0x26, -0x41, 0xb0, 0x8c, 0x9c, 0x10, 0x85, 0x6c, 0xb4, 0x31, 0xa6, 0x5b, 0x7a, -0x10, 0x51, 0x15, 0x3c, 0xa2, 0x42, 0xd3, 0x23, 0x02, 0xc0, 0x17, 0x7e, -0x03, 0x28, 0xba, 0xce, 0x9b, 0xae, 0xdd, 0x1a, 0x19, 0xd0, 0x15, 0xac, -0xeb, 0x20, 0x3c, 0x3a, 0x00, 0xc6, 0xbb, 0x8a, 0xd5, 0x64, 0xc2, 0x21, -0x1d, 0x6c, 0x15, 0x5a, 0xd3, 0x44, 0x98, 0x14, 0x95, 0xb3, 0xb7, 0xdd, -0xa6, 0xea, 0x06, 0x54, 0x78, 0xc3, 0xe8, 0x79, 0x9b, 0x86, 0x29, 0x76, -0x8b, 0x6b, 0xaa, 0x0d, 0xa8, 0x2f, 0x22, 0x2a, 0xeb, 0x68, 0x81, 0x6c, -0x56, 0xfd, 0x79, 0xac, 0x79, 0x4b, 0xa0, 0x01, 0x3f, 0x17, 0x43, 0x82, -0xb4, 0xd5, 0x00, 0x14, 0xb7, 0xf5, 0x00, 0xf4, 0x15, 0xa8, 0xd7, 0x4b, -0xb1, 0xbc, 0xa8, 0x36, 0x98, 0xf0, 0x8c, 0xe7, 0xf4, 0x7b, 0x35, 0xd8, -0xad, 0x0d, 0x5f, 0x9d, 0x96, 0xab, 0xed, 0x48, 0xe2, 0xdc, 0x1c, 0xbe, -0x12, 0xfa, 0x41, 0x6f, 0xf5, 0x1e, 0xb6, 0x9f, 0xee, 0xac, 0x21, 0xf4, -0xf6, 0x00, 0x38, 0xb1, 0x1f, 0xfd, 0xd0, 0x0e, 0xc7, 0xdd, 0xa0, 0x39, -0x07, 0x8c, 0x35, 0x1f, 0x7e, 0xcc, 0xbf, 0xf6, 0xe0, 0x06, 0x66, 0x7d, -0x10, 0x3f, 0xc5, 0x3e, 0xde, 0x42, 0xf9, 0x3d, 0x00, 0x54, 0x81, 0x67, -0x8a, 0xe6, 0x63, 0x0d, 0x01, 0xd0, 0x31, 0xe0, 0x6e, 0xd0, 0xe1, 0x59, -0xf6, 0x1b, 0xf7, 0x0d, 0x52, 0x06, 0x80, 0x61, 0x4f, 0xe8, 0x77, 0xdd, -0x6f, 0x48, 0x20, 0x1d, 0xbb, 0x2a, 0x16, 0x8b, 0x54, 0x87, 0x92, 0x83, -0xe6, 0x8f, 0x55, 0x59, 0x06, 0x00, 0xe9, 0xc5, 0xce, 0x21, 0x63, 0x87, -0xaf, 0x86, 0xcc, 0xba, 0xd6, 0xe7, 0x00, 0xf6, 0x91, 0x92, 0x92, 0xea, -0xe8, 0x42, 0x06, 0x69, 0x13, 0xf5, 0x00, 0xd0, 0xb0, 0xa7, 0xcb, 0x4c, -0xb0, 0xd2, 0x2d, 0x28, 0x63, 0xf0, 0x6a, 0xc7, 0x80, 0x6a, 0x19, 0xb2, -0x66, 0x51, 0xf3, 0xb1, 0x21, 0xa0, 0x48, 0xad, 0x1e, 0x80, 0x62, 0xaf, -0x00, 0xf4, 0xa5, 0x4e, 0x83, 0x75, 0x1b, 0xfe, 0x00, 0xc4, 0xcf, 0x55, -0xb2, 0x50, 0xa6, 0xeb, 0x38, 0xed, 0x8f, 0xd3, 0x1d, 0x00, 0xf6, 0xe3, -0x90, 0x1c, 0x60, 0x9e, 0x8e, 0xeb, 0x0b, 0xba, 0x44, 0x06, 0x68, 0xbb, -0xd3, 0x10, 0x63, 0x35, 0xe1, 0x86, 0x5c, 0x5c, 0x2b, 0x85, 0xa6, 0xe7, -0x38, 0x2c, 0x18, 0x83, 0x1f, 0x8f, 0x9b, 0x8e, 0x4d, 0x26, 0xcd, 0x34, -0x0c, 0x66, 0x1d, 0x70, 0xb7, 0x01, 0xe6, 0x02, 0xa8, 0x51, 0x63, 0xcf, -0xbb, 0x03, 0xca, 0x85, 0xc6, 0x9c, 0xf6, 0xf1, 0x51, 0xe0, 0x60, 0x07, -0x40, 0x86, 0xf0, 0x1e, 0x6e, 0xef, 0x61, 0x10, 0xd9, 0x36, 0xcc, 0xfc, -0x58, 0xe2, 0x37, 0x0d, 0x58, 0xb7, 0xbe, 0xca, 0xc9, 0xd8, 0xcd, 0xaa, -0xd5, 0x5b, 0x77, 0x83, 0xcb, 0x0e, 0x30, 0xce, 0xc8, 0xb8, 0xcd, 0xbf, -0x1e, 0x63, 0x04, 0xad, 0xb7, 0xcd, 0x43, 0x62, 0x4c, 0xe0, 0x1a, 0xd4, -0x21, 0xe2, 0xdd, 0x33, 0xdf, 0xb1, 0xdd, 0xdc, 0x01, 0x22, 0x18, 0xce, -0xa1, 0xd8, 0xcb, 0x67, 0xd5, 0x38, 0x4a, 0xbc, 0xd5, 0x81, 0x3d, 0x03, -0x98, 0x35, 0x60, 0x41, 0x85, 0x0c, 0x1d, 0xe7, 0x76, 0xf8, 0x11, 0x52, -0x76, 0xf6, 0x06, 0x16, 0x02, 0x45, 0xc8, 0xd8, 0x2f, 0x5e, 0x57, 0xbc, -0x3b, 0x89, 0x97, 0x09, 0x3e, 0x03, 0x34, 0x1a, 0x9d, 0x37, 0x87, 0x48, -0x0a, 0xe0, 0xa7, 0x4f, 0x8c, 0x3a, 0xa2, 0xaf, 0xfd, 0x7b, 0x80, 0xcf, -0xe5, 0x18, 0x61, 0x68, 0xba, 0x61, 0x8b, 0x09, 0xaa, 0xa3, 0x0c, 0x47, -0x3c, 0x43, 0x03, 0xac, 0xa3, 0x2e, 0x5e, 0x72, 0x0c, 0x80, 0x19, 0x61, -0xe6, 0x6e, 0x0e, 0xd9, 0xe8, 0xe8, 0xaf, 0x11, 0x9b, 0x4a, 0x73, 0x7a, -0x61, 0x66, 0xf0, 0x54, 0x1d, 0x18, 0xc8, 0x23, 0x36, 0xbf, 0xb5, 0xf4, -0x86, 0x54, 0xed, 0xb5, 0x91, 0xee, 0xb8, 0xbc, 0xde, 0xc3, 0x87, 0x9b, -0x2f, 0x81, 0xf2, 0xee, 0xa3, 0xec, 0x02 \ No newline at end of file diff --git a/third_party/zstd/build/single_file_libs/examples/testcard.png b/third_party/zstd/build/single_file_libs/examples/testcard.png deleted file mode 100755 index 43088bb16..000000000 Binary files a/third_party/zstd/build/single_file_libs/examples/testcard.png and /dev/null differ diff --git a/third_party/zstd/build/single_file_libs/zstd-in.c b/third_party/zstd/build/single_file_libs/zstd-in.c deleted file mode 100644 index e6fca9e4a..000000000 --- a/third_party/zstd/build/single_file_libs/zstd-in.c +++ /dev/null @@ -1,90 +0,0 @@ -/** - * \file zstd.c - * Single-file Zstandard library. - * - * Generate using: - * \code - * python combine.py -r ../../lib -x legacy/zstd_legacy.h -o zstd.c zstd-in.c - * \endcode - */ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under both the BSD-style license (found in the - * LICENSE file in the root directory of this source tree) and the GPLv2 (found - * in the COPYING file in the root directory of this source tree). - * You may select, at your option, one of the above-listed licenses. - */ -/* - * Settings to bake for the single library file. - * - * Note: It's important that none of these affects 'zstd.h' (only the - * implementation files we're amalgamating). - * - * Note: MEM_MODULE stops xxhash redefining BYTE, U16, etc., which are also - * defined in mem.h (breaking C99 compatibility). - * - * Note: the undefs for xxHash allow Zstd's implementation to coincide with - * standalone xxHash usage (with global defines). - * - * Note: if you enable ZSTD_LEGACY_SUPPORT the combine.py script will need - * re-running without the "-x legacy/zstd_legacy.h" option (it excludes the - * legacy support at the source level). - * - * Note: multithreading is enabled for all platforms apart from Emscripten. - */ -#define DEBUGLEVEL 0 -#define MEM_MODULE -#undef XXH_NAMESPACE -#define XXH_NAMESPACE ZSTD_ -#undef XXH_PRIVATE_API -#define XXH_PRIVATE_API -#undef XXH_INLINE_ALL -#define XXH_INLINE_ALL -#define ZSTD_LEGACY_SUPPORT 0 -#ifndef __EMSCRIPTEN__ -#define ZSTD_MULTITHREAD -#endif -#define ZSTD_TRACE 0 -/* TODO: Can't amalgamate ASM function */ -#define ZSTD_DISABLE_ASM 1 - -/* Include zstd_deps.h first with all the options we need enabled. */ -#define ZSTD_DEPS_NEED_MALLOC -#define ZSTD_DEPS_NEED_MATH64 -#include "common/zstd_deps.h" - -#include "common/debug.c" -#include "common/entropy_common.c" -#include "common/error_private.c" -#include "common/fse_decompress.c" -#include "common/threading.c" -#include "common/pool.c" -#include "common/zstd_common.c" - -#include "compress/fse_compress.c" -#include "compress/hist.c" -#include "compress/huf_compress.c" -#include "compress/zstd_compress_literals.c" -#include "compress/zstd_compress_sequences.c" -#include "compress/zstd_compress_superblock.c" -#include "compress/zstd_compress.c" -#include "compress/zstd_double_fast.c" -#include "compress/zstd_fast.c" -#include "compress/zstd_lazy.c" -#include "compress/zstd_ldm.c" -#include "compress/zstd_opt.c" -#ifdef ZSTD_MULTITHREAD -#include "compress/zstdmt_compress.c" -#endif - -#include "decompress/huf_decompress.c" -#include "decompress/zstd_ddict.c" -#include "decompress/zstd_decompress.c" -#include "decompress/zstd_decompress_block.c" - -#include "dictBuilder/cover.c" -#include "dictBuilder/divsufsort.c" -#include "dictBuilder/fastcover.c" -#include "dictBuilder/zdict.c" diff --git a/third_party/zstd/build/single_file_libs/zstddeclib-in.c b/third_party/zstd/build/single_file_libs/zstddeclib-in.c deleted file mode 100644 index 8d9c1f54b..000000000 --- a/third_party/zstd/build/single_file_libs/zstddeclib-in.c +++ /dev/null @@ -1,62 +0,0 @@ -/** - * \file zstddeclib.c - * Single-file Zstandard decompressor. - * - * Generate using: - * \code - * python combine.py -r ../../lib -x legacy/zstd_legacy.h -o zstddeclib.c zstddeclib-in.c - * \endcode - */ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under both the BSD-style license (found in the - * LICENSE file in the root directory of this source tree) and the GPLv2 (found - * in the COPYING file in the root directory of this source tree). - * You may select, at your option, one of the above-listed licenses. - */ -/* - * Settings to bake for the standalone decompressor. - * - * Note: It's important that none of these affects 'zstd.h' (only the - * implementation files we're amalgamating). - * - * Note: MEM_MODULE stops xxhash redefining BYTE, U16, etc., which are also - * defined in mem.h (breaking C99 compatibility). - * - * Note: the undefs for xxHash allow Zstd's implementation to coincide with - * standalone xxHash usage (with global defines). - * - * Note: if you enable ZSTD_LEGACY_SUPPORT the combine.py script will need - * re-running without the "-x legacy/zstd_legacy.h" option (it excludes the - * legacy support at the source level). - */ -#define DEBUGLEVEL 0 -#define MEM_MODULE -#undef XXH_NAMESPACE -#define XXH_NAMESPACE ZSTD_ -#undef XXH_PRIVATE_API -#define XXH_PRIVATE_API -#undef XXH_INLINE_ALL -#define XXH_INLINE_ALL -#define ZSTD_LEGACY_SUPPORT 0 -#define ZSTD_STRIP_ERROR_STRINGS -#define ZSTD_TRACE 0 -/* TODO: Can't amalgamate ASM function */ -#define ZSTD_DISABLE_ASM 1 - -/* Include zstd_deps.h first with all the options we need enabled. */ -#define ZSTD_DEPS_NEED_MALLOC -#include "common/zstd_deps.h" - -#include "common/debug.c" -#include "common/entropy_common.c" -#include "common/error_private.c" -#include "common/fse_decompress.c" -#include "common/zstd_common.c" - -#include "decompress/huf_decompress.c" -#include "decompress/zstd_ddict.c" -#include "decompress/zstd_decompress.c" -#include "decompress/zstd_decompress_block.c" diff --git a/third_party/zstd/contrib/VS2005/README.md b/third_party/zstd/contrib/VS2005/README.md deleted file mode 100644 index ec1ef68a0..000000000 --- a/third_party/zstd/contrib/VS2005/README.md +++ /dev/null @@ -1,3 +0,0 @@ -## Project Support Notice - -The VS2005 Project directory has been moved to the contrib directory in order to indicate that it will no longer be supported. diff --git a/third_party/zstd/contrib/VS2005/fullbench/fullbench.vcproj b/third_party/zstd/contrib/VS2005/fullbench/fullbench.vcproj deleted file mode 100644 index 94e288f71..000000000 --- a/third_party/zstd/contrib/VS2005/fullbench/fullbench.vcproj +++ /dev/null @@ -1,440 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/third_party/zstd/contrib/VS2005/fuzzer/fuzzer.vcproj b/third_party/zstd/contrib/VS2005/fuzzer/fuzzer.vcproj deleted file mode 100644 index 04003fcff..000000000 --- a/third_party/zstd/contrib/VS2005/fuzzer/fuzzer.vcproj +++ /dev/null @@ -1,488 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/third_party/zstd/contrib/VS2005/zstd.sln b/third_party/zstd/contrib/VS2005/zstd.sln deleted file mode 100644 index dfc73b468..000000000 --- a/third_party/zstd/contrib/VS2005/zstd.sln +++ /dev/null @@ -1,55 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual C++ Express 2005 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zstd", "zstd\zstd.vcproj", "{1A2AB08E-5CE7-4C5B-BE55-458157C14051}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fuzzer", "fuzzer\fuzzer.vcproj", "{A62E89D2-9DDE-42BA-8F9B-9DA74889A6B0}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fullbench", "fullbench\fullbench.vcproj", "{CC8F1D1B-BA2F-43E3-A71F-FA415D81AAD3}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zstdlib", "zstdlib\zstdlib.vcproj", "{99DE2A79-7298-4004-A0ED-030D7A3796CA}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {1A2AB08E-5CE7-4C5B-BE55-458157C14051}.Debug|Win32.ActiveCfg = Debug|Win32 - {1A2AB08E-5CE7-4C5B-BE55-458157C14051}.Debug|Win32.Build.0 = Debug|Win32 - {1A2AB08E-5CE7-4C5B-BE55-458157C14051}.Debug|x64.ActiveCfg = Debug|x64 - {1A2AB08E-5CE7-4C5B-BE55-458157C14051}.Debug|x64.Build.0 = Debug|x64 - {1A2AB08E-5CE7-4C5B-BE55-458157C14051}.Release|Win32.ActiveCfg = Release|Win32 - {1A2AB08E-5CE7-4C5B-BE55-458157C14051}.Release|Win32.Build.0 = Release|Win32 - {1A2AB08E-5CE7-4C5B-BE55-458157C14051}.Release|x64.ActiveCfg = Release|x64 - {1A2AB08E-5CE7-4C5B-BE55-458157C14051}.Release|x64.Build.0 = Release|x64 - {A62E89D2-9DDE-42BA-8F9B-9DA74889A6B0}.Debug|Win32.ActiveCfg = Debug|Win32 - {A62E89D2-9DDE-42BA-8F9B-9DA74889A6B0}.Debug|Win32.Build.0 = Debug|Win32 - {A62E89D2-9DDE-42BA-8F9B-9DA74889A6B0}.Debug|x64.ActiveCfg = Debug|x64 - {A62E89D2-9DDE-42BA-8F9B-9DA74889A6B0}.Debug|x64.Build.0 = Debug|x64 - {A62E89D2-9DDE-42BA-8F9B-9DA74889A6B0}.Release|Win32.ActiveCfg = Release|Win32 - {A62E89D2-9DDE-42BA-8F9B-9DA74889A6B0}.Release|Win32.Build.0 = Release|Win32 - {A62E89D2-9DDE-42BA-8F9B-9DA74889A6B0}.Release|x64.ActiveCfg = Release|x64 - {A62E89D2-9DDE-42BA-8F9B-9DA74889A6B0}.Release|x64.Build.0 = Release|x64 - {CC8F1D1B-BA2F-43E3-A71F-FA415D81AAD3}.Debug|Win32.ActiveCfg = Debug|Win32 - {CC8F1D1B-BA2F-43E3-A71F-FA415D81AAD3}.Debug|Win32.Build.0 = Debug|Win32 - {CC8F1D1B-BA2F-43E3-A71F-FA415D81AAD3}.Debug|x64.ActiveCfg = Debug|x64 - {CC8F1D1B-BA2F-43E3-A71F-FA415D81AAD3}.Debug|x64.Build.0 = Debug|x64 - {CC8F1D1B-BA2F-43E3-A71F-FA415D81AAD3}.Release|Win32.ActiveCfg = Release|Win32 - {CC8F1D1B-BA2F-43E3-A71F-FA415D81AAD3}.Release|Win32.Build.0 = Release|Win32 - {CC8F1D1B-BA2F-43E3-A71F-FA415D81AAD3}.Release|x64.ActiveCfg = Release|x64 - {CC8F1D1B-BA2F-43E3-A71F-FA415D81AAD3}.Release|x64.Build.0 = Release|x64 - {99DE2A79-7298-4004-A0ED-030D7A3796CA}.Debug|Win32.ActiveCfg = Debug|Win32 - {99DE2A79-7298-4004-A0ED-030D7A3796CA}.Debug|Win32.Build.0 = Debug|Win32 - {99DE2A79-7298-4004-A0ED-030D7A3796CA}.Debug|x64.ActiveCfg = Debug|x64 - {99DE2A79-7298-4004-A0ED-030D7A3796CA}.Debug|x64.Build.0 = Debug|x64 - {99DE2A79-7298-4004-A0ED-030D7A3796CA}.Release|Win32.ActiveCfg = Release|Win32 - {99DE2A79-7298-4004-A0ED-030D7A3796CA}.Release|Win32.Build.0 = Release|Win32 - {99DE2A79-7298-4004-A0ED-030D7A3796CA}.Release|x64.ActiveCfg = Release|x64 - {99DE2A79-7298-4004-A0ED-030D7A3796CA}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/third_party/zstd/contrib/VS2005/zstd/zstd.vcproj b/third_party/zstd/contrib/VS2005/zstd/zstd.vcproj deleted file mode 100644 index cd8f852ba..000000000 --- a/third_party/zstd/contrib/VS2005/zstd/zstd.vcproj +++ /dev/null @@ -1,552 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/third_party/zstd/contrib/VS2005/zstdlib/zstdlib.vcproj b/third_party/zstd/contrib/VS2005/zstdlib/zstdlib.vcproj deleted file mode 100644 index 0ad30b6a5..000000000 --- a/third_party/zstd/contrib/VS2005/zstdlib/zstdlib.vcproj +++ /dev/null @@ -1,546 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/third_party/zstd/contrib/cleanTabs b/third_party/zstd/contrib/cleanTabs deleted file mode 100755 index 215913a90..000000000 --- a/third_party/zstd/contrib/cleanTabs +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -sed -i '' $'s/\t/ /g' ../lib/**/*.{h,c} ../programs/*.{h,c} ../tests/*.c ./**/*.{h,cpp} ../examples/*.c ../zlibWrapper/*.{h,c} diff --git a/third_party/zstd/contrib/diagnose_corruption/.gitignore b/third_party/zstd/contrib/diagnose_corruption/.gitignore deleted file mode 100644 index a8e92b69b..000000000 --- a/third_party/zstd/contrib/diagnose_corruption/.gitignore +++ /dev/null @@ -1 +0,0 @@ -check_flipped_bits diff --git a/third_party/zstd/contrib/diagnose_corruption/Makefile b/third_party/zstd/contrib/diagnose_corruption/Makefile deleted file mode 100644 index ecc9e6395..000000000 --- a/third_party/zstd/contrib/diagnose_corruption/Makefile +++ /dev/null @@ -1,35 +0,0 @@ -# ################################################################ -# Copyright (c) Meta Platforms, Inc. and affiliates. -# All rights reserved. -# -# This source code is licensed under both the BSD-style license (found in the -# LICENSE file in the root directory of this source tree) and the GPLv2 (found -# in the COPYING file in the root directory of this source tree). -# ################################################################ - -.PHONY: all -all: check_flipped_bits - -ZSTDLIBDIR ?= ../../lib - -CFLAGS ?= -O3 -CFLAGS += -I$(ZSTDLIBDIR) -I$(ZSTDLIBDIR)/common -I$(ZSTDLIBDIR)/compress \ - -I$(ZSTDLIBDIR)/decompress -CFLAGS += -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow \ - -Wstrict-aliasing=1 -Wswitch-enum -Wdeclaration-after-statement \ - -Wstrict-prototypes -Wundef \ - -Wvla -Wformat=2 -Winit-self -Wfloat-equal -Wwrite-strings \ - -Wredundant-decls -Wmissing-prototypes -CFLAGS += $(DEBUGFLAGS) $(MOREFLAGS) -FLAGS = $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) - -.PHONY: $(ZSTDLIBDIR)/libzstd.a -$(ZSTDLIBDIR)/libzstd.a: - $(MAKE) -C $(ZSTDLIBDIR) libzstd.a - -check_flipped_bits: check_flipped_bits.c $(ZSTDLIBDIR)/libzstd.a - $(CC) $(FLAGS) $< -o $@$(EXT) $(ZSTDLIBDIR)/libzstd.a - -.PHONY: clean -clean: - rm -f check_flipped_bits diff --git a/third_party/zstd/contrib/diagnose_corruption/check_flipped_bits.c b/third_party/zstd/contrib/diagnose_corruption/check_flipped_bits.c deleted file mode 100644 index 09ddd4674..000000000 --- a/third_party/zstd/contrib/diagnose_corruption/check_flipped_bits.c +++ /dev/null @@ -1,400 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under both the BSD-style license (found in the - * LICENSE file in the root directory of this source tree) and the GPLv2 (found - * in the COPYING file in the root directory of this source tree). - * You may select, at your option, one of the above-listed licenses. - */ - -#define ZSTD_STATIC_LINKING_ONLY -#include "zstd.h" -#include "zstd_errors.h" - -#include -#include -#include -#include -#include -#include - -typedef struct { - char *input; - size_t input_size; - - char *perturbed; /* same size as input */ - - char *output; - size_t output_size; - - const char *dict_file_name; - const char *dict_file_dir_name; - int32_t dict_id; - char *dict; - size_t dict_size; - ZSTD_DDict* ddict; - - ZSTD_DCtx* dctx; - - int success_count; - int error_counts[ZSTD_error_maxCode]; -} stuff_t; - -static void free_stuff(stuff_t* stuff) { - free(stuff->input); - free(stuff->output); - ZSTD_freeDDict(stuff->ddict); - free(stuff->dict); - ZSTD_freeDCtx(stuff->dctx); -} - -static void usage(void) { - fprintf(stderr, "check_flipped_bits input_filename [-d dict] [-D dict_dir]\n"); - fprintf(stderr, "\n"); - fprintf(stderr, "Arguments:\n"); - fprintf(stderr, " -d file: path to a dictionary file to use.\n"); - fprintf(stderr, " -D dir : path to a directory, with files containing dictionaries, of the\n" - " form DICTID.zstd-dict, e.g., 12345.zstd-dict.\n"); - exit(1); -} - -static void print_summary(stuff_t* stuff) { - int error_code; - fprintf(stderr, "%9d successful decompressions\n", stuff->success_count); - for (error_code = 0; error_code < ZSTD_error_maxCode; error_code++) { - int count = stuff->error_counts[error_code]; - if (count) { - fprintf( - stderr, "%9d failed decompressions with message: %s\n", - count, ZSTD_getErrorString(error_code)); - } - } -} - -static char* readFile(const char* filename, size_t* size) { - struct stat statbuf; - int ret; - FILE* f; - char *buf; - size_t bytes_read; - - ret = stat(filename, &statbuf); - if (ret != 0) { - fprintf(stderr, "stat failed: %m\n"); - return NULL; - } - if ((statbuf.st_mode & S_IFREG) != S_IFREG) { - fprintf(stderr, "Input must be regular file\n"); - return NULL; - } - - *size = statbuf.st_size; - - f = fopen(filename, "r"); - if (f == NULL) { - fprintf(stderr, "fopen failed: %m\n"); - return NULL; - } - - buf = malloc(*size); - if (buf == NULL) { - fprintf(stderr, "malloc failed\n"); - fclose(f); - return NULL; - } - - bytes_read = fread(buf, 1, *size, f); - if (bytes_read != *size) { - fprintf(stderr, "failed to read whole file\n"); - fclose(f); - free(buf); - return NULL; - } - - ret = fclose(f); - if (ret != 0) { - fprintf(stderr, "fclose failed: %m\n"); - free(buf); - return NULL; - } - - return buf; -} - -static ZSTD_DDict* readDict(const char* filename, char **buf, size_t* size, int32_t* dict_id) { - ZSTD_DDict* ddict; - *buf = readFile(filename, size); - if (*buf == NULL) { - fprintf(stderr, "Opening dictionary file '%s' failed\n", filename); - return NULL; - } - - ddict = ZSTD_createDDict_advanced(*buf, *size, ZSTD_dlm_byRef, ZSTD_dct_auto, ZSTD_defaultCMem); - if (ddict == NULL) { - fprintf(stderr, "Failed to create ddict.\n"); - return NULL; - } - if (dict_id != NULL) { - *dict_id = ZSTD_getDictID_fromDDict(ddict); - } - return ddict; -} - -static ZSTD_DDict* readDictByID(stuff_t *stuff, int32_t dict_id, char **buf, size_t* size) { - if (stuff->dict_file_dir_name == NULL) { - return NULL; - } else { - size_t dir_name_len = strlen(stuff->dict_file_dir_name); - int dir_needs_separator = 0; - size_t dict_file_name_alloc_size = dir_name_len + 1 /* '/' */ + 10 /* max int32_t len */ + strlen(".zstd-dict") + 1 /* '\0' */; - char *dict_file_name = malloc(dict_file_name_alloc_size); - ZSTD_DDict* ddict; - int32_t read_dict_id; - if (dict_file_name == NULL) { - fprintf(stderr, "malloc failed.\n"); - return 0; - } - - if (dir_name_len > 0 && stuff->dict_file_dir_name[dir_name_len - 1] != '/') { - dir_needs_separator = 1; - } - - snprintf( - dict_file_name, - dict_file_name_alloc_size, - "%s%s%u.zstd-dict", - stuff->dict_file_dir_name, - dir_needs_separator ? "/" : "", - dict_id); - - /* fprintf(stderr, "Loading dict %u from '%s'.\n", dict_id, dict_file_name); */ - - ddict = readDict(dict_file_name, buf, size, &read_dict_id); - if (ddict == NULL) { - fprintf(stderr, "Failed to create ddict from '%s'.\n", dict_file_name); - free(dict_file_name); - return 0; - } - if (read_dict_id != dict_id) { - fprintf(stderr, "Read dictID (%u) does not match expected (%u).\n", read_dict_id, dict_id); - free(dict_file_name); - ZSTD_freeDDict(ddict); - return 0; - } - - free(dict_file_name); - return ddict; - } -} - -static int init_stuff(stuff_t* stuff, int argc, char *argv[]) { - const char* input_filename; - - if (argc < 2) { - usage(); - } - - input_filename = argv[1]; - stuff->input_size = 0; - stuff->input = readFile(input_filename, &stuff->input_size); - if (stuff->input == NULL) { - fprintf(stderr, "Failed to read input file.\n"); - return 0; - } - - stuff->perturbed = malloc(stuff->input_size); - if (stuff->perturbed == NULL) { - fprintf(stderr, "malloc failed.\n"); - return 0; - } - memcpy(stuff->perturbed, stuff->input, stuff->input_size); - - stuff->output_size = ZSTD_DStreamOutSize(); - stuff->output = malloc(stuff->output_size); - if (stuff->output == NULL) { - fprintf(stderr, "malloc failed.\n"); - return 0; - } - - stuff->dict_file_name = NULL; - stuff->dict_file_dir_name = NULL; - stuff->dict_id = 0; - stuff->dict = NULL; - stuff->dict_size = 0; - stuff->ddict = NULL; - - if (argc > 2) { - if (!strcmp(argv[2], "-d")) { - if (argc > 3) { - stuff->dict_file_name = argv[3]; - } else { - usage(); - } - } else - if (!strcmp(argv[2], "-D")) { - if (argc > 3) { - stuff->dict_file_dir_name = argv[3]; - } else { - usage(); - } - } else { - usage(); - } - } - - if (stuff->dict_file_dir_name) { - int32_t dict_id = ZSTD_getDictID_fromFrame(stuff->input, stuff->input_size); - if (dict_id != 0) { - stuff->ddict = readDictByID(stuff, dict_id, &stuff->dict, &stuff->dict_size); - if (stuff->ddict == NULL) { - fprintf(stderr, "Failed to create cached ddict.\n"); - return 0; - } - stuff->dict_id = dict_id; - } - } else - if (stuff->dict_file_name) { - stuff->ddict = readDict(stuff->dict_file_name, &stuff->dict, &stuff->dict_size, &stuff->dict_id); - if (stuff->ddict == NULL) { - fprintf(stderr, "Failed to create ddict from '%s'.\n", stuff->dict_file_name); - return 0; - } - } - - stuff->dctx = ZSTD_createDCtx(); - if (stuff->dctx == NULL) { - return 0; - } - - stuff->success_count = 0; - memset(stuff->error_counts, 0, sizeof(stuff->error_counts)); - - return 1; -} - -static int test_decompress(stuff_t* stuff) { - size_t ret; - ZSTD_inBuffer in = {stuff->perturbed, stuff->input_size, 0}; - ZSTD_outBuffer out = {stuff->output, stuff->output_size, 0}; - ZSTD_DCtx* dctx = stuff->dctx; - int32_t custom_dict_id = ZSTD_getDictID_fromFrame(in.src, in.size); - char *custom_dict = NULL; - size_t custom_dict_size = 0; - ZSTD_DDict* custom_ddict = NULL; - - if (custom_dict_id != 0 && custom_dict_id != stuff->dict_id) { - /* fprintf(stderr, "Instead of dict %u, this perturbed blob wants dict %u.\n", stuff->dict_id, custom_dict_id); */ - custom_ddict = readDictByID(stuff, custom_dict_id, &custom_dict, &custom_dict_size); - } - - ZSTD_DCtx_reset(dctx, ZSTD_reset_session_only); - - if (custom_ddict != NULL) { - ZSTD_DCtx_refDDict(dctx, custom_ddict); - } else { - ZSTD_DCtx_refDDict(dctx, stuff->ddict); - } - - while (in.pos != in.size) { - out.pos = 0; - ret = ZSTD_decompressStream(dctx, &out, &in); - - if (ZSTD_isError(ret)) { - unsigned int code = ZSTD_getErrorCode(ret); - if (code >= ZSTD_error_maxCode) { - fprintf(stderr, "Received unexpected error code!\n"); - exit(1); - } - stuff->error_counts[code]++; - /* - fprintf( - stderr, "Decompression failed: %s\n", ZSTD_getErrorName(ret)); - */ - if (custom_ddict != NULL) { - ZSTD_freeDDict(custom_ddict); - free(custom_dict); - } - return 0; - } - } - - stuff->success_count++; - - if (custom_ddict != NULL) { - ZSTD_freeDDict(custom_ddict); - free(custom_dict); - } - return 1; -} - -static int perturb_bits(stuff_t* stuff) { - size_t pos; - size_t bit; - for (pos = 0; pos < stuff->input_size; pos++) { - unsigned char old_val = stuff->input[pos]; - if (pos % 1000 == 0) { - fprintf(stderr, "Perturbing byte %zu / %zu\n", pos, stuff->input_size); - } - for (bit = 0; bit < 8; bit++) { - unsigned char new_val = old_val ^ (1 << bit); - stuff->perturbed[pos] = new_val; - if (test_decompress(stuff)) { - fprintf( - stderr, - "Flipping byte %zu bit %zu (0x%02x -> 0x%02x) " - "produced a successful decompression!\n", - pos, bit, old_val, new_val); - } - } - stuff->perturbed[pos] = old_val; - } - return 1; -} - -static int perturb_bytes(stuff_t* stuff) { - size_t pos; - size_t new_val; - for (pos = 0; pos < stuff->input_size; pos++) { - unsigned char old_val = stuff->input[pos]; - if (pos % 1000 == 0) { - fprintf(stderr, "Perturbing byte %zu / %zu\n", pos, stuff->input_size); - } - for (new_val = 0; new_val < 256; new_val++) { - stuff->perturbed[pos] = new_val; - if (test_decompress(stuff)) { - fprintf( - stderr, - "Changing byte %zu (0x%02x -> 0x%02x) " - "produced a successful decompression!\n", - pos, old_val, (unsigned char)new_val); - } - } - stuff->perturbed[pos] = old_val; - } - return 1; -} - -int main(int argc, char* argv[]) { - stuff_t stuff; - - if(!init_stuff(&stuff, argc, argv)) { - fprintf(stderr, "Failed to init.\n"); - return 1; - } - - if (test_decompress(&stuff)) { - fprintf(stderr, "Blob already decompresses successfully!\n"); - return 1; - } - - perturb_bits(&stuff); - - perturb_bytes(&stuff); - - print_summary(&stuff); - - free_stuff(&stuff); - - return 0; -} diff --git a/third_party/zstd/contrib/docker/Dockerfile b/third_party/zstd/contrib/docker/Dockerfile deleted file mode 100644 index 912bf1949..000000000 --- a/third_party/zstd/contrib/docker/Dockerfile +++ /dev/null @@ -1,20 +0,0 @@ -# Dockerfile -# First image to build the binary -FROM alpine@sha256:69665d02cb32192e52e07644d76bc6f25abeb5410edc1c7a81a10ba3f0efb90a as builder - -RUN apk --no-cache add make gcc libc-dev -COPY . /src -RUN mkdir /pkg && cd /src && make && make DESTDIR=/pkg install - -# Second minimal image to only keep the built binary -FROM alpine@sha256:69665d02cb32192e52e07644d76bc6f25abeb5410edc1c7a81a10ba3f0efb90a - -# Copy the built files -COPY --from=builder /pkg / - -# Copy the license as well -RUN mkdir -p /usr/local/share/licenses/zstd -COPY --from=builder /src/LICENSE /usr/local/share/licences/zstd/ - -# Just run `zstd` if no other command is given -CMD ["/usr/local/bin/zstd"] diff --git a/third_party/zstd/contrib/docker/README.md b/third_party/zstd/contrib/docker/README.md deleted file mode 100644 index 43f6d7a1a..000000000 --- a/third_party/zstd/contrib/docker/README.md +++ /dev/null @@ -1,20 +0,0 @@ - -## Requirement - -The `Dockerfile` script requires a version of `docker` >= 17.05 - -## Installing docker - -The official docker install docs use a ppa with a modern version available: -https://docs.docker.com/install/linux/docker-ce/ubuntu/ - -## How to run - -`docker build -t zstd .` - -## test - -``` -echo foo | docker run -i --rm zstd | docker run -i --rm zstd zstdcat -foo -``` diff --git a/third_party/zstd/contrib/externalSequenceProducer/.gitignore b/third_party/zstd/contrib/externalSequenceProducer/.gitignore deleted file mode 100644 index 147710aee..000000000 --- a/third_party/zstd/contrib/externalSequenceProducer/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# build artifacts -externalSequenceProducer diff --git a/third_party/zstd/contrib/externalSequenceProducer/Makefile b/third_party/zstd/contrib/externalSequenceProducer/Makefile deleted file mode 100644 index 0591ae01b..000000000 --- a/third_party/zstd/contrib/externalSequenceProducer/Makefile +++ /dev/null @@ -1,40 +0,0 @@ -# ################################################################ -# Copyright (c) Yann Collet, Meta Platforms, Inc. -# All rights reserved. -# -# This source code is licensed under both the BSD-style license (found in the -# LICENSE file in the root directory of this source tree) and the GPLv2 (found -# in the COPYING file in the root directory of this source tree). -# ################################################################ - -PROGDIR = ../../programs -LIBDIR = ../../lib - -LIBZSTD = $(LIBDIR)/libzstd.a - -CPPFLAGS+= -I$(LIBDIR) -I$(LIBDIR)/compress -I$(LIBDIR)/common - -CFLAGS ?= -O3 -CFLAGS += -std=gnu99 -DEBUGFLAGS= -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow \ - -Wstrict-aliasing=1 -Wswitch-enum \ - -Wstrict-prototypes -Wundef -Wpointer-arith \ - -Wvla -Wformat=2 -Winit-self -Wfloat-equal -Wwrite-strings \ - -Wredundant-decls -CFLAGS += $(DEBUGFLAGS) $(MOREFLAGS) - -default: externalSequenceProducer - -all: externalSequenceProducer - -externalSequenceProducer: sequence_producer.c main.c $(LIBZSTD) - $(CC) $(CPPFLAGS) $(CFLAGS) $^ $(LDFLAGS) -o $@ - -.PHONY: $(LIBZSTD) -$(LIBZSTD): - $(MAKE) -C $(LIBDIR) libzstd.a CFLAGS="$(CFLAGS)" - -clean: - $(RM) *.o - $(MAKE) -C $(LIBDIR) clean > /dev/null - $(RM) externalSequenceProducer diff --git a/third_party/zstd/contrib/externalSequenceProducer/README.md b/third_party/zstd/contrib/externalSequenceProducer/README.md deleted file mode 100644 index c16a17007..000000000 --- a/third_party/zstd/contrib/externalSequenceProducer/README.md +++ /dev/null @@ -1,14 +0,0 @@ -externalSequenceProducer -===================== - -`externalSequenceProducer` is a test tool for the Block-Level Sequence Producer API. -It demonstrates how to use the API to perform a simple round-trip test. - -A sample sequence producer is provided in sequence_producer.c, but the user can swap -this out with a different one if desired. The sample sequence producer implements -LZ parsing with a 1KB hashtable. Dictionary-based parsing is not currently supported. - -Command line : -``` -externalSequenceProducer filename -``` diff --git a/third_party/zstd/contrib/externalSequenceProducer/main.c b/third_party/zstd/contrib/externalSequenceProducer/main.c deleted file mode 100644 index e67e29538..000000000 --- a/third_party/zstd/contrib/externalSequenceProducer/main.c +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (c) Yann Collet, Meta Platforms, Inc. - * All rights reserved. - * - * This source code is licensed under both the BSD-style license (found in the - * LICENSE file in the root directory of this source tree) and the GPLv2 (found - * in the COPYING file in the root directory of this source tree). - * You may select, at your option, one of the above-listed licenses. - */ - -#include -#include -#include -#include - -#define ZSTD_STATIC_LINKING_ONLY -#include "zstd.h" -#include "zstd_errors.h" -#include "sequence_producer.h" // simpleSequenceProducer - -#define CHECK(res) \ -do { \ - if (ZSTD_isError(res)) { \ - printf("ERROR: %s\n", ZSTD_getErrorName(res)); \ - return 1; \ - } \ -} while (0) \ - -int main(int argc, char *argv[]) { - if (argc != 2) { - printf("Usage: externalSequenceProducer \n"); - return 1; - } - - ZSTD_CCtx* const zc = ZSTD_createCCtx(); - - int simpleSequenceProducerState = 0xdeadbeef; - - // Here is the crucial bit of code! - ZSTD_registerSequenceProducer( - zc, - &simpleSequenceProducerState, - simpleSequenceProducer - ); - - { - size_t const res = ZSTD_CCtx_setParameter(zc, ZSTD_c_enableSeqProducerFallback, 1); - CHECK(res); - } - - FILE *f = fopen(argv[1], "rb"); - assert(f); - { - int const ret = fseek(f, 0, SEEK_END); - assert(ret == 0); - } - size_t const srcSize = ftell(f); - { - int const ret = fseek(f, 0, SEEK_SET); - assert(ret == 0); - } - - char* const src = malloc(srcSize + 1); - assert(src); - { - size_t const ret = fread(src, srcSize, 1, f); - assert(ret == 1); - int const ret2 = fclose(f); - assert(ret2 == 0); - } - - size_t const dstSize = ZSTD_compressBound(srcSize); - char* const dst = malloc(dstSize); - assert(dst); - - size_t const cSize = ZSTD_compress2(zc, dst, dstSize, src, srcSize); - CHECK(cSize); - - char* const val = malloc(srcSize); - assert(val); - - { - size_t const res = ZSTD_decompress(val, srcSize, dst, cSize); - CHECK(res); - } - - if (memcmp(src, val, srcSize) == 0) { - printf("Compression and decompression were successful!\n"); - printf("Original size: %lu\n", srcSize); - printf("Compressed size: %lu\n", cSize); - } else { - printf("ERROR: input and validation buffers don't match!\n"); - for (size_t i = 0; i < srcSize; i++) { - if (src[i] != val[i]) { - printf("First bad index: %zu\n", i); - break; - } - } - return 1; - } - - ZSTD_freeCCtx(zc); - free(src); - free(dst); - free(val); - return 0; -} diff --git a/third_party/zstd/contrib/externalSequenceProducer/sequence_producer.c b/third_party/zstd/contrib/externalSequenceProducer/sequence_producer.c deleted file mode 100644 index 60a2f9572..000000000 --- a/third_party/zstd/contrib/externalSequenceProducer/sequence_producer.c +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (c) Yann Collet, Meta Platforms, Inc. - * All rights reserved. - * - * This source code is licensed under both the BSD-style license (found in the - * LICENSE file in the root directory of this source tree) and the GPLv2 (found - * in the COPYING file in the root directory of this source tree). - * You may select, at your option, one of the above-listed licenses. - */ - -#include "zstd_compress_internal.h" -#include "sequence_producer.h" - -#define HSIZE 1024 -static U32 const HLOG = 10; -static U32 const MLS = 4; -static U32 const BADIDX = 0xffffffff; - -size_t simpleSequenceProducer( - void* sequenceProducerState, - ZSTD_Sequence* outSeqs, size_t outSeqsCapacity, - const void* src, size_t srcSize, - const void* dict, size_t dictSize, - int compressionLevel, - size_t windowSize -) { - const BYTE* const istart = (const BYTE*)src; - const BYTE* const iend = istart + srcSize; - const BYTE* ip = istart; - const BYTE* anchor = istart; - size_t seqCount = 0; - U32 hashTable[HSIZE]; - - (void)sequenceProducerState; - (void)dict; - (void)dictSize; - (void)outSeqsCapacity; - (void)compressionLevel; - - { int i; - for (i=0; i < HSIZE; i++) { - hashTable[i] = BADIDX; - } } - - while (ip + MLS < iend) { - size_t const hash = ZSTD_hashPtr(ip, HLOG, MLS); - U32 const matchIndex = hashTable[hash]; - hashTable[hash] = (U32)(ip - istart); - - if (matchIndex != BADIDX) { - const BYTE* const match = istart + matchIndex; - U32 const matchLen = (U32)ZSTD_count(ip, match, iend); - if (matchLen >= ZSTD_MINMATCH_MIN) { - U32 const litLen = (U32)(ip - anchor); - U32 const offset = (U32)(ip - match); - ZSTD_Sequence const seq = { - offset, litLen, matchLen, 0 - }; - - /* Note: it's crucial to stay within the window size! */ - if (offset <= windowSize) { - outSeqs[seqCount++] = seq; - ip += matchLen; - anchor = ip; - continue; - } - } - } - - ip++; - } - - { ZSTD_Sequence const finalSeq = { - 0, (U32)(iend - anchor), 0, 0 - }; - outSeqs[seqCount++] = finalSeq; - } - - return seqCount; -} diff --git a/third_party/zstd/contrib/externalSequenceProducer/sequence_producer.h b/third_party/zstd/contrib/externalSequenceProducer/sequence_producer.h deleted file mode 100644 index 19f9982ac..000000000 --- a/third_party/zstd/contrib/externalSequenceProducer/sequence_producer.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) Yann Collet, Meta Platforms, Inc. - * All rights reserved. - * - * This source code is licensed under both the BSD-style license (found in the - * LICENSE file in the root directory of this source tree) and the GPLv2 (found - * in the COPYING file in the root directory of this source tree). - * You may select, at your option, one of the above-listed licenses. - */ - -#ifndef MATCHFINDER_H -#define MATCHFINDER_H - -#define ZSTD_STATIC_LINKING_ONLY -#include "zstd.h" - -size_t simpleSequenceProducer( - void* sequenceProducerState, - ZSTD_Sequence* outSeqs, size_t outSeqsCapacity, - const void* src, size_t srcSize, - const void* dict, size_t dictSize, - int compressionLevel, - size_t windowSize -); - -#endif diff --git a/third_party/zstd/contrib/freestanding_lib/freestanding.py b/third_party/zstd/contrib/freestanding_lib/freestanding.py deleted file mode 100755 index df6983245..000000000 --- a/third_party/zstd/contrib/freestanding_lib/freestanding.py +++ /dev/null @@ -1,774 +0,0 @@ -#!/usr/bin/env python3 -# ################################################################ -# Copyright (c) Meta Platforms, Inc. and affiliates. -# All rights reserved. -# -# This source code is licensed under both the BSD-style license (found in the -# LICENSE file in the root directory of this source tree) and the GPLv2 (found -# in the COPYING file in the root directory of this source tree). -# You may select, at your option, one of the above-listed licenses. -# ########################################################################## - -import argparse -import contextlib -import os -import re -import shutil -import sys -from typing import Optional - - -INCLUDED_SUBDIRS = ["common", "compress", "decompress"] - -SKIPPED_FILES = [ - "common/mem.h", - "common/zstd_deps.h", - "common/pool.c", - "common/pool.h", - "common/threading.c", - "common/threading.h", - "common/zstd_trace.h", - "compress/zstdmt_compress.h", - "compress/zstdmt_compress.c", -] - -XXHASH_FILES = [ - "common/xxhash.c", - "common/xxhash.h", -] - - -class FileLines(object): - def __init__(self, filename): - self.filename = filename - with open(self.filename, "r") as f: - self.lines = f.readlines() - - def write(self): - with open(self.filename, "w") as f: - f.write("".join(self.lines)) - - -class PartialPreprocessor(object): - """ - Looks for simple ifdefs and ifndefs and replaces them. - Handles && and ||. - Has fancy logic to handle translating elifs to ifs. - Only looks for macros in the first part of the expression with no - parens. - Does not handle multi-line macros (only looks in first line). - """ - def __init__(self, defs: [(str, Optional[str])], replaces: [(str, str)], undefs: [str]): - MACRO_GROUP = r"(?P[a-zA-Z_][a-zA-Z_0-9]*)" - ELIF_GROUP = r"(?Pel)?" - OP_GROUP = r"(?P&&|\|\|)?" - - self._defs = {macro:value for macro, value in defs} - self._replaces = {macro:value for macro, value in replaces} - self._defs.update(self._replaces) - self._undefs = set(undefs) - - self._define = re.compile(r"\s*#\s*define") - self._if = re.compile(r"\s*#\s*if") - self._elif = re.compile(r"\s*#\s*(?Pel)if") - self._else = re.compile(r"\s*#\s*(?Pelse)") - self._endif = re.compile(r"\s*#\s*endif") - - self._ifdef = re.compile(fr"\s*#\s*if(?Pn)?def {MACRO_GROUP}\s*") - self._if_defined = re.compile( - fr"\s*#\s*{ELIF_GROUP}if\s+(?P!)?\s*defined\s*\(\s*{MACRO_GROUP}\s*\)\s*{OP_GROUP}" - ) - self._if_defined_value = re.compile( - fr"\s*#\s*{ELIF_GROUP}if\s+defined\s*\(\s*{MACRO_GROUP}\s*\)\s*" - fr"(?P&&)\s*" - fr"(?P\()?\s*" - fr"(?P[a-zA-Z_][a-zA-Z_0-9]*)\s*" - fr"(?P[=>[0-9]*)\s*" - fr"(?P\))?\s*" - ) - self._if_true = re.compile( - fr"\s*#\s*{ELIF_GROUP}if\s+{MACRO_GROUP}\s*{OP_GROUP}" - ) - - self._c_comment = re.compile(r"/\*.*?\*/") - self._cpp_comment = re.compile(r"//") - - def _log(self, *args, **kwargs): - print(*args, **kwargs) - - def _strip_comments(self, line): - # First strip c-style comments (may include //) - while True: - m = self._c_comment.search(line) - if m is None: - break - line = line[:m.start()] + line[m.end():] - - # Then strip cpp-style comments - m = self._cpp_comment.search(line) - if m is not None: - line = line[:m.start()] - - return line - - def _fixup_indentation(self, macro, replace: [str]): - if len(replace) == 0: - return replace - if len(replace) == 1 and self._define.match(replace[0]) is None: - # If there is only one line, only replace defines - return replace - - - all_pound = True - for line in replace: - if not line.startswith('#'): - all_pound = False - if all_pound: - replace = [line[1:] for line in replace] - - min_spaces = len(replace[0]) - for line in replace: - spaces = 0 - for i, c in enumerate(line): - if c != ' ': - # Non-preprocessor line ==> skip the fixup - if not all_pound and c != '#': - return replace - spaces = i - break - min_spaces = min(min_spaces, spaces) - - replace = [line[min_spaces:] for line in replace] - - if all_pound: - replace = ["#" + line for line in replace] - - return replace - - def _handle_if_block(self, macro, idx, is_true, prepend): - """ - Remove the #if or #elif block starting on this line. - """ - REMOVE_ONE = 0 - KEEP_ONE = 1 - REMOVE_REST = 2 - - if is_true: - state = KEEP_ONE - else: - state = REMOVE_ONE - - line = self._inlines[idx] - is_if = self._if.match(line) is not None - assert is_if or self._elif.match(line) is not None - depth = 0 - - start_idx = idx - - idx += 1 - replace = prepend - finished = False - while idx < len(self._inlines): - line = self._inlines[idx] - # Nested if statement - if self._if.match(line): - depth += 1 - idx += 1 - continue - # We're inside a nested statement - if depth > 0: - if self._endif.match(line): - depth -= 1 - idx += 1 - continue - - # We're at the original depth - - # Looking only for an endif. - # We've found a true statement, but haven't - # completely elided the if block, so we just - # remove the remainder. - if state == REMOVE_REST: - if self._endif.match(line): - if is_if: - # Remove the endif because we took the first if - idx += 1 - finished = True - break - idx += 1 - continue - - if state == KEEP_ONE: - m = self._elif.match(line) - if self._endif.match(line): - replace += self._inlines[start_idx + 1:idx] - idx += 1 - finished = True - break - if self._elif.match(line) or self._else.match(line): - replace += self._inlines[start_idx + 1:idx] - state = REMOVE_REST - idx += 1 - continue - - if state == REMOVE_ONE: - m = self._elif.match(line) - if m is not None: - if is_if: - idx += 1 - b = m.start('elif') - e = m.end('elif') - assert e - b == 2 - replace.append(line[:b] + line[e:]) - finished = True - break - m = self._else.match(line) - if m is not None: - if is_if: - idx += 1 - while self._endif.match(self._inlines[idx]) is None: - replace.append(self._inlines[idx]) - idx += 1 - idx += 1 - finished = True - break - if self._endif.match(line): - if is_if: - # Remove the endif because no other elifs - idx += 1 - finished = True - break - idx += 1 - continue - if not finished: - raise RuntimeError("Unterminated if block!") - - replace = self._fixup_indentation(macro, replace) - - self._log(f"\tHardwiring {macro}") - if start_idx > 0: - self._log(f"\t\t {self._inlines[start_idx - 1][:-1]}") - for x in range(start_idx, idx): - self._log(f"\t\t- {self._inlines[x][:-1]}") - for line in replace: - self._log(f"\t\t+ {line[:-1]}") - if idx < len(self._inlines): - self._log(f"\t\t {self._inlines[idx][:-1]}") - - return idx, replace - - def _preprocess_once(self): - outlines = [] - idx = 0 - changed = False - while idx < len(self._inlines): - line = self._inlines[idx] - sline = self._strip_comments(line) - m = self._ifdef.fullmatch(sline) - if_true = False - if m is None: - m = self._if_defined_value.fullmatch(sline) - if m is None: - m = self._if_defined.match(sline) - if m is None: - m = self._if_true.match(sline) - if_true = (m is not None) - if m is None: - outlines.append(line) - idx += 1 - continue - - groups = m.groupdict() - macro = groups['macro'] - op = groups.get('op') - - if not (macro in self._defs or macro in self._undefs): - outlines.append(line) - idx += 1 - continue - - defined = macro in self._defs - - # Needed variables set: - # resolved: Is the statement fully resolved? - # is_true: If resolved, is the statement true? - ifdef = False - if if_true: - if not defined: - outlines.append(line) - idx += 1 - continue - - defined_value = self._defs[macro] - is_int = True - try: - defined_value = int(defined_value) - except TypeError: - is_int = False - except ValueError: - is_int = False - - resolved = is_int - is_true = (defined_value != 0) - - if resolved and op is not None: - if op == '&&': - resolved = not is_true - else: - assert op == '||' - resolved = is_true - - else: - ifdef = groups.get('not') is None - elseif = groups.get('elif') is not None - - macro2 = groups.get('macro2') - cmp = groups.get('cmp') - value = groups.get('value') - openp = groups.get('openp') - closep = groups.get('closep') - - is_true = (ifdef == defined) - resolved = True - if op is not None: - if op == '&&': - resolved = not is_true - else: - assert op == '||' - resolved = is_true - - if macro2 is not None and not resolved: - assert ifdef and defined and op == '&&' and cmp is not None - # If the statement is true, but we have a single value check, then - # check the value. - defined_value = self._defs[macro] - are_ints = True - try: - defined_value = int(defined_value) - value = int(value) - except TypeError: - are_ints = False - except ValueError: - are_ints = False - if ( - macro == macro2 and - ((openp is None) == (closep is None)) and - are_ints - ): - resolved = True - if cmp == '<': - is_true = defined_value < value - elif cmp == '<=': - is_true = defined_value <= value - elif cmp == '==': - is_true = defined_value == value - elif cmp == '!=': - is_true = defined_value != value - elif cmp == '>=': - is_true = defined_value >= value - elif cmp == '>': - is_true = defined_value > value - else: - resolved = False - - if op is not None and not resolved: - # Remove the first op in the line + spaces - if op == '&&': - opre = op - else: - assert op == '||' - opre = r'\|\|' - needle = re.compile(fr"(?P\s*#\s*(el)?if\s+).*?(?P{opre}\s*)") - match = needle.match(line) - assert match is not None - newline = line[:match.end('if')] + line[match.end('op'):] - - self._log(f"\tHardwiring partially resolved {macro}") - self._log(f"\t\t- {line[:-1]}") - self._log(f"\t\t+ {newline[:-1]}") - - outlines.append(newline) - idx += 1 - continue - - # Skip any statements we cannot fully compute - if not resolved: - outlines.append(line) - idx += 1 - continue - - prepend = [] - if macro in self._replaces: - assert not ifdef - assert op is None - value = self._replaces.pop(macro) - prepend = [f"#define {macro} {value}\n"] - - idx, replace = self._handle_if_block(macro, idx, is_true, prepend) - outlines += replace - changed = True - - return changed, outlines - - def preprocess(self, filename): - with open(filename, 'r') as f: - self._inlines = f.readlines() - changed = True - iters = 0 - while changed: - iters += 1 - changed, outlines = self._preprocess_once() - self._inlines = outlines - - with open(filename, 'w') as f: - f.write(''.join(self._inlines)) - - -class Freestanding(object): - def __init__( - self, zstd_deps: str, mem: str, source_lib: str, output_lib: str, - external_xxhash: bool, xxh64_state: Optional[str], - xxh64_prefix: Optional[str], rewritten_includes: [(str, str)], - defs: [(str, Optional[str])], replaces: [(str, str)], - undefs: [str], excludes: [str], seds: [str], spdx: bool, - ): - self._zstd_deps = zstd_deps - self._mem = mem - self._src_lib = source_lib - self._dst_lib = output_lib - self._external_xxhash = external_xxhash - self._xxh64_state = xxh64_state - self._xxh64_prefix = xxh64_prefix - self._rewritten_includes = rewritten_includes - self._defs = defs - self._replaces = replaces - self._undefs = undefs - self._excludes = excludes - self._seds = seds - self._spdx = spdx - - def _dst_lib_file_paths(self): - """ - Yields all the file paths in the dst_lib. - """ - for root, dirname, filenames in os.walk(self._dst_lib): - for filename in filenames: - filepath = os.path.join(root, filename) - yield filepath - - def _log(self, *args, **kwargs): - print(*args, **kwargs) - - def _copy_file(self, lib_path): - suffixes = [".c", ".h", ".S"] - if not any((lib_path.endswith(suffix) for suffix in suffixes)): - return - if lib_path in SKIPPED_FILES: - self._log(f"\tSkipping file: {lib_path}") - return - if self._external_xxhash and lib_path in XXHASH_FILES: - self._log(f"\tSkipping xxhash file: {lib_path}") - return - - src_path = os.path.join(self._src_lib, lib_path) - dst_path = os.path.join(self._dst_lib, lib_path) - self._log(f"\tCopying: {src_path} -> {dst_path}") - shutil.copyfile(src_path, dst_path) - - def _copy_source_lib(self): - self._log("Copying source library into output library") - - assert os.path.exists(self._src_lib) - os.makedirs(self._dst_lib, exist_ok=True) - self._copy_file("zstd.h") - self._copy_file("zstd_errors.h") - for subdir in INCLUDED_SUBDIRS: - src_dir = os.path.join(self._src_lib, subdir) - dst_dir = os.path.join(self._dst_lib, subdir) - - assert os.path.exists(src_dir) - os.makedirs(dst_dir, exist_ok=True) - - for filename in os.listdir(src_dir): - lib_path = os.path.join(subdir, filename) - self._copy_file(lib_path) - - def _copy_zstd_deps(self): - dst_zstd_deps = os.path.join(self._dst_lib, "common", "zstd_deps.h") - self._log(f"Copying zstd_deps: {self._zstd_deps} -> {dst_zstd_deps}") - shutil.copyfile(self._zstd_deps, dst_zstd_deps) - - def _copy_mem(self): - dst_mem = os.path.join(self._dst_lib, "common", "mem.h") - self._log(f"Copying mem: {self._mem} -> {dst_mem}") - shutil.copyfile(self._mem, dst_mem) - - def _hardwire_preprocessor(self, name: str, value: Optional[str] = None, undef=False): - """ - If value=None then hardwire that it is defined, but not what the value is. - If undef=True then value must be None. - If value='' then the macro is defined to '' exactly. - """ - assert not (undef and value is not None) - for filepath in self._dst_lib_file_paths(): - file = FileLines(filepath) - - def _hardwire_defines(self): - self._log("Hardwiring macros") - partial_preprocessor = PartialPreprocessor(self._defs, self._replaces, self._undefs) - for filepath in self._dst_lib_file_paths(): - partial_preprocessor.preprocess(filepath) - - def _remove_excludes(self): - self._log("Removing excluded sections") - for exclude in self._excludes: - self._log(f"\tRemoving excluded sections for: {exclude}") - begin_re = re.compile(f"BEGIN {exclude}") - end_re = re.compile(f"END {exclude}") - for filepath in self._dst_lib_file_paths(): - file = FileLines(filepath) - outlines = [] - skipped = [] - emit = True - for line in file.lines: - if emit and begin_re.search(line) is not None: - assert end_re.search(line) is None - emit = False - if emit: - outlines.append(line) - else: - skipped.append(line) - if end_re.search(line) is not None: - assert begin_re.search(line) is None - self._log(f"\t\tRemoving excluded section: {exclude}") - for s in skipped: - self._log(f"\t\t\t- {s}") - emit = True - skipped = [] - if not emit: - raise RuntimeError("Excluded section unfinished!") - file.lines = outlines - file.write() - - def _rewrite_include(self, original, rewritten): - self._log(f"\tRewriting include: {original} -> {rewritten}") - regex = re.compile(f"\\s*#\\s*include\\s*(?P{original})") - for filepath in self._dst_lib_file_paths(): - file = FileLines(filepath) - for i, line in enumerate(file.lines): - match = regex.match(line) - if match is None: - continue - s = match.start('include') - e = match.end('include') - file.lines[i] = line[:s] + rewritten + line[e:] - file.write() - - def _rewrite_includes(self): - self._log("Rewriting includes") - for original, rewritten in self._rewritten_includes: - self._rewrite_include(original, rewritten) - - def _replace_xxh64_prefix(self): - if self._xxh64_prefix is None: - return - self._log(f"Replacing XXH64 prefix with {self._xxh64_prefix}") - replacements = [] - if self._xxh64_state is not None: - replacements.append( - (re.compile(r"([^\w]|^)(?PXXH64_state_t)([^\w]|$)"), self._xxh64_state) - ) - if self._xxh64_prefix is not None: - replacements.append( - (re.compile(r"([^\w]|^)(?PXXH64)[\(_]"), self._xxh64_prefix) - ) - for filepath in self._dst_lib_file_paths(): - file = FileLines(filepath) - for i, line in enumerate(file.lines): - modified = False - for regex, replacement in replacements: - match = regex.search(line) - while match is not None: - modified = True - b = match.start('orig') - e = match.end('orig') - line = line[:b] + replacement + line[e:] - match = regex.search(line) - if modified: - self._log(f"\t- {file.lines[i][:-1]}") - self._log(f"\t+ {line[:-1]}") - file.lines[i] = line - file.write() - - def _parse_sed(self, sed): - assert sed[0] == 's' - delim = sed[1] - match = re.fullmatch(f's{delim}(.+){delim}(.*){delim}(.*)', sed) - assert match is not None - regex = re.compile(match.group(1)) - format_str = match.group(2) - is_global = match.group(3) == 'g' - return regex, format_str, is_global - - def _process_sed(self, sed): - self._log(f"Processing sed: {sed}") - regex, format_str, is_global = self._parse_sed(sed) - - for filepath in self._dst_lib_file_paths(): - file = FileLines(filepath) - for i, line in enumerate(file.lines): - modified = False - while True: - match = regex.search(line) - if match is None: - break - replacement = format_str.format(match.groups(''), match.groupdict('')) - b = match.start() - e = match.end() - line = line[:b] + replacement + line[e:] - modified = True - if not is_global: - break - if modified: - self._log(f"\t- {file.lines[i][:-1]}") - self._log(f"\t+ {line[:-1]}") - file.lines[i] = line - file.write() - - def _process_seds(self): - self._log("Processing seds") - for sed in self._seds: - self._process_sed(sed) - - def _process_spdx(self): - if not self._spdx: - return - self._log("Processing spdx") - SPDX_C = "// SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause\n" - SPDX_H_S = "/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */\n" - for filepath in self._dst_lib_file_paths(): - file = FileLines(filepath) - if file.lines[0] == SPDX_C or file.lines[0] == SPDX_H_S: - continue - for line in file.lines: - if "SPDX-License-Identifier" in line: - raise RuntimeError(f"Unexpected SPDX license identifier: {file.filename} {repr(line)}") - if file.filename.endswith(".c"): - file.lines.insert(0, SPDX_C) - elif file.filename.endswith(".h") or file.filename.endswith(".S"): - file.lines.insert(0, SPDX_H_S) - else: - raise RuntimeError(f"Unexpected file extension: {file.filename}") - file.write() - - - - def go(self): - self._copy_source_lib() - self._copy_zstd_deps() - self._copy_mem() - self._hardwire_defines() - self._remove_excludes() - self._rewrite_includes() - self._replace_xxh64_prefix() - self._process_seds() - self._process_spdx() - - -def parse_optional_pair(defines: [str]) -> [(str, Optional[str])]: - output = [] - for define in defines: - parsed = define.split('=') - if len(parsed) == 1: - output.append((parsed[0], None)) - elif len(parsed) == 2: - output.append((parsed[0], parsed[1])) - else: - raise RuntimeError(f"Bad define: {define}") - return output - - -def parse_pair(rewritten_includes: [str]) -> [(str, str)]: - output = [] - for rewritten_include in rewritten_includes: - parsed = rewritten_include.split('=') - if len(parsed) == 2: - output.append((parsed[0], parsed[1])) - else: - raise RuntimeError(f"Bad rewritten include: {rewritten_include}") - return output - - - -def main(name, args): - parser = argparse.ArgumentParser(prog=name) - parser.add_argument("--zstd-deps", default="zstd_deps.h", help="Zstd dependencies file") - parser.add_argument("--mem", default="mem.h", help="Memory module") - parser.add_argument("--source-lib", default="../../lib", help="Location of the zstd library") - parser.add_argument("--output-lib", default="./freestanding_lib", help="Where to output the freestanding zstd library") - parser.add_argument("--xxhash", default=None, help="Alternate external xxhash include e.g. --xxhash=''. If set xxhash is not included.") - parser.add_argument("--xxh64-state", default=None, help="Alternate XXH64 state type (excluding _) e.g. --xxh64-state='struct xxh64_state'") - parser.add_argument("--xxh64-prefix", default=None, help="Alternate XXH64 function prefix (excluding _) e.g. --xxh64-prefix=xxh64") - parser.add_argument("--rewrite-include", default=[], dest="rewritten_includes", action="append", help="Rewrite an include REGEX=NEW (e.g. '=')") - parser.add_argument("--sed", default=[], dest="seds", action="append", help="Apply a sed replacement. Format: `s/REGEX/FORMAT/[g]`. REGEX is a Python regex. FORMAT is a Python format string formatted by the regex dict.") - parser.add_argument("--spdx", action="store_true", help="Add SPDX License Identifiers") - parser.add_argument("-D", "--define", default=[], dest="defs", action="append", help="Pre-define this macro (can be passed multiple times)") - parser.add_argument("-U", "--undefine", default=[], dest="undefs", action="append", help="Pre-undefine this macro (can be passed multiple times)") - parser.add_argument("-R", "--replace", default=[], dest="replaces", action="append", help="Pre-define this macro and replace the first ifndef block with its definition") - parser.add_argument("-E", "--exclude", default=[], dest="excludes", action="append", help="Exclude all lines between 'BEGIN ' and 'END '") - args = parser.parse_args(args) - - # Always remove threading - if "ZSTD_MULTITHREAD" not in args.undefs: - args.undefs.append("ZSTD_MULTITHREAD") - - args.defs = parse_optional_pair(args.defs) - for name, _ in args.defs: - if name in args.undefs: - raise RuntimeError(f"{name} is both defined and undefined!") - - # Always set tracing to 0 - if "ZSTD_NO_TRACE" not in (arg[0] for arg in args.defs): - args.defs.append(("ZSTD_NO_TRACE", None)) - args.defs.append(("ZSTD_TRACE", "0")) - - args.replaces = parse_pair(args.replaces) - for name, _ in args.replaces: - if name in args.undefs or name in args.defs: - raise RuntimeError(f"{name} is both replaced and (un)defined!") - - args.rewritten_includes = parse_pair(args.rewritten_includes) - - external_xxhash = False - if args.xxhash is not None: - external_xxhash = True - args.rewritten_includes.append(('"(\\.\\./common/)?xxhash.h"', args.xxhash)) - - if args.xxh64_prefix is not None: - if not external_xxhash: - raise RuntimeError("--xxh64-prefix may only be used with --xxhash provided") - - if args.xxh64_state is not None: - if not external_xxhash: - raise RuntimeError("--xxh64-state may only be used with --xxhash provided") - - Freestanding( - args.zstd_deps, - args.mem, - args.source_lib, - args.output_lib, - external_xxhash, - args.xxh64_state, - args.xxh64_prefix, - args.rewritten_includes, - args.defs, - args.replaces, - args.undefs, - args.excludes, - args.seds, - args.spdx, - ).go() - -if __name__ == "__main__": - main(sys.argv[0], sys.argv[1:]) diff --git a/third_party/zstd/contrib/gen_html/.gitignore b/third_party/zstd/contrib/gen_html/.gitignore deleted file mode 100644 index 344611428..000000000 --- a/third_party/zstd/contrib/gen_html/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -# make artefact -gen_html -zstd_manual.html diff --git a/third_party/zstd/contrib/gen_html/Makefile b/third_party/zstd/contrib/gen_html/Makefile deleted file mode 100644 index 26e870399..000000000 --- a/third_party/zstd/contrib/gen_html/Makefile +++ /dev/null @@ -1,51 +0,0 @@ -# ################################################################ -# Copyright (c) Meta Platforms, Inc. and affiliates. -# All rights reserved. -# -# This source code is licensed under both the BSD-style license (found in the -# LICENSE file in the root directory of this source tree) and the GPLv2 (found -# in the COPYING file in the root directory of this source tree). -# ################################################################ - -CXXFLAGS ?= -O3 -CXXFLAGS += -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow -Wstrict-aliasing=1 -Wswitch-enum -Wno-comment -CXXFLAGS += $(MOREFLAGS) -FLAGS = $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) - -ZSTDAPI = ../../lib/zstd.h -ZSTDMANUAL = ../../doc/zstd_manual.html -LIBVER_MAJOR_SCRIPT:=`sed -n '/define ZSTD_VERSION_MAJOR/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < $(ZSTDAPI)` -LIBVER_MINOR_SCRIPT:=`sed -n '/define ZSTD_VERSION_MINOR/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < $(ZSTDAPI)` -LIBVER_PATCH_SCRIPT:=`sed -n '/define ZSTD_VERSION_RELEASE/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < $(ZSTDAPI)` -LIBVER_SCRIPT:= $(LIBVER_MAJOR_SCRIPT).$(LIBVER_MINOR_SCRIPT).$(LIBVER_PATCH_SCRIPT) -LIBVER := $(shell echo $(LIBVER_SCRIPT)) - - -# Define *.exe as extension for Windows systems -ifneq (,$(filter Windows%,$(OS))) -EXT =.exe -else -EXT = -endif - - -.PHONY: default -default: gen_html - -.PHONY: all -all: manual - -gen_html: gen_html.cpp - $(CXX) $(FLAGS) $^ -o $@$(EXT) - -$(ZSTDMANUAL): gen_html $(ZSTDAPI) - echo "Update zstd manual in /doc" - ./gen_html $(LIBVER) $(ZSTDAPI) $(ZSTDMANUAL) - -.PHONY: manual -manual: gen_html $(ZSTDMANUAL) - -.PHONY: clean -clean: - @$(RM) gen_html$(EXT) - @echo Cleaning completed diff --git a/third_party/zstd/contrib/gen_html/README.md b/third_party/zstd/contrib/gen_html/README.md deleted file mode 100644 index 63a4caa25..000000000 --- a/third_party/zstd/contrib/gen_html/README.md +++ /dev/null @@ -1,31 +0,0 @@ -gen_html - a program for automatic generation of zstd manual -============================================================ - -#### Introduction - -This simple C++ program generates a single-page HTML manual from `zstd.h`. - -The format of recognized comment blocks is following: -- comments of type `/*!` mean: this is a function declaration; switch comments with declarations -- comments of type `/**` and `/*-` mean: this is a comment; use a `

` header for the first line -- comments of type `/*=` and `/**=` mean: use a `

` header and show also all functions until first empty line -- comments of type `/*X` where `X` is different from above-mentioned are ignored - -Moreover: -- `ZSTDLIB_API` is removed to improve readability -- `typedef` are detected and included even if uncommented -- comments of type `/**<` and `/*!<` are detected and only function declaration is highlighted (bold) - - -#### Usage - -The program requires 3 parameters: -``` -gen_html [zstd_version] [input_file] [output_html] -``` - -To compile program and generate zstd manual we have used: -``` -make -./gen_html.exe 1.1.1 ../../lib/zstd.h zstd_manual.html -``` diff --git a/third_party/zstd/contrib/gen_html/gen-zstd-manual.sh b/third_party/zstd/contrib/gen_html/gen-zstd-manual.sh deleted file mode 100755 index 57a8b6ea5..000000000 --- a/third_party/zstd/contrib/gen_html/gen-zstd-manual.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh - -LIBVER_MAJOR_SCRIPT=`sed -n '/define ZSTD_VERSION_MAJOR/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < ../../lib/zstd.h` -LIBVER_MINOR_SCRIPT=`sed -n '/define ZSTD_VERSION_MINOR/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < ../../lib/zstd.h` -LIBVER_PATCH_SCRIPT=`sed -n '/define ZSTD_VERSION_RELEASE/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < ../../lib/zstd.h` -LIBVER_SCRIPT=$LIBVER_MAJOR_SCRIPT.$LIBVER_MINOR_SCRIPT.$LIBVER_PATCH_SCRIPT - -echo ZSTD_VERSION=$LIBVER_SCRIPT -./gen_html $LIBVER_SCRIPT ../../lib/zstd.h ./zstd_manual.html diff --git a/third_party/zstd/contrib/gen_html/gen_html.cpp b/third_party/zstd/contrib/gen_html/gen_html.cpp deleted file mode 100644 index 1da5879ad..000000000 --- a/third_party/zstd/contrib/gen_html/gen_html.cpp +++ /dev/null @@ -1,224 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under both the BSD-style license (found in the - * LICENSE file in the root directory of this source tree) and the GPLv2 (found - * in the COPYING file in the root directory of this source tree). - */ - -#include -#include -#include -#include -using namespace std; - - -/* trim string at the beginning and at the end */ -void trim(string& s, string characters) -{ - size_t p = s.find_first_not_of(characters); - s.erase(0, p); - - p = s.find_last_not_of(characters); - if (string::npos != p) - s.erase(p+1); -} - - -/* trim C++ style comments */ -void trim_comments(string &s) -{ - size_t spos, epos; - - spos = s.find("/*"); - epos = s.find("*/"); - s = s.substr(spos+3, epos-(spos+3)); -} - - -/* get lines until a given terminator */ -vector get_lines(vector& input, int& linenum, string terminator) -{ - vector out; - string line; - size_t epos; - - while ((size_t)linenum < input.size()) { - line = input[linenum]; - - if (terminator.empty() && line.empty()) { linenum--; break; } - - epos = line.find(terminator); - if (!terminator.empty() && epos!=string::npos) { - out.push_back(line); - break; - } - out.push_back(line); - linenum++; - } - return out; -} - - -/* print line with ZSTDLIB_API removed and C++ comments not bold */ -void print_line(stringstream &sout, string line) -{ - size_t spos; - - if (line.substr(0,12) == "ZSTDLIB_API ") line = line.substr(12); - spos = line.find("/*"); - if (spos!=string::npos) { - sout << line.substr(0, spos); - sout << "" << line.substr(spos) << "" << endl; - } else { - // fprintf(stderr, "lines=%s\n", line.c_str()); - sout << line << endl; - } -} - - -int main(int argc, char *argv[]) { - char exclam; - int linenum, chapter = 1; - vector input, lines, comments, chapters; - string line, version; - size_t spos, l; - stringstream sout; - ifstream istream; - ofstream ostream; - - if (argc < 4) { - cout << "usage: " << argv[0] << " [zstd_version] [input_file] [output_html]" << endl; - return 1; - } - - version = "zstd " + string(argv[1]) + " Manual"; - - istream.open(argv[2], ifstream::in); - if (!istream.is_open()) { - cout << "Error opening file " << argv[2] << endl; - return 1; - } - - ostream.open(argv[3], ifstream::out); - if (!ostream.is_open()) { - cout << "Error opening file " << argv[3] << endl; - return 1; - } - - while (getline(istream, line)) { - input.push_back(line); - } - - for (linenum=0; (size_t)linenum < input.size(); linenum++) { - line = input[linenum]; - - /* typedefs are detected and included even if uncommented */ - if (line.substr(0,7) == "typedef" && line.find("{")!=string::npos) { - lines = get_lines(input, linenum, "}"); - sout << "
";
-            for (l=0; l

" << endl; - continue; - } - - /* comments of type /**< and /*!< are detected and only function declaration is highlighted (bold) */ - if ((line.find("/**<")!=string::npos || line.find("/*!<")!=string::npos) && line.find("*/")!=string::npos) { - sout << "
";
-            print_line(sout, line);
-            sout << "

" << endl; - continue; - } - - spos = line.find("/**="); - if (spos==string::npos) { - spos = line.find("/*!"); - if (spos==string::npos) - spos = line.find("/**"); - if (spos==string::npos) - spos = line.find("/*-"); - if (spos==string::npos) - spos = line.find("/*="); - if (spos==string::npos) - continue; - exclam = line[spos+2]; - } - else exclam = '='; - - comments = get_lines(input, linenum, "*/"); - if (!comments.empty()) comments[0] = line.substr(spos+3); - if (!comments.empty()) comments[comments.size()-1] = comments[comments.size()-1].substr(0, comments[comments.size()-1].find("*/")); - for (l=0; l"; - for (l=0; l

"; - for (l=0; l
" << endl << endl; - } else if (exclam == '=') { /* comments of type /*= and /**= mean: use a

header and show also all functions until first empty line */ - trim(comments[0], " "); - sout << "

" << comments[0] << "

";
-            for (l=1; l
";
-            lines = get_lines(input, ++linenum, "");
-            for (l=0; l
" << endl; - } else { /* comments of type /** and /*- mean: this is a comment; use a

header for the first line */ - if (comments.empty()) continue; - - trim(comments[0], " "); - sout << "

" << comments[0] << "

";
-            chapters.push_back(comments[0]);
-            chapter++;
-
-            for (l=1; l 1)
-                sout << "
" << endl << endl; - else - sout << "
" << endl << endl; - } - } - - ostream << "\n\n\n" << version << "\n\n" << endl; - ostream << "

" << version << "

\n"; - - ostream << "
\n

Contents

\n
    \n"; - for (size_t i=0; i" << chapters[i].c_str() << "\n"; - ostream << "
\n
\n"; - - ostream << sout.str(); - ostream << "" << endl << "" << endl; - - return 0; -} diff --git a/third_party/zstd/contrib/largeNbDicts/.gitignore b/third_party/zstd/contrib/largeNbDicts/.gitignore deleted file mode 100644 index e77c4e496..000000000 --- a/third_party/zstd/contrib/largeNbDicts/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# build artifacts -largeNbDicts diff --git a/third_party/zstd/contrib/largeNbDicts/Makefile b/third_party/zstd/contrib/largeNbDicts/Makefile deleted file mode 100644 index 40734e62e..000000000 --- a/third_party/zstd/contrib/largeNbDicts/Makefile +++ /dev/null @@ -1,58 +0,0 @@ -# ################################################################ -# Copyright (c) Meta Platforms, Inc. and affiliates. -# All rights reserved. -# -# This source code is licensed under both the BSD-style license (found in the -# LICENSE file in the root directory of this source tree) and the GPLv2 (found -# in the COPYING file in the root directory of this source tree). -# ################################################################ - -PROGDIR = ../../programs -LIBDIR = ../../lib - -LIBZSTD = $(LIBDIR)/libzstd.a - -CPPFLAGS+= -I$(LIBDIR) -I$(LIBDIR)/common -I$(LIBDIR)/dictBuilder -I$(PROGDIR) - -CFLAGS ?= -O3 -CFLAGS += -std=gnu99 -DEBUGFLAGS= -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow \ - -Wstrict-aliasing=1 -Wswitch-enum \ - -Wstrict-prototypes -Wundef -Wpointer-arith \ - -Wvla -Wformat=2 -Winit-self -Wfloat-equal -Wwrite-strings \ - -Wredundant-decls -CFLAGS += $(DEBUGFLAGS) $(MOREFLAGS) - - -default: largeNbDicts - -all : largeNbDicts - -largeNbDicts: util.o timefn.o benchfn.o datagen.o xxhash.o largeNbDicts.c $(LIBZSTD) - $(CC) $(CPPFLAGS) $(CFLAGS) $^ $(LDFLAGS) -o $@ - -.PHONY: $(LIBZSTD) -$(LIBZSTD): - $(MAKE) -C $(LIBDIR) libzstd.a CFLAGS="$(CFLAGS)" - -benchfn.o: $(PROGDIR)/benchfn.c - $(CC) $(CPPFLAGS) $(CFLAGS) $^ -c - -timefn.o: $(PROGDIR)/timefn.c - $(CC) $(CPPFLAGS) $(CFLAGS) $^ -c - -datagen.o: $(PROGDIR)/datagen.c - $(CC) $(CPPFLAGS) $(CFLAGS) $^ -c - -util.o: $(PROGDIR)/util.c - $(CC) $(CPPFLAGS) $(CFLAGS) $^ -c - - -xxhash.o : $(LIBDIR)/common/xxhash.c - $(CC) $(CPPFLAGS) $(CFLAGS) $^ -c - - -clean: - $(RM) *.o - $(MAKE) -C $(LIBDIR) clean > /dev/null - $(RM) largeNbDicts diff --git a/third_party/zstd/contrib/largeNbDicts/README.md b/third_party/zstd/contrib/largeNbDicts/README.md deleted file mode 100644 index 010102c90..000000000 --- a/third_party/zstd/contrib/largeNbDicts/README.md +++ /dev/null @@ -1,33 +0,0 @@ -largeNbDicts -===================== - -`largeNbDicts` is a benchmark test tool -dedicated to the specific scenario of -dictionary decompression using a very large number of dictionaries. -When dictionaries are constantly changing, they are always "cold", -suffering from increased latency due to cache misses. - -The tool is created in a bid to investigate performance for this scenario, -and experiment mitigation techniques. - -Command line : -``` -largeNbDicts [Options] filename(s) - -Options : --z : benchmark compression (default) --d : benchmark decompression --r : recursively load all files in subdirectories (default: off) --B# : split input into blocks of size # (default: no split) --# : use compression level # (default: 3) --D # : use # as a dictionary (default: create one) --i# : nb benchmark rounds (default: 6) ---nbBlocks=#: use # blocks for bench (default: one per file) ---nbDicts=# : create # dictionaries for bench (default: one per block) --h : help (this text) - -Advanced Options (see zstd.h for documentation) : ---dedicated-dict-search ---dict-content-type=# ---dict-attach-pref=# -``` diff --git a/third_party/zstd/contrib/largeNbDicts/largeNbDicts.c b/third_party/zstd/contrib/largeNbDicts/largeNbDicts.c deleted file mode 100644 index eeaaf7182..000000000 --- a/third_party/zstd/contrib/largeNbDicts/largeNbDicts.c +++ /dev/null @@ -1,1085 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under both the BSD-style license (found in the - * LICENSE file in the root directory of this source tree) and the GPLv2 (found - * in the COPYING file in the root directory of this source tree). - * You may select, at your option, one of the above-listed licenses. - */ - -/* largeNbDicts - * This is a benchmark test tool - * dedicated to the specific case of dictionary decompression - * using a very large nb of dictionaries - * thus suffering latency from lots of cache misses. - * It's created in a bid to investigate performance and find optimizations. */ - - -/*--- Dependencies ---*/ - -#include /* size_t */ -#include /* malloc, free, abort, qsort*/ -#include /* fprintf */ -#include /* UINT_MAX */ -#include /* assert */ - -#include "util.h" -#include "benchfn.h" -#define ZSTD_STATIC_LINKING_ONLY -#include "zstd.h" -#include "zdict.h" - - -/*--- Constants --- */ - -#define KB *(1<<10) -#define MB *(1<<20) - -#define BLOCKSIZE_DEFAULT 0 /* no slicing into blocks */ -#define DICTSIZE (4 KB) -#define CLEVEL_DEFAULT 3 -#define DICT_LOAD_METHOD ZSTD_dlm_byCopy - -#define BENCH_TIME_DEFAULT_S 6 -#define RUN_TIME_DEFAULT_MS 1000 -#define BENCH_TIME_DEFAULT_MS (BENCH_TIME_DEFAULT_S * RUN_TIME_DEFAULT_MS) - -#define DISPLAY_LEVEL_DEFAULT 3 - -#define BENCH_SIZE_MAX (1200 MB) - - -/*--- Macros ---*/ - -#define CONTROL(c) { if (!(c)) abort(); } -#undef MIN -#define MIN(a,b) ((a) < (b) ? (a) : (b)) - - -/*--- Display Macros ---*/ - -#define DISPLAY(...) fprintf(stdout, __VA_ARGS__) -#define DISPLAYLEVEL(l, ...) { if (g_displayLevel>=l) { DISPLAY(__VA_ARGS__); } } -static int g_displayLevel = DISPLAY_LEVEL_DEFAULT; /* 0 : no display, 1: errors, 2 : + result + interaction + warnings, 3 : + progression, 4 : + information */ - - -/*--- buffer_t ---*/ - -typedef struct { - void* ptr; - size_t size; - size_t capacity; -} buffer_t; - -static const buffer_t kBuffNull = { NULL, 0, 0 }; - -/* @return : kBuffNull if any error */ -static buffer_t createBuffer(size_t capacity) -{ - assert(capacity > 0); - void* const ptr = malloc(capacity); - if (ptr==NULL) return kBuffNull; - - buffer_t buffer; - buffer.ptr = ptr; - buffer.capacity = capacity; - buffer.size = 0; - return buffer; -} - -static void freeBuffer(buffer_t buff) -{ - free(buff.ptr); -} - - -static void fillBuffer_fromHandle(buffer_t* buff, FILE* f) -{ - size_t const readSize = fread(buff->ptr, 1, buff->capacity, f); - buff->size = readSize; -} - - -/* @return : kBuffNull if any error */ -static buffer_t createBuffer_fromFile(const char* fileName) -{ - U64 const fileSize = UTIL_getFileSize(fileName); - size_t const bufferSize = (size_t) fileSize; - - if (fileSize == UTIL_FILESIZE_UNKNOWN) return kBuffNull; - assert((U64)bufferSize == fileSize); /* check overflow */ - - { FILE* const f = fopen(fileName, "rb"); - if (f == NULL) return kBuffNull; - - buffer_t buff = createBuffer(bufferSize); - CONTROL(buff.ptr != NULL); - - fillBuffer_fromHandle(&buff, f); - CONTROL(buff.size == buff.capacity); - - fclose(f); /* do nothing specific if fclose() fails */ - return buff; - } -} - - -/* @return : kBuffNull if any error */ -static buffer_t -createDictionaryBuffer(const char* dictionaryName, - const void* srcBuffer, - const size_t* srcBlockSizes, size_t nbBlocks, - size_t requestedDictSize) -{ - if (dictionaryName) { - DISPLAYLEVEL(3, "loading dictionary %s \n", dictionaryName); - return createBuffer_fromFile(dictionaryName); /* note : result might be kBuffNull */ - - } else { - - DISPLAYLEVEL(3, "creating dictionary, of target size %u bytes \n", - (unsigned)requestedDictSize); - void* const dictBuffer = malloc(requestedDictSize); - CONTROL(dictBuffer != NULL); - - assert(nbBlocks <= UINT_MAX); - size_t const dictSize = ZDICT_trainFromBuffer(dictBuffer, requestedDictSize, - srcBuffer, - srcBlockSizes, (unsigned)nbBlocks); - CONTROL(!ZSTD_isError(dictSize)); - - buffer_t result; - result.ptr = dictBuffer; - result.capacity = requestedDictSize; - result.size = dictSize; - return result; - } -} - -/*! BMK_loadFiles() : - * Loads `buffer`, with content from files listed within `fileNamesTable`. - * Fills `buffer` entirely. - * @return : 0 on success, !=0 on error */ -static int loadFiles(void* buffer, size_t bufferSize, - size_t* fileSizes, - const char* const * fileNamesTable, unsigned nbFiles) -{ - size_t pos = 0, totalSize = 0; - - for (unsigned n=0; n 0); - void* const srcBuffer = malloc(loadedSize); - assert(srcBuffer != NULL); - - assert(nbFiles > 0); - size_t* const fileSizes = (size_t*)calloc(nbFiles, sizeof(*fileSizes)); - assert(fileSizes != NULL); - - /* Load input buffer */ - int const errorCode = loadFiles(srcBuffer, loadedSize, - fileSizes, - fileNamesTable, nbFiles); - assert(errorCode == 0); - - void** sliceTable = (void**)malloc(nbFiles * sizeof(*sliceTable)); - assert(sliceTable != NULL); - - char* const ptr = (char*)srcBuffer; - size_t pos = 0; - unsigned fileNb = 0; - for ( ; (pos < loadedSize) && (fileNb < nbFiles); fileNb++) { - sliceTable[fileNb] = ptr + pos; - pos += fileSizes[fileNb]; - } - assert(pos == loadedSize); - assert(fileNb == nbFiles); - - - buffer_t buffer; - buffer.ptr = srcBuffer; - buffer.capacity = loadedSize; - buffer.size = loadedSize; - - slice_collection_t slices; - slices.slicePtrs = sliceTable; - slices.capacities = fileSizes; - slices.nbSlices = nbFiles; - - buffer_collection_t bc; - bc.buffer = buffer; - bc.slices = slices; - return bc; -} - - - - -/*--- ddict_collection_t ---*/ - -typedef struct { - ZSTD_DDict** ddicts; - size_t nbDDict; -} ddict_collection_t; - -typedef struct { - ZSTD_CDict** cdicts; - size_t nbCDict; -} cdict_collection_t; - -static const cdict_collection_t kNullCDictCollection = { NULL, 0 }; - -static void freeCDictCollection(cdict_collection_t cdictc) -{ - for (size_t dictNb=0; dictNb < cdictc.nbCDict; dictNb++) { - ZSTD_freeCDict(cdictc.cdicts[dictNb]); - } - free(cdictc.cdicts); -} - -/* returns .buffers=NULL if operation fails */ -static cdict_collection_t createCDictCollection(const void* dictBuffer, size_t dictSize, size_t nbCDict, ZSTD_dictContentType_e dictContentType, ZSTD_CCtx_params* cctxParams) -{ - ZSTD_CDict** const cdicts = malloc(nbCDict * sizeof(ZSTD_CDict*)); - if (cdicts==NULL) return kNullCDictCollection; - for (size_t dictNb=0; dictNb < nbCDict; dictNb++) { - cdicts[dictNb] = ZSTD_createCDict_advanced2(dictBuffer, dictSize, DICT_LOAD_METHOD, dictContentType, cctxParams, ZSTD_defaultCMem); - CONTROL(cdicts[dictNb] != NULL); - } - cdict_collection_t cdictc; - cdictc.cdicts = cdicts; - cdictc.nbCDict = nbCDict; - return cdictc; -} - -static const ddict_collection_t kNullDDictCollection = { NULL, 0 }; - -static void freeDDictCollection(ddict_collection_t ddictc) -{ - for (size_t dictNb=0; dictNb < ddictc.nbDDict; dictNb++) { - ZSTD_freeDDict(ddictc.ddicts[dictNb]); - } - free(ddictc.ddicts); -} - -/* returns .buffers=NULL if operation fails */ -static ddict_collection_t createDDictCollection(const void* dictBuffer, size_t dictSize, size_t nbDDict) -{ - ZSTD_DDict** const ddicts = malloc(nbDDict * sizeof(ZSTD_DDict*)); - assert(ddicts != NULL); - if (ddicts==NULL) return kNullDDictCollection; - for (size_t dictNb=0; dictNb < nbDDict; dictNb++) { - ddicts[dictNb] = ZSTD_createDDict(dictBuffer, dictSize); - assert(ddicts[dictNb] != NULL); - } - ddict_collection_t ddictc; - ddictc.ddicts = ddicts; - ddictc.nbDDict = nbDDict; - return ddictc; -} - - -/* mess with addresses, so that linear scanning dictionaries != linear address scanning */ -void shuffleCDictionaries(cdict_collection_t dicts) -{ - size_t const nbDicts = dicts.nbCDict; - for (size_t r=0; rcctx, ci->dictionaries.cdicts[ci->dictNb]); - ZSTD_compress2(ci->cctx, - dst, srcSize, - src, srcSize); - - ci->dictNb = ci->dictNb + 1; - if (ci->dictNb >= ci->nbDicts) ci->dictNb = 0; - - return srcSize; -} - -/* benched function */ -size_t decompress(const void* src, size_t srcSize, void* dst, size_t dstCapacity, void* payload) -{ - decompressInstructions* const di = (decompressInstructions*) payload; - - size_t const result = ZSTD_decompress_usingDDict(di->dctx, - dst, dstCapacity, - src, srcSize, - di->dictionaries.ddicts[di->dictNb]); - - di->dictNb = di->dictNb + 1; - if (di->dictNb >= di->nbDicts) di->dictNb = 0; - - return result; -} - -typedef enum { - fastest = 0, - median = 1, -} metricAggregatePref_e; - -/* compareFunction() : - * Sort input in decreasing order when used with qsort() */ -int compareFunction(const void *a, const void *b) -{ - double x = *(const double *)a; - double y = *(const double *)b; - if (x < y) - return 1; - else if (x > y) - return -1; - return 0; -} - -double aggregateData(double *data, size_t size, - metricAggregatePref_e metricAggregatePref) -{ - qsort(data, size, sizeof(*data), compareFunction); - if (metricAggregatePref == fastest) - return data[0]; - else /* median */ - return (data[(size - 1) / 2] + data[size / 2]) / 2; -} - -static int benchMem(slice_collection_t dstBlocks, slice_collection_t srcBlocks, - ddict_collection_t ddictionaries, - cdict_collection_t cdictionaries, unsigned nbRounds, - int benchCompression, const char *exeName, - ZSTD_CCtx_params *cctxParams, - metricAggregatePref_e metricAggregatePref) -{ - assert(dstBlocks.nbSlices == srcBlocks.nbSlices); - if (benchCompression) assert(cctxParams); - - unsigned const ms_per_round = RUN_TIME_DEFAULT_MS; - unsigned const total_time_ms = nbRounds * ms_per_round; - - double *const speedPerRound = (double *)malloc(nbRounds * sizeof(double)); - - BMK_timedFnState_t* const benchState = - BMK_createTimedFnState(total_time_ms, ms_per_round); - - decompressInstructions di = createDecompressInstructions(ddictionaries); - compressInstructions ci = - createCompressInstructions(cdictionaries, cctxParams); - void* payload = benchCompression ? (void*)&ci : (void*)&di; - BMK_benchParams_t const bp = { - .benchFn = benchCompression ? compress : decompress, - .benchPayload = payload, - .initFn = NULL, - .initPayload = NULL, - .errorFn = ZSTD_isError, - .blockCount = dstBlocks.nbSlices, - .srcBuffers = (const void* const*) srcBlocks.slicePtrs, - .srcSizes = srcBlocks.capacities, - .dstBuffers = dstBlocks.slicePtrs, - .dstCapacities = dstBlocks.capacities, - .blockResults = NULL - }; - - size_t roundNb = 0; - for (;;) { - BMK_runOutcome_t const outcome = BMK_benchTimedFn(benchState, bp); - CONTROL(BMK_isSuccessful_runOutcome(outcome)); - - BMK_runTime_t const result = BMK_extract_runTime(outcome); - double const dTime_ns = result.nanoSecPerRun; - double const dTime_sec = (double)dTime_ns / 1000000000; - size_t const srcSize = result.sumOfReturn; - double const speed_MBps = (double)srcSize / dTime_sec / (1 MB); - speedPerRound[roundNb] = speed_MBps; - if (benchCompression) - DISPLAY("Compression Speed : %.1f MB/s \r", speed_MBps); - else - DISPLAY("Decompression Speed : %.1f MB/s \r", speed_MBps); - - fflush(stdout); - if (BMK_isCompleted_TimedFn(benchState)) break; - roundNb++; - } - DISPLAY("\n"); - /* BMK_benchTimedFn may not run exactly nbRounds iterations */ - double speedAggregated = - aggregateData(speedPerRound, roundNb + 1, metricAggregatePref); - if (metricAggregatePref == fastest) - DISPLAY("Fastest Speed : %.1f MB/s \n", speedAggregated); - else - DISPLAY("Median Speed : %.1f MB/s \n", speedAggregated); - - char* csvFileName = malloc(strlen(exeName) + 5); - strcpy(csvFileName, exeName); - strcat(csvFileName, ".csv"); - FILE* csvFile = fopen(csvFileName, "r"); - if (!csvFile) { - csvFile = fopen(csvFileName, "wt"); - assert(csvFile); - fprintf(csvFile, "%s\n", exeName); - /* Print table headers */ - fprintf( - csvFile, - "Compression/Decompression,Level,nbDicts,dictAttachPref,metricAggregatePref,Speed\n"); - } else { - fclose(csvFile); - csvFile = fopen(csvFileName, "at"); - assert(csvFile); - } - - int cLevel = -1; - int dictAttachPref = -1; - if (benchCompression) { - ZSTD_CCtxParams_getParameter(cctxParams, ZSTD_c_compressionLevel, - &cLevel); - ZSTD_CCtxParams_getParameter(cctxParams, ZSTD_c_forceAttachDict, - &dictAttachPref); - } - fprintf(csvFile, "%s,%d,%ld,%d,%d,%.1f\n", - benchCompression ? "Compression" : "Decompression", cLevel, - benchCompression ? ci.nbDicts : di.nbDicts, dictAttachPref, - metricAggregatePref, speedAggregated); - fclose(csvFile); - free(csvFileName); - - freeDecompressInstructions(di); - freeCompressInstructions(ci); - BMK_freeTimedFnState(benchState); - - return 0; /* success */ -} - - -/*! bench() : - * fileName : file to load for benchmarking purpose - * dictionary : optional (can be NULL), file to load as dictionary, - * if none provided : will be calculated on the fly by the program. - * @return : 0 is success, 1+ otherwise */ -int bench(const char **fileNameTable, unsigned nbFiles, const char *dictionary, - size_t blockSize, int clevel, unsigned nbDictMax, unsigned nbBlocks, - unsigned nbRounds, int benchCompression, - ZSTD_dictContentType_e dictContentType, ZSTD_CCtx_params *cctxParams, - const char *exeName, metricAggregatePref_e metricAggregatePref) -{ - int result = 0; - - DISPLAYLEVEL(3, "loading %u files... \n", nbFiles); - buffer_collection_t const srcs = createBufferCollection_fromFiles(fileNameTable, nbFiles); - CONTROL(srcs.buffer.ptr != NULL); - buffer_t srcBuffer = srcs.buffer; - size_t const srcSize = srcBuffer.size; - DISPLAYLEVEL(3, "created src buffer of size %.1f MB \n", - (double)srcSize / (1 MB)); - - slice_collection_t const srcSlices = splitSlices(srcs.slices, blockSize, nbBlocks); - nbBlocks = (unsigned)(srcSlices.nbSlices); - DISPLAYLEVEL(3, "split input into %u blocks ", nbBlocks); - if (blockSize) - DISPLAYLEVEL(3, "of max size %u bytes ", (unsigned)blockSize); - DISPLAYLEVEL(3, "\n"); - size_t const totalSrcSlicesSize = sliceCollection_totalCapacity(srcSlices); - - - size_t* const dstCapacities = malloc(nbBlocks * sizeof(*dstCapacities)); - CONTROL(dstCapacities != NULL); - size_t dstBufferCapacity = 0; - for (size_t bnb=0; bnb='0') && (**stringPtr <='9')) { - unsigned const max = (((unsigned)(-1)) / 10) - 1; - assert(result <= max); /* check overflow */ - result *= 10, result += (unsigned)**stringPtr - '0', (*stringPtr)++ ; - } - if ((**stringPtr=='K') || (**stringPtr=='M')) { - unsigned const maxK = ((unsigned)(-1)) >> 10; - assert(result <= maxK); /* check overflow */ - result <<= 10; - if (**stringPtr=='M') { - assert(result <= maxK); /* check overflow */ - result <<= 10; - } - (*stringPtr)++; /* skip `K` or `M` */ - if (**stringPtr=='i') (*stringPtr)++; - if (**stringPtr=='B') (*stringPtr)++; - } - return result; -} - -/** longCommandWArg() : - * check if *stringPtr is the same as longCommand. - * If yes, @return 1 and advances *stringPtr to the position which immediately follows longCommand. - * @return 0 and doesn't modify *stringPtr otherwise. - */ -static int longCommandWArg(const char** stringPtr, const char* longCommand) -{ - size_t const comSize = strlen(longCommand); - int const result = !strncmp(*stringPtr, longCommand, comSize); - if (result) *stringPtr += comSize; - return result; -} - - -int usage(const char* exeName) -{ - DISPLAY (" \n"); - DISPLAY (" %s [Options] filename(s) \n", exeName); - DISPLAY (" \n"); - DISPLAY ("Options : \n"); - DISPLAY ("-z : benchmark compression (default) \n"); - DISPLAY ("-d : benchmark decompression \n"); - DISPLAY ("-r : recursively load all files in subdirectories (default: off) \n"); - DISPLAY ("-B# : split input into blocks of size # (default: no split) \n"); - DISPLAY ("-# : use compression level # (default: %u) \n", CLEVEL_DEFAULT); - DISPLAY ("-D # : use # as a dictionary (default: create one) \n"); - DISPLAY ("-i# : nb benchmark rounds (default: %u) \n", BENCH_TIME_DEFAULT_S); - DISPLAY ("-p# : print speed for all rounds 0=fastest 1=median (default: 0) \n"); - DISPLAY ("--nbBlocks=#: use # blocks for bench (default: one per file) \n"); - DISPLAY ("--nbDicts=# : create # dictionaries for bench (default: one per block) \n"); - DISPLAY ("-h : help (this text) \n"); - DISPLAY (" \n"); - DISPLAY ("Advanced Options (see zstd.h for documentation) : \n"); - DISPLAY ("--dedicated-dict-search\n"); - DISPLAY ("--dict-content-type=#\n"); - DISPLAY ("--dict-attach-pref=#\n"); - return 0; -} - -int bad_usage(const char* exeName) -{ - DISPLAY (" bad usage : \n"); - usage(exeName); - return 1; -} - -int main (int argc, const char** argv) -{ - int recursiveMode = 0; - int benchCompression = 1; - int dedicatedDictSearch = 0; - unsigned nbRounds = BENCH_TIME_DEFAULT_S; - const char* const exeName = argv[0]; - - if (argc < 2) return bad_usage(exeName); - - const char** nameTable = (const char**)malloc((size_t)argc * sizeof(const char*)); - assert(nameTable != NULL); - unsigned nameIdx = 0; - - const char* dictionary = NULL; - int cLevel = CLEVEL_DEFAULT; - size_t blockSize = BLOCKSIZE_DEFAULT; - unsigned nbDicts = 0; /* determine nbDicts automatically: 1 dictionary per block */ - unsigned nbBlocks = 0; /* determine nbBlocks automatically, from source and blockSize */ - ZSTD_dictContentType_e dictContentType = ZSTD_dct_auto; - ZSTD_dictAttachPref_e dictAttachPref = ZSTD_dictDefaultAttach; - ZSTD_paramSwitch_e prefetchCDictTables = ZSTD_ps_auto; - metricAggregatePref_e metricAggregatePref = fastest; - - for (int argNb = 1; argNb < argc ; argNb++) { - const char* argument = argv[argNb]; - if (!strcmp(argument, "-h")) { free(nameTable); return usage(exeName); } - if (!strcmp(argument, "-d")) { benchCompression = 0; continue; } - if (!strcmp(argument, "-z")) { benchCompression = 1; continue; } - if (!strcmp(argument, "-r")) { recursiveMode = 1; continue; } - if (!strcmp(argument, "-D")) { argNb++; assert(argNb < argc); dictionary = argv[argNb]; continue; } - if (longCommandWArg(&argument, "-i")) { nbRounds = readU32FromChar(&argument); continue; } - if (longCommandWArg(&argument, "-p")) { metricAggregatePref = (int)readU32FromChar(&argument); continue;} - if (longCommandWArg(&argument, "--dictionary=")) { dictionary = argument; continue; } - if (longCommandWArg(&argument, "-B")) { blockSize = readU32FromChar(&argument); continue; } - if (longCommandWArg(&argument, "--blockSize=")) { blockSize = readU32FromChar(&argument); continue; } - if (longCommandWArg(&argument, "--nbDicts=")) { nbDicts = readU32FromChar(&argument); continue; } - if (longCommandWArg(&argument, "--nbBlocks=")) { nbBlocks = readU32FromChar(&argument); continue; } - if (longCommandWArg(&argument, "--clevel=")) { cLevel = (int)readU32FromChar(&argument); continue; } - if (longCommandWArg(&argument, "--dedicated-dict-search")) { dedicatedDictSearch = 1; continue; } - if (longCommandWArg(&argument, "--dict-content-type=")) { dictContentType = (int)readU32FromChar(&argument); continue; } - if (longCommandWArg(&argument, "--dict-attach-pref=")) { dictAttachPref = (int)readU32FromChar(&argument); continue; } - if (longCommandWArg(&argument, "--prefetch-cdict-tables=")) { prefetchCDictTables = (int)readU32FromChar(&argument); continue; } - if (longCommandWArg(&argument, "-")) { cLevel = (int)readU32FromChar(&argument); continue; } - /* anything that's not a command is a filename */ - nameTable[nameIdx++] = argument; - } - - FileNamesTable* filenameTable; - - if (recursiveMode) { -#ifndef UTIL_HAS_CREATEFILELIST - assert(0); /* missing capability, do not run */ -#endif - filenameTable = UTIL_createExpandedFNT(nameTable, nameIdx, 1 /* follow_links */); - } else { - filenameTable = UTIL_assembleFileNamesTable(nameTable, nameIdx, NULL); - nameTable = NULL; /* UTIL_createFileNamesTable() takes ownership of nameTable */ - } - - ZSTD_CCtx_params* cctxParams = ZSTD_createCCtxParams(); - ZSTD_CCtxParams_init(cctxParams, cLevel); - ZSTD_CCtxParams_setParameter(cctxParams, ZSTD_c_enableDedicatedDictSearch, dedicatedDictSearch); - ZSTD_CCtxParams_setParameter(cctxParams, ZSTD_c_nbWorkers, 0); - ZSTD_CCtxParams_setParameter(cctxParams, ZSTD_c_forceAttachDict, dictAttachPref); - ZSTD_CCtxParams_setParameter(cctxParams, ZSTD_c_prefetchCDictTables, prefetchCDictTables); - - int result = - bench(filenameTable->fileNames, (unsigned)filenameTable->tableSize, - dictionary, blockSize, cLevel, nbDicts, nbBlocks, nbRounds, - benchCompression, dictContentType, cctxParams, exeName, - metricAggregatePref); - - UTIL_freeFileNamesTable(filenameTable); - free(nameTable); - ZSTD_freeCCtxParams(cctxParams); - - return result; -} diff --git a/third_party/zstd/contrib/linux-kernel/.gitignore b/third_party/zstd/contrib/linux-kernel/.gitignore deleted file mode 100644 index d8dfeef21..000000000 --- a/third_party/zstd/contrib/linux-kernel/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -!lib/zstd -!lib/zstd/* -*.o -*.a diff --git a/third_party/zstd/contrib/linux-kernel/Makefile b/third_party/zstd/contrib/linux-kernel/Makefile deleted file mode 100644 index 63dd15d95..000000000 --- a/third_party/zstd/contrib/linux-kernel/Makefile +++ /dev/null @@ -1,108 +0,0 @@ -# ################################################################ -# Copyright (c) Meta Platforms, Inc. and affiliates. -# All rights reserved. -# -# This source code is licensed under both the BSD-style license (found in the -# LICENSE file in the root directory of this source tree) and the GPLv2 (found -# in the COPYING file in the root directory of this source tree). -# You may select, at your option, one of the above-listed licenses. -# ################################################################ - -.PHONY: libzstd -libzstd: - rm -rf linux - mkdir -p linux - mkdir -p linux/include/linux - mkdir -p linux/lib/zstd - ../freestanding_lib/freestanding.py \ - --source-lib ../../lib \ - --output-lib linux/lib/zstd \ - --xxhash '' \ - --xxh64-state 'struct xxh64_state' \ - --xxh64-prefix 'xxh64' \ - --rewrite-include '=' \ - --rewrite-include '=' \ - --rewrite-include '"\.\./zstd.h"=' \ - --rewrite-include '"(\.\./)?zstd_errors.h"=' \ - --sed 's,/\*\*\*,/* *,g' \ - --sed 's,/\*\*,/*,g' \ - --spdx \ - -DZSTD_NO_INTRINSICS \ - -DZSTD_NO_UNUSED_FUNCTIONS \ - -DZSTD_LEGACY_SUPPORT=0 \ - -DZSTD_STATIC_LINKING_ONLY \ - -DFSE_STATIC_LINKING_ONLY \ - -DXXH_STATIC_LINKING_ONLY \ - -D__GNUC__ \ - -D__linux__=1 \ - -DSTATIC_BMI2=0 \ - -DZSTD_ADDRESS_SANITIZER=0 \ - -DZSTD_MEMORY_SANITIZER=0 \ - -DZSTD_DATAFLOW_SANITIZER=0 \ - -DZSTD_COMPRESS_HEAPMODE=1 \ - -UNO_PREFETCH \ - -U__cplusplus \ - -UZSTD_DLL_EXPORT \ - -UZSTD_DLL_IMPORT \ - -U__ICCARM__ \ - -UZSTD_MULTITHREAD \ - -U_MSC_VER \ - -U_WIN32 \ - -RZSTDLIB_VISIBLE= \ - -RZSTDERRORLIB_VISIBLE= \ - -RZSTD_FALLTHROUGH=fallthrough \ - -DZSTD_HAVE_WEAK_SYMBOLS=0 \ - -DZSTD_TRACE=0 \ - -DZSTD_NO_TRACE \ - -DZSTD_DISABLE_ASM \ - -DZSTD_LINUX_KERNEL - rm linux/lib/zstd/decompress/huf_decompress_amd64.S - mv linux/lib/zstd/zstd.h linux/include/linux/zstd_lib.h - mv linux/lib/zstd/zstd_errors.h linux/include/linux/ - cp linux_zstd.h linux/include/linux/zstd.h - cp zstd_common_module.c linux/lib/zstd - cp zstd_compress_module.c linux/lib/zstd - cp zstd_decompress_module.c linux/lib/zstd - cp decompress_sources.h linux/lib/zstd - cp linux.mk linux/lib/zstd/Makefile - -LINUX ?= $(HOME)/repos/linux - -.PHONY: import -import: libzstd - rm -f $(LINUX)/include/linux/zstd.h - rm -f $(LINUX)/include/linux/zstd_errors.h - rm -rf $(LINUX)/lib/zstd - cp linux/include/linux/zstd.h $(LINUX)/include/linux - cp linux/include/linux/zstd_lib.h $(LINUX)/include/linux - cp linux/include/linux/zstd_errors.h $(LINUX)/include/linux - cp -r linux/lib/zstd $(LINUX)/lib - -import-upstream: - rm -rf $(LINUX)/lib/zstd - mkdir $(LINUX)/lib/zstd - cp ../../lib/zstd.h $(LINUX)/include/linux/zstd_lib.h - cp -r ../../lib/common $(LINUX)/lib/zstd - cp -r ../../lib/compress $(LINUX)/lib/zstd - cp -r ../../lib/decompress $(LINUX)/lib/zstd - mv $(LINUX)/lib/zstd/zstd_errors.h $(LINUX)/include/linux - rm $(LINUX)/lib/zstd/common/threading.* - rm $(LINUX)/lib/zstd/common/pool.* - rm $(LINUX)/lib/zstd/common/xxhash.* - rm $(LINUX)/lib/zstd/compress/zstdmt_* - -DEBUGFLAGS= -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow \ - -Wstrict-aliasing=1 -Wswitch-enum -Wdeclaration-after-statement \ - -Wstrict-prototypes -Wundef -Wpointer-arith \ - -Wvla -Wformat=2 -Winit-self -Wfloat-equal -Wwrite-strings \ - -Wredundant-decls -Wmissing-prototypes -Wc++-compat \ - -Wimplicit-fallthrough - -.PHONY: test -test: libzstd - $(MAKE) -C test run-test CFLAGS="-O3 $(CFLAGS) $(DEBUGFLAGS) -Werror" -j - -.PHONY: clean -clean: - $(RM) -rf linux - $(MAKE) -C test clean diff --git a/third_party/zstd/contrib/linux-kernel/README.md b/third_party/zstd/contrib/linux-kernel/README.md deleted file mode 100644 index bfa070d17..000000000 --- a/third_party/zstd/contrib/linux-kernel/README.md +++ /dev/null @@ -1,14 +0,0 @@ -# Zstd in the Linux Kernel - -This directory contains the scripts needed to transform upstream zstd into the version imported into the kernel. All the transforms are automated and tested by our continuous integration. - -## Upgrading Zstd in the Linux Kernel - -1. `cd` into this directory. -2. Run `make libzstd` and read the output. Make sure that all the diffs printed and changes made by the script are correct. -3. Run `make test` and ensure that it passes. -4. Import zstd into the Linux Kernel `make import LINUX=/path/to/linux/repo` -5. Inspect the diff for sanity. -6. Check the Linux Kernel history for zstd. If any patches were made to the kernel version of zstd, but not to upstream zstd, then port them upstream if necessary. -7. Test the diff. Benchmark if necessary. Make sure to test multiple architectures: At least x86, i386, and arm. -8. Submit the patch to the LKML. diff --git a/third_party/zstd/contrib/linux-kernel/btrfs-benchmark.sh b/third_party/zstd/contrib/linux-kernel/btrfs-benchmark.sh deleted file mode 100755 index 5e28da9c6..000000000 --- a/third_party/zstd/contrib/linux-kernel/btrfs-benchmark.sh +++ /dev/null @@ -1,104 +0,0 @@ -# !/bin/sh -set -e - -# Benchmarks run on a Ubuntu 14.04 VM with 2 cores and 4 GiB of RAM. -# The VM is running on a Macbook Pro with a 3.1 GHz Intel Core i7 processor and -# 16 GB of RAM and an SSD. - -# silesia is a directory that can be downloaded from -# http://mattmahoney.net/dc/silesia.html -# ls -l silesia/ -# total 203M -# -rwxr-xr-x 1 terrelln 9.8M Apr 12 2002 dickens -# -rwxr-xr-x 1 terrelln 49M May 31 2002 mozilla -# -rwxr-xr-x 1 terrelln 9.6M Mar 20 2003 mr -# -rwxr-xr-x 1 terrelln 32M Apr 2 2002 nci -# -rwxr-xr-x 1 terrelln 5.9M Jul 4 2002 ooffice -# -rwxr-xr-x 1 terrelln 9.7M Apr 11 2002 osdb -# -rwxr-xr-x 1 terrelln 6.4M Apr 2 2002 reymont -# -rwxr-xr-x 1 terrelln 21M Mar 25 2002 samba -# -rwxr-xr-x 1 terrelln 7.0M Mar 24 2002 sao -# -rwxr-xr-x 1 terrelln 40M Mar 25 2002 webster -# -rwxr-xr-x 1 terrelln 8.1M Apr 4 2002 x-ray -# -rwxr-xr-x 1 terrelln 5.1M Nov 30 2000 xml - -# $HOME is on a ext4 filesystem -BENCHMARK_DIR="$HOME/silesia/" -N=10 - -# Normalize the environment -sudo umount /mnt/btrfs 2> /dev/null > /dev/null || true -sudo mount -t btrfs $@ /dev/sda3 /mnt/btrfs -sudo rm -rf /mnt/btrfs/* -sync -sudo umount /mnt/btrfs -sudo mount -t btrfs $@ /dev/sda3 /mnt/btrfs - -# Run the benchmark -echo "Compression" -time sh -c "for i in \$(seq $N); do sudo cp -r $BENCHMARK_DIR /mnt/btrfs/\$i; done; sync" - -echo "Approximate compression ratio" -printf "%d / %d\n" \ - $(df /mnt/btrfs --output=used -B 1 | tail -n 1) \ - $(sudo du /mnt/btrfs -b -d 0 | tr '\t' '\n' | head -n 1); - -# Unmount and remount to avoid any caching -sudo umount /mnt/btrfs -sudo mount -t btrfs $@ /dev/sda3 /mnt/btrfs - -echo "Decompression" -time sudo tar -c /mnt/btrfs 2> /dev/null | wc -c > /dev/null - -sudo rm -rf /mnt/btrfs/* -sudo umount /mnt/btrfs - -# Run for each of -o compress-force={none, lzo, zlib, zstd} 5 times and take the -# min time and ratio. -# Ran zstd with compression levels {1, 3, 6, 9, 12, 15}. -# Original size: 2119415342 B (using du /mnt/btrfs) - -# none -# compress: 4.205 s -# decompress: 3.090 s -# ratio: 0.99 - -# lzo -# compress: 5.328 s -# decompress: 4.793 s -# ratio: 1.66 - -# zlib -# compress: 32.588 s -# decompress: 8.791 s -# ratio : 2.58 - -# zstd 1 -# compress: 8.147 s -# decompress: 5.527 s -# ratio : 2.57 - -# zstd 3 -# compress: 12.207 s -# decompress: 5.195 s -# ratio : 2.71 - -# zstd 6 -# compress: 30.253 s -# decompress: 5.324 s -# ratio : 2.87 - -# zstd 9 -# compress: 49.659 s -# decompress: 5.220 s -# ratio : 2.92 - -# zstd 12 -# compress: 99.245 s -# decompress: 5.193 s -# ratio : 2.93 - -# zstd 15 -# compress: 196.997 s -# decompress: 5.992 s -# ratio : 3.01 diff --git a/third_party/zstd/contrib/linux-kernel/btrfs-extract-benchmark.sh b/third_party/zstd/contrib/linux-kernel/btrfs-extract-benchmark.sh deleted file mode 100755 index 69721d093..000000000 --- a/third_party/zstd/contrib/linux-kernel/btrfs-extract-benchmark.sh +++ /dev/null @@ -1,99 +0,0 @@ -# !/bin/sh -set -e - -# Benchmarks run on a Ubuntu 14.04 VM with 2 cores and 4 GiB of RAM. -# The VM is running on a Macbook Pro with a 3.1 GHz Intel Core i7 processor and -# 16 GB of RAM and an SSD. - -# silesia is a directory that can be downloaded from -# http://mattmahoney.net/dc/silesia.html -# ls -l silesia/ -# total 203M -# -rwxr-xr-x 1 terrelln 9.8M Apr 12 2002 dickens -# -rwxr-xr-x 1 terrelln 49M May 31 2002 mozilla -# -rwxr-xr-x 1 terrelln 9.6M Mar 20 2003 mr -# -rwxr-xr-x 1 terrelln 32M Apr 2 2002 nci -# -rwxr-xr-x 1 terrelln 5.9M Jul 4 2002 ooffice -# -rwxr-xr-x 1 terrelln 9.7M Apr 11 2002 osdb -# -rwxr-xr-x 1 terrelln 6.4M Apr 2 2002 reymont -# -rwxr-xr-x 1 terrelln 21M Mar 25 2002 samba -# -rwxr-xr-x 1 terrelln 7.0M Mar 24 2002 sao -# -rwxr-xr-x 1 terrelln 40M Mar 25 2002 webster -# -rwxr-xr-x 1 terrelln 8.1M Apr 4 2002 x-ray -# -rwxr-xr-x 1 terrelln 5.1M Nov 30 2000 xml - -# $HOME is on a ext4 filesystem -BENCHMARK_FILE="linux-4.11.6.tar" -BENCHMARK_DIR="$HOME/$BENCHMARK_FILE" - -# Normalize the environment -sudo umount /mnt/btrfs 2> /dev/null > /dev/null || true -sudo mount -t btrfs $@ /dev/sda3 /mnt/btrfs -sudo rm -rf /mnt/btrfs/* -sync -sudo umount /mnt/btrfs -sudo mount -t btrfs $@ /dev/sda3 /mnt/btrfs - -# Run the benchmark -echo "Copy" -time sh -c "sudo cp -r $BENCHMARK_DIR /mnt/btrfs/$BENCHMARK_FILE && sync" - -echo "Approximate tarred compression ratio" -printf "%d / %d\n" \ - $(df /mnt/btrfs --output=used -B 1 | tail -n 1) \ - $(sudo du /mnt/btrfs -b -d 0 | tr '\t' '\n' | head -n 1); - -# Unmount and remount to avoid any caching -sudo umount /mnt/btrfs -sudo mount -t btrfs $@ /dev/sda3 /mnt/btrfs - -echo "Extract" -time sh -c "sudo tar -C /mnt/btrfs -xf /mnt/btrfs/$BENCHMARK_FILE && sync" - -# Remove the tarball, leaving only the extracted data -sudo rm /mnt/btrfs/$BENCHMARK_FILE -# Unmount and remount to avoid any caching -sudo umount /mnt/btrfs -sudo mount -t btrfs $@ /dev/sda3 /mnt/btrfs - -echo "Approximate extracted compression ratio" -printf "%d / %d\n" \ - $(df /mnt/btrfs --output=used -B 1 | tail -n 1) \ - $(sudo du /mnt/btrfs -b -d 0 | tr '\t' '\n' | head -n 1); - -echo "Read" -time sudo tar -c /mnt/btrfs 2> /dev/null | wc -c > /dev/null - -sudo rm -rf /mnt/btrfs/* -sudo umount /mnt/btrfs - -# Run for each of -o compress-force={none, lzo, zlib, zstd} 5 times and take the -# min time and ratio. - -# none -# copy: 0.981 s -# extract: 5.501 s -# read: 8.807 s -# tarball ratio: 0.97 -# extracted ratio: 0.78 - -# lzo -# copy: 1.631 s -# extract: 8.458 s -# read: 8.585 s -# tarball ratio: 2.06 -# extracted ratio: 1.38 - -# zlib -# copy: 7.750 s -# extract: 21.544 s -# read: 11.744 s -# tarball ratio : 3.40 -# extracted ratio: 1.86 - -# zstd 1 -# copy: 2.579 s -# extract: 11.479 s -# read: 9.389 s -# tarball ratio : 3.57 -# extracted ratio: 1.85 diff --git a/third_party/zstd/contrib/linux-kernel/decompress_sources.h b/third_party/zstd/contrib/linux-kernel/decompress_sources.h deleted file mode 100644 index 8a47eb2a4..000000000 --- a/third_party/zstd/contrib/linux-kernel/decompress_sources.h +++ /dev/null @@ -1,34 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under both the BSD-style license (found in the - * LICENSE file in the root directory of this source tree) and the GPLv2 (found - * in the COPYING file in the root directory of this source tree). - * You may select, at your option, one of the above-listed licenses. - */ - -/* - * This file includes every .c file needed for decompression. - * It is used by lib/decompress_unzstd.c to include the decompression - * source into the translation-unit, so it can be used for kernel - * decompression. - */ - -/* - * Disable the ASM Huffman implementation because we need to - * include all the sources. - */ -#define ZSTD_DISABLE_ASM 1 - -#include "common/debug.c" -#include "common/entropy_common.c" -#include "common/error_private.c" -#include "common/fse_decompress.c" -#include "common/zstd_common.c" -#include "decompress/huf_decompress.c" -#include "decompress/zstd_ddict.c" -#include "decompress/zstd_decompress.c" -#include "decompress/zstd_decompress_block.c" -#include "zstd_decompress_module.c" diff --git a/third_party/zstd/contrib/linux-kernel/linux.mk b/third_party/zstd/contrib/linux-kernel/linux.mk deleted file mode 100644 index 464c410b2..000000000 --- a/third_party/zstd/contrib/linux-kernel/linux.mk +++ /dev/null @@ -1,43 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause -# ################################################################ -# Copyright (c) Meta Platforms, Inc. and affiliates. -# All rights reserved. -# -# This source code is licensed under both the BSD-style license (found in the -# LICENSE file in the root directory of this source tree) and the GPLv2 (found -# in the COPYING file in the root directory of this source tree). -# You may select, at your option, one of the above-listed licenses. -# ################################################################ -obj-$(CONFIG_ZSTD_COMPRESS) += zstd_compress.o -obj-$(CONFIG_ZSTD_DECOMPRESS) += zstd_decompress.o -obj-$(CONFIG_ZSTD_COMMON) += zstd_common.o - -zstd_compress-y := \ - zstd_compress_module.o \ - compress/fse_compress.o \ - compress/hist.o \ - compress/huf_compress.o \ - compress/zstd_compress.o \ - compress/zstd_compress_literals.o \ - compress/zstd_compress_sequences.o \ - compress/zstd_compress_superblock.o \ - compress/zstd_double_fast.o \ - compress/zstd_fast.o \ - compress/zstd_lazy.o \ - compress/zstd_ldm.o \ - compress/zstd_opt.o \ - -zstd_decompress-y := \ - zstd_decompress_module.o \ - decompress/huf_decompress.o \ - decompress/zstd_ddict.o \ - decompress/zstd_decompress.o \ - decompress/zstd_decompress_block.o \ - -zstd_common-y := \ - zstd_common_module.o \ - common/debug.o \ - common/entropy_common.o \ - common/error_private.o \ - common/fse_decompress.o \ - common/zstd_common.o \ diff --git a/third_party/zstd/contrib/linux-kernel/linux_zstd.h b/third_party/zstd/contrib/linux-kernel/linux_zstd.h deleted file mode 100644 index f109d49f4..000000000 --- a/third_party/zstd/contrib/linux-kernel/linux_zstd.h +++ /dev/null @@ -1,447 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under both the BSD-style license (found in the - * LICENSE file in the root directory of https://github.com/facebook/zstd) and - * the GPLv2 (found in the COPYING file in the root directory of - * https://github.com/facebook/zstd). You may select, at your option, one of the - * above-listed licenses. - */ - -#ifndef LINUX_ZSTD_H -#define LINUX_ZSTD_H - -/** - * This is a kernel-style API that wraps the upstream zstd API, which cannot be - * used directly because the symbols aren't exported. It exposes the minimal - * functionality which is currently required by users of zstd in the kernel. - * Expose extra functions from lib/zstd/zstd.h as needed. - */ - -/* ====== Dependency ====== */ -#include -#include -#include - -/* ====== Helper Functions ====== */ -/** - * zstd_compress_bound() - maximum compressed size in worst case scenario - * @src_size: The size of the data to compress. - * - * Return: The maximum compressed size in the worst case scenario. - */ -size_t zstd_compress_bound(size_t src_size); - -/** - * zstd_is_error() - tells if a size_t function result is an error code - * @code: The function result to check for error. - * - * Return: Non-zero iff the code is an error. - */ -unsigned int zstd_is_error(size_t code); - -/** - * enum zstd_error_code - zstd error codes - */ -typedef ZSTD_ErrorCode zstd_error_code; - -/** - * zstd_get_error_code() - translates an error function result to an error code - * @code: The function result for which zstd_is_error(code) is true. - * - * Return: A unique error code for this error. - */ -zstd_error_code zstd_get_error_code(size_t code); - -/** - * zstd_get_error_name() - translates an error function result to a string - * @code: The function result for which zstd_is_error(code) is true. - * - * Return: An error string corresponding to the error code. - */ -const char *zstd_get_error_name(size_t code); - -/** - * zstd_min_clevel() - minimum allowed compression level - * - * Return: The minimum allowed compression level. - */ -int zstd_min_clevel(void); - -/** - * zstd_max_clevel() - maximum allowed compression level - * - * Return: The maximum allowed compression level. - */ -int zstd_max_clevel(void); - -/* ====== Parameter Selection ====== */ - -/** - * enum zstd_strategy - zstd compression search strategy - * - * From faster to stronger. See zstd_lib.h. - */ -typedef ZSTD_strategy zstd_strategy; - -/** - * struct zstd_compression_parameters - zstd compression parameters - * @windowLog: Log of the largest match distance. Larger means more - * compression, and more memory needed during decompression. - * @chainLog: Fully searched segment. Larger means more compression, - * slower, and more memory (useless for fast). - * @hashLog: Dispatch table. Larger means more compression, - * slower, and more memory. - * @searchLog: Number of searches. Larger means more compression and slower. - * @searchLength: Match length searched. Larger means faster decompression, - * sometimes less compression. - * @targetLength: Acceptable match size for optimal parser (only). Larger means - * more compression, and slower. - * @strategy: The zstd compression strategy. - * - * See zstd_lib.h. - */ -typedef ZSTD_compressionParameters zstd_compression_parameters; - -/** - * struct zstd_frame_parameters - zstd frame parameters - * @contentSizeFlag: Controls whether content size will be present in the - * frame header (when known). - * @checksumFlag: Controls whether a 32-bit checksum is generated at the - * end of the frame for error detection. - * @noDictIDFlag: Controls whether dictID will be saved into the frame - * header when using dictionary compression. - * - * The default value is all fields set to 0. See zstd_lib.h. - */ -typedef ZSTD_frameParameters zstd_frame_parameters; - -/** - * struct zstd_parameters - zstd parameters - * @cParams: The compression parameters. - * @fParams: The frame parameters. - */ -typedef ZSTD_parameters zstd_parameters; - -/** - * zstd_get_params() - returns zstd_parameters for selected level - * @level: The compression level - * @estimated_src_size: The estimated source size to compress or 0 - * if unknown. - * - * Return: The selected zstd_parameters. - */ -zstd_parameters zstd_get_params(int level, - unsigned long long estimated_src_size); - -/* ====== Single-pass Compression ====== */ - -typedef ZSTD_CCtx zstd_cctx; - -/** - * zstd_cctx_workspace_bound() - max memory needed to initialize a zstd_cctx - * @parameters: The compression parameters to be used. - * - * If multiple compression parameters might be used, the caller must call - * zstd_cctx_workspace_bound() for each set of parameters and use the maximum - * size. - * - * Return: A lower bound on the size of the workspace that is passed to - * zstd_init_cctx(). - */ -size_t zstd_cctx_workspace_bound(const zstd_compression_parameters *parameters); - -/** - * zstd_init_cctx() - initialize a zstd compression context - * @workspace: The workspace to emplace the context into. It must outlive - * the returned context. - * @workspace_size: The size of workspace. Use zstd_cctx_workspace_bound() to - * determine how large the workspace must be. - * - * Return: A zstd compression context or NULL on error. - */ -zstd_cctx *zstd_init_cctx(void *workspace, size_t workspace_size); - -/** - * zstd_compress_cctx() - compress src into dst with the initialized parameters - * @cctx: The context. Must have been initialized with zstd_init_cctx(). - * @dst: The buffer to compress src into. - * @dst_capacity: The size of the destination buffer. May be any size, but - * ZSTD_compressBound(srcSize) is guaranteed to be large enough. - * @src: The data to compress. - * @src_size: The size of the data to compress. - * @parameters: The compression parameters to be used. - * - * Return: The compressed size or an error, which can be checked using - * zstd_is_error(). - */ -size_t zstd_compress_cctx(zstd_cctx *cctx, void *dst, size_t dst_capacity, - const void *src, size_t src_size, const zstd_parameters *parameters); - -/* ====== Single-pass Decompression ====== */ - -typedef ZSTD_DCtx zstd_dctx; - -/** - * zstd_dctx_workspace_bound() - max memory needed to initialize a zstd_dctx - * - * Return: A lower bound on the size of the workspace that is passed to - * zstd_init_dctx(). - */ -size_t zstd_dctx_workspace_bound(void); - -/** - * zstd_init_dctx() - initialize a zstd decompression context - * @workspace: The workspace to emplace the context into. It must outlive - * the returned context. - * @workspace_size: The size of workspace. Use zstd_dctx_workspace_bound() to - * determine how large the workspace must be. - * - * Return: A zstd decompression context or NULL on error. - */ -zstd_dctx *zstd_init_dctx(void *workspace, size_t workspace_size); - -/** - * zstd_decompress_dctx() - decompress zstd compressed src into dst - * @dctx: The decompression context. - * @dst: The buffer to decompress src into. - * @dst_capacity: The size of the destination buffer. Must be at least as large - * as the decompressed size. If the caller cannot upper bound the - * decompressed size, then it's better to use the streaming API. - * @src: The zstd compressed data to decompress. Multiple concatenated - * frames and skippable frames are allowed. - * @src_size: The exact size of the data to decompress. - * - * Return: The decompressed size or an error, which can be checked using - * zstd_is_error(). - */ -size_t zstd_decompress_dctx(zstd_dctx *dctx, void *dst, size_t dst_capacity, - const void *src, size_t src_size); - -/* ====== Streaming Buffers ====== */ - -/** - * struct zstd_in_buffer - input buffer for streaming - * @src: Start of the input buffer. - * @size: Size of the input buffer. - * @pos: Position where reading stopped. Will be updated. - * Necessarily 0 <= pos <= size. - * - * See zstd_lib.h. - */ -typedef ZSTD_inBuffer zstd_in_buffer; - -/** - * struct zstd_out_buffer - output buffer for streaming - * @dst: Start of the output buffer. - * @size: Size of the output buffer. - * @pos: Position where writing stopped. Will be updated. - * Necessarily 0 <= pos <= size. - * - * See zstd_lib.h. - */ -typedef ZSTD_outBuffer zstd_out_buffer; - -/* ====== Streaming Compression ====== */ - -typedef ZSTD_CStream zstd_cstream; - -/** - * zstd_cstream_workspace_bound() - memory needed to initialize a zstd_cstream - * @cparams: The compression parameters to be used for compression. - * - * Return: A lower bound on the size of the workspace that is passed to - * zstd_init_cstream(). - */ -size_t zstd_cstream_workspace_bound(const zstd_compression_parameters *cparams); - -/** - * zstd_init_cstream() - initialize a zstd streaming compression context - * @parameters The zstd parameters to use for compression. - * @pledged_src_size: If params.fParams.contentSizeFlag == 1 then the caller - * must pass the source size (zero means empty source). - * Otherwise, the caller may optionally pass the source - * size, or zero if unknown. - * @workspace: The workspace to emplace the context into. It must outlive - * the returned context. - * @workspace_size: The size of workspace. - * Use zstd_cstream_workspace_bound(params->cparams) to - * determine how large the workspace must be. - * - * Return: The zstd streaming compression context or NULL on error. - */ -zstd_cstream *zstd_init_cstream(const zstd_parameters *parameters, - unsigned long long pledged_src_size, void *workspace, size_t workspace_size); - -/** - * zstd_reset_cstream() - reset the context using parameters from creation - * @cstream: The zstd streaming compression context to reset. - * @pledged_src_size: Optionally the source size, or zero if unknown. - * - * Resets the context using the parameters from creation. Skips dictionary - * loading, since it can be reused. If `pledged_src_size` is non-zero the frame - * content size is always written into the frame header. - * - * Return: Zero or an error, which can be checked using - * zstd_is_error(). - */ -size_t zstd_reset_cstream(zstd_cstream *cstream, - unsigned long long pledged_src_size); - -/** - * zstd_compress_stream() - streaming compress some of input into output - * @cstream: The zstd streaming compression context. - * @output: Destination buffer. `output->pos` is updated to indicate how much - * compressed data was written. - * @input: Source buffer. `input->pos` is updated to indicate how much data - * was read. Note that it may not consume the entire input, in which - * case `input->pos < input->size`, and it's up to the caller to - * present remaining data again. - * - * The `input` and `output` buffers may be any size. Guaranteed to make some - * forward progress if `input` and `output` are not empty. - * - * Return: A hint for the number of bytes to use as the input for the next - * function call or an error, which can be checked using - * zstd_is_error(). - */ -size_t zstd_compress_stream(zstd_cstream *cstream, zstd_out_buffer *output, - zstd_in_buffer *input); - -/** - * zstd_flush_stream() - flush internal buffers into output - * @cstream: The zstd streaming compression context. - * @output: Destination buffer. `output->pos` is updated to indicate how much - * compressed data was written. - * - * zstd_flush_stream() must be called until it returns 0, meaning all the data - * has been flushed. Since zstd_flush_stream() causes a block to be ended, - * calling it too often will degrade the compression ratio. - * - * Return: The number of bytes still present within internal buffers or an - * error, which can be checked using zstd_is_error(). - */ -size_t zstd_flush_stream(zstd_cstream *cstream, zstd_out_buffer *output); - -/** - * zstd_end_stream() - flush internal buffers into output and end the frame - * @cstream: The zstd streaming compression context. - * @output: Destination buffer. `output->pos` is updated to indicate how much - * compressed data was written. - * - * zstd_end_stream() must be called until it returns 0, meaning all the data has - * been flushed and the frame epilogue has been written. - * - * Return: The number of bytes still present within internal buffers or an - * error, which can be checked using zstd_is_error(). - */ -size_t zstd_end_stream(zstd_cstream *cstream, zstd_out_buffer *output); - -/* ====== Streaming Decompression ====== */ - -typedef ZSTD_DStream zstd_dstream; - -/** - * zstd_dstream_workspace_bound() - memory needed to initialize a zstd_dstream - * @max_window_size: The maximum window size allowed for compressed frames. - * - * Return: A lower bound on the size of the workspace that is passed - * to zstd_init_dstream(). - */ -size_t zstd_dstream_workspace_bound(size_t max_window_size); - -/** - * zstd_init_dstream() - initialize a zstd streaming decompression context - * @max_window_size: The maximum window size allowed for compressed frames. - * @workspace: The workspace to emplace the context into. It must outlive - * the returned context. - * @workspaceSize: The size of workspace. - * Use zstd_dstream_workspace_bound(max_window_size) to - * determine how large the workspace must be. - * - * Return: The zstd streaming decompression context. - */ -zstd_dstream *zstd_init_dstream(size_t max_window_size, void *workspace, - size_t workspace_size); - -/** - * zstd_reset_dstream() - reset the context using parameters from creation - * @dstream: The zstd streaming decompression context to reset. - * - * Resets the context using the parameters from creation. Skips dictionary - * loading, since it can be reused. - * - * Return: Zero or an error, which can be checked using zstd_is_error(). - */ -size_t zstd_reset_dstream(zstd_dstream *dstream); - -/** - * zstd_decompress_stream() - streaming decompress some of input into output - * @dstream: The zstd streaming decompression context. - * @output: Destination buffer. `output.pos` is updated to indicate how much - * decompressed data was written. - * @input: Source buffer. `input.pos` is updated to indicate how much data was - * read. Note that it may not consume the entire input, in which case - * `input.pos < input.size`, and it's up to the caller to present - * remaining data again. - * - * The `input` and `output` buffers may be any size. Guaranteed to make some - * forward progress if `input` and `output` are not empty. - * zstd_decompress_stream() will not consume the last byte of the frame until - * the entire frame is flushed. - * - * Return: Returns 0 iff a frame is completely decoded and fully flushed. - * Otherwise returns a hint for the number of bytes to use as the - * input for the next function call or an error, which can be checked - * using zstd_is_error(). The size hint will never load more than the - * frame. - */ -size_t zstd_decompress_stream(zstd_dstream *dstream, zstd_out_buffer *output, - zstd_in_buffer *input); - -/* ====== Frame Inspection Functions ====== */ - -/** - * zstd_find_frame_compressed_size() - returns the size of a compressed frame - * @src: Source buffer. It should point to the start of a zstd encoded - * frame or a skippable frame. - * @src_size: The size of the source buffer. It must be at least as large as the - * size of the frame. - * - * Return: The compressed size of the frame pointed to by `src` or an error, - * which can be check with zstd_is_error(). - * Suitable to pass to ZSTD_decompress() or similar functions. - */ -size_t zstd_find_frame_compressed_size(const void *src, size_t src_size); - -/** - * struct zstd_frame_params - zstd frame parameters stored in the frame header - * @frameContentSize: The frame content size, or ZSTD_CONTENTSIZE_UNKNOWN if not - * present. - * @windowSize: The window size, or 0 if the frame is a skippable frame. - * @blockSizeMax: The maximum block size. - * @frameType: The frame type (zstd or skippable) - * @headerSize: The size of the frame header. - * @dictID: The dictionary id, or 0 if not present. - * @checksumFlag: Whether a checksum was used. - * - * See zstd_lib.h. - */ -typedef ZSTD_frameHeader zstd_frame_header; - -/** - * zstd_get_frame_header() - extracts parameters from a zstd or skippable frame - * @params: On success the frame parameters are written here. - * @src: The source buffer. It must point to a zstd or skippable frame. - * @src_size: The size of the source buffer. - * - * Return: 0 on success. If more data is required it returns how many bytes - * must be provided to make forward progress. Otherwise it returns - * an error, which can be checked using zstd_is_error(). - */ -size_t zstd_get_frame_header(zstd_frame_header *params, const void *src, - size_t src_size); - -#endif /* LINUX_ZSTD_H */ diff --git a/third_party/zstd/contrib/linux-kernel/mem.h b/third_party/zstd/contrib/linux-kernel/mem.h deleted file mode 100644 index 2e91e7780..000000000 --- a/third_party/zstd/contrib/linux-kernel/mem.h +++ /dev/null @@ -1,262 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under both the BSD-style license (found in the - * LICENSE file in the root directory of this source tree) and the GPLv2 (found - * in the COPYING file in the root directory of this source tree). - * You may select, at your option, one of the above-listed licenses. - */ - -#ifndef MEM_H_MODULE -#define MEM_H_MODULE - -/*-**************************************** -* Dependencies -******************************************/ -#include /* get_unaligned, put_unaligned* */ -#include /* inline */ -#include /* swab32, swab64 */ -#include /* size_t, ptrdiff_t */ -#include "debug.h" /* DEBUG_STATIC_ASSERT */ - -/*-**************************************** -* Compiler specifics -******************************************/ -#undef MEM_STATIC /* may be already defined from common/compiler.h */ -#define MEM_STATIC static inline - -/*-************************************************************** -* Basic Types -*****************************************************************/ -typedef uint8_t BYTE; -typedef uint8_t U8; -typedef int8_t S8; -typedef uint16_t U16; -typedef int16_t S16; -typedef uint32_t U32; -typedef int32_t S32; -typedef uint64_t U64; -typedef int64_t S64; - -/*-************************************************************** -* Memory I/O API -*****************************************************************/ -/*=== Static platform detection ===*/ -MEM_STATIC unsigned MEM_32bits(void); -MEM_STATIC unsigned MEM_64bits(void); -MEM_STATIC unsigned MEM_isLittleEndian(void); - -/*=== Native unaligned read/write ===*/ -MEM_STATIC U16 MEM_read16(const void* memPtr); -MEM_STATIC U32 MEM_read32(const void* memPtr); -MEM_STATIC U64 MEM_read64(const void* memPtr); -MEM_STATIC size_t MEM_readST(const void* memPtr); - -MEM_STATIC void MEM_write16(void* memPtr, U16 value); -MEM_STATIC void MEM_write32(void* memPtr, U32 value); -MEM_STATIC void MEM_write64(void* memPtr, U64 value); - -/*=== Little endian unaligned read/write ===*/ -MEM_STATIC U16 MEM_readLE16(const void* memPtr); -MEM_STATIC U32 MEM_readLE24(const void* memPtr); -MEM_STATIC U32 MEM_readLE32(const void* memPtr); -MEM_STATIC U64 MEM_readLE64(const void* memPtr); -MEM_STATIC size_t MEM_readLEST(const void* memPtr); - -MEM_STATIC void MEM_writeLE16(void* memPtr, U16 val); -MEM_STATIC void MEM_writeLE24(void* memPtr, U32 val); -MEM_STATIC void MEM_writeLE32(void* memPtr, U32 val32); -MEM_STATIC void MEM_writeLE64(void* memPtr, U64 val64); -MEM_STATIC void MEM_writeLEST(void* memPtr, size_t val); - -/*=== Big endian unaligned read/write ===*/ -MEM_STATIC U32 MEM_readBE32(const void* memPtr); -MEM_STATIC U64 MEM_readBE64(const void* memPtr); -MEM_STATIC size_t MEM_readBEST(const void* memPtr); - -MEM_STATIC void MEM_writeBE32(void* memPtr, U32 val32); -MEM_STATIC void MEM_writeBE64(void* memPtr, U64 val64); -MEM_STATIC void MEM_writeBEST(void* memPtr, size_t val); - -/*=== Byteswap ===*/ -MEM_STATIC U32 MEM_swap32(U32 in); -MEM_STATIC U64 MEM_swap64(U64 in); -MEM_STATIC size_t MEM_swapST(size_t in); - -/*-************************************************************** -* Memory I/O Implementation -*****************************************************************/ -MEM_STATIC unsigned MEM_32bits(void) -{ - return sizeof(size_t) == 4; -} - -MEM_STATIC unsigned MEM_64bits(void) -{ - return sizeof(size_t) == 8; -} - -#if defined(__LITTLE_ENDIAN) -#define MEM_LITTLE_ENDIAN 1 -#else -#define MEM_LITTLE_ENDIAN 0 -#endif - -MEM_STATIC unsigned MEM_isLittleEndian(void) -{ - return MEM_LITTLE_ENDIAN; -} - -MEM_STATIC U16 MEM_read16(const void *memPtr) -{ - return get_unaligned((const U16 *)memPtr); -} - -MEM_STATIC U32 MEM_read32(const void *memPtr) -{ - return get_unaligned((const U32 *)memPtr); -} - -MEM_STATIC U64 MEM_read64(const void *memPtr) -{ - return get_unaligned((const U64 *)memPtr); -} - -MEM_STATIC size_t MEM_readST(const void *memPtr) -{ - return get_unaligned((const size_t *)memPtr); -} - -MEM_STATIC void MEM_write16(void *memPtr, U16 value) -{ - put_unaligned(value, (U16 *)memPtr); -} - -MEM_STATIC void MEM_write32(void *memPtr, U32 value) -{ - put_unaligned(value, (U32 *)memPtr); -} - -MEM_STATIC void MEM_write64(void *memPtr, U64 value) -{ - put_unaligned(value, (U64 *)memPtr); -} - -/*=== Little endian r/w ===*/ - -MEM_STATIC U16 MEM_readLE16(const void *memPtr) -{ - return get_unaligned_le16(memPtr); -} - -MEM_STATIC void MEM_writeLE16(void *memPtr, U16 val) -{ - put_unaligned_le16(val, memPtr); -} - -MEM_STATIC U32 MEM_readLE24(const void *memPtr) -{ - return MEM_readLE16(memPtr) + (((const BYTE *)memPtr)[2] << 16); -} - -MEM_STATIC void MEM_writeLE24(void *memPtr, U32 val) -{ - MEM_writeLE16(memPtr, (U16)val); - ((BYTE *)memPtr)[2] = (BYTE)(val >> 16); -} - -MEM_STATIC U32 MEM_readLE32(const void *memPtr) -{ - return get_unaligned_le32(memPtr); -} - -MEM_STATIC void MEM_writeLE32(void *memPtr, U32 val32) -{ - put_unaligned_le32(val32, memPtr); -} - -MEM_STATIC U64 MEM_readLE64(const void *memPtr) -{ - return get_unaligned_le64(memPtr); -} - -MEM_STATIC void MEM_writeLE64(void *memPtr, U64 val64) -{ - put_unaligned_le64(val64, memPtr); -} - -MEM_STATIC size_t MEM_readLEST(const void *memPtr) -{ - if (MEM_32bits()) - return (size_t)MEM_readLE32(memPtr); - else - return (size_t)MEM_readLE64(memPtr); -} - -MEM_STATIC void MEM_writeLEST(void *memPtr, size_t val) -{ - if (MEM_32bits()) - MEM_writeLE32(memPtr, (U32)val); - else - MEM_writeLE64(memPtr, (U64)val); -} - -/*=== Big endian r/w ===*/ - -MEM_STATIC U32 MEM_readBE32(const void *memPtr) -{ - return get_unaligned_be32(memPtr); -} - -MEM_STATIC void MEM_writeBE32(void *memPtr, U32 val32) -{ - put_unaligned_be32(val32, memPtr); -} - -MEM_STATIC U64 MEM_readBE64(const void *memPtr) -{ - return get_unaligned_be64(memPtr); -} - -MEM_STATIC void MEM_writeBE64(void *memPtr, U64 val64) -{ - put_unaligned_be64(val64, memPtr); -} - -MEM_STATIC size_t MEM_readBEST(const void *memPtr) -{ - if (MEM_32bits()) - return (size_t)MEM_readBE32(memPtr); - else - return (size_t)MEM_readBE64(memPtr); -} - -MEM_STATIC void MEM_writeBEST(void *memPtr, size_t val) -{ - if (MEM_32bits()) - MEM_writeBE32(memPtr, (U32)val); - else - MEM_writeBE64(memPtr, (U64)val); -} - -MEM_STATIC U32 MEM_swap32(U32 in) -{ - return swab32(in); -} - -MEM_STATIC U64 MEM_swap64(U64 in) -{ - return swab64(in); -} - -MEM_STATIC size_t MEM_swapST(size_t in) -{ - if (MEM_32bits()) - return (size_t)MEM_swap32((U32)in); - else - return (size_t)MEM_swap64((U64)in); -} - -#endif /* MEM_H_MODULE */ diff --git a/third_party/zstd/contrib/linux-kernel/squashfs-benchmark.sh b/third_party/zstd/contrib/linux-kernel/squashfs-benchmark.sh deleted file mode 100755 index 02dfd7325..000000000 --- a/third_party/zstd/contrib/linux-kernel/squashfs-benchmark.sh +++ /dev/null @@ -1,39 +0,0 @@ -# !/bin/sh -set -e - -# Benchmarks run on a Ubuntu 14.04 VM with 2 cores and 4 GiB of RAM. -# The VM is running on a Macbook Pro with a 3.1 GHz Intel Core i7 processor and -# 16 GB of RAM and an SSD. - -# $BENCHMARK_DIR is generated with the following commands, from the Ubuntu image -# ubuntu-16.10-desktop-amd64.iso. -# > mkdir mnt -# > sudo mount -o loop ubuntu-16.10-desktop-amd64.iso mnt -# > cp mnt/casper/filesystem.squashfs . -# > sudo unsquashfs filesystem.squashfs - -# $HOME is on a ext4 filesystem -BENCHMARK_DIR="$HOME/squashfs-root/" -BENCHMARK_FS="$HOME/filesystem.squashfs" - -# Normalize the environment -sudo rm -f $BENCHMARK_FS 2> /dev/null > /dev/null || true -sudo umount /mnt/squashfs 2> /dev/null > /dev/null || true - -# Run the benchmark -echo "Compression" -echo "sudo mksquashfs $BENCHMARK_DIR $BENCHMARK_FS $@" -time sudo mksquashfs $BENCHMARK_DIR $BENCHMARK_FS $@ 2> /dev/null > /dev/null - -echo "Approximate compression ratio" -printf "%d / %d\n" \ - $(sudo du -sx --block-size=1 $BENCHMARK_DIR | cut -f1) \ - $(sudo du -sx --block-size=1 $BENCHMARK_FS | cut -f1); - -# Mount the filesystem -sudo mount -t squashfs $BENCHMARK_FS /mnt/squashfs - -echo "Decompression" -time sudo tar -c /mnt/squashfs 2> /dev/null | wc -c > /dev/null - -sudo umount /mnt/squashfs diff --git a/third_party/zstd/contrib/linux-kernel/test/Makefile b/third_party/zstd/contrib/linux-kernel/test/Makefile deleted file mode 100644 index 67b55e665..000000000 --- a/third_party/zstd/contrib/linux-kernel/test/Makefile +++ /dev/null @@ -1,49 +0,0 @@ -# ################################################################ -# Copyright (c) Meta Platforms, Inc. and affiliates. -# All rights reserved. -# -# This source code is licensed under both the BSD-style license (found in the -# LICENSE file in the root directory of this source tree) and the GPLv2 (found -# in the COPYING file in the root directory of this source tree). -# You may select, at your option, one of the above-listed licenses. -# ################################################################ - -LINUX := ../linux -LINUX_ZSTDLIB := $(LINUX)/lib/zstd - -CPPFLAGS += -I$(LINUX)/include -I$(LINUX_ZSTDLIB) -Iinclude -DNDEBUG -Wno-deprecated-declarations -# Don't poison the workspace, it currently doesn't work with static allocation and workspace reuse -CPPFLAGS += -DZSTD_ASAN_DONT_POISON_WORKSPACE - -LINUX_ZSTD_MODULE := $(wildcard $(LINUX_ZSTDLIB)/*.c) -LINUX_ZSTD_COMMON := $(wildcard $(LINUX_ZSTDLIB)/common/*.c) -LINUX_ZSTD_COMPRESS := $(wildcard $(LINUX_ZSTDLIB)/compress/*.c) -LINUX_ZSTD_DECOMPRESS := $(wildcard $(LINUX_ZSTDLIB)/decompress/*.c $(LINUX_ZSTDLIB)/decompress/*.S) -LINUX_ZSTD_FILES := $(LINUX_ZSTD_MODULE) $(LINUX_ZSTD_COMMON) $(LINUX_ZSTD_COMPRESS) $(LINUX_ZSTD_DECOMPRESS) -LINUX_ZSTD_OBJECTS0 := $(LINUX_ZSTD_FILES:.c=.o) -LINUX_ZSTD_OBJECTS := $(LINUX_ZSTD_OBJECTS0:.S=.o) - -%.o: %.S - $(COMPILE.S) $(OUTPUT_OPTION) $< - -liblinuxzstd.a: $(LINUX_ZSTD_OBJECTS) - $(AR) $(ARFLAGS) $@ $^ - -test: test.c liblinuxzstd.a - $(CC) $(LDFLAGS) $(CPPFLAGS) $(CFLAGS) $^ -o $@ - -static_test: static_test.c - $(CC) $(LDFLAGS) $(CPPFLAGS) $(CFLAGS) $^ -o $@ - -run-test: test static_test - ./macro-test.sh - ./test - ./static_test - -.PHONY: -clean: - $(RM) -f $(LINUX_ZSTDLIB)/*.o - $(RM) -f $(LINUX_ZSTDLIB)/**/*.o - $(RM) -f *.o *.a - $(RM) -f static_test - $(RM) -f test diff --git a/third_party/zstd/contrib/linux-kernel/test/include/asm/unaligned.h b/third_party/zstd/contrib/linux-kernel/test/include/asm/unaligned.h deleted file mode 100644 index 86ec4ca38..000000000 --- a/third_party/zstd/contrib/linux-kernel/test/include/asm/unaligned.h +++ /dev/null @@ -1,187 +0,0 @@ -#ifndef ASM_UNALIGNED_H -#define ASM_UNALIGNED_H - -#include -#include - -#ifndef __LITTLE_ENDIAN -# if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) || defined(__LITTLE_ENDIAN__) -# define __LITTLE_ENDIAN 1 -# endif -#endif - -#ifdef __LITTLE_ENDIAN -# define _IS_LITTLE_ENDIAN 1 -#else -# define _IS_LITTLE_ENDIAN 0 -#endif - -static unsigned _isLittleEndian(void) -{ - const union { uint32_t u; uint8_t c[4]; } one = { 1 }; - assert(_IS_LITTLE_ENDIAN == one.c[0]); - (void)one; - return _IS_LITTLE_ENDIAN; -} - -static uint16_t _swap16(uint16_t in) -{ - return ((in & 0xF) << 8) + ((in & 0xF0) >> 8); -} - -static uint32_t _swap32(uint32_t in) -{ - return __builtin_bswap32(in); -} - -static uint64_t _swap64(uint64_t in) -{ - return __builtin_bswap64(in); -} - -/* Little endian */ -static uint16_t get_unaligned_le16(const void* memPtr) -{ - uint16_t val; - __builtin_memcpy(&val, memPtr, sizeof(val)); - if (!_isLittleEndian()) _swap16(val); - return val; -} - -static uint32_t get_unaligned_le32(const void* memPtr) -{ - uint32_t val; - __builtin_memcpy(&val, memPtr, sizeof(val)); - if (!_isLittleEndian()) _swap32(val); - return val; -} - -static uint64_t get_unaligned_le64(const void* memPtr) -{ - uint64_t val; - __builtin_memcpy(&val, memPtr, sizeof(val)); - if (!_isLittleEndian()) _swap64(val); - return val; -} - -static void put_unaligned_le16(uint16_t value, void* memPtr) -{ - if (!_isLittleEndian()) value = _swap16(value); - __builtin_memcpy(memPtr, &value, sizeof(value)); -} - -static void put_unaligned_le32(uint32_t value, void* memPtr) -{ - if (!_isLittleEndian()) value = _swap32(value); - __builtin_memcpy(memPtr, &value, sizeof(value)); -} - -static void put_unaligned_le64(uint64_t value, void* memPtr) -{ - if (!_isLittleEndian()) value = _swap64(value); - __builtin_memcpy(memPtr, &value, sizeof(value)); -} - -/* big endian */ -static uint32_t get_unaligned_be32(const void* memPtr) -{ - uint32_t val; - __builtin_memcpy(&val, memPtr, sizeof(val)); - if (_isLittleEndian()) _swap32(val); - return val; -} - -static uint64_t get_unaligned_be64(const void* memPtr) -{ - uint64_t val; - __builtin_memcpy(&val, memPtr, sizeof(val)); - if (_isLittleEndian()) _swap64(val); - return val; -} - -static void put_unaligned_be32(uint32_t value, void* memPtr) -{ - if (_isLittleEndian()) value = _swap32(value); - __builtin_memcpy(memPtr, &value, sizeof(value)); -} - -static void put_unaligned_be64(uint64_t value, void* memPtr) -{ - if (_isLittleEndian()) value = _swap64(value); - __builtin_memcpy(memPtr, &value, sizeof(value)); -} - -/* generic */ -extern void __bad_unaligned_access_size(void); - -#define __get_unaligned_le(ptr) ((typeof(*(ptr)))({ \ - __builtin_choose_expr(sizeof(*(ptr)) == 1, *(ptr), \ - __builtin_choose_expr(sizeof(*(ptr)) == 2, get_unaligned_le16((ptr)), \ - __builtin_choose_expr(sizeof(*(ptr)) == 4, get_unaligned_le32((ptr)), \ - __builtin_choose_expr(sizeof(*(ptr)) == 8, get_unaligned_le64((ptr)), \ - __bad_unaligned_access_size())))); \ - })) - -#define __get_unaligned_be(ptr) ((typeof(*(ptr)))({ \ - __builtin_choose_expr(sizeof(*(ptr)) == 1, *(ptr), \ - __builtin_choose_expr(sizeof(*(ptr)) == 2, get_unaligned_be16((ptr)), \ - __builtin_choose_expr(sizeof(*(ptr)) == 4, get_unaligned_be32((ptr)), \ - __builtin_choose_expr(sizeof(*(ptr)) == 8, get_unaligned_be64((ptr)), \ - __bad_unaligned_access_size())))); \ - })) - -#define __put_unaligned_le(val, ptr) \ - ({ \ - void *__gu_p = (ptr); \ - switch (sizeof(*(ptr))) { \ - case 1: \ - *(uint8_t *)__gu_p = (uint8_t)(val); \ - break; \ - case 2: \ - put_unaligned_le16((uint16_t)(val), __gu_p); \ - break; \ - case 4: \ - put_unaligned_le32((uint32_t)(val), __gu_p); \ - break; \ - case 8: \ - put_unaligned_le64((uint64_t)(val), __gu_p); \ - break; \ - default: \ - __bad_unaligned_access_size(); \ - break; \ - } \ - (void)0; \ - }) - -#define __put_unaligned_be(val, ptr) \ - ({ \ - void *__gu_p = (ptr); \ - switch (sizeof(*(ptr))) { \ - case 1: \ - *(uint8_t *)__gu_p = (uint8_t)(val); \ - break; \ - case 2: \ - put_unaligned_be16((uint16_t)(val), __gu_p); \ - break; \ - case 4: \ - put_unaligned_be32((uint32_t)(val), __gu_p); \ - break; \ - case 8: \ - put_unaligned_be64((uint64_t)(val), __gu_p); \ - break; \ - default: \ - __bad_unaligned_access_size(); \ - break; \ - } \ - (void)0; \ - }) - -#if _IS_LITTLE_ENDIAN -# define get_unaligned __get_unaligned_le -# define put_unaligned __put_unaligned_le -#else -# define get_unaligned __get_unaligned_be -# define put_unaligned __put_unaligned_be -#endif - -#endif // ASM_UNALIGNED_H diff --git a/third_party/zstd/contrib/linux-kernel/test/include/linux/compiler.h b/third_party/zstd/contrib/linux-kernel/test/include/linux/compiler.h deleted file mode 100644 index 988ce4a20..000000000 --- a/third_party/zstd/contrib/linux-kernel/test/include/linux/compiler.h +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under both the BSD-style license (found in the - * LICENSE file in the root directory of this source tree) and the GPLv2 (found - * in the COPYING file in the root directory of this source tree). - * You may select, at your option, one of the above-listed licenses. - */ -#ifndef LINUX_COMPILER_H -#define LINUX_COMPILER_H - -#ifndef inline -#define inline __inline __attribute__((unused)) -#endif - -#ifndef noinline -#define noinline __attribute__((noinline)) -#endif - -#define fallthrough __attribute__((__fallthrough__)) - -#endif diff --git a/third_party/zstd/contrib/linux-kernel/test/include/linux/errno.h b/third_party/zstd/contrib/linux-kernel/test/include/linux/errno.h deleted file mode 100644 index b4bdcba0e..000000000 --- a/third_party/zstd/contrib/linux-kernel/test/include/linux/errno.h +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under both the BSD-style license (found in the - * LICENSE file in the root directory of this source tree) and the GPLv2 (found - * in the COPYING file in the root directory of this source tree). - * You may select, at your option, one of the above-listed licenses. - */ -#ifndef LINUX_ERRNO_H -#define LINUX_ERRNO_H - -#define EINVAL 22 - -#endif diff --git a/third_party/zstd/contrib/linux-kernel/test/include/linux/kernel.h b/third_party/zstd/contrib/linux-kernel/test/include/linux/kernel.h deleted file mode 100644 index a4d791cd1..000000000 --- a/third_party/zstd/contrib/linux-kernel/test/include/linux/kernel.h +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under both the BSD-style license (found in the - * LICENSE file in the root directory of this source tree) and the GPLv2 (found - * in the COPYING file in the root directory of this source tree). - * You may select, at your option, one of the above-listed licenses. - */ -#ifndef LINUX_KERNEL_H -#define LINUX_KERNEL_H - -#define WARN_ON(x) - -#define PTR_ALIGN(p, a) (typeof(p))ALIGN((unsigned long long)(p), (a)) -#define ALIGN(x, a) ALIGN_MASK((x), (a) - 1) -#define ALIGN_MASK(x, mask) (((x) + (mask)) & ~(mask)) - -#endif diff --git a/third_party/zstd/contrib/linux-kernel/test/include/linux/limits.h b/third_party/zstd/contrib/linux-kernel/test/include/linux/limits.h deleted file mode 100644 index 574aa7b34..000000000 --- a/third_party/zstd/contrib/linux-kernel/test/include/linux/limits.h +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under both the BSD-style license (found in the - * LICENSE file in the root directory of this source tree) and the GPLv2 (found - * in the COPYING file in the root directory of this source tree). - * You may select, at your option, one of the above-listed licenses. - */ -#ifndef LINUX_LIMITS_H -#define LINUX_LIMITS_H - -#include - -#endif diff --git a/third_party/zstd/contrib/linux-kernel/test/include/linux/math64.h b/third_party/zstd/contrib/linux-kernel/test/include/linux/math64.h deleted file mode 100644 index 7f6713e73..000000000 --- a/third_party/zstd/contrib/linux-kernel/test/include/linux/math64.h +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under both the BSD-style license (found in the - * LICENSE file in the root directory of this source tree) and the GPLv2 (found - * in the COPYING file in the root directory of this source tree). - * You may select, at your option, one of the above-listed licenses. - */ -#ifndef LINUX_MATH64_H -#define LINUX_MATH64_H - -#define div_u64(dividend, divisor) ((dividend) / (divisor)) - -#endif diff --git a/third_party/zstd/contrib/linux-kernel/test/include/linux/module.h b/third_party/zstd/contrib/linux-kernel/test/include/linux/module.h deleted file mode 100644 index 06ef56f9e..000000000 --- a/third_party/zstd/contrib/linux-kernel/test/include/linux/module.h +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under both the BSD-style license (found in the - * LICENSE file in the root directory of this source tree) and the GPLv2 (found - * in the COPYING file in the root directory of this source tree). - * You may select, at your option, one of the above-listed licenses. - */ -#ifndef LINUX_MODULE_H -#define LINUX_MODULE_H - -#define EXPORT_SYMBOL(symbol) \ - void* __##symbol = symbol -#define EXPORT_SYMBOL_GPL(symbol) \ - void* __##symbol = symbol -#define MODULE_LICENSE(license) -#define MODULE_DESCRIPTION(description) - -#endif diff --git a/third_party/zstd/contrib/linux-kernel/test/include/linux/printk.h b/third_party/zstd/contrib/linux-kernel/test/include/linux/printk.h deleted file mode 100644 index 92a25278e..000000000 --- a/third_party/zstd/contrib/linux-kernel/test/include/linux/printk.h +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under both the BSD-style license (found in the - * LICENSE file in the root directory of this source tree) and the GPLv2 (found - * in the COPYING file in the root directory of this source tree). - * You may select, at your option, one of the above-listed licenses. - */ -#ifndef LINUX_PRINTK_H -#define LINUX_PRINTK_H - -#define pr_debug(...) - -#endif diff --git a/third_party/zstd/contrib/linux-kernel/test/include/linux/stddef.h b/third_party/zstd/contrib/linux-kernel/test/include/linux/stddef.h deleted file mode 100644 index 15c7408fc..000000000 --- a/third_party/zstd/contrib/linux-kernel/test/include/linux/stddef.h +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under both the BSD-style license (found in the - * LICENSE file in the root directory of this source tree) and the GPLv2 (found - * in the COPYING file in the root directory of this source tree). - * You may select, at your option, one of the above-listed licenses. - */ -#ifndef LINUX_STDDEF_H -#define LINUX_STDDEF_H - -#include - -#endif diff --git a/third_party/zstd/contrib/linux-kernel/test/include/linux/swab.h b/third_party/zstd/contrib/linux-kernel/test/include/linux/swab.h deleted file mode 100644 index 2b48b434c..000000000 --- a/third_party/zstd/contrib/linux-kernel/test/include/linux/swab.h +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under both the BSD-style license (found in the - * LICENSE file in the root directory of this source tree) and the GPLv2 (found - * in the COPYING file in the root directory of this source tree). - * You may select, at your option, one of the above-listed licenses. - */ -#ifndef LINUX_SWAB_H -#define LINUX_SWAB_H - -#define swab32(x) __builtin_bswap32((x)) -#define swab64(x) __builtin_bswap64((x)) - -#endif diff --git a/third_party/zstd/contrib/linux-kernel/test/include/linux/types.h b/third_party/zstd/contrib/linux-kernel/test/include/linux/types.h deleted file mode 100644 index b413db6f9..000000000 --- a/third_party/zstd/contrib/linux-kernel/test/include/linux/types.h +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under both the BSD-style license (found in the - * LICENSE file in the root directory of this source tree) and the GPLv2 (found - * in the COPYING file in the root directory of this source tree). - * You may select, at your option, one of the above-listed licenses. - */ -#ifndef LINUX_TYPES_H -#define LINUX_TYPES_H - -#include -#include - -#endif diff --git a/third_party/zstd/contrib/linux-kernel/test/include/linux/xxhash.h b/third_party/zstd/contrib/linux-kernel/test/include/linux/xxhash.h deleted file mode 100644 index d41cbd933..000000000 --- a/third_party/zstd/contrib/linux-kernel/test/include/linux/xxhash.h +++ /dev/null @@ -1,745 +0,0 @@ -/* - * xxHash - Extremely Fast Hash algorithm - * Copyright (C) 2012-2016, Yann Collet. - * - * BSD 2-Clause License (https://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. - * - * This program is free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License version 2 as published by the - * Free Software Foundation. This program is dual-licensed; you may select - * either version 2 of the GNU General Public License ("GPL") or BSD license - * ("BSD"). - * - * You can contact the author at: - * - xxHash homepage: https://cyan4973.github.io/xxHash/ - * - xxHash source repository: https://github.com/Cyan4973/xxHash - */ - -/* - * Notice extracted from xxHash homepage: - * - * xxHash is an extremely fast Hash algorithm, running at RAM speed limits. - * It also successfully passes all tests from the SMHasher suite. - * - * Comparison (single thread, Windows Seven 32 bits, using SMHasher on a Core 2 - * Duo @3GHz) - * - * Name Speed Q.Score Author - * xxHash 5.4 GB/s 10 - * CrapWow 3.2 GB/s 2 Andrew - * MumurHash 3a 2.7 GB/s 10 Austin Appleby - * SpookyHash 2.0 GB/s 10 Bob Jenkins - * SBox 1.4 GB/s 9 Bret Mulvey - * Lookup3 1.2 GB/s 9 Bob Jenkins - * SuperFastHash 1.2 GB/s 1 Paul Hsieh - * CityHash64 1.05 GB/s 10 Pike & Alakuijala - * FNV 0.55 GB/s 5 Fowler, Noll, Vo - * CRC32 0.43 GB/s 9 - * MD5-32 0.33 GB/s 10 Ronald L. Rivest - * SHA1-32 0.28 GB/s 10 - * - * Q.Score is a measure of quality of the hash function. - * It depends on successfully passing SMHasher test set. - * 10 is a perfect score. - * - * A 64-bits version, named xxh64 offers much better speed, - * but for 64-bits applications only. - * Name Speed on 64 bits Speed on 32 bits - * xxh64 13.8 GB/s 1.9 GB/s - * xxh32 6.8 GB/s 6.0 GB/s - */ - -#ifndef XXHASH_H -#define XXHASH_H - -#include - -#define XXH_API static inline __attribute__((unused)) -/*-**************************** - * Simple Hash Functions - *****************************/ - -/** - * xxh32() - calculate the 32-bit hash of the input with a given seed. - * - * @input: The data to hash. - * @length: The length of the data to hash. - * @seed: The seed can be used to alter the result predictably. - * - * Speed on Core 2 Duo @ 3 GHz (single thread, SMHasher benchmark) : 5.4 GB/s - * - * Return: The 32-bit hash of the data. - */ -XXH_API uint32_t xxh32(const void *input, size_t length, uint32_t seed); - -/** - * xxh64() - calculate the 64-bit hash of the input with a given seed. - * - * @input: The data to hash. - * @length: The length of the data to hash. - * @seed: The seed can be used to alter the result predictably. - * - * This function runs 2x faster on 64-bit systems, but slower on 32-bit systems. - * - * Return: The 64-bit hash of the data. - */ -XXH_API uint64_t xxh64(const void *input, size_t length, uint64_t seed); - -/** - * xxhash() - calculate wordsize hash of the input with a given seed - * @input: The data to hash. - * @length: The length of the data to hash. - * @seed: The seed can be used to alter the result predictably. - * - * If the hash does not need to be comparable between machines with - * different word sizes, this function will call whichever of xxh32() - * or xxh64() is faster. - * - * Return: wordsize hash of the data. - */ - -static inline unsigned long xxhash(const void *input, size_t length, - uint64_t seed) -{ - if (sizeof(size_t) == 8) - return xxh64(input, length, seed); - else - return xxh32(input, length, seed); -} - -/*-**************************** - * Streaming Hash Functions - *****************************/ - -/* - * These definitions are only meant to allow allocation of XXH state - * statically, on stack, or in a struct for example. - * Do not use members directly. - */ - -/** - * struct xxh32_state - private xxh32 state, do not use members directly - */ -struct xxh32_state { - uint32_t total_len_32; - uint32_t large_len; - uint32_t v1; - uint32_t v2; - uint32_t v3; - uint32_t v4; - uint32_t mem32[4]; - uint32_t memsize; -}; - -/** - * struct xxh32_state - private xxh64 state, do not use members directly - */ -struct xxh64_state { - uint64_t total_len; - uint64_t v1; - uint64_t v2; - uint64_t v3; - uint64_t v4; - uint64_t mem64[4]; - uint32_t memsize; -}; - -/** - * xxh32_reset() - reset the xxh32 state to start a new hashing operation - * - * @state: The xxh32 state to reset. - * @seed: Initialize the hash state with this seed. - * - * Call this function on any xxh32_state to prepare for a new hashing operation. - */ -XXH_API void xxh32_reset(struct xxh32_state *state, uint32_t seed); - -/** - * xxh32_update() - hash the data given and update the xxh32 state - * - * @state: The xxh32 state to update. - * @input: The data to hash. - * @length: The length of the data to hash. - * - * After calling xxh32_reset() call xxh32_update() as many times as necessary. - * - * Return: Zero on success, otherwise an error code. - */ -XXH_API int xxh32_update(struct xxh32_state *state, const void *input, size_t length); - -/** - * xxh32_digest() - produce the current xxh32 hash - * - * @state: Produce the current xxh32 hash of this state. - * - * A hash value can be produced at any time. It is still possible to continue - * inserting input into the hash state after a call to xxh32_digest(), and - * generate new hashes later on, by calling xxh32_digest() again. - * - * Return: The xxh32 hash stored in the state. - */ -XXH_API uint32_t xxh32_digest(const struct xxh32_state *state); - -/** - * xxh64_reset() - reset the xxh64 state to start a new hashing operation - * - * @state: The xxh64 state to reset. - * @seed: Initialize the hash state with this seed. - */ -XXH_API void xxh64_reset(struct xxh64_state *state, uint64_t seed); - -/** - * xxh64_update() - hash the data given and update the xxh64 state - * @state: The xxh64 state to update. - * @input: The data to hash. - * @length: The length of the data to hash. - * - * After calling xxh64_reset() call xxh64_update() as many times as necessary. - * - * Return: Zero on success, otherwise an error code. - */ -XXH_API int xxh64_update(struct xxh64_state *state, const void *input, size_t length); - -/** - * xxh64_digest() - produce the current xxh64 hash - * - * @state: Produce the current xxh64 hash of this state. - * - * A hash value can be produced at any time. It is still possible to continue - * inserting input into the hash state after a call to xxh64_digest(), and - * generate new hashes later on, by calling xxh64_digest() again. - * - * Return: The xxh64 hash stored in the state. - */ -XXH_API uint64_t xxh64_digest(const struct xxh64_state *state); - -/*-************************** - * Utils - ***************************/ - -/** - * xxh32_copy_state() - copy the source state into the destination state - * - * @src: The source xxh32 state. - * @dst: The destination xxh32 state. - */ -XXH_API void xxh32_copy_state(struct xxh32_state *dst, const struct xxh32_state *src); - -/** - * xxh64_copy_state() - copy the source state into the destination state - * - * @src: The source xxh64 state. - * @dst: The destination xxh64 state. - */ -XXH_API void xxh64_copy_state(struct xxh64_state *dst, const struct xxh64_state *src); - -/* - * xxHash - Extremely Fast Hash algorithm - * Copyright (C) 2012-2016, Yann Collet. - * - * BSD 2-Clause License (https://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. - * - * This program is free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License version 2 as published by the - * Free Software Foundation. This program is dual-licensed; you may select - * either version 2 of the GNU General Public License ("GPL") or BSD license - * ("BSD"). - * - * You can contact the author at: - * - xxHash homepage: https://cyan4973.github.io/xxHash/ - * - xxHash source repository: https://github.com/Cyan4973/xxHash - */ - -#include -#include -#include -#include -#include - -/*-************************************* - * Macros - **************************************/ -#define xxh_rotl32(x, r) ((x << r) | (x >> (32 - r))) -#define xxh_rotl64(x, r) ((x << r) | (x >> (64 - r))) - -#ifdef __LITTLE_ENDIAN -# define XXH_CPU_LITTLE_ENDIAN 1 -#else -# define XXH_CPU_LITTLE_ENDIAN 0 -#endif - -/*-************************************* - * Constants - **************************************/ -static const uint32_t PRIME32_1 = 2654435761U; -static const uint32_t PRIME32_2 = 2246822519U; -static const uint32_t PRIME32_3 = 3266489917U; -static const uint32_t PRIME32_4 = 668265263U; -static const uint32_t PRIME32_5 = 374761393U; - -static const uint64_t PRIME64_1 = 11400714785074694791ULL; -static const uint64_t PRIME64_2 = 14029467366897019727ULL; -static const uint64_t PRIME64_3 = 1609587929392839161ULL; -static const uint64_t PRIME64_4 = 9650029242287828579ULL; -static const uint64_t PRIME64_5 = 2870177450012600261ULL; - -/*-************************** - * Utils - ***************************/ -XXH_API void xxh32_copy_state(struct xxh32_state *dst, const struct xxh32_state *src) -{ - __builtin_memcpy(dst, src, sizeof(*dst)); -} - -XXH_API void xxh64_copy_state(struct xxh64_state *dst, const struct xxh64_state *src) -{ - __builtin_memcpy(dst, src, sizeof(*dst)); -} - -/*-*************************** - * Simple Hash Functions - ****************************/ -static uint32_t xxh32_round(uint32_t seed, const uint32_t input) -{ - seed += input * PRIME32_2; - seed = xxh_rotl32(seed, 13); - seed *= PRIME32_1; - return seed; -} - -XXH_API uint32_t xxh32(const void *input, const size_t len, const uint32_t seed) -{ - const uint8_t *p = (const uint8_t *)input; - const uint8_t *b_end = p + len; - uint32_t h32; - - if (len >= 16) { - const uint8_t *const limit = b_end - 16; - uint32_t v1 = seed + PRIME32_1 + PRIME32_2; - uint32_t v2 = seed + PRIME32_2; - uint32_t v3 = seed + 0; - uint32_t v4 = seed - PRIME32_1; - - do { - v1 = xxh32_round(v1, get_unaligned_le32(p)); - p += 4; - v2 = xxh32_round(v2, get_unaligned_le32(p)); - p += 4; - v3 = xxh32_round(v3, get_unaligned_le32(p)); - p += 4; - v4 = xxh32_round(v4, get_unaligned_le32(p)); - p += 4; - } while (p <= limit); - - h32 = xxh_rotl32(v1, 1) + xxh_rotl32(v2, 7) + - xxh_rotl32(v3, 12) + xxh_rotl32(v4, 18); - } else { - h32 = seed + PRIME32_5; - } - - h32 += (uint32_t)len; - - while (p + 4 <= b_end) { - h32 += get_unaligned_le32(p) * PRIME32_3; - h32 = xxh_rotl32(h32, 17) * PRIME32_4; - p += 4; - } - - while (p < b_end) { - h32 += (*p) * PRIME32_5; - h32 = xxh_rotl32(h32, 11) * PRIME32_1; - p++; - } - - h32 ^= h32 >> 15; - h32 *= PRIME32_2; - h32 ^= h32 >> 13; - h32 *= PRIME32_3; - h32 ^= h32 >> 16; - - return h32; -} - -static uint64_t xxh64_round(uint64_t acc, const uint64_t input) -{ - acc += input * PRIME64_2; - acc = xxh_rotl64(acc, 31); - acc *= PRIME64_1; - return acc; -} - -static uint64_t xxh64_merge_round(uint64_t acc, uint64_t val) -{ - val = xxh64_round(0, val); - acc ^= val; - acc = acc * PRIME64_1 + PRIME64_4; - return acc; -} - -XXH_API uint64_t xxh64(const void *input, const size_t len, const uint64_t seed) -{ - const uint8_t *p = (const uint8_t *)input; - const uint8_t *const b_end = p + len; - uint64_t h64; - - if (len >= 32) { - const uint8_t *const limit = b_end - 32; - uint64_t v1 = seed + PRIME64_1 + PRIME64_2; - uint64_t v2 = seed + PRIME64_2; - uint64_t v3 = seed + 0; - uint64_t v4 = seed - PRIME64_1; - - do { - v1 = xxh64_round(v1, get_unaligned_le64(p)); - p += 8; - v2 = xxh64_round(v2, get_unaligned_le64(p)); - p += 8; - v3 = xxh64_round(v3, get_unaligned_le64(p)); - p += 8; - v4 = xxh64_round(v4, get_unaligned_le64(p)); - p += 8; - } while (p <= limit); - - h64 = xxh_rotl64(v1, 1) + xxh_rotl64(v2, 7) + - xxh_rotl64(v3, 12) + xxh_rotl64(v4, 18); - h64 = xxh64_merge_round(h64, v1); - h64 = xxh64_merge_round(h64, v2); - h64 = xxh64_merge_round(h64, v3); - h64 = xxh64_merge_round(h64, v4); - - } else { - h64 = seed + PRIME64_5; - } - - h64 += (uint64_t)len; - - while (p + 8 <= b_end) { - const uint64_t k1 = xxh64_round(0, get_unaligned_le64(p)); - - h64 ^= k1; - h64 = xxh_rotl64(h64, 27) * PRIME64_1 + PRIME64_4; - p += 8; - } - - if (p + 4 <= b_end) { - h64 ^= (uint64_t)(get_unaligned_le32(p)) * PRIME64_1; - h64 = xxh_rotl64(h64, 23) * PRIME64_2 + PRIME64_3; - p += 4; - } - - while (p < b_end) { - h64 ^= (*p) * PRIME64_5; - h64 = xxh_rotl64(h64, 11) * PRIME64_1; - p++; - } - - h64 ^= h64 >> 33; - h64 *= PRIME64_2; - h64 ^= h64 >> 29; - h64 *= PRIME64_3; - h64 ^= h64 >> 32; - - return h64; -} - -/*-************************************************** - * Advanced Hash Functions - ***************************************************/ -XXH_API void xxh32_reset(struct xxh32_state *statePtr, const uint32_t seed) -{ - /* use a local state for memcpy() to avoid strict-aliasing warnings */ - struct xxh32_state state; - - __builtin_memset(&state, 0, sizeof(state)); - state.v1 = seed + PRIME32_1 + PRIME32_2; - state.v2 = seed + PRIME32_2; - state.v3 = seed + 0; - state.v4 = seed - PRIME32_1; - __builtin_memcpy(statePtr, &state, sizeof(state)); -} - -XXH_API void xxh64_reset(struct xxh64_state *statePtr, const uint64_t seed) -{ - /* use a local state for memcpy() to avoid strict-aliasing warnings */ - struct xxh64_state state; - - __builtin_memset(&state, 0, sizeof(state)); - state.v1 = seed + PRIME64_1 + PRIME64_2; - state.v2 = seed + PRIME64_2; - state.v3 = seed + 0; - state.v4 = seed - PRIME64_1; - __builtin_memcpy(statePtr, &state, sizeof(state)); -} - -XXH_API int xxh32_update(struct xxh32_state *state, const void *input, const size_t len) -{ - const uint8_t *p = (const uint8_t *)input; - const uint8_t *const b_end = p + len; - - if (input == NULL) - return -EINVAL; - - state->total_len_32 += (uint32_t)len; - state->large_len |= (len >= 16) | (state->total_len_32 >= 16); - - if (state->memsize + len < 16) { /* fill in tmp buffer */ - __builtin_memcpy((uint8_t *)(state->mem32) + state->memsize, input, len); - state->memsize += (uint32_t)len; - return 0; - } - - if (state->memsize) { /* some data left from previous update */ - const uint32_t *p32 = state->mem32; - - __builtin_memcpy((uint8_t *)(state->mem32) + state->memsize, input, - 16 - state->memsize); - - state->v1 = xxh32_round(state->v1, get_unaligned_le32(p32)); - p32++; - state->v2 = xxh32_round(state->v2, get_unaligned_le32(p32)); - p32++; - state->v3 = xxh32_round(state->v3, get_unaligned_le32(p32)); - p32++; - state->v4 = xxh32_round(state->v4, get_unaligned_le32(p32)); - p32++; - - p += 16-state->memsize; - state->memsize = 0; - } - - if (p <= b_end - 16) { - const uint8_t *const limit = b_end - 16; - uint32_t v1 = state->v1; - uint32_t v2 = state->v2; - uint32_t v3 = state->v3; - uint32_t v4 = state->v4; - - do { - v1 = xxh32_round(v1, get_unaligned_le32(p)); - p += 4; - v2 = xxh32_round(v2, get_unaligned_le32(p)); - p += 4; - v3 = xxh32_round(v3, get_unaligned_le32(p)); - p += 4; - v4 = xxh32_round(v4, get_unaligned_le32(p)); - p += 4; - } while (p <= limit); - - state->v1 = v1; - state->v2 = v2; - state->v3 = v3; - state->v4 = v4; - } - - if (p < b_end) { - __builtin_memcpy(state->mem32, p, (size_t)(b_end-p)); - state->memsize = (uint32_t)(b_end-p); - } - - return 0; -} - -XXH_API uint32_t xxh32_digest(const struct xxh32_state *state) -{ - const uint8_t *p = (const uint8_t *)state->mem32; - const uint8_t *const b_end = (const uint8_t *)(state->mem32) + - state->memsize; - uint32_t h32; - - if (state->large_len) { - h32 = xxh_rotl32(state->v1, 1) + xxh_rotl32(state->v2, 7) + - xxh_rotl32(state->v3, 12) + xxh_rotl32(state->v4, 18); - } else { - h32 = state->v3 /* == seed */ + PRIME32_5; - } - - h32 += state->total_len_32; - - while (p + 4 <= b_end) { - h32 += get_unaligned_le32(p) * PRIME32_3; - h32 = xxh_rotl32(h32, 17) * PRIME32_4; - p += 4; - } - - while (p < b_end) { - h32 += (*p) * PRIME32_5; - h32 = xxh_rotl32(h32, 11) * PRIME32_1; - p++; - } - - h32 ^= h32 >> 15; - h32 *= PRIME32_2; - h32 ^= h32 >> 13; - h32 *= PRIME32_3; - h32 ^= h32 >> 16; - - return h32; -} - -XXH_API int xxh64_update(struct xxh64_state *state, const void *input, const size_t len) -{ - const uint8_t *p = (const uint8_t *)input; - const uint8_t *const b_end = p + len; - - if (input == NULL) - return -EINVAL; - - state->total_len += len; - - if (state->memsize + len < 32) { /* fill in tmp buffer */ - __builtin_memcpy(((uint8_t *)state->mem64) + state->memsize, input, len); - state->memsize += (uint32_t)len; - return 0; - } - - if (state->memsize) { /* tmp buffer is full */ - uint64_t *p64 = state->mem64; - - __builtin_memcpy(((uint8_t *)p64) + state->memsize, input, - 32 - state->memsize); - - state->v1 = xxh64_round(state->v1, get_unaligned_le64(p64)); - p64++; - state->v2 = xxh64_round(state->v2, get_unaligned_le64(p64)); - p64++; - state->v3 = xxh64_round(state->v3, get_unaligned_le64(p64)); - p64++; - state->v4 = xxh64_round(state->v4, get_unaligned_le64(p64)); - - p += 32 - state->memsize; - state->memsize = 0; - } - - if (p + 32 <= b_end) { - const uint8_t *const limit = b_end - 32; - uint64_t v1 = state->v1; - uint64_t v2 = state->v2; - uint64_t v3 = state->v3; - uint64_t v4 = state->v4; - - do { - v1 = xxh64_round(v1, get_unaligned_le64(p)); - p += 8; - v2 = xxh64_round(v2, get_unaligned_le64(p)); - p += 8; - v3 = xxh64_round(v3, get_unaligned_le64(p)); - p += 8; - v4 = xxh64_round(v4, get_unaligned_le64(p)); - p += 8; - } while (p <= limit); - - state->v1 = v1; - state->v2 = v2; - state->v3 = v3; - state->v4 = v4; - } - - if (p < b_end) { - __builtin_memcpy(state->mem64, p, (size_t)(b_end-p)); - state->memsize = (uint32_t)(b_end - p); - } - - return 0; -} - -XXH_API uint64_t xxh64_digest(const struct xxh64_state *state) -{ - const uint8_t *p = (const uint8_t *)state->mem64; - const uint8_t *const b_end = (const uint8_t *)state->mem64 + - state->memsize; - uint64_t h64; - - if (state->total_len >= 32) { - const uint64_t v1 = state->v1; - const uint64_t v2 = state->v2; - const uint64_t v3 = state->v3; - const uint64_t v4 = state->v4; - - h64 = xxh_rotl64(v1, 1) + xxh_rotl64(v2, 7) + - xxh_rotl64(v3, 12) + xxh_rotl64(v4, 18); - h64 = xxh64_merge_round(h64, v1); - h64 = xxh64_merge_round(h64, v2); - h64 = xxh64_merge_round(h64, v3); - h64 = xxh64_merge_round(h64, v4); - } else { - h64 = state->v3 + PRIME64_5; - } - - h64 += (uint64_t)state->total_len; - - while (p + 8 <= b_end) { - const uint64_t k1 = xxh64_round(0, get_unaligned_le64(p)); - - h64 ^= k1; - h64 = xxh_rotl64(h64, 27) * PRIME64_1 + PRIME64_4; - p += 8; - } - - if (p + 4 <= b_end) { - h64 ^= (uint64_t)(get_unaligned_le32(p)) * PRIME64_1; - h64 = xxh_rotl64(h64, 23) * PRIME64_2 + PRIME64_3; - p += 4; - } - - while (p < b_end) { - h64 ^= (*p) * PRIME64_5; - h64 = xxh_rotl64(h64, 11) * PRIME64_1; - p++; - } - - h64 ^= h64 >> 33; - h64 *= PRIME64_2; - h64 ^= h64 >> 29; - h64 *= PRIME64_3; - h64 ^= h64 >> 32; - - return h64; -} - -#endif /* XXHASH_H */ diff --git a/third_party/zstd/contrib/linux-kernel/test/macro-test.sh b/third_party/zstd/contrib/linux-kernel/test/macro-test.sh deleted file mode 100755 index 9ea84aa66..000000000 --- a/third_party/zstd/contrib/linux-kernel/test/macro-test.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env sh - -set -e - -SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd) -INCLUDE_DIR="$SCRIPT_DIR/../linux/include" -LIB_DIR="$SCRIPT_DIR/../linux/lib" - - -print() { - printf '%b' "${*}" -} - -println() { - printf '%b\n' "${*}" -} - -die() { - println "$@" 1>&2 - exit 1 -} - -test_not_present() { - print "Testing that '$1' is not present... " - grep -r $1 "$INCLUDE_DIR" "$LIB_DIR" && die "Fail!" - println "Okay" -} - -println "This test checks that the macro removal process worked as expected" -println "If this test fails, then freestanding.py wasn't able to remove one of these" -println "macros from the source code completely. You'll either need to rewrite the check" -println "or improve freestanding.py." -println "" - -test_not_present "ZSTD_NO_INTRINSICS" -test_not_present "ZSTD_NO_UNUSED_FUNCTIONS" -test_not_present "ZSTD_LEGACY_SUPPORT" -test_not_present "STATIC_BMI2" -test_not_present "ZSTD_DLL_EXPORT" -test_not_present "ZSTD_DLL_IMPORT" -test_not_present "__ICCARM__" -test_not_present "_MSC_VER" -test_not_present "_WIN32" -test_not_present "__linux__" diff --git a/third_party/zstd/contrib/linux-kernel/test/static_test.c b/third_party/zstd/contrib/linux-kernel/test/static_test.c deleted file mode 100644 index ba4a420d4..000000000 --- a/third_party/zstd/contrib/linux-kernel/test/static_test.c +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under both the BSD-style license (found in the - * LICENSE file in the root directory of this source tree) and the GPLv2 (found - * in the COPYING file in the root directory of this source tree). - * You may select, at your option, one of the above-listed licenses. - */ -#include -#include -#include -#include - -#include "decompress_sources.h" -#include - -#define CONTROL(x) \ - do { \ - if (!(x)) { \ - fprintf(stderr, "%s:%u: %s failed!\n", __FUNCTION__, __LINE__, #x); \ - abort(); \ - } \ - } while (0) - - -static const char kEmptyZstdFrame[] = { - 0x28, 0xb5, 0x2f, 0xfd, 0x24, 0x00, 0x01, 0x00, 0x00, 0x99, 0xe9, 0xd8, 0x51 -}; - -static void test_decompress_unzstd(void) { - fprintf(stderr, "Testing decompress unzstd... "); - { - size_t const wkspSize = zstd_dctx_workspace_bound(); - void* wksp = malloc(wkspSize); - ZSTD_DCtx* dctx = zstd_init_dctx(wksp, wkspSize); - CONTROL(wksp != NULL); - CONTROL(dctx != NULL); - { - size_t const dSize = zstd_decompress_dctx(dctx, NULL, 0, kEmptyZstdFrame, sizeof(kEmptyZstdFrame)); - CONTROL(!zstd_is_error(dSize)); - CONTROL(dSize == 0); - } - free(wksp); - } - fprintf(stderr, "Ok\n"); -} - -int main(void) { - test_decompress_unzstd(); - return 0; -} diff --git a/third_party/zstd/contrib/linux-kernel/test/test.c b/third_party/zstd/contrib/linux-kernel/test/test.c deleted file mode 100644 index 0f4ba3f45..000000000 --- a/third_party/zstd/contrib/linux-kernel/test/test.c +++ /dev/null @@ -1,229 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under both the BSD-style license (found in the - * LICENSE file in the root directory of this source tree) and the GPLv2 (found - * in the COPYING file in the root directory of this source tree). - * You may select, at your option, one of the above-listed licenses. - */ -#include -#include -#include -#include - -#include - -#define CONTROL(x) \ - do { \ - if (!(x)) { \ - fprintf(stderr, "%s:%u: %s failed!\n", __FUNCTION__, __LINE__, #x); \ - abort(); \ - } \ - } while (0) - -typedef struct { - char *data; - char *data2; - size_t dataSize; - char *comp; - size_t compSize; -} test_data_t; - -static test_data_t create_test_data(void) { - test_data_t data; - data.dataSize = 128 * 1024; - data.data = (char*)malloc(data.dataSize); - CONTROL(data.data != NULL); - data.data2 = (char*)malloc(data.dataSize); - CONTROL(data.data2 != NULL); - data.compSize = zstd_compress_bound(data.dataSize); - data.comp = (char*)malloc(data.compSize); - CONTROL(data.comp != NULL); - memset(data.data, 0, data.dataSize); - return data; -} - -static void free_test_data(test_data_t const *data) { - free(data->data); - free(data->data2); - free(data->comp); -} - -#define MIN(a, b) ((a) < (b) ? (a) : (b)) -#define MAX(a, b) ((a) > (b) ? (a) : (b)) - -static void test_btrfs(test_data_t const *data) { - size_t const size = MIN(data->dataSize, 128 * 1024); - fprintf(stderr, "testing btrfs use cases... "); - for (int level = -1; level < 16; ++level) { - zstd_parameters params = zstd_get_params(level, size); - size_t const workspaceSize = - MAX(zstd_cstream_workspace_bound(¶ms.cParams), - zstd_dstream_workspace_bound(size)); - void *workspace = malloc(workspaceSize); - - char const *ip = data->data; - char const *iend = ip + size; - char *op = data->comp; - char *oend = op + data->compSize; - - CONTROL(params.cParams.windowLog <= 17); - CONTROL(workspace != NULL); - { - zstd_cstream *cctx = zstd_init_cstream(¶ms, size, workspace, workspaceSize); - zstd_out_buffer out = {NULL, 0, 0}; - zstd_in_buffer in = {NULL, 0, 0}; - CONTROL(cctx != NULL); - for (;;) { - if (in.pos == in.size) { - in.src = ip; - in.size = MIN(4096, iend - ip); - in.pos = 0; - ip += in.size; - } - - if (out.pos == out.size) { - out.dst = op; - out.size = MIN(4096, oend - op); - out.pos = 0; - op += out.size; - } - - if (ip != iend || in.pos < in.size) { - CONTROL(!zstd_is_error(zstd_compress_stream(cctx, &out, &in))); - } else { - size_t const ret = zstd_end_stream(cctx, &out); - CONTROL(!zstd_is_error(ret)); - if (ret == 0) { - break; - } - } - } - op += out.pos; - } - - ip = data->comp; - iend = op; - op = data->data2; - oend = op + size; - { - zstd_dstream *dctx = zstd_init_dstream(1ULL << params.cParams.windowLog, workspace, workspaceSize); - zstd_out_buffer out = {NULL, 0, 0}; - zstd_in_buffer in = {NULL, 0, 0}; - CONTROL(dctx != NULL); - for (;;) { - if (in.pos == in.size) { - in.src = ip; - in.size = MIN(4096, iend - ip); - in.pos = 0; - ip += in.size; - } - - if (out.pos == out.size) { - out.dst = op; - out.size = MIN(4096, oend - op); - out.pos = 0; - op += out.size; - } - { - size_t const ret = zstd_decompress_stream(dctx, &out, &in); - CONTROL(!zstd_is_error(ret)); - if (ret == 0) { - break; - } - } - } - } - CONTROL((size_t)(op - data->data2) == data->dataSize); - CONTROL(!memcmp(data->data, data->data2, data->dataSize)); - free(workspace); - } - fprintf(stderr, "Ok\n"); -} - -static void test_decompress_unzstd(test_data_t const *data) { - size_t cSize; - fprintf(stderr, "Testing decompress unzstd... "); - { - zstd_parameters params = zstd_get_params(19, 0); - size_t const wkspSize = zstd_cctx_workspace_bound(¶ms.cParams); - void* wksp = malloc(wkspSize); - zstd_cctx* cctx = zstd_init_cctx(wksp, wkspSize); - CONTROL(wksp != NULL); - CONTROL(cctx != NULL); - cSize = zstd_compress_cctx(cctx, data->comp, data->compSize, data->data, data->dataSize, ¶ms); - CONTROL(!zstd_is_error(cSize)); - free(wksp); - } - { - size_t const wkspSize = zstd_dctx_workspace_bound(); - void* wksp = malloc(wkspSize); - zstd_dctx* dctx = zstd_init_dctx(wksp, wkspSize); - CONTROL(wksp != NULL); - CONTROL(dctx != NULL); - { - size_t const dSize = zstd_decompress_dctx(dctx, data->data2, data->dataSize, data->comp, cSize); - CONTROL(!zstd_is_error(dSize)); - CONTROL(dSize == data->dataSize); - } - CONTROL(!memcmp(data->data, data->data2, data->dataSize)); - free(wksp); - } - fprintf(stderr, "Ok\n"); -} - -static void test_f2fs(void) { - fprintf(stderr, "testing f2fs uses... "); - CONTROL(zstd_min_clevel() < 0); - CONTROL(zstd_max_clevel() == 22); - fprintf(stderr, "Ok\n"); -} - -static char *g_stack = NULL; - -static void __attribute__((noinline)) use(void *x) { - asm volatile("" : "+r"(x)); -} - -static void __attribute__((noinline)) fill_stack(void) { - memset(g_stack, 0x33, 8192); -} - -static void __attribute__((noinline)) set_stack(void) { - - char stack[8192]; - g_stack = stack; - use(g_stack); -} - -static void __attribute__((noinline)) check_stack(void) { - size_t cleanStack = 0; - while (cleanStack < 8192 && g_stack[cleanStack] == 0x33) { - ++cleanStack; - } - { - size_t const stackSize = 8192 - cleanStack; - fprintf(stderr, "Maximum stack size: %zu\n", stackSize); - CONTROL(stackSize <= 2048 + 512); - } -} - -static void test_stack_usage(test_data_t const *data) { - set_stack(); - fill_stack(); - test_f2fs(); - test_btrfs(data); - test_decompress_unzstd(data); - check_stack(); -} - -int main(void) { - test_data_t data = create_test_data(); - test_f2fs(); - test_btrfs(&data); - test_decompress_unzstd(&data); - test_stack_usage(&data); - free_test_data(&data); - return 0; -} diff --git a/third_party/zstd/contrib/linux-kernel/zstd_common_module.c b/third_party/zstd/contrib/linux-kernel/zstd_common_module.c deleted file mode 100644 index 466828e35..000000000 --- a/third_party/zstd/contrib/linux-kernel/zstd_common_module.c +++ /dev/null @@ -1,29 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under both the BSD-style license (found in the - * LICENSE file in the root directory of this source tree) and the GPLv2 (found - * in the COPYING file in the root directory of this source tree). - * You may select, at your option, one of the above-listed licenses. - */ - -#include - -#include "common/huf.h" -#include "common/fse.h" -#include "common/zstd_internal.h" - -// Export symbols shared by compress and decompress into a common module - -#undef ZSTD_isError /* defined within zstd_internal.h */ -EXPORT_SYMBOL_GPL(FSE_readNCount); -EXPORT_SYMBOL_GPL(HUF_readStats); -EXPORT_SYMBOL_GPL(HUF_readStats_wksp); -EXPORT_SYMBOL_GPL(ZSTD_isError); -EXPORT_SYMBOL_GPL(ZSTD_getErrorName); -EXPORT_SYMBOL_GPL(ZSTD_getErrorCode); - -MODULE_LICENSE("Dual BSD/GPL"); -MODULE_DESCRIPTION("Zstd Common"); diff --git a/third_party/zstd/contrib/linux-kernel/zstd_compress_module.c b/third_party/zstd/contrib/linux-kernel/zstd_compress_module.c deleted file mode 100644 index 8ecf43226..000000000 --- a/third_party/zstd/contrib/linux-kernel/zstd_compress_module.c +++ /dev/null @@ -1,164 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under both the BSD-style license (found in the - * LICENSE file in the root directory of this source tree) and the GPLv2 (found - * in the COPYING file in the root directory of this source tree). - * You may select, at your option, one of the above-listed licenses. - */ - -#include -#include -#include -#include - -#include "common/zstd_deps.h" -#include "common/zstd_internal.h" - -#define ZSTD_FORWARD_IF_ERR(ret) \ - do { \ - size_t const __ret = (ret); \ - if (ZSTD_isError(__ret)) \ - return __ret; \ - } while (0) - -static size_t zstd_cctx_init(zstd_cctx *cctx, const zstd_parameters *parameters, - unsigned long long pledged_src_size) -{ - ZSTD_FORWARD_IF_ERR(ZSTD_CCtx_reset( - cctx, ZSTD_reset_session_and_parameters)); - ZSTD_FORWARD_IF_ERR(ZSTD_CCtx_setPledgedSrcSize( - cctx, pledged_src_size)); - ZSTD_FORWARD_IF_ERR(ZSTD_CCtx_setParameter( - cctx, ZSTD_c_windowLog, parameters->cParams.windowLog)); - ZSTD_FORWARD_IF_ERR(ZSTD_CCtx_setParameter( - cctx, ZSTD_c_hashLog, parameters->cParams.hashLog)); - ZSTD_FORWARD_IF_ERR(ZSTD_CCtx_setParameter( - cctx, ZSTD_c_chainLog, parameters->cParams.chainLog)); - ZSTD_FORWARD_IF_ERR(ZSTD_CCtx_setParameter( - cctx, ZSTD_c_searchLog, parameters->cParams.searchLog)); - ZSTD_FORWARD_IF_ERR(ZSTD_CCtx_setParameter( - cctx, ZSTD_c_minMatch, parameters->cParams.minMatch)); - ZSTD_FORWARD_IF_ERR(ZSTD_CCtx_setParameter( - cctx, ZSTD_c_targetLength, parameters->cParams.targetLength)); - ZSTD_FORWARD_IF_ERR(ZSTD_CCtx_setParameter( - cctx, ZSTD_c_strategy, parameters->cParams.strategy)); - ZSTD_FORWARD_IF_ERR(ZSTD_CCtx_setParameter( - cctx, ZSTD_c_contentSizeFlag, parameters->fParams.contentSizeFlag)); - ZSTD_FORWARD_IF_ERR(ZSTD_CCtx_setParameter( - cctx, ZSTD_c_checksumFlag, parameters->fParams.checksumFlag)); - ZSTD_FORWARD_IF_ERR(ZSTD_CCtx_setParameter( - cctx, ZSTD_c_dictIDFlag, !parameters->fParams.noDictIDFlag)); - return 0; -} - -int zstd_min_clevel(void) -{ - return ZSTD_minCLevel(); -} -EXPORT_SYMBOL(zstd_min_clevel); - -int zstd_max_clevel(void) -{ - return ZSTD_maxCLevel(); -} -EXPORT_SYMBOL(zstd_max_clevel); - -size_t zstd_compress_bound(size_t src_size) -{ - return ZSTD_compressBound(src_size); -} -EXPORT_SYMBOL(zstd_compress_bound); - -zstd_parameters zstd_get_params(int level, - unsigned long long estimated_src_size) -{ - return ZSTD_getParams(level, estimated_src_size, 0); -} -EXPORT_SYMBOL(zstd_get_params); - -size_t zstd_cctx_workspace_bound(const zstd_compression_parameters *cparams) -{ - return ZSTD_estimateCCtxSize_usingCParams(*cparams); -} -EXPORT_SYMBOL(zstd_cctx_workspace_bound); - -zstd_cctx *zstd_init_cctx(void *workspace, size_t workspace_size) -{ - if (workspace == NULL) - return NULL; - return ZSTD_initStaticCCtx(workspace, workspace_size); -} -EXPORT_SYMBOL(zstd_init_cctx); - -size_t zstd_compress_cctx(zstd_cctx *cctx, void *dst, size_t dst_capacity, - const void *src, size_t src_size, const zstd_parameters *parameters) -{ - ZSTD_FORWARD_IF_ERR(zstd_cctx_init(cctx, parameters, src_size)); - return ZSTD_compress2(cctx, dst, dst_capacity, src, src_size); -} -EXPORT_SYMBOL(zstd_compress_cctx); - -size_t zstd_cstream_workspace_bound(const zstd_compression_parameters *cparams) -{ - return ZSTD_estimateCStreamSize_usingCParams(*cparams); -} -EXPORT_SYMBOL(zstd_cstream_workspace_bound); - -zstd_cstream *zstd_init_cstream(const zstd_parameters *parameters, - unsigned long long pledged_src_size, void *workspace, size_t workspace_size) -{ - zstd_cstream *cstream; - - if (workspace == NULL) - return NULL; - - cstream = ZSTD_initStaticCStream(workspace, workspace_size); - if (cstream == NULL) - return NULL; - - /* 0 means unknown in linux zstd API but means 0 in new zstd API */ - if (pledged_src_size == 0) - pledged_src_size = ZSTD_CONTENTSIZE_UNKNOWN; - - if (ZSTD_isError(zstd_cctx_init(cstream, parameters, pledged_src_size))) - return NULL; - - return cstream; -} -EXPORT_SYMBOL(zstd_init_cstream); - -size_t zstd_reset_cstream(zstd_cstream *cstream, - unsigned long long pledged_src_size) -{ - if (pledged_src_size == 0) - pledged_src_size = ZSTD_CONTENTSIZE_UNKNOWN; - ZSTD_FORWARD_IF_ERR( ZSTD_CCtx_reset(cstream, ZSTD_reset_session_only) ); - ZSTD_FORWARD_IF_ERR( ZSTD_CCtx_setPledgedSrcSize(cstream, pledged_src_size) ); - return 0; -} -EXPORT_SYMBOL(zstd_reset_cstream); - -size_t zstd_compress_stream(zstd_cstream *cstream, zstd_out_buffer *output, - zstd_in_buffer *input) -{ - return ZSTD_compressStream(cstream, output, input); -} -EXPORT_SYMBOL(zstd_compress_stream); - -size_t zstd_flush_stream(zstd_cstream *cstream, zstd_out_buffer *output) -{ - return ZSTD_flushStream(cstream, output); -} -EXPORT_SYMBOL(zstd_flush_stream); - -size_t zstd_end_stream(zstd_cstream *cstream, zstd_out_buffer *output) -{ - return ZSTD_endStream(cstream, output); -} -EXPORT_SYMBOL(zstd_end_stream); - -MODULE_LICENSE("Dual BSD/GPL"); -MODULE_DESCRIPTION("Zstd Compressor"); diff --git a/third_party/zstd/contrib/linux-kernel/zstd_decompress_module.c b/third_party/zstd/contrib/linux-kernel/zstd_decompress_module.c deleted file mode 100644 index eb1c49e69..000000000 --- a/third_party/zstd/contrib/linux-kernel/zstd_decompress_module.c +++ /dev/null @@ -1,105 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under both the BSD-style license (found in the - * LICENSE file in the root directory of this source tree) and the GPLv2 (found - * in the COPYING file in the root directory of this source tree). - * You may select, at your option, one of the above-listed licenses. - */ - -#include -#include -#include -#include - -#include "common/zstd_deps.h" - -/* Common symbols. zstd_compress must depend on zstd_decompress. */ - -unsigned int zstd_is_error(size_t code) -{ - return ZSTD_isError(code); -} -EXPORT_SYMBOL(zstd_is_error); - -zstd_error_code zstd_get_error_code(size_t code) -{ - return ZSTD_getErrorCode(code); -} -EXPORT_SYMBOL(zstd_get_error_code); - -const char *zstd_get_error_name(size_t code) -{ - return ZSTD_getErrorName(code); -} -EXPORT_SYMBOL(zstd_get_error_name); - -/* Decompression symbols. */ - -size_t zstd_dctx_workspace_bound(void) -{ - return ZSTD_estimateDCtxSize(); -} -EXPORT_SYMBOL(zstd_dctx_workspace_bound); - -zstd_dctx *zstd_init_dctx(void *workspace, size_t workspace_size) -{ - if (workspace == NULL) - return NULL; - return ZSTD_initStaticDCtx(workspace, workspace_size); -} -EXPORT_SYMBOL(zstd_init_dctx); - -size_t zstd_decompress_dctx(zstd_dctx *dctx, void *dst, size_t dst_capacity, - const void *src, size_t src_size) -{ - return ZSTD_decompressDCtx(dctx, dst, dst_capacity, src, src_size); -} -EXPORT_SYMBOL(zstd_decompress_dctx); - -size_t zstd_dstream_workspace_bound(size_t max_window_size) -{ - return ZSTD_estimateDStreamSize(max_window_size); -} -EXPORT_SYMBOL(zstd_dstream_workspace_bound); - -zstd_dstream *zstd_init_dstream(size_t max_window_size, void *workspace, - size_t workspace_size) -{ - if (workspace == NULL) - return NULL; - (void)max_window_size; - return ZSTD_initStaticDStream(workspace, workspace_size); -} -EXPORT_SYMBOL(zstd_init_dstream); - -size_t zstd_reset_dstream(zstd_dstream *dstream) -{ - return ZSTD_resetDStream(dstream); -} -EXPORT_SYMBOL(zstd_reset_dstream); - -size_t zstd_decompress_stream(zstd_dstream *dstream, zstd_out_buffer *output, - zstd_in_buffer *input) -{ - return ZSTD_decompressStream(dstream, output, input); -} -EXPORT_SYMBOL(zstd_decompress_stream); - -size_t zstd_find_frame_compressed_size(const void *src, size_t src_size) -{ - return ZSTD_findFrameCompressedSize(src, src_size); -} -EXPORT_SYMBOL(zstd_find_frame_compressed_size); - -size_t zstd_get_frame_header(zstd_frame_header *header, const void *src, - size_t src_size) -{ - return ZSTD_getFrameHeader(header, src, src_size); -} -EXPORT_SYMBOL(zstd_get_frame_header); - -MODULE_LICENSE("Dual BSD/GPL"); -MODULE_DESCRIPTION("Zstd Decompressor"); diff --git a/third_party/zstd/contrib/linux-kernel/zstd_deps.h b/third_party/zstd/contrib/linux-kernel/zstd_deps.h deleted file mode 100644 index 670c5fa2a..000000000 --- a/third_party/zstd/contrib/linux-kernel/zstd_deps.h +++ /dev/null @@ -1,125 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under both the BSD-style license (found in the - * LICENSE file in the root directory of this source tree) and the GPLv2 (found - * in the COPYING file in the root directory of this source tree). - * You may select, at your option, one of the above-listed licenses. - */ - -/* - * This file provides common libc dependencies that zstd requires. - * The purpose is to allow replacing this file with a custom implementation - * to compile zstd without libc support. - */ - -/* Need: - * NULL - * INT_MAX - * UINT_MAX - * ZSTD_memcpy() - * ZSTD_memset() - * ZSTD_memmove() - */ -#ifndef ZSTD_DEPS_COMMON -#define ZSTD_DEPS_COMMON - -#include -#include - -#define ZSTD_memcpy(d,s,n) __builtin_memcpy((d),(s),(n)) -#define ZSTD_memmove(d,s,n) __builtin_memmove((d),(s),(n)) -#define ZSTD_memset(d,s,n) __builtin_memset((d),(s),(n)) - -#endif /* ZSTD_DEPS_COMMON */ - -/* - * Define malloc as always failing. That means the user must - * either use ZSTD_customMem or statically allocate memory. - * Need: - * ZSTD_malloc() - * ZSTD_free() - * ZSTD_calloc() - */ -#ifdef ZSTD_DEPS_NEED_MALLOC -#ifndef ZSTD_DEPS_MALLOC -#define ZSTD_DEPS_MALLOC - -#define ZSTD_malloc(s) ({ (void)(s); NULL; }) -#define ZSTD_free(p) ((void)(p)) -#define ZSTD_calloc(n,s) ({ (void)(n); (void)(s); NULL; }) - -#endif /* ZSTD_DEPS_MALLOC */ -#endif /* ZSTD_DEPS_NEED_MALLOC */ - -/* - * Provides 64-bit math support. - * Need: - * U64 ZSTD_div64(U64 dividend, U32 divisor) - */ -#ifdef ZSTD_DEPS_NEED_MATH64 -#ifndef ZSTD_DEPS_MATH64 -#define ZSTD_DEPS_MATH64 - -#include - -static uint64_t ZSTD_div64(uint64_t dividend, uint32_t divisor) { - return div_u64(dividend, divisor); -} - -#endif /* ZSTD_DEPS_MATH64 */ -#endif /* ZSTD_DEPS_NEED_MATH64 */ - -/* - * This is only requested when DEBUGLEVEL >= 1, meaning - * it is disabled in production. - * Need: - * assert() - */ -#ifdef ZSTD_DEPS_NEED_ASSERT -#ifndef ZSTD_DEPS_ASSERT -#define ZSTD_DEPS_ASSERT - -#include - -#define assert(x) WARN_ON(!(x)) - -#endif /* ZSTD_DEPS_ASSERT */ -#endif /* ZSTD_DEPS_NEED_ASSERT */ - -/* - * This is only requested when DEBUGLEVEL >= 2, meaning - * it is disabled in production. - * Need: - * ZSTD_DEBUG_PRINT() - */ -#ifdef ZSTD_DEPS_NEED_IO -#ifndef ZSTD_DEPS_IO -#define ZSTD_DEPS_IO - -#include - -#define ZSTD_DEBUG_PRINT(...) pr_debug(__VA_ARGS__) - -#endif /* ZSTD_DEPS_IO */ -#endif /* ZSTD_DEPS_NEED_IO */ - -/* - * Only requested when MSAN is enabled. - * Need: - * intptr_t - */ -#ifdef ZSTD_DEPS_NEED_STDINT -#ifndef ZSTD_DEPS_STDINT -#define ZSTD_DEPS_STDINT - -/* - * The Linux Kernel doesn't provide intptr_t, only uintptr_t, which - * is an unsigned long. - */ -typedef long intptr_t; - -#endif /* ZSTD_DEPS_STDINT */ -#endif /* ZSTD_DEPS_NEED_STDINT */ diff --git a/third_party/zstd/contrib/match_finders/README.md b/third_party/zstd/contrib/match_finders/README.md deleted file mode 100644 index 54055c370..000000000 --- a/third_party/zstd/contrib/match_finders/README.md +++ /dev/null @@ -1,42 +0,0 @@ -## Edit Distance Match Finder - -``` -/* This match finder leverages techniques used in file comparison algorithms - * to find matches between a dictionary and a source file. - * - * The original motivation for studying this approach was to try and optimize - * Zstandard for the use case of patching: the most common scenario being - * updating an existing software package with the next version. When patching, - * the difference between the old version of the package and the new version - * is generally tiny (most of the new file will be identical to - * the old one). In more technical terms, the edit distance (the minimal number - * of changes required to take one sequence of bytes to another) between the - * files would be small relative to the size of the file. - * - * Various 'diffing' algorithms utilize this notion of edit distance and - * the corresponding concept of a minimal edit script between two - * sequences to identify the regions within two files where they differ. - * The core algorithm used in this match finder is described in: - * - * "An O(ND) Difference Algorithm and its Variations", Eugene W. Myers, - * Algorithmica Vol. 1, 1986, pp. 251-266, - * . - * - * Additional algorithmic heuristics for speed improvement have also been included. - * These we inspired from implementations of various regular and binary diffing - * algorithms such as GNU diff, bsdiff, and Xdelta. - * - * Note: after some experimentation, this approach proved to not provide enough - * utility to justify the additional CPU used in finding matches. The one area - * where this approach consistently outperforms Zstandard even on level 19 is - * when compressing small files (<10 KB) using an equally small dictionary that - * is very similar to the source file. For the use case that this was intended, - * (large similar files) this approach by itself took 5-10X longer than zstd-19 and - * generally resulted in 2-3X larger files. The core advantage that zstd-19 has - * over this approach for match finding is the overlapping matches. This approach - * cannot find any. - * - * I'm leaving this in the contrib section in case this ever becomes interesting - * to explore again. - * */ -``` diff --git a/third_party/zstd/contrib/match_finders/zstd_edist.c b/third_party/zstd/contrib/match_finders/zstd_edist.c deleted file mode 100644 index d685cdd9e..000000000 --- a/third_party/zstd/contrib/match_finders/zstd_edist.c +++ /dev/null @@ -1,558 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under both the BSD-style license (found in the - * LICENSE file in the root directory of this source tree) and the GPLv2 (found - * in the COPYING file in the root directory of this source tree). - * You may select, at your option, one of the above-listed licenses. - */ - -/*-************************************* -* Dependencies -***************************************/ - -/* Currently relies on qsort when combining contiguous matches. This can probably - * be avoided but would require changes to the algorithm. The qsort is far from - * the bottleneck in this algorithm even for medium sized files so it's probably - * not worth trying to address */ -#include -#include - -#include "zstd_edist.h" -#include "mem.h" - -/*-************************************* -* Constants -***************************************/ - -/* Just a sential for the entries of the diagonal matrix */ -#define ZSTD_EDIST_DIAG_MAX (S32)(1 << 30) - -/* How large should a snake be to be considered a 'big' snake. - * For an explanation of what a 'snake' is with respect to the - * edit distance matrix, see the linked paper in zstd_edist.h */ -#define ZSTD_EDIST_SNAKE_THRESH 20 - -/* After how many iterations should we start to use the heuristic - * based on 'big' snakes */ -#define ZSTD_EDIST_SNAKE_ITER_THRESH 200 - -/* After how many iterations should be just give up and take - * the best available edit script for this round */ -#define ZSTD_EDIST_EXPENSIVE_THRESH 1024 - -/*-************************************* -* Structures -***************************************/ - -typedef struct { - U32 dictIdx; - U32 srcIdx; - U32 matchLength; -} ZSTD_eDist_match; - -typedef struct { - const BYTE* dict; - const BYTE* src; - size_t dictSize; - size_t srcSize; - S32* forwardDiag; /* Entries of the forward diagonal stored here */ - S32* backwardDiag; /* Entries of the backward diagonal stored here. - * Note: this buffer and the 'forwardDiag' buffer - * are contiguous. See the ZSTD_eDist_genSequences */ - ZSTD_eDist_match* matches; /* Accumulate matches of length 1 in this buffer. - * In a subsequence post-processing step, we combine - * contiguous matches. */ - U32 nbMatches; -} ZSTD_eDist_state; - -typedef struct { - S32 dictMid; /* The mid diagonal for the dictionary */ - S32 srcMid; /* The mid diagonal for the source */ - int lowUseHeuristics; /* Should we use heuristics for the low part */ - int highUseHeuristics; /* Should we use heuristics for the high part */ -} ZSTD_eDist_partition; - -/*-************************************* -* Internal -***************************************/ - -static void ZSTD_eDist_diag(ZSTD_eDist_state* state, - ZSTD_eDist_partition* partition, - S32 dictLow, S32 dictHigh, S32 srcLow, - S32 srcHigh, int useHeuristics) -{ - S32* const forwardDiag = state->forwardDiag; - S32* const backwardDiag = state->backwardDiag; - const BYTE* const dict = state->dict; - const BYTE* const src = state->src; - - S32 const diagMin = dictLow - srcHigh; - S32 const diagMax = dictHigh - srcLow; - S32 const forwardMid = dictLow - srcLow; - S32 const backwardMid = dictHigh - srcHigh; - - S32 forwardMin = forwardMid; - S32 forwardMax = forwardMid; - S32 backwardMin = backwardMid; - S32 backwardMax = backwardMid; - int odd = (forwardMid - backwardMid) & 1; - U32 iterations; - - forwardDiag[forwardMid] = dictLow; - backwardDiag[backwardMid] = dictHigh; - - /* Main loop for updating diag entries. Unless useHeuristics is - * set to false, this loop will run until it finds the minimal - * edit script */ - for (iterations = 1;;iterations++) { - S32 diag; - int bigSnake = 0; - - if (forwardMin > diagMin) { - forwardMin--; - forwardDiag[forwardMin - 1] = -1; - } else { - forwardMin++; - } - - if (forwardMax < diagMax) { - forwardMax++; - forwardDiag[forwardMax + 1] = -1; - } else { - forwardMax--; - } - - for (diag = forwardMax; diag >= forwardMin; diag -= 2) { - S32 dictIdx; - S32 srcIdx; - S32 low = forwardDiag[diag - 1]; - S32 high = forwardDiag[diag + 1]; - S32 dictIdx0 = low < high ? high : low + 1; - - for (dictIdx = dictIdx0, srcIdx = dictIdx0 - diag; - dictIdx < dictHigh && srcIdx < srcHigh && dict[dictIdx] == src[srcIdx]; - dictIdx++, srcIdx++) continue; - - if (dictIdx - dictIdx0 > ZSTD_EDIST_SNAKE_THRESH) - bigSnake = 1; - - forwardDiag[diag] = dictIdx; - - if (odd && backwardMin <= diag && diag <= backwardMax && backwardDiag[diag] <= dictIdx) { - partition->dictMid = dictIdx; - partition->srcMid = srcIdx; - partition->lowUseHeuristics = 0; - partition->highUseHeuristics = 0; - return; - } - } - - if (backwardMin > diagMin) { - backwardMin--; - backwardDiag[backwardMin - 1] = ZSTD_EDIST_DIAG_MAX; - } else { - backwardMin++; - } - - if (backwardMax < diagMax) { - backwardMax++; - backwardDiag[backwardMax + 1] = ZSTD_EDIST_DIAG_MAX; - } else { - backwardMax--; - } - - - for (diag = backwardMax; diag >= backwardMin; diag -= 2) { - S32 dictIdx; - S32 srcIdx; - S32 low = backwardDiag[diag - 1]; - S32 high = backwardDiag[diag + 1]; - S32 dictIdx0 = low < high ? low : high - 1; - - for (dictIdx = dictIdx0, srcIdx = dictIdx0 - diag; - dictLow < dictIdx && srcLow < srcIdx && dict[dictIdx - 1] == src[srcIdx - 1]; - dictIdx--, srcIdx--) continue; - - if (dictIdx0 - dictIdx > ZSTD_EDIST_SNAKE_THRESH) - bigSnake = 1; - - backwardDiag[diag] = dictIdx; - - if (!odd && forwardMin <= diag && diag <= forwardMax && dictIdx <= forwardDiag[diag]) { - partition->dictMid = dictIdx; - partition->srcMid = srcIdx; - partition->lowUseHeuristics = 0; - partition->highUseHeuristics = 0; - return; - } - } - - if (!useHeuristics) - continue; - - /* Everything under this point is a heuristic. Using these will - * substantially speed up the match finding. In some cases, taking - * the total match finding time from several minutes to seconds. - * Of course, the caveat is that the edit script found may no longer - * be optimal */ - - /* Big snake heuristic */ - if (iterations > ZSTD_EDIST_SNAKE_ITER_THRESH && bigSnake) { - { - S32 best = 0; - - for (diag = forwardMax; diag >= forwardMin; diag -= 2) { - S32 diagDiag = diag - forwardMid; - S32 dictIdx = forwardDiag[diag]; - S32 srcIdx = dictIdx - diag; - S32 v = (dictIdx - dictLow) * 2 - diagDiag; - - if (v > 12 * (iterations + (diagDiag < 0 ? -diagDiag : diagDiag))) { - if (v > best - && dictLow + ZSTD_EDIST_SNAKE_THRESH <= dictIdx && dictIdx <= dictHigh - && srcLow + ZSTD_EDIST_SNAKE_THRESH <= srcIdx && srcIdx <= srcHigh) { - S32 k; - for (k = 1; dict[dictIdx - k] == src[srcIdx - k]; k++) { - if (k == ZSTD_EDIST_SNAKE_THRESH) { - best = v; - partition->dictMid = dictIdx; - partition->srcMid = srcIdx; - break; - } - } - } - } - } - - if (best > 0) { - partition->lowUseHeuristics = 0; - partition->highUseHeuristics = 1; - return; - } - } - - { - S32 best = 0; - - for (diag = backwardMax; diag >= backwardMin; diag -= 2) { - S32 diagDiag = diag - backwardMid; - S32 dictIdx = backwardDiag[diag]; - S32 srcIdx = dictIdx - diag; - S32 v = (dictHigh - dictIdx) * 2 + diagDiag; - - if (v > 12 * (iterations + (diagDiag < 0 ? -diagDiag : diagDiag))) { - if (v > best - && dictLow < dictIdx && dictIdx <= dictHigh - ZSTD_EDIST_SNAKE_THRESH - && srcLow < srcIdx && srcIdx <= srcHigh - ZSTD_EDIST_SNAKE_THRESH) { - int k; - for (k = 0; dict[dictIdx + k] == src[srcIdx + k]; k++) { - if (k == ZSTD_EDIST_SNAKE_THRESH - 1) { - best = v; - partition->dictMid = dictIdx; - partition->srcMid = srcIdx; - break; - } - } - } - } - } - - if (best > 0) { - partition->lowUseHeuristics = 1; - partition->highUseHeuristics = 0; - return; - } - } - } - - /* More general 'too expensive' heuristic */ - if (iterations >= ZSTD_EDIST_EXPENSIVE_THRESH) { - S32 forwardDictSrcBest; - S32 forwardDictBest = 0; - S32 backwardDictSrcBest; - S32 backwardDictBest = 0; - - forwardDictSrcBest = -1; - for (diag = forwardMax; diag >= forwardMin; diag -= 2) { - S32 dictIdx = MIN(forwardDiag[diag], dictHigh); - S32 srcIdx = dictIdx - diag; - - if (srcHigh < srcIdx) { - dictIdx = srcHigh + diag; - srcIdx = srcHigh; - } - - if (forwardDictSrcBest < dictIdx + srcIdx) { - forwardDictSrcBest = dictIdx + srcIdx; - forwardDictBest = dictIdx; - } - } - - backwardDictSrcBest = ZSTD_EDIST_DIAG_MAX; - for (diag = backwardMax; diag >= backwardMin; diag -= 2) { - S32 dictIdx = MAX(dictLow, backwardDiag[diag]); - S32 srcIdx = dictIdx - diag; - - if (srcIdx < srcLow) { - dictIdx = srcLow + diag; - srcIdx = srcLow; - } - - if (dictIdx + srcIdx < backwardDictSrcBest) { - backwardDictSrcBest = dictIdx + srcIdx; - backwardDictBest = dictIdx; - } - } - - if ((dictHigh + srcHigh) - backwardDictSrcBest < forwardDictSrcBest - (dictLow + srcLow)) { - partition->dictMid = forwardDictBest; - partition->srcMid = forwardDictSrcBest - forwardDictBest; - partition->lowUseHeuristics = 0; - partition->highUseHeuristics = 1; - } else { - partition->dictMid = backwardDictBest; - partition->srcMid = backwardDictSrcBest - backwardDictBest; - partition->lowUseHeuristics = 1; - partition->highUseHeuristics = 0; - } - return; - } - } -} - -static void ZSTD_eDist_insertMatch(ZSTD_eDist_state* state, - S32 const dictIdx, S32 const srcIdx) -{ - state->matches[state->nbMatches].dictIdx = dictIdx; - state->matches[state->nbMatches].srcIdx = srcIdx; - state->matches[state->nbMatches].matchLength = 1; - state->nbMatches++; -} - -static int ZSTD_eDist_compare(ZSTD_eDist_state* state, - S32 dictLow, S32 dictHigh, S32 srcLow, - S32 srcHigh, int useHeuristics) -{ - const BYTE* const dict = state->dict; - const BYTE* const src = state->src; - - /* Found matches while traversing from the low end */ - while (dictLow < dictHigh && srcLow < srcHigh && dict[dictLow] == src[srcLow]) { - ZSTD_eDist_insertMatch(state, dictLow, srcLow); - dictLow++; - srcLow++; - } - - /* Found matches while traversing from the high end */ - while (dictLow < dictHigh && srcLow < srcHigh && dict[dictHigh - 1] == src[srcHigh - 1]) { - ZSTD_eDist_insertMatch(state, dictHigh - 1, srcHigh - 1); - dictHigh--; - srcHigh--; - } - - /* If the low and high end end up touching. If we wanted to make - * note of the differences like most diffing algorithms do, we would - * do so here. In our case, we're only concerned with matches - * Note: if you wanted to find the edit distance of the algorithm, - * you could just accumulate the cost for an insertion/deletion - * below. */ - if (dictLow == dictHigh) { - while (srcLow < srcHigh) { - /* Reaching this point means inserting src[srcLow] into - * the current position of dict */ - srcLow++; - } - } else if (srcLow == srcHigh) { - while (dictLow < dictHigh) { - /* Reaching this point means deleting dict[dictLow] from - * the current position of dict */ - dictLow++; - } - } else { - ZSTD_eDist_partition partition; - partition.dictMid = 0; - partition.srcMid = 0; - ZSTD_eDist_diag(state, &partition, dictLow, dictHigh, - srcLow, srcHigh, useHeuristics); - if (ZSTD_eDist_compare(state, dictLow, partition.dictMid, - srcLow, partition.srcMid, partition.lowUseHeuristics)) - return 1; - if (ZSTD_eDist_compare(state, partition.dictMid, dictHigh, - partition.srcMid, srcHigh, partition.highUseHeuristics)) - return 1; - } - - return 0; -} - -static int ZSTD_eDist_matchComp(const void* p, const void* q) -{ - S32 const l = ((ZSTD_eDist_match*)p)->srcIdx; - S32 const r = ((ZSTD_eDist_match*)q)->srcIdx; - return (l - r); -} - -/* The matches from the approach above will all be of the form - * (dictIdx, srcIdx, 1). This method combines contiguous matches - * of length MINMATCH or greater. Matches less than MINMATCH - * are discarded */ -static void ZSTD_eDist_combineMatches(ZSTD_eDist_state* state) -{ - /* Create a new buffer to put the combined matches into - * and memcpy to state->matches after */ - ZSTD_eDist_match* combinedMatches = - ZSTD_malloc(state->nbMatches * sizeof(ZSTD_eDist_match), - ZSTD_defaultCMem); - - U32 nbCombinedMatches = 1; - size_t i; - - /* Make sure that the srcIdx and dictIdx are in sorted order. - * The combination step won't work otherwise */ - qsort(state->matches, state->nbMatches, sizeof(ZSTD_eDist_match), ZSTD_eDist_matchComp); - - memcpy(combinedMatches, state->matches, sizeof(ZSTD_eDist_match)); - for (i = 1; i < state->nbMatches; i++) { - ZSTD_eDist_match const match = state->matches[i]; - ZSTD_eDist_match const combinedMatch = - combinedMatches[nbCombinedMatches - 1]; - if (combinedMatch.srcIdx + combinedMatch.matchLength == match.srcIdx && - combinedMatch.dictIdx + combinedMatch.matchLength == match.dictIdx) { - combinedMatches[nbCombinedMatches - 1].matchLength++; - } else { - /* Discard matches that are less than MINMATCH */ - if (combinedMatches[nbCombinedMatches - 1].matchLength < MINMATCH) { - nbCombinedMatches--; - } - - memcpy(combinedMatches + nbCombinedMatches, - state->matches + i, sizeof(ZSTD_eDist_match)); - nbCombinedMatches++; - } - } - memcpy(state->matches, combinedMatches, nbCombinedMatches * sizeof(ZSTD_eDist_match)); - state->nbMatches = nbCombinedMatches; - ZSTD_free(combinedMatches, ZSTD_defaultCMem); -} - -static size_t ZSTD_eDist_convertMatchesToSequences(ZSTD_Sequence* sequences, - ZSTD_eDist_state* state) -{ - const ZSTD_eDist_match* matches = state->matches; - size_t const nbMatches = state->nbMatches; - size_t const dictSize = state->dictSize; - size_t nbSequences = 0; - size_t i; - for (i = 0; i < nbMatches; i++) { - ZSTD_eDist_match const match = matches[i]; - U32 const litLength = !i ? match.srcIdx : - match.srcIdx - (matches[i - 1].srcIdx + matches[i - 1].matchLength); - U32 const offset = (match.srcIdx + dictSize) - match.dictIdx; - U32 const matchLength = match.matchLength; - sequences[nbSequences].offset = offset; - sequences[nbSequences].litLength = litLength; - sequences[nbSequences].matchLength = matchLength; - nbSequences++; - } - return nbSequences; -} - -/*-************************************* -* Internal utils -***************************************/ - -static size_t ZSTD_eDist_hamingDist(const BYTE* const a, - const BYTE* const b, size_t n) -{ - size_t i; - size_t dist = 0; - for (i = 0; i < n; i++) - dist += a[i] != b[i]; - return dist; -} - -/* This is a pretty naive recursive implementation that should only - * be used for quick tests obviously. Don't try and run this on a - * GB file or something. There are faster implementations. Use those - * if you need to run it for large files. */ -static size_t ZSTD_eDist_levenshteinDist(const BYTE* const s, - size_t const sn, const BYTE* const t, - size_t const tn) -{ - size_t a, b, c; - - if (!sn) - return tn; - if (!tn) - return sn; - - if (s[sn - 1] == t[tn - 1]) - return ZSTD_eDist_levenshteinDist( - s, sn - 1, t, tn - 1); - - a = ZSTD_eDist_levenshteinDist(s, sn - 1, t, tn - 1); - b = ZSTD_eDist_levenshteinDist(s, sn, t, tn - 1); - c = ZSTD_eDist_levenshteinDist(s, sn - 1, t, tn); - - if (a > b) - a = b; - if (a > c) - a = c; - - return a + 1; -} - -static void ZSTD_eDist_validateMatches(ZSTD_eDist_match* matches, - size_t const nbMatches, const BYTE* const dict, - size_t const dictSize, const BYTE* const src, - size_t const srcSize) -{ - size_t i; - for (i = 0; i < nbMatches; i++) { - ZSTD_eDist_match match = matches[i]; - U32 const dictIdx = match.dictIdx; - U32 const srcIdx = match.srcIdx; - U32 const matchLength = match.matchLength; - - assert(dictIdx + matchLength < dictSize); - assert(srcIdx + matchLength < srcSize); - assert(!memcmp(dict + dictIdx, src + srcIdx, matchLength)); - } -} - -/*-************************************* -* API -***************************************/ - -size_t ZSTD_eDist_genSequences(ZSTD_Sequence* sequences, - const void* dict, size_t dictSize, - const void* src, size_t srcSize, - int useHeuristics) -{ - size_t const nbDiags = dictSize + srcSize + 3; - S32* buffer = ZSTD_malloc(nbDiags * 2 * sizeof(S32), ZSTD_defaultCMem); - ZSTD_eDist_state state; - size_t nbSequences = 0; - - state.dict = (const BYTE*)dict; - state.src = (const BYTE*)src; - state.dictSize = dictSize; - state.srcSize = srcSize; - state.forwardDiag = buffer; - state.backwardDiag = buffer + nbDiags; - state.forwardDiag += srcSize + 1; - state.backwardDiag += srcSize + 1; - state.matches = ZSTD_malloc(srcSize * sizeof(ZSTD_eDist_match), ZSTD_defaultCMem); - state.nbMatches = 0; - - ZSTD_eDist_compare(&state, 0, dictSize, 0, srcSize, 1); - ZSTD_eDist_combineMatches(&state); - nbSequences = ZSTD_eDist_convertMatchesToSequences(sequences, &state); - - ZSTD_free(buffer, ZSTD_defaultCMem); - ZSTD_free(state.matches, ZSTD_defaultCMem); - - return nbSequences; -} diff --git a/third_party/zstd/contrib/match_finders/zstd_edist.h b/third_party/zstd/contrib/match_finders/zstd_edist.h deleted file mode 100644 index c739e2abc..000000000 --- a/third_party/zstd/contrib/match_finders/zstd_edist.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under both the BSD-style license (found in the - * LICENSE file in the root directory of this source tree) and the GPLv2 (found - * in the COPYING file in the root directory of this source tree). - * You may select, at your option, one of the above-listed licenses. - */ - -/* This match finder leverages techniques used in file comparison algorithms - * to find matches between a dictionary and a source file. - * - * The original motivation for studying this approach was to try and optimize - * Zstandard for the use case of patching: the most common scenario being - * updating an existing software package with the next version. When patching, - * the difference between the old version of the package and the new version - * is generally tiny (most of the new file will be identical to - * the old one). In more technical terms, the edit distance (the minimal number - * of changes required to take one sequence of bytes to another) between the - * files would be small relative to the size of the file. - * - * Various 'diffing' algorithms utilize this notion of edit distance and - * the corresponding concept of a minimal edit script between two - * sequences to identify the regions within two files where they differ. - * The core algorithm used in this match finder is described in: - * - * "An O(ND) Difference Algorithm and its Variations", Eugene W. Myers, - * Algorithmica Vol. 1, 1986, pp. 251-266, - * . - * - * Additional algorithmic heuristics for speed improvement have also been included. - * These we inspired from implementations of various regular and binary diffing - * algorithms such as GNU diff, bsdiff, and Xdelta. - * - * Note: after some experimentation, this approach proved to not provide enough - * utility to justify the additional CPU used in finding matches. The one area - * where this approach consistently outperforms Zstandard even on level 19 is - * when compressing small files (<10 KB) using an equally small dictionary that - * is very similar to the source file. For the use case that this was intended, - * (large similar files) this approach by itself took 5-10X longer than zstd-19 and - * generally resulted in 2-3X larger files. The core advantage that zstd-19 has - * over this approach for match finding is the overlapping matches. This approach - * cannot find any. - * - * I'm leaving this in the contrib section in case this ever becomes interesting - * to explore again. - * */ - -#ifndef ZSTD_EDIST_H -#define ZSTD_EDIST_H - -/*-************************************* -* Dependencies -***************************************/ - -#include -#include "zstd_internal.h" /* ZSTD_Sequence */ - -/*! ZSTD_eDist_genSequences() : - * Will populate the provided ZSTD_Sequence buffer with sequences - * based on the optimal or near-optimal (depending on 'useHeuristics') - * edit script between 'dict' and 'src.' - * @return : the number of sequences found */ -size_t ZSTD_eDist_genSequences(ZSTD_Sequence* sequences, - const void* dict, size_t dictSize, - const void* src, size_t srcSize, - int useHeuristics); - -#endif diff --git a/third_party/zstd/contrib/premake/premake4.lua b/third_party/zstd/contrib/premake/premake4.lua deleted file mode 100644 index 6675e2e48..000000000 --- a/third_party/zstd/contrib/premake/premake4.lua +++ /dev/null @@ -1,6 +0,0 @@ --- Include zstd.lua in your GENie or premake4 file, which exposes a project_zstd function -dofile('zstd.lua') - -solution 'example' - configurations { 'Debug', 'Release' } - project_zstd('../../lib/') diff --git a/third_party/zstd/contrib/premake/zstd.lua b/third_party/zstd/contrib/premake/zstd.lua deleted file mode 100644 index df1ace3ee..000000000 --- a/third_party/zstd/contrib/premake/zstd.lua +++ /dev/null @@ -1,80 +0,0 @@ --- This GENie/premake file copies the behavior of the Makefile in the lib folder. --- Basic usage: project_zstd(ZSTD_DIR) - -function project_zstd(dir, compression, decompression, deprecated, dictbuilder, legacy) - if compression == nil then compression = true end - if decompression == nil then decompression = true end - if deprecated == nil then deprecated = false end - if dictbuilder == nil then dictbuilder = false end - - if legacy == nil then legacy = 0 end - - if not compression then - dictbuilder = false - deprecated = false - end - - if not decompression then - legacy = 0 - deprecated = false - end - - project 'zstd' - kind 'StaticLib' - language 'C' - - files { - dir .. 'zstd.h', - dir .. 'common/**.c', - dir .. 'common/**.h' - } - - if compression then - files { - dir .. 'compress/**.c', - dir .. 'compress/**.h' - } - end - - if decompression then - files { - dir .. 'decompress/**.c', - dir .. 'decompress/**.h' - } - end - - if dictbuilder then - files { - dir .. 'dictBuilder/**.c', - dir .. 'dictBuilder/**.h' - } - end - - if deprecated then - files { - dir .. 'deprecated/**.c', - dir .. 'deprecated/**.h' - } - end - - if legacy ~= 0 then - if legacy >= 8 then - files { - dir .. 'legacy/zstd_v0' .. (legacy - 7) .. '.*' - } - end - includedirs { - dir .. 'legacy' - } - end - - includedirs { - dir, - dir .. 'common' - } - - defines { - 'XXH_NAMESPACE=ZSTD_', - 'ZSTD_LEGACY_SUPPORT=' .. legacy - } -end diff --git a/third_party/zstd/contrib/pzstd/.gitignore b/third_party/zstd/contrib/pzstd/.gitignore deleted file mode 100644 index 84e68fb07..000000000 --- a/third_party/zstd/contrib/pzstd/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# compilation result -pzstd diff --git a/third_party/zstd/contrib/pzstd/BUCK b/third_party/zstd/contrib/pzstd/BUCK deleted file mode 100644 index d04eeedd8..000000000 --- a/third_party/zstd/contrib/pzstd/BUCK +++ /dev/null @@ -1,72 +0,0 @@ -cxx_library( - name='libpzstd', - visibility=['PUBLIC'], - header_namespace='', - exported_headers=[ - 'ErrorHolder.h', - 'Logging.h', - 'Pzstd.h', - ], - headers=[ - 'SkippableFrame.h', - ], - srcs=[ - 'Pzstd.cpp', - 'SkippableFrame.cpp', - ], - deps=[ - ':options', - '//contrib/pzstd/utils:utils', - '//lib:mem', - '//lib:zstd', - ], -) - -cxx_library( - name='options', - visibility=['PUBLIC'], - header_namespace='', - exported_headers=['Options.h'], - srcs=['Options.cpp'], - deps=[ - '//contrib/pzstd/utils:scope_guard', - '//lib:zstd', - '//programs:util', - ], -) - -cxx_binary( - name='pzstd', - visibility=['PUBLIC'], - srcs=['main.cpp'], - deps=[ - ':libpzstd', - ':options', - ], -) - -# Must run "make googletest" first -cxx_library( - name='gtest', - srcs=glob([ - 'googletest/googletest/src/gtest-all.cc', - 'googletest/googlemock/src/gmock-all.cc', - 'googletest/googlemock/src/gmock_main.cc', - ]), - header_namespace='', - exported_headers=subdir_glob([ - ('googletest/googletest/include', '**/*.h'), - ('googletest/googlemock/include', '**/*.h'), - ]), - headers=subdir_glob([ - ('googletest/googletest', 'src/*.cc'), - ('googletest/googletest', 'src/*.h'), - ('googletest/googlemock', 'src/*.cc'), - ('googletest/googlemock', 'src/*.h'), - ]), - platform_linker_flags=[ - ('android', []), - ('', ['-lpthread']), - ], - visibility=['PUBLIC'], -) diff --git a/third_party/zstd/contrib/pzstd/ErrorHolder.h b/third_party/zstd/contrib/pzstd/ErrorHolder.h deleted file mode 100644 index 2c2797ede..000000000 --- a/third_party/zstd/contrib/pzstd/ErrorHolder.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under both the BSD-style license (found in the - * LICENSE file in the root directory of this source tree) and the GPLv2 (found - * in the COPYING file in the root directory of this source tree). - */ -#pragma once - -#include -#include -#include -#include - -namespace pzstd { - -// Coordinates graceful shutdown of the pzstd pipeline -class ErrorHolder { - std::atomic error_; - std::string message_; - - public: - ErrorHolder() : error_(false) {} - - bool hasError() noexcept { - return error_.load(); - } - - void setError(std::string message) noexcept { - // Given multiple possibly concurrent calls, exactly one will ever succeed. - bool expected = false; - if (error_.compare_exchange_strong(expected, true)) { - message_ = std::move(message); - } - } - - bool check(bool predicate, std::string message) noexcept { - if (!predicate) { - setError(std::move(message)); - } - return !hasError(); - } - - std::string getError() noexcept { - error_.store(false); - return std::move(message_); - } - - ~ErrorHolder() { - assert(!hasError()); - } -}; -} diff --git a/third_party/zstd/contrib/pzstd/Logging.h b/third_party/zstd/contrib/pzstd/Logging.h deleted file mode 100644 index 84a08d200..000000000 --- a/third_party/zstd/contrib/pzstd/Logging.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under both the BSD-style license (found in the - * LICENSE file in the root directory of this source tree) and the GPLv2 (found - * in the COPYING file in the root directory of this source tree). - */ -#pragma once - -#include -#include - -namespace pzstd { - -constexpr int kLogError = 1; -constexpr int kLogInfo = 2; -constexpr int kLogDebug = 3; -constexpr int kLogVerbose = 4; - -class Logger { - std::mutex mutex_; - FILE* out_; - const int level_; - - using Clock = std::chrono::system_clock; - Clock::time_point lastUpdate_; - std::chrono::milliseconds refreshRate_; - - public: - explicit Logger(int level, FILE* out = stderr) - : out_(out), level_(level), lastUpdate_(Clock::now()), - refreshRate_(150) {} - - - bool logsAt(int level) { - return level <= level_; - } - - template - void operator()(int level, const char *fmt, Args... args) { - if (level > level_) { - return; - } - std::lock_guard lock(mutex_); - std::fprintf(out_, fmt, args...); - } - - template - void update(int level, const char *fmt, Args... args) { - if (level > level_) { - return; - } - std::lock_guard lock(mutex_); - auto now = Clock::now(); - if (now - lastUpdate_ > refreshRate_) { - lastUpdate_ = now; - std::fprintf(out_, "\r"); - std::fprintf(out_, fmt, args...); - } - } - - void clear(int level) { - if (level > level_) { - return; - } - std::lock_guard lock(mutex_); - std::fprintf(out_, "\r%79s\r", ""); - } -}; - -} diff --git a/third_party/zstd/contrib/pzstd/Makefile b/third_party/zstd/contrib/pzstd/Makefile deleted file mode 100644 index e62f8e873..000000000 --- a/third_party/zstd/contrib/pzstd/Makefile +++ /dev/null @@ -1,268 +0,0 @@ -# ################################################################ -# Copyright (c) Meta Platforms, Inc. and affiliates. -# All rights reserved. -# -# This source code is licensed under both the BSD-style license (found in the -# LICENSE file in the root directory of this source tree) and the GPLv2 (found -# in the COPYING file in the root directory of this source tree). -# ################################################################ - -# Standard variables for installation -DESTDIR ?= -PREFIX ?= /usr/local -BINDIR := $(DESTDIR)$(PREFIX)/bin - -ZSTDDIR = ../../lib -PROGDIR = ../../programs - -# External program to use to run tests, e.g. qemu or valgrind -TESTPROG ?= -# Flags to pass to the tests -TESTFLAGS ?= - -# We use gcc/clang to generate the header dependencies of files -DEPFLAGS = -MMD -MP -MF $*.Td -POSTCOMPILE = mv -f $*.Td $*.d - -# CFLAGS, CXXFLAGS, CPPFLAGS, and LDFLAGS are for the users to override -CFLAGS ?= -O3 -Wall -Wextra -CXXFLAGS ?= -O3 -Wall -Wextra -pedantic -CPPFLAGS ?= -LDFLAGS ?= - -# PZstd uses legacy APIs -CFLAGS += -Wno-deprecated-declarations - -# Include flags -PZSTD_INC = -I$(ZSTDDIR) -I$(ZSTDDIR)/common -I$(PROGDIR) -I. -GTEST_INC = -isystem googletest/googletest/include - -# If default C++ version is older than C++11, explicitly set C++11, which is the -# minimum required by the code. -ifeq ($(shell echo "\043if __cplusplus < 201103L\n\043error\n\043endif" | $(CXX) -x c++ -Werror -c - -o /dev/null 2>/dev/null && echo 1 || echo 0),0) -PZSTD_CXX_STD := -std=c++11 -endif - -PZSTD_CPPFLAGS = $(PZSTD_INC) -PZSTD_CCXXFLAGS = -PZSTD_CFLAGS = $(PZSTD_CCXXFLAGS) -PZSTD_CXXFLAGS = $(PZSTD_CCXXFLAGS) $(PZSTD_CXX_STD) -PZSTD_LDFLAGS = -EXTRA_FLAGS = -ALL_CFLAGS = $(EXTRA_FLAGS) $(CPPFLAGS) $(PZSTD_CPPFLAGS) $(CFLAGS) $(PZSTD_CFLAGS) -ALL_CXXFLAGS = $(EXTRA_FLAGS) $(CPPFLAGS) $(PZSTD_CPPFLAGS) $(CXXFLAGS) $(PZSTD_CXXFLAGS) -ALL_LDFLAGS = $(EXTRA_FLAGS) $(CXXFLAGS) $(LDFLAGS) $(PZSTD_LDFLAGS) - - -# gtest libraries need to go before "-lpthread" because they depend on it. -GTEST_LIB = -L googletest/build/googlemock/gtest -LIBS = - -# Compilation commands -LD_COMMAND = $(CXX) $^ $(ALL_LDFLAGS) $(LIBS) -pthread -o $@ -CC_COMMAND = $(CC) $(DEPFLAGS) $(ALL_CFLAGS) -c $< -o $@ -CXX_COMMAND = $(CXX) $(DEPFLAGS) $(ALL_CXXFLAGS) -c $< -o $@ - -# List all the pzstd source files so we can determine their dependencies -PZSTD_SRCS := $(wildcard *.cpp) -PZSTD_TESTS := $(wildcard test/*.cpp) -UTILS_TESTS := $(wildcard utils/test/*.cpp) -ALL_SRCS := $(PZSTD_SRCS) $(PZSTD_TESTS) $(UTILS_TESTS) - - -# Define *.exe as extension for Windows systems -ifneq (,$(filter Windows%,$(OS))) -EXT =.exe -else -EXT = -endif - -# Standard targets -.PHONY: default -default: all - -.PHONY: test-pzstd -test-pzstd: TESTFLAGS=--gtest_filter=-*ExtremelyLarge* -test-pzstd: clean googletest pzstd tests check - -.PHONY: test-pzstd32 -test-pzstd32: clean googletest32 all32 check - -.PHONY: test-pzstd-tsan -test-pzstd-tsan: LDFLAGS=-fuse-ld=gold -test-pzstd-tsan: TESTFLAGS=--gtest_filter=-*ExtremelyLarge* -test-pzstd-tsan: clean googletest tsan check - -.PHONY: test-pzstd-asan -test-pzstd-asan: LDFLAGS=-fuse-ld=gold -test-pzstd-asan: TESTFLAGS=--gtest_filter=-*ExtremelyLarge* -test-pzstd-asan: clean asan check - -.PHONY: check -check: - $(TESTPROG) ./utils/test/BufferTest$(EXT) $(TESTFLAGS) - $(TESTPROG) ./utils/test/RangeTest$(EXT) $(TESTFLAGS) - $(TESTPROG) ./utils/test/ResourcePoolTest$(EXT) $(TESTFLAGS) - $(TESTPROG) ./utils/test/ScopeGuardTest$(EXT) $(TESTFLAGS) - $(TESTPROG) ./utils/test/ThreadPoolTest$(EXT) $(TESTFLAGS) - $(TESTPROG) ./utils/test/WorkQueueTest$(EXT) $(TESTFLAGS) - $(TESTPROG) ./test/OptionsTest$(EXT) $(TESTFLAGS) - $(TESTPROG) ./test/PzstdTest$(EXT) $(TESTFLAGS) - -.PHONY: install -install: PZSTD_CPPFLAGS += -DNDEBUG -install: pzstd$(EXT) - install -d -m 755 $(BINDIR)/ - install -m 755 pzstd$(EXT) $(BINDIR)/pzstd$(EXT) - -.PHONY: uninstall -uninstall: - $(RM) $(BINDIR)/pzstd$(EXT) - -# Targets for many different builds -.PHONY: all -all: PZSTD_CPPFLAGS += -DNDEBUG -all: pzstd$(EXT) - -.PHONY: debug -debug: EXTRA_FLAGS += -g -debug: pzstd$(EXT) tests roundtrip - -.PHONY: tsan -tsan: PZSTD_CCXXFLAGS += -fsanitize=thread -fPIC -tsan: PZSTD_LDFLAGS += -fsanitize=thread -tsan: debug - -.PHONY: asan -asan: EXTRA_FLAGS += -fsanitize=address -asan: debug - -.PHONY: ubsan -ubsan: EXTRA_FLAGS += -fsanitize=undefined -ubsan: debug - -.PHONY: all32 -all32: EXTRA_FLAGS += -m32 -all32: all tests roundtrip - -.PHONY: debug32 -debug32: EXTRA_FLAGS += -m32 -debug32: debug - -.PHONY: asan32 -asan32: EXTRA_FLAGS += -m32 -asan32: asan - -.PHONY: tsan32 -tsan32: EXTRA_FLAGS += -m32 -tsan32: tsan - -.PHONY: ubsan32 -ubsan32: EXTRA_FLAGS += -m32 -ubsan32: ubsan - -# Run long round trip tests -.PHONY: roundtripcheck -roundtripcheck: roundtrip check - $(TESTPROG) ./test/RoundTripTest$(EXT) $(TESTFLAGS) - -# Build the main binary -pzstd$(EXT): main.o $(PROGDIR)/util.o Options.o Pzstd.o SkippableFrame.o $(ZSTDDIR)/libzstd.a - $(LD_COMMAND) - -# Target that depends on all the tests -.PHONY: tests -tests: EXTRA_FLAGS += -Wno-deprecated-declarations -tests: $(patsubst %,%$(EXT),$(basename $(PZSTD_TESTS) $(UTILS_TESTS))) - -# Build the round trip tests -.PHONY: roundtrip -roundtrip: EXTRA_FLAGS += -Wno-deprecated-declarations -roundtrip: test/RoundTripTest$(EXT) - -# Use the static library that zstd builds for simplicity and -# so we get the compiler options correct -.PHONY: $(ZSTDDIR)/libzstd.a -$(ZSTDDIR)/libzstd.a: - CFLAGS="$(ALL_CFLAGS)" LDFLAGS="$(ALL_LDFLAGS)" $(MAKE) -C $(ZSTDDIR) libzstd.a - -# Rules to build the tests -test/RoundTripTest$(EXT): test/RoundTripTest.o $(PROGDIR)/datagen.o \ - $(PROGDIR)/util.o Options.o \ - Pzstd.o SkippableFrame.o $(ZSTDDIR)/libzstd.a - $(LD_COMMAND) - -test/%Test$(EXT): PZSTD_LDFLAGS += $(GTEST_LIB) -test/%Test$(EXT): LIBS += -lgtest -lgtest_main -test/%Test$(EXT): test/%Test.o $(PROGDIR)/datagen.o \ - $(PROGDIR)/util.o Options.o Pzstd.o \ - SkippableFrame.o $(ZSTDDIR)/libzstd.a - $(LD_COMMAND) - -utils/test/%Test$(EXT): PZSTD_LDFLAGS += $(GTEST_LIB) -utils/test/%Test$(EXT): LIBS += -lgtest -lgtest_main -utils/test/%Test$(EXT): utils/test/%Test.o - $(LD_COMMAND) - - -GTEST_CMAKEFLAGS = - -# Install googletest -.PHONY: googletest -googletest: PZSTD_CCXXFLAGS += -fPIC -googletest: - @$(RM) -rf googletest - @git clone https://github.com/google/googletest - @mkdir -p googletest/build - @cd googletest/build && cmake $(GTEST_CMAKEFLAGS) -DCMAKE_CXX_FLAGS="$(ALL_CXXFLAGS)" .. && $(MAKE) - -.PHONY: googletest32 -googletest32: PZSTD_CCXXFLAGS += -m32 -googletest32: googletest - -.PHONY: googletest-mingw64 -googletest-mingw64: GTEST_CMAKEFLAGS += -G "MSYS Makefiles" -googletest-mingw64: googletest - -.PHONY: clean -clean: - $(RM) -f *.o pzstd$(EXT) *.Td *.d - $(RM) -f test/*.o test/*Test$(EXT) test/*.Td test/*.d - $(RM) -f utils/test/*.o utils/test/*Test$(EXT) utils/test/*.Td utils/test/*.d - $(RM) -f $(PROGDIR)/*.o $(PROGDIR)/*.Td $(PROGDIR)/*.d - $(MAKE) -C $(ZSTDDIR) clean - @echo Cleaning completed - - -# Cancel implicit rules -%.o: %.c -%.o: %.cpp - -# Object file rules -%.o: %.c - $(CC_COMMAND) - $(POSTCOMPILE) - -$(PROGDIR)/%.o: $(PROGDIR)/%.c - $(CC_COMMAND) - $(POSTCOMPILE) - -%.o: %.cpp - $(CXX_COMMAND) - $(POSTCOMPILE) - -test/%.o: PZSTD_CPPFLAGS += $(GTEST_INC) -test/%.o: test/%.cpp - $(CXX_COMMAND) - $(POSTCOMPILE) - -utils/test/%.o: PZSTD_CPPFLAGS += $(GTEST_INC) -utils/test/%.o: utils/test/%.cpp - $(CXX_COMMAND) - $(POSTCOMPILE) - -# Dependency file stuff -.PRECIOUS: %.d test/%.d utils/test/%.d - -# Include rules that specify header file dependencies --include $(patsubst %,%.d,$(basename $(ALL_SRCS))) diff --git a/third_party/zstd/contrib/pzstd/Options.cpp b/third_party/zstd/contrib/pzstd/Options.cpp deleted file mode 100644 index a77824edb..000000000 --- a/third_party/zstd/contrib/pzstd/Options.cpp +++ /dev/null @@ -1,424 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under both the BSD-style license (found in the - * LICENSE file in the root directory of this source tree) and the GPLv2 (found - * in the COPYING file in the root directory of this source tree). - */ -#include "Options.h" -#include "util.h" -#include "utils/ScopeGuard.h" - -#include -#include -#include -#include -#include -#include -#include - - -namespace pzstd { - -namespace { -unsigned defaultNumThreads() { -#ifdef PZSTD_NUM_THREADS - return PZSTD_NUM_THREADS; -#else - return std::thread::hardware_concurrency(); -#endif -} - -unsigned parseUnsigned(const char **arg) { - unsigned result = 0; - while (**arg >= '0' && **arg <= '9') { - result *= 10; - result += **arg - '0'; - ++(*arg); - } - return result; -} - -const char *getArgument(const char *options, const char **argv, int &i, - int argc) { - if (options[1] != 0) { - return options + 1; - } - ++i; - if (i == argc) { - std::fprintf(stderr, "Option -%c requires an argument, but none provided\n", - *options); - return nullptr; - } - return argv[i]; -} - -const std::string kZstdExtension = ".zst"; -constexpr char kStdIn[] = "-"; -constexpr char kStdOut[] = "-"; -constexpr unsigned kDefaultCompressionLevel = 3; -constexpr unsigned kMaxNonUltraCompressionLevel = 19; - -#ifdef _WIN32 -const char nullOutput[] = "nul"; -#else -const char nullOutput[] = "/dev/null"; -#endif - -void notSupported(const char *option) { - std::fprintf(stderr, "Operation not supported: %s\n", option); -} - -void usage() { - std::fprintf(stderr, "Usage:\n"); - std::fprintf(stderr, " pzstd [args] [FILE(s)]\n"); - std::fprintf(stderr, "Parallel ZSTD options:\n"); - std::fprintf(stderr, " -p, --processes # : number of threads to use for (de)compression (default:)\n"); - - std::fprintf(stderr, "ZSTD options:\n"); - std::fprintf(stderr, " -# : # compression level (1-%d, default:%d)\n", kMaxNonUltraCompressionLevel, kDefaultCompressionLevel); - std::fprintf(stderr, " -d, --decompress : decompression\n"); - std::fprintf(stderr, " -o file : result stored into `file` (only if 1 input file)\n"); - std::fprintf(stderr, " -f, --force : overwrite output without prompting, (de)compress links\n"); - std::fprintf(stderr, " --rm : remove source file(s) after successful (de)compression\n"); - std::fprintf(stderr, " -k, --keep : preserve source file(s) (default)\n"); - std::fprintf(stderr, " -h, --help : display help and exit\n"); - std::fprintf(stderr, " -V, --version : display version number and exit\n"); - std::fprintf(stderr, " -v, --verbose : verbose mode; specify multiple times to increase log level (default:2)\n"); - std::fprintf(stderr, " -q, --quiet : suppress warnings; specify twice to suppress errors too\n"); - std::fprintf(stderr, " -c, --stdout : write to standard output (even if it is the console)\n"); -#ifdef UTIL_HAS_CREATEFILELIST - std::fprintf(stderr, " -r : operate recursively on directories\n"); -#endif - std::fprintf(stderr, " --ultra : enable levels beyond %i, up to %i (requires more memory)\n", kMaxNonUltraCompressionLevel, ZSTD_maxCLevel()); - std::fprintf(stderr, " -C, --check : integrity check (default)\n"); - std::fprintf(stderr, " --no-check : no integrity check\n"); - std::fprintf(stderr, " -t, --test : test compressed file integrity\n"); - std::fprintf(stderr, " -- : all arguments after \"--\" are treated as files\n"); -} -} // anonymous namespace - -Options::Options() - : numThreads(defaultNumThreads()), maxWindowLog(23), - compressionLevel(kDefaultCompressionLevel), decompress(false), - overwrite(false), keepSource(true), writeMode(WriteMode::Auto), - checksum(true), verbosity(2) {} - -Options::Status Options::parse(int argc, const char **argv) { - bool test = false; - bool recursive = false; - bool ultra = false; - bool forceStdout = false; - bool followLinks = false; - // Local copy of input files, which are pointers into argv. - std::vector localInputFiles; - for (int i = 1; i < argc; ++i) { - const char *arg = argv[i]; - // Protect against empty arguments - if (arg[0] == 0) { - continue; - } - // Everything after "--" is an input file - if (!std::strcmp(arg, "--")) { - ++i; - std::copy(argv + i, argv + argc, std::back_inserter(localInputFiles)); - break; - } - // Long arguments that don't have a short option - { - bool isLongOption = true; - if (!std::strcmp(arg, "--rm")) { - keepSource = false; - } else if (!std::strcmp(arg, "--ultra")) { - ultra = true; - maxWindowLog = 0; - } else if (!std::strcmp(arg, "--no-check")) { - checksum = false; - } else if (!std::strcmp(arg, "--sparse")) { - writeMode = WriteMode::Sparse; - notSupported("Sparse mode"); - return Status::Failure; - } else if (!std::strcmp(arg, "--no-sparse")) { - writeMode = WriteMode::Regular; - notSupported("Sparse mode"); - return Status::Failure; - } else if (!std::strcmp(arg, "--dictID")) { - notSupported(arg); - return Status::Failure; - } else if (!std::strcmp(arg, "--no-dictID")) { - notSupported(arg); - return Status::Failure; - } else { - isLongOption = false; - } - if (isLongOption) { - continue; - } - } - // Arguments with a short option simply set their short option. - const char *options = nullptr; - if (!std::strcmp(arg, "--processes")) { - options = "p"; - } else if (!std::strcmp(arg, "--version")) { - options = "V"; - } else if (!std::strcmp(arg, "--help")) { - options = "h"; - } else if (!std::strcmp(arg, "--decompress")) { - options = "d"; - } else if (!std::strcmp(arg, "--force")) { - options = "f"; - } else if (!std::strcmp(arg, "--stdout")) { - options = "c"; - } else if (!std::strcmp(arg, "--keep")) { - options = "k"; - } else if (!std::strcmp(arg, "--verbose")) { - options = "v"; - } else if (!std::strcmp(arg, "--quiet")) { - options = "q"; - } else if (!std::strcmp(arg, "--check")) { - options = "C"; - } else if (!std::strcmp(arg, "--test")) { - options = "t"; - } else if (arg[0] == '-' && arg[1] != 0) { - options = arg + 1; - } else { - localInputFiles.emplace_back(arg); - continue; - } - assert(options != nullptr); - - bool finished = false; - while (!finished && *options != 0) { - // Parse the compression level - if (*options >= '0' && *options <= '9') { - compressionLevel = parseUnsigned(&options); - continue; - } - - switch (*options) { - case 'h': - case 'H': - usage(); - return Status::Message; - case 'V': - std::fprintf(stderr, "PZSTD version: %s.\n", ZSTD_VERSION_STRING); - return Status::Message; - case 'p': { - finished = true; - const char *optionArgument = getArgument(options, argv, i, argc); - if (optionArgument == nullptr) { - return Status::Failure; - } - if (*optionArgument < '0' || *optionArgument > '9') { - std::fprintf(stderr, "Option -p expects a number, but %s provided\n", - optionArgument); - return Status::Failure; - } - numThreads = parseUnsigned(&optionArgument); - if (*optionArgument != 0) { - std::fprintf(stderr, - "Option -p expects a number, but %u%s provided\n", - numThreads, optionArgument); - return Status::Failure; - } - break; - } - case 'o': { - finished = true; - const char *optionArgument = getArgument(options, argv, i, argc); - if (optionArgument == nullptr) { - return Status::Failure; - } - outputFile = optionArgument; - break; - } - case 'C': - checksum = true; - break; - case 'k': - keepSource = true; - break; - case 'd': - decompress = true; - break; - case 'f': - overwrite = true; - forceStdout = true; - followLinks = true; - break; - case 't': - test = true; - decompress = true; - break; -#ifdef UTIL_HAS_CREATEFILELIST - case 'r': - recursive = true; - break; -#endif - case 'c': - outputFile = kStdOut; - forceStdout = true; - break; - case 'v': - ++verbosity; - break; - case 'q': - --verbosity; - // Ignore them for now - break; - // Unsupported options from Zstd - case 'D': - case 's': - notSupported("Zstd dictionaries."); - return Status::Failure; - case 'b': - case 'e': - case 'i': - case 'B': - notSupported("Zstd benchmarking options."); - return Status::Failure; - default: - std::fprintf(stderr, "Invalid argument: %s\n", arg); - return Status::Failure; - } - if (!finished) { - ++options; - } - } // while (*options != 0); - } // for (int i = 1; i < argc; ++i); - - // Set options for test mode - if (test) { - outputFile = nullOutput; - keepSource = true; - } - - // Input file defaults to standard input if not provided. - if (localInputFiles.empty()) { - localInputFiles.emplace_back(kStdIn); - } - - // Check validity of input files - if (localInputFiles.size() > 1) { - const auto it = std::find(localInputFiles.begin(), localInputFiles.end(), - std::string{kStdIn}); - if (it != localInputFiles.end()) { - std::fprintf( - stderr, - "Cannot specify standard input when handling multiple files\n"); - return Status::Failure; - } - } - if (localInputFiles.size() > 1 || recursive) { - if (!outputFile.empty() && outputFile != nullOutput) { - std::fprintf( - stderr, - "Cannot specify an output file when handling multiple inputs\n"); - return Status::Failure; - } - } - - g_utilDisplayLevel = verbosity; - // Remove local input files that are symbolic links - if (!followLinks) { - std::remove_if(localInputFiles.begin(), localInputFiles.end(), - [&](const char *path) { - bool isLink = UTIL_isLink(path); - if (isLink && verbosity >= 2) { - std::fprintf( - stderr, - "Warning : %s is symbolic link, ignoring\n", - path); - } - return isLink; - }); - } - - // Translate input files/directories into files to (de)compress - if (recursive) { - FileNamesTable* const files = UTIL_createExpandedFNT(localInputFiles.data(), localInputFiles.size(), followLinks); - if (files == nullptr) { - std::fprintf(stderr, "Error traversing directories\n"); - return Status::Failure; - } - auto guard = - makeScopeGuard([&] { UTIL_freeFileNamesTable(files); }); - if (files->tableSize == 0) { - std::fprintf(stderr, "No files found\n"); - return Status::Failure; - } - inputFiles.resize(files->tableSize); - std::copy(files->fileNames, files->fileNames + files->tableSize, inputFiles.begin()); - } else { - inputFiles.resize(localInputFiles.size()); - std::copy(localInputFiles.begin(), localInputFiles.end(), - inputFiles.begin()); - } - localInputFiles.clear(); - assert(!inputFiles.empty()); - - // If reading from standard input, default to standard output - if (inputFiles[0] == kStdIn && outputFile.empty()) { - assert(inputFiles.size() == 1); - outputFile = "-"; - } - - if (inputFiles[0] == kStdIn && IS_CONSOLE(stdin)) { - assert(inputFiles.size() == 1); - std::fprintf(stderr, "Cannot read input from interactive console\n"); - return Status::Failure; - } - if (outputFile == "-" && IS_CONSOLE(stdout) && !(forceStdout && decompress)) { - std::fprintf(stderr, "Will not write to console stdout unless -c or -f is " - "specified and decompressing\n"); - return Status::Failure; - } - - // Check compression level - { - unsigned maxCLevel = - ultra ? ZSTD_maxCLevel() : kMaxNonUltraCompressionLevel; - if (compressionLevel > maxCLevel || compressionLevel == 0) { - std::fprintf(stderr, "Invalid compression level %u.\n", compressionLevel); - return Status::Failure; - } - } - - // Check that numThreads is set - if (numThreads == 0) { - std::fprintf(stderr, "Invalid arguments: # of threads not specified " - "and unable to determine hardware concurrency.\n"); - return Status::Failure; - } - - // Modify verbosity - // If we are piping input and output, turn off interaction - if (inputFiles[0] == kStdIn && outputFile == kStdOut && verbosity == 2) { - verbosity = 1; - } - // If we are in multi-file mode, turn off interaction - if (inputFiles.size() > 1 && verbosity == 2) { - verbosity = 1; - } - - return Status::Success; -} - -std::string Options::getOutputFile(const std::string &inputFile) const { - if (!outputFile.empty()) { - return outputFile; - } - // Attempt to add/remove zstd extension from the input file - if (decompress) { - int stemSize = inputFile.size() - kZstdExtension.size(); - if (stemSize > 0 && inputFile.substr(stemSize) == kZstdExtension) { - return inputFile.substr(0, stemSize); - } else { - return ""; - } - } else { - return inputFile + kZstdExtension; - } -} -} diff --git a/third_party/zstd/contrib/pzstd/Options.h b/third_party/zstd/contrib/pzstd/Options.h deleted file mode 100644 index 92c18a350..000000000 --- a/third_party/zstd/contrib/pzstd/Options.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under both the BSD-style license (found in the - * LICENSE file in the root directory of this source tree) and the GPLv2 (found - * in the COPYING file in the root directory of this source tree). - */ -#pragma once - -#define ZSTD_STATIC_LINKING_ONLY -#define ZSTD_DISABLE_DEPRECATE_WARNINGS /* No deprecation warnings, pzstd itself is deprecated - * and uses deprecated functions - */ -#include "zstd.h" -#undef ZSTD_STATIC_LINKING_ONLY - -#include -#include -#include - -namespace pzstd { - -struct Options { - enum class WriteMode { Regular, Auto, Sparse }; - - unsigned numThreads; - unsigned maxWindowLog; - unsigned compressionLevel; - bool decompress; - std::vector inputFiles; - std::string outputFile; - bool overwrite; - bool keepSource; - WriteMode writeMode; - bool checksum; - int verbosity; - - enum class Status { - Success, // Successfully parsed options - Failure, // Failure to parse options - Message // Options specified to print a message (e.g. "-h") - }; - - Options(); - Options(unsigned numThreads, unsigned maxWindowLog, unsigned compressionLevel, - bool decompress, std::vector inputFiles, - std::string outputFile, bool overwrite, bool keepSource, - WriteMode writeMode, bool checksum, int verbosity) - : numThreads(numThreads), maxWindowLog(maxWindowLog), - compressionLevel(compressionLevel), decompress(decompress), - inputFiles(std::move(inputFiles)), outputFile(std::move(outputFile)), - overwrite(overwrite), keepSource(keepSource), writeMode(writeMode), - checksum(checksum), verbosity(verbosity) {} - - Status parse(int argc, const char **argv); - - ZSTD_parameters determineParameters() const { - ZSTD_parameters params = ZSTD_getParams(compressionLevel, 0, 0); - params.fParams.contentSizeFlag = 0; - params.fParams.checksumFlag = checksum; - if (maxWindowLog != 0 && params.cParams.windowLog > maxWindowLog) { - params.cParams.windowLog = maxWindowLog; - params.cParams = ZSTD_adjustCParams(params.cParams, 0, 0); - } - return params; - } - - std::string getOutputFile(const std::string &inputFile) const; -}; -} diff --git a/third_party/zstd/contrib/pzstd/Pzstd.cpp b/third_party/zstd/contrib/pzstd/Pzstd.cpp deleted file mode 100644 index 67b941991..000000000 --- a/third_party/zstd/contrib/pzstd/Pzstd.cpp +++ /dev/null @@ -1,618 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under both the BSD-style license (found in the - * LICENSE file in the root directory of this source tree) and the GPLv2 (found - * in the COPYING file in the root directory of this source tree). - */ -#include "platform.h" /* Large Files support, SET_BINARY_MODE */ -#include "Pzstd.h" -#include "SkippableFrame.h" -#include "utils/FileSystem.h" -#include "utils/Portability.h" -#include "utils/Range.h" -#include "utils/ScopeGuard.h" -#include "utils/ThreadPool.h" -#include "utils/WorkQueue.h" - -#include -#include -#include -#include -#include -#include -#include - - -namespace pzstd { - -namespace { -#ifdef _WIN32 -const std::string nullOutput = "nul"; -#else -const std::string nullOutput = "/dev/null"; -#endif -} - -using std::size_t; - -static std::uintmax_t fileSizeOrZero(const std::string &file) { - if (file == "-") { - return 0; - } - std::error_code ec; - auto size = file_size(file, ec); - if (ec) { - size = 0; - } - return size; -} - -static std::uint64_t handleOneInput(const Options &options, - const std::string &inputFile, - FILE* inputFd, - const std::string &outputFile, - FILE* outputFd, - SharedState& state) { - auto inputSize = fileSizeOrZero(inputFile); - // WorkQueue outlives ThreadPool so in the case of error we are certain - // we don't accidentally try to call push() on it after it is destroyed - WorkQueue> outs{options.numThreads + 1}; - std::uint64_t bytesRead; - std::uint64_t bytesWritten; - { - // Initialize the (de)compression thread pool with numThreads - ThreadPool executor(options.numThreads); - // Run the reader thread on an extra thread - ThreadPool readExecutor(1); - if (!options.decompress) { - // Add a job that reads the input and starts all the compression jobs - readExecutor.add( - [&state, &outs, &executor, inputFd, inputSize, &options, &bytesRead] { - bytesRead = asyncCompressChunks( - state, - outs, - executor, - inputFd, - inputSize, - options.numThreads, - options.determineParameters()); - }); - // Start writing - bytesWritten = writeFile(state, outs, outputFd, options.decompress); - } else { - // Add a job that reads the input and starts all the decompression jobs - readExecutor.add([&state, &outs, &executor, inputFd, &bytesRead] { - bytesRead = asyncDecompressFrames(state, outs, executor, inputFd); - }); - // Start writing - bytesWritten = writeFile(state, outs, outputFd, options.decompress); - } - } - if (!state.errorHolder.hasError()) { - std::string inputFileName = inputFile == "-" ? "stdin" : inputFile; - std::string outputFileName = outputFile == "-" ? "stdout" : outputFile; - if (!options.decompress) { - double ratio = static_cast(bytesWritten) / - static_cast(bytesRead + !bytesRead); - state.log(kLogInfo, "%-20s :%6.2f%% (%6" PRIu64 " => %6" PRIu64 - " bytes, %s)\n", - inputFileName.c_str(), ratio * 100, bytesRead, bytesWritten, - outputFileName.c_str()); - } else { - state.log(kLogInfo, "%-20s: %" PRIu64 " bytes \n", - inputFileName.c_str(),bytesWritten); - } - } - return bytesWritten; -} - -static FILE *openInputFile(const std::string &inputFile, - ErrorHolder &errorHolder) { - if (inputFile == "-") { - SET_BINARY_MODE(stdin); - return stdin; - } - // Check if input file is a directory - { - std::error_code ec; - if (is_directory(inputFile, ec)) { - errorHolder.setError("Output file is a directory -- ignored"); - return nullptr; - } - } - auto inputFd = std::fopen(inputFile.c_str(), "rb"); - if (!errorHolder.check(inputFd != nullptr, "Failed to open input file")) { - return nullptr; - } - return inputFd; -} - -static FILE *openOutputFile(const Options &options, - const std::string &outputFile, - SharedState& state) { - if (outputFile == "-") { - SET_BINARY_MODE(stdout); - return stdout; - } - // Check if the output file exists and then open it - if (!options.overwrite && outputFile != nullOutput) { - auto outputFd = std::fopen(outputFile.c_str(), "rb"); - if (outputFd != nullptr) { - std::fclose(outputFd); - if (!state.log.logsAt(kLogInfo)) { - state.errorHolder.setError("Output file exists"); - return nullptr; - } - state.log( - kLogInfo, - "pzstd: %s already exists; do you wish to overwrite (y/n) ? ", - outputFile.c_str()); - int c = getchar(); - if (c != 'y' && c != 'Y') { - state.errorHolder.setError("Not overwritten"); - return nullptr; - } - } - } - auto outputFd = std::fopen(outputFile.c_str(), "wb"); - if (!state.errorHolder.check( - outputFd != nullptr, "Failed to open output file")) { - return nullptr; - } - return outputFd; -} - -int pzstdMain(const Options &options) { - int returnCode = 0; - SharedState state(options); - for (const auto& input : options.inputFiles) { - // Setup the shared state - auto printErrorGuard = makeScopeGuard([&] { - if (state.errorHolder.hasError()) { - returnCode = 1; - state.log(kLogError, "pzstd: %s: %s.\n", input.c_str(), - state.errorHolder.getError().c_str()); - } - }); - // Open the input file - auto inputFd = openInputFile(input, state.errorHolder); - if (inputFd == nullptr) { - continue; - } - auto closeInputGuard = makeScopeGuard([&] { std::fclose(inputFd); }); - // Open the output file - auto outputFile = options.getOutputFile(input); - if (!state.errorHolder.check(outputFile != "", - "Input file does not have extension .zst")) { - continue; - } - auto outputFd = openOutputFile(options, outputFile, state); - if (outputFd == nullptr) { - continue; - } - auto closeOutputGuard = makeScopeGuard([&] { std::fclose(outputFd); }); - // (de)compress the file - handleOneInput(options, input, inputFd, outputFile, outputFd, state); - if (state.errorHolder.hasError()) { - continue; - } - // Delete the input file if necessary - if (!options.keepSource) { - // Be sure that we are done and have written everything before we delete - if (!state.errorHolder.check(std::fclose(inputFd) == 0, - "Failed to close input file")) { - continue; - } - closeInputGuard.dismiss(); - if (!state.errorHolder.check(std::fclose(outputFd) == 0, - "Failed to close output file")) { - continue; - } - closeOutputGuard.dismiss(); - if (std::remove(input.c_str()) != 0) { - state.errorHolder.setError("Failed to remove input file"); - continue; - } - } - } - // Returns 1 if any of the files failed to (de)compress. - return returnCode; -} - -/// Construct a `ZSTD_inBuffer` that points to the data in `buffer`. -static ZSTD_inBuffer makeZstdInBuffer(const Buffer& buffer) { - return ZSTD_inBuffer{buffer.data(), buffer.size(), 0}; -} - -/** - * Advance `buffer` and `inBuffer` by the amount of data read, as indicated by - * `inBuffer.pos`. - */ -void advance(Buffer& buffer, ZSTD_inBuffer& inBuffer) { - auto pos = inBuffer.pos; - inBuffer.src = static_cast(inBuffer.src) + pos; - inBuffer.size -= pos; - inBuffer.pos = 0; - return buffer.advance(pos); -} - -/// Construct a `ZSTD_outBuffer` that points to the data in `buffer`. -static ZSTD_outBuffer makeZstdOutBuffer(Buffer& buffer) { - return ZSTD_outBuffer{buffer.data(), buffer.size(), 0}; -} - -/** - * Split `buffer` and advance `outBuffer` by the amount of data written, as - * indicated by `outBuffer.pos`. - */ -Buffer split(Buffer& buffer, ZSTD_outBuffer& outBuffer) { - auto pos = outBuffer.pos; - outBuffer.dst = static_cast(outBuffer.dst) + pos; - outBuffer.size -= pos; - outBuffer.pos = 0; - return buffer.splitAt(pos); -} - -/** - * Stream chunks of input from `in`, compress it, and stream it out to `out`. - * - * @param state The shared state - * @param in Queue that we `pop()` input buffers from - * @param out Queue that we `push()` compressed output buffers to - * @param maxInputSize An upper bound on the size of the input - */ -static void compress( - SharedState& state, - std::shared_ptr in, - std::shared_ptr out, - size_t maxInputSize) { - auto& errorHolder = state.errorHolder; - auto guard = makeScopeGuard([&] { out->finish(); }); - // Initialize the CCtx - auto ctx = state.cStreamPool->get(); - if (!errorHolder.check(ctx != nullptr, "Failed to allocate ZSTD_CStream")) { - return; - } - { - auto err = ZSTD_CCtx_reset(ctx.get(), ZSTD_reset_session_only); - if (!errorHolder.check(!ZSTD_isError(err), ZSTD_getErrorName(err))) { - return; - } - } - - // Allocate space for the result - auto outBuffer = Buffer(ZSTD_compressBound(maxInputSize)); - auto zstdOutBuffer = makeZstdOutBuffer(outBuffer); - { - Buffer inBuffer; - // Read a buffer in from the input queue - while (in->pop(inBuffer) && !errorHolder.hasError()) { - auto zstdInBuffer = makeZstdInBuffer(inBuffer); - // Compress the whole buffer and send it to the output queue - while (!inBuffer.empty() && !errorHolder.hasError()) { - if (!errorHolder.check( - !outBuffer.empty(), "ZSTD_compressBound() was too small")) { - return; - } - // Compress - auto err = - ZSTD_compressStream(ctx.get(), &zstdOutBuffer, &zstdInBuffer); - if (!errorHolder.check(!ZSTD_isError(err), ZSTD_getErrorName(err))) { - return; - } - // Split the compressed data off outBuffer and pass to the output queue - out->push(split(outBuffer, zstdOutBuffer)); - // Forget about the data we already compressed - advance(inBuffer, zstdInBuffer); - } - } - } - // Write the epilog - size_t bytesLeft; - do { - if (!errorHolder.check( - !outBuffer.empty(), "ZSTD_compressBound() was too small")) { - return; - } - bytesLeft = ZSTD_endStream(ctx.get(), &zstdOutBuffer); - if (!errorHolder.check( - !ZSTD_isError(bytesLeft), ZSTD_getErrorName(bytesLeft))) { - return; - } - out->push(split(outBuffer, zstdOutBuffer)); - } while (bytesLeft != 0 && !errorHolder.hasError()); -} - -/** - * Calculates how large each independently compressed frame should be. - * - * @param size The size of the source if known, 0 otherwise - * @param numThreads The number of threads available to run compression jobs on - * @param params The zstd parameters to be used for compression - */ -static size_t calculateStep( - std::uintmax_t size, - size_t numThreads, - const ZSTD_parameters ¶ms) { - (void)size; - (void)numThreads; - // Not validated to work correctly for window logs > 23. - // It will definitely fail if windowLog + 2 is >= 4GB because - // the skippable frame can only store sizes up to 4GB. - assert(params.cParams.windowLog <= 23); - return size_t{1} << (params.cParams.windowLog + 2); -} - -namespace { -enum class FileStatus { Continue, Done, Error }; -/// Determines the status of the file descriptor `fd`. -FileStatus fileStatus(FILE* fd) { - if (std::feof(fd)) { - return FileStatus::Done; - } else if (std::ferror(fd)) { - return FileStatus::Error; - } - return FileStatus::Continue; -} -} // anonymous namespace - -/** - * Reads `size` data in chunks of `chunkSize` and puts it into `queue`. - * Will read less if an error or EOF occurs. - * Returns the status of the file after all of the reads have occurred. - */ -static FileStatus -readData(BufferWorkQueue& queue, size_t chunkSize, size_t size, FILE* fd, - std::uint64_t *totalBytesRead) { - Buffer buffer(size); - while (!buffer.empty()) { - auto bytesRead = - std::fread(buffer.data(), 1, std::min(chunkSize, buffer.size()), fd); - *totalBytesRead += bytesRead; - queue.push(buffer.splitAt(bytesRead)); - auto status = fileStatus(fd); - if (status != FileStatus::Continue) { - return status; - } - } - return FileStatus::Continue; -} - -std::uint64_t asyncCompressChunks( - SharedState& state, - WorkQueue>& chunks, - ThreadPool& executor, - FILE* fd, - std::uintmax_t size, - size_t numThreads, - ZSTD_parameters params) { - auto chunksGuard = makeScopeGuard([&] { chunks.finish(); }); - std::uint64_t bytesRead = 0; - - // Break the input up into chunks of size `step` and compress each chunk - // independently. - size_t step = calculateStep(size, numThreads, params); - state.log(kLogDebug, "Chosen frame size: %zu\n", step); - auto status = FileStatus::Continue; - while (status == FileStatus::Continue && !state.errorHolder.hasError()) { - // Make a new input queue that we will put the chunk's input data into. - auto in = std::make_shared(); - auto inGuard = makeScopeGuard([&] { in->finish(); }); - // Make a new output queue that compress will put the compressed data into. - auto out = std::make_shared(); - // Start compression in the thread pool - executor.add([&state, in, out, step] { - return compress( - state, std::move(in), std::move(out), step); - }); - // Pass the output queue to the writer thread. - chunks.push(std::move(out)); - state.log(kLogVerbose, "%s\n", "Starting a new frame"); - // Fill the input queue for the compression job we just started - status = readData(*in, ZSTD_CStreamInSize(), step, fd, &bytesRead); - } - state.errorHolder.check(status != FileStatus::Error, "Error reading input"); - return bytesRead; -} - -/** - * Decompress a frame, whose data is streamed into `in`, and stream the output - * to `out`. - * - * @param state The shared state - * @param in Queue that we `pop()` input buffers from. It contains - * exactly one compressed frame. - * @param out Queue that we `push()` decompressed output buffers to - */ -static void decompress( - SharedState& state, - std::shared_ptr in, - std::shared_ptr out) { - auto& errorHolder = state.errorHolder; - auto guard = makeScopeGuard([&] { out->finish(); }); - // Initialize the DCtx - auto ctx = state.dStreamPool->get(); - if (!errorHolder.check(ctx != nullptr, "Failed to allocate ZSTD_DStream")) { - return; - } - { - auto err = ZSTD_DCtx_reset(ctx.get(), ZSTD_reset_session_only); - if (!errorHolder.check(!ZSTD_isError(err), ZSTD_getErrorName(err))) { - return; - } - } - - const size_t outSize = ZSTD_DStreamOutSize(); - Buffer inBuffer; - size_t returnCode = 0; - // Read a buffer in from the input queue - while (in->pop(inBuffer) && !errorHolder.hasError()) { - auto zstdInBuffer = makeZstdInBuffer(inBuffer); - // Decompress the whole buffer and send it to the output queue - while (!inBuffer.empty() && !errorHolder.hasError()) { - // Allocate a buffer with at least outSize bytes. - Buffer outBuffer(outSize); - auto zstdOutBuffer = makeZstdOutBuffer(outBuffer); - // Decompress - returnCode = - ZSTD_decompressStream(ctx.get(), &zstdOutBuffer, &zstdInBuffer); - if (!errorHolder.check( - !ZSTD_isError(returnCode), ZSTD_getErrorName(returnCode))) { - return; - } - // Pass the buffer with the decompressed data to the output queue - out->push(split(outBuffer, zstdOutBuffer)); - // Advance past the input we already read - advance(inBuffer, zstdInBuffer); - if (returnCode == 0) { - // The frame is over, prepare to (maybe) start a new frame - ZSTD_initDStream(ctx.get()); - } - } - } - if (!errorHolder.check(returnCode <= 1, "Incomplete block")) { - return; - } - // We've given ZSTD_decompressStream all of our data, but there may still - // be data to read. - while (returnCode == 1) { - // Allocate a buffer with at least outSize bytes. - Buffer outBuffer(outSize); - auto zstdOutBuffer = makeZstdOutBuffer(outBuffer); - // Pass in no input. - ZSTD_inBuffer zstdInBuffer{nullptr, 0, 0}; - // Decompress - returnCode = - ZSTD_decompressStream(ctx.get(), &zstdOutBuffer, &zstdInBuffer); - if (!errorHolder.check( - !ZSTD_isError(returnCode), ZSTD_getErrorName(returnCode))) { - return; - } - // Pass the buffer with the decompressed data to the output queue - out->push(split(outBuffer, zstdOutBuffer)); - } -} - -std::uint64_t asyncDecompressFrames( - SharedState& state, - WorkQueue>& frames, - ThreadPool& executor, - FILE* fd) { - auto framesGuard = makeScopeGuard([&] { frames.finish(); }); - std::uint64_t totalBytesRead = 0; - - // Split the source up into its component frames. - // If we find our recognized skippable frame we know the next frames size - // which means that we can decompress each standard frame in independently. - // Otherwise, we will decompress using only one decompression task. - const size_t chunkSize = ZSTD_DStreamInSize(); - auto status = FileStatus::Continue; - while (status == FileStatus::Continue && !state.errorHolder.hasError()) { - // Make a new input queue that we will put the frames's bytes into. - auto in = std::make_shared(); - auto inGuard = makeScopeGuard([&] { in->finish(); }); - // Make a output queue that decompress will put the decompressed data into - auto out = std::make_shared(); - - size_t frameSize; - { - // Calculate the size of the next frame. - // frameSize is 0 if the frame info can't be decoded. - Buffer buffer(SkippableFrame::kSize); - auto bytesRead = std::fread(buffer.data(), 1, buffer.size(), fd); - totalBytesRead += bytesRead; - status = fileStatus(fd); - if (bytesRead == 0 && status != FileStatus::Continue) { - break; - } - buffer.subtract(buffer.size() - bytesRead); - frameSize = SkippableFrame::tryRead(buffer.range()); - in->push(std::move(buffer)); - } - if (frameSize == 0) { - // We hit a non SkippableFrame, so this will be the last job. - // Make sure that we don't use too much memory - in->setMaxSize(64); - out->setMaxSize(64); - } - // Start decompression in the thread pool - executor.add([&state, in, out] { - return decompress(state, std::move(in), std::move(out)); - }); - // Pass the output queue to the writer thread - frames.push(std::move(out)); - if (frameSize == 0) { - // We hit a non SkippableFrame ==> not compressed by pzstd or corrupted - // Pass the rest of the source to this decompression task - state.log(kLogVerbose, "%s\n", - "Input not in pzstd format, falling back to serial decompression"); - while (status == FileStatus::Continue && !state.errorHolder.hasError()) { - status = readData(*in, chunkSize, chunkSize, fd, &totalBytesRead); - } - break; - } - state.log(kLogVerbose, "Decompressing a frame of size %zu", frameSize); - // Fill the input queue for the decompression job we just started - status = readData(*in, chunkSize, frameSize, fd, &totalBytesRead); - } - state.errorHolder.check(status != FileStatus::Error, "Error reading input"); - return totalBytesRead; -} - -/// Write `data` to `fd`, returns true iff success. -static bool writeData(ByteRange data, FILE* fd) { - while (!data.empty()) { - data.advance(std::fwrite(data.begin(), 1, data.size(), fd)); - if (std::ferror(fd)) { - return false; - } - } - return true; -} - -std::uint64_t writeFile( - SharedState& state, - WorkQueue>& outs, - FILE* outputFd, - bool decompress) { - auto& errorHolder = state.errorHolder; - auto lineClearGuard = makeScopeGuard([&state] { - state.log.clear(kLogInfo); - }); - std::uint64_t bytesWritten = 0; - std::shared_ptr out; - // Grab the output queue for each decompression job (in order). - while (outs.pop(out)) { - if (errorHolder.hasError()) { - continue; - } - if (!decompress) { - // If we are compressing and want to write skippable frames we can't - // start writing before compression is done because we need to know the - // compressed size. - // Wait for the compressed size to be available and write skippable frame - assert(uint64_t(out->size()) < uint64_t(1) << 32); - SkippableFrame frame(uint32_t(out->size())); - if (!writeData(frame.data(), outputFd)) { - errorHolder.setError("Failed to write output"); - return bytesWritten; - } - bytesWritten += frame.kSize; - } - // For each chunk of the frame: Pop it from the queue and write it - Buffer buffer; - while (out->pop(buffer) && !errorHolder.hasError()) { - if (!writeData(buffer.range(), outputFd)) { - errorHolder.setError("Failed to write output"); - return bytesWritten; - } - bytesWritten += buffer.size(); - state.log.update(kLogInfo, "Written: %u MB ", - static_cast(bytesWritten >> 20)); - } - } - return bytesWritten; -} -} diff --git a/third_party/zstd/contrib/pzstd/Pzstd.h b/third_party/zstd/contrib/pzstd/Pzstd.h deleted file mode 100644 index 3645e5942..000000000 --- a/third_party/zstd/contrib/pzstd/Pzstd.h +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under both the BSD-style license (found in the - * LICENSE file in the root directory of this source tree) and the GPLv2 (found - * in the COPYING file in the root directory of this source tree). - */ -#pragma once - -#include "ErrorHolder.h" -#include "Logging.h" -#include "Options.h" -#include "utils/Buffer.h" -#include "utils/Range.h" -#include "utils/ResourcePool.h" -#include "utils/ThreadPool.h" -#include "utils/WorkQueue.h" -#define ZSTD_STATIC_LINKING_ONLY -#define ZSTD_DISABLE_DEPRECATE_WARNINGS /* No deprecation warnings, pzstd itself is deprecated - * and uses deprecated functions - */ -#include "zstd.h" -#undef ZSTD_STATIC_LINKING_ONLY - -#include -#include -#include - -namespace pzstd { -/** - * Runs pzstd with `options` and returns the number of bytes written. - * An error occurred if `errorHandler.hasError()`. - * - * @param options The pzstd options to use for (de)compression - * @returns 0 upon success and non-zero on failure. - */ -int pzstdMain(const Options& options); - -class SharedState { - public: - SharedState(const Options& options) : log(options.verbosity) { - if (!options.decompress) { - auto parameters = options.determineParameters(); - cStreamPool.reset(new ResourcePool{ - [this, parameters]() -> ZSTD_CStream* { - this->log(kLogVerbose, "%s\n", "Creating new ZSTD_CStream"); - auto zcs = ZSTD_createCStream(); - if (zcs) { - auto err = ZSTD_initCStream_advanced( - zcs, nullptr, 0, parameters, 0); - if (ZSTD_isError(err)) { - ZSTD_freeCStream(zcs); - return nullptr; - } - } - return zcs; - }, - [](ZSTD_CStream *zcs) { - ZSTD_freeCStream(zcs); - }}); - } else { - dStreamPool.reset(new ResourcePool{ - [this]() -> ZSTD_DStream* { - this->log(kLogVerbose, "%s\n", "Creating new ZSTD_DStream"); - auto zds = ZSTD_createDStream(); - if (zds) { - auto err = ZSTD_initDStream(zds); - if (ZSTD_isError(err)) { - ZSTD_freeDStream(zds); - return nullptr; - } - } - return zds; - }, - [](ZSTD_DStream *zds) { - ZSTD_freeDStream(zds); - }}); - } - } - - ~SharedState() { - // The resource pools have references to this, so destroy them first. - cStreamPool.reset(); - dStreamPool.reset(); - } - - Logger log; - ErrorHolder errorHolder; - std::unique_ptr> cStreamPool; - std::unique_ptr> dStreamPool; -}; - -/** - * Streams input from `fd`, breaks input up into chunks, and compresses each - * chunk independently. Output of each chunk gets streamed to a queue, and - * the output queues get put into `chunks` in order. - * - * @param state The shared state - * @param chunks Each compression jobs output queue gets `pushed()` here - * as soon as it is available - * @param executor The thread pool to run compression jobs in - * @param fd The input file descriptor - * @param size The size of the input file if known, 0 otherwise - * @param numThreads The number of threads in the thread pool - * @param parameters The zstd parameters to use for compression - * @returns The number of bytes read from the file - */ -std::uint64_t asyncCompressChunks( - SharedState& state, - WorkQueue>& chunks, - ThreadPool& executor, - FILE* fd, - std::uintmax_t size, - std::size_t numThreads, - ZSTD_parameters parameters); - -/** - * Streams input from `fd`. If pzstd headers are available it breaks the input - * up into independent frames. It sends each frame to an independent - * decompression job. Output of each frame gets streamed to a queue, and - * the output queues get put into `frames` in order. - * - * @param state The shared state - * @param frames Each decompression jobs output queue gets `pushed()` here - * as soon as it is available - * @param executor The thread pool to run compression jobs in - * @param fd The input file descriptor - * @returns The number of bytes read from the file - */ -std::uint64_t asyncDecompressFrames( - SharedState& state, - WorkQueue>& frames, - ThreadPool& executor, - FILE* fd); - -/** - * Streams input in from each queue in `outs` in order, and writes the data to - * `outputFd`. - * - * @param state The shared state - * @param outs A queue of output queues, one for each - * (de)compression job. - * @param outputFd The file descriptor to write to - * @param decompress Are we decompressing? - * @returns The number of bytes written - */ -std::uint64_t writeFile( - SharedState& state, - WorkQueue>& outs, - FILE* outputFd, - bool decompress); -} diff --git a/third_party/zstd/contrib/pzstd/README.md b/third_party/zstd/contrib/pzstd/README.md deleted file mode 100644 index bc8f831f8..000000000 --- a/third_party/zstd/contrib/pzstd/README.md +++ /dev/null @@ -1,56 +0,0 @@ -# Parallel Zstandard (PZstandard) - -Parallel Zstandard is a Pigz-like tool for Zstandard. -It provides Zstandard format compatible compression and decompression that is able to utilize multiple cores. -It breaks the input up into equal sized chunks and compresses each chunk independently into a Zstandard frame. -It then concatenates the frames together to produce the final compressed output. -Pzstandard will write a 12 byte header for each frame that is a skippable frame in the Zstandard format, which tells PZstandard the size of the next compressed frame. -PZstandard supports parallel decompression of files compressed with PZstandard. -When decompressing files compressed with Zstandard, PZstandard does IO in one thread, and decompression in another. - -## Usage - -PZstandard supports the same command line interface as Zstandard, but also provides the `-p` option to specify the number of threads. -Dictionary mode is not currently supported. - -Basic usage - - pzstd input-file -o output-file -p num-threads -# # Compression - pzstd -d input-file -o output-file -p num-threads # Decompression - -PZstandard also supports piping and fifo pipes - - cat input-file | pzstd -p num-threads -# -c > /dev/null - -For more options - - pzstd --help - -PZstandard tries to pick a smart default number of threads if not specified (displayed in `pzstd --help`). -If this number is not suitable, during compilation you can define `PZSTD_NUM_THREADS` to the number of threads you prefer. - -## Benchmarks - -As a reference, PZstandard and Pigz were compared on an Intel Core i7 @ 3.1 GHz, each using 4 threads, with the [Silesia compression corpus](https://sun.aei.polsl.pl//~sdeor/index.php?page=silesia). - -Compression Speed vs Ratio with 4 Threads | Decompression Speed with 4 Threads -------------------------------------------|----------------------------------- -![Compression Speed vs Ratio](images/Cspeed.png "Compression Speed vs Ratio") | ![Decompression Speed](images/Dspeed.png "Decompression Speed") - -The test procedure was to run each of the following commands 2 times for each compression level, and take the minimum time. - - time pzstd -# -p 4 -c silesia.tar > silesia.tar.zst - time pzstd -d -p 4 -c silesia.tar.zst > /dev/null - - time pigz -# -p 4 -k -c silesia.tar > silesia.tar.gz - time pigz -d -p 4 -k -c silesia.tar.gz > /dev/null - -PZstandard was tested using compression levels 1-19, and Pigz was tested using compression levels 1-9. -Pigz cannot do parallel decompression, it simply does each of reading, decompression, and writing on separate threads. - -## Tests - -Tests require that you have [gtest](https://github.com/google/googletest) installed. -Set `GTEST_INC` and `GTEST_LIB` in `Makefile` to specify the location of the gtest headers and libraries. -Alternatively, run `make googletest`, which will clone googletest and build it. -Run `make tests && make check` to run tests. diff --git a/third_party/zstd/contrib/pzstd/SkippableFrame.cpp b/third_party/zstd/contrib/pzstd/SkippableFrame.cpp deleted file mode 100644 index 3bea4eb65..000000000 --- a/third_party/zstd/contrib/pzstd/SkippableFrame.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under both the BSD-style license (found in the - * LICENSE file in the root directory of this source tree) and the GPLv2 (found - * in the COPYING file in the root directory of this source tree). - */ -#include "SkippableFrame.h" -#include "mem.h" -#include "utils/Range.h" - -#include - -using namespace pzstd; - -SkippableFrame::SkippableFrame(std::uint32_t size) : frameSize_(size) { - MEM_writeLE32(data_.data(), kSkippableFrameMagicNumber); - MEM_writeLE32(data_.data() + 4, kFrameContentsSize); - MEM_writeLE32(data_.data() + 8, frameSize_); -} - -/* static */ std::size_t SkippableFrame::tryRead(ByteRange bytes) { - if (bytes.size() < SkippableFrame::kSize || - MEM_readLE32(bytes.begin()) != kSkippableFrameMagicNumber || - MEM_readLE32(bytes.begin() + 4) != kFrameContentsSize) { - return 0; - } - return MEM_readLE32(bytes.begin() + 8); -} diff --git a/third_party/zstd/contrib/pzstd/SkippableFrame.h b/third_party/zstd/contrib/pzstd/SkippableFrame.h deleted file mode 100644 index 817415e92..000000000 --- a/third_party/zstd/contrib/pzstd/SkippableFrame.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under both the BSD-style license (found in the - * LICENSE file in the root directory of this source tree) and the GPLv2 (found - * in the COPYING file in the root directory of this source tree). - */ -#pragma once - -#include "utils/Range.h" - -#include -#include -#include -#include - -namespace pzstd { -/** - * We put a skippable frame before each frame. - * It contains a skippable frame magic number, the size of the skippable frame, - * and the size of the next frame. - * Each skippable frame is exactly 12 bytes in little endian format. - * The first 8 bytes are for compatibility with the ZSTD format. - * If we have N threads, the output will look like - * - * [0x184D2A50|4|size1] [frame1 of size size1] - * [0x184D2A50|4|size2] [frame2 of size size2] - * ... - * [0x184D2A50|4|sizeN] [frameN of size sizeN] - * - * Each sizeX is 4 bytes. - * - * These skippable frames should allow us to skip through the compressed file - * and only load at most N pages. - */ -class SkippableFrame { - public: - static constexpr std::size_t kSize = 12; - - private: - std::uint32_t frameSize_; - std::array data_; - static constexpr std::uint32_t kSkippableFrameMagicNumber = 0x184D2A50; - // Could be improved if the size fits in less bytes - static constexpr std::uint32_t kFrameContentsSize = kSize - 8; - - public: - // Write the skippable frame to data_ in LE format. - explicit SkippableFrame(std::uint32_t size); - - // Read the skippable frame from bytes in LE format. - static std::size_t tryRead(ByteRange bytes); - - ByteRange data() const { - return {data_.data(), data_.size()}; - } - - // Size of the next frame. - std::size_t frameSize() const { - return frameSize_; - } -}; -} diff --git a/third_party/zstd/contrib/pzstd/images/Cspeed.png b/third_party/zstd/contrib/pzstd/images/Cspeed.png deleted file mode 100644 index aca4f663e..000000000 Binary files a/third_party/zstd/contrib/pzstd/images/Cspeed.png and /dev/null differ diff --git a/third_party/zstd/contrib/pzstd/images/Dspeed.png b/third_party/zstd/contrib/pzstd/images/Dspeed.png deleted file mode 100644 index e48881bcd..000000000 Binary files a/third_party/zstd/contrib/pzstd/images/Dspeed.png and /dev/null differ diff --git a/third_party/zstd/contrib/pzstd/main.cpp b/third_party/zstd/contrib/pzstd/main.cpp deleted file mode 100644 index 422b4a56a..000000000 --- a/third_party/zstd/contrib/pzstd/main.cpp +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under both the BSD-style license (found in the - * LICENSE file in the root directory of this source tree) and the GPLv2 (found - * in the COPYING file in the root directory of this source tree). - */ -#include "ErrorHolder.h" -#include "Options.h" -#include "Pzstd.h" - -using namespace pzstd; - -int main(int argc, const char** argv) { - Options options; - switch (options.parse(argc, argv)) { - case Options::Status::Failure: - return 1; - case Options::Status::Message: - return 0; - default: - break; - } - - return pzstdMain(options); -} diff --git a/third_party/zstd/contrib/pzstd/test/BUCK b/third_party/zstd/contrib/pzstd/test/BUCK deleted file mode 100644 index 6d3fdd3c2..000000000 --- a/third_party/zstd/contrib/pzstd/test/BUCK +++ /dev/null @@ -1,37 +0,0 @@ -cxx_test( - name='options_test', - srcs=['OptionsTest.cpp'], - deps=['//contrib/pzstd:options'], -) - -cxx_test( - name='pzstd_test', - srcs=['PzstdTest.cpp'], - deps=[ - ':round_trip', - '//contrib/pzstd:libpzstd', - '//contrib/pzstd/utils:scope_guard', - '//programs:datagen', - ], -) - -cxx_binary( - name='round_trip_test', - srcs=['RoundTripTest.cpp'], - deps=[ - ':round_trip', - '//contrib/pzstd/utils:scope_guard', - '//programs:datagen', - ] -) - -cxx_library( - name='round_trip', - header_namespace='test', - exported_headers=['RoundTrip.h'], - deps=[ - '//contrib/pzstd:libpzstd', - '//contrib/pzstd:options', - '//contrib/pzstd/utils:scope_guard', - ] -) diff --git a/third_party/zstd/contrib/pzstd/test/OptionsTest.cpp b/third_party/zstd/contrib/pzstd/test/OptionsTest.cpp deleted file mode 100644 index 91e39750d..000000000 --- a/third_party/zstd/contrib/pzstd/test/OptionsTest.cpp +++ /dev/null @@ -1,536 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under both the BSD-style license (found in the - * LICENSE file in the root directory of this source tree) and the GPLv2 (found - * in the COPYING file in the root directory of this source tree). - */ -#include "Options.h" - -#include -#include - -using namespace pzstd; - -namespace pzstd { -bool operator==(const Options &lhs, const Options &rhs) { - return lhs.numThreads == rhs.numThreads && - lhs.maxWindowLog == rhs.maxWindowLog && - lhs.compressionLevel == rhs.compressionLevel && - lhs.decompress == rhs.decompress && lhs.inputFiles == rhs.inputFiles && - lhs.outputFile == rhs.outputFile && lhs.overwrite == rhs.overwrite && - lhs.keepSource == rhs.keepSource && lhs.writeMode == rhs.writeMode && - lhs.checksum == rhs.checksum && lhs.verbosity == rhs.verbosity; -} - -std::ostream &operator<<(std::ostream &out, const Options &opt) { - out << "{"; - { - out << "\n\t" - << "numThreads: " << opt.numThreads; - out << ",\n\t" - << "maxWindowLog: " << opt.maxWindowLog; - out << ",\n\t" - << "compressionLevel: " << opt.compressionLevel; - out << ",\n\t" - << "decompress: " << opt.decompress; - out << ",\n\t" - << "inputFiles: {"; - { - bool first = true; - for (const auto &file : opt.inputFiles) { - if (!first) { - out << ","; - } - first = false; - out << "\n\t\t" << file; - } - } - out << "\n\t}"; - out << ",\n\t" - << "outputFile: " << opt.outputFile; - out << ",\n\t" - << "overwrite: " << opt.overwrite; - out << ",\n\t" - << "keepSource: " << opt.keepSource; - out << ",\n\t" - << "writeMode: " << static_cast(opt.writeMode); - out << ",\n\t" - << "checksum: " << opt.checksum; - out << ",\n\t" - << "verbosity: " << opt.verbosity; - } - out << "\n}"; - return out; -} -} - -namespace { -#ifdef _WIN32 -const char nullOutput[] = "nul"; -#else -const char nullOutput[] = "/dev/null"; -#endif - -constexpr auto autoMode = Options::WriteMode::Auto; -} // anonymous namespace - -#define EXPECT_SUCCESS(...) EXPECT_EQ(Options::Status::Success, __VA_ARGS__) -#define EXPECT_FAILURE(...) EXPECT_EQ(Options::Status::Failure, __VA_ARGS__) -#define EXPECT_MESSAGE(...) EXPECT_EQ(Options::Status::Message, __VA_ARGS__) - -template -std::array makeArray(Args... args) { - return {{nullptr, args...}}; -} - -TEST(Options, ValidInputs) { - { - Options options; - auto args = makeArray("--processes", "5", "-o", "x", "y", "-f"); - EXPECT_SUCCESS(options.parse(args.size(), args.data())); - Options expected = {5, 23, 3, false, {"y"}, "x", - true, true, autoMode, true, 2}; - EXPECT_EQ(expected, options); - } - { - Options options; - auto args = makeArray("-p", "1", "input", "-19"); - EXPECT_SUCCESS(options.parse(args.size(), args.data())); - Options expected = {1, 23, 19, false, {"input"}, "", - false, true, autoMode, true, 2}; - EXPECT_EQ(expected, options); - } - { - Options options; - auto args = - makeArray("--ultra", "-22", "-p", "1", "-o", "x", "-d", "x.zst", "-f"); - EXPECT_SUCCESS(options.parse(args.size(), args.data())); - Options expected = {1, 0, 22, true, {"x.zst"}, "x", - true, true, autoMode, true, 2}; - EXPECT_EQ(expected, options); - } - { - Options options; - auto args = makeArray("--processes", "100", "hello.zst", "--decompress", - "--force"); - EXPECT_SUCCESS(options.parse(args.size(), args.data())); - Options expected = {100, 23, 3, true, {"hello.zst"}, "", true, - true, autoMode, true, 2}; - EXPECT_EQ(expected, options); - } - { - Options options; - auto args = makeArray("x", "-dp", "1", "-c"); - EXPECT_SUCCESS(options.parse(args.size(), args.data())); - Options expected = {1, 23, 3, true, {"x"}, "-", - false, true, autoMode, true, 2}; - EXPECT_EQ(expected, options); - } - { - Options options; - auto args = makeArray("x", "-dp", "1", "--stdout"); - EXPECT_SUCCESS(options.parse(args.size(), args.data())); - Options expected = {1, 23, 3, true, {"x"}, "-", - false, true, autoMode, true, 2}; - EXPECT_EQ(expected, options); - } - { - Options options; - auto args = makeArray("-p", "1", "x", "-5", "-fo", "-", "--ultra", "-d"); - EXPECT_SUCCESS(options.parse(args.size(), args.data())); - Options expected = {1, 0, 5, true, {"x"}, "-", - true, true, autoMode, true, 2}; - EXPECT_EQ(expected, options); - } - { - Options options; - auto args = makeArray("silesia.tar", "-o", "silesia.tar.pzstd", "-p", "2"); - EXPECT_SUCCESS(options.parse(args.size(), args.data())); - Options expected = {2, - 23, - 3, - false, - {"silesia.tar"}, - "silesia.tar.pzstd", - false, - true, - autoMode, - true, - 2}; - EXPECT_EQ(expected, options); - } - { - Options options; - auto args = makeArray("x", "-p", "1"); - EXPECT_SUCCESS(options.parse(args.size(), args.data())); - } - { - Options options; - auto args = makeArray("x", "-p", "1"); - EXPECT_SUCCESS(options.parse(args.size(), args.data())); - } -} - -TEST(Options, GetOutputFile) { - { - Options options; - auto args = makeArray("x"); - EXPECT_SUCCESS(options.parse(args.size(), args.data())); - EXPECT_EQ("x.zst", options.getOutputFile(options.inputFiles[0])); - } - { - Options options; - auto args = makeArray("x", "y", "-o", nullOutput); - EXPECT_SUCCESS(options.parse(args.size(), args.data())); - EXPECT_EQ(nullOutput, options.getOutputFile(options.inputFiles[0])); - } - { - Options options; - auto args = makeArray("x.zst", "-do", nullOutput); - EXPECT_SUCCESS(options.parse(args.size(), args.data())); - EXPECT_EQ(nullOutput, options.getOutputFile(options.inputFiles[0])); - } - { - Options options; - auto args = makeArray("x.zst", "-d"); - EXPECT_SUCCESS(options.parse(args.size(), args.data())); - EXPECT_EQ("x", options.getOutputFile(options.inputFiles[0])); - } - { - Options options; - auto args = makeArray("xzst", "-d"); - EXPECT_SUCCESS(options.parse(args.size(), args.data())); - EXPECT_EQ("", options.getOutputFile(options.inputFiles[0])); - } - { - Options options; - auto args = makeArray("xzst", "-doxx"); - EXPECT_SUCCESS(options.parse(args.size(), args.data())); - EXPECT_EQ("xx", options.getOutputFile(options.inputFiles[0])); - } -} - -TEST(Options, MultipleFiles) { - { - Options options; - auto args = makeArray("x", "y", "z"); - EXPECT_SUCCESS(options.parse(args.size(), args.data())); - Options expected; - expected.inputFiles = {"x", "y", "z"}; - expected.verbosity = 1; - EXPECT_EQ(expected, options); - } - { - Options options; - auto args = makeArray("x", "y", "z", "-o", nullOutput); - EXPECT_SUCCESS(options.parse(args.size(), args.data())); - Options expected; - expected.inputFiles = {"x", "y", "z"}; - expected.outputFile = nullOutput; - expected.verbosity = 1; - EXPECT_EQ(expected, options); - } - { - Options options; - auto args = makeArray("x", "y", "-o-"); - EXPECT_FAILURE(options.parse(args.size(), args.data())); - } - { - Options options; - auto args = makeArray("x", "y", "-o", "file"); - EXPECT_FAILURE(options.parse(args.size(), args.data())); - } - { - Options options; - auto args = makeArray("-qqvd12qp4", "-f", "x", "--", "--rm", "-c"); - EXPECT_SUCCESS(options.parse(args.size(), args.data())); - Options expected = {4, 23, 12, true, {"x", "--rm", "-c"}, - "", true, true, autoMode, true, - 0}; - EXPECT_EQ(expected, options); - } -} - -TEST(Options, NumThreads) { - { - Options options; - auto args = makeArray("x", "-dfo", "-"); - EXPECT_SUCCESS(options.parse(args.size(), args.data())); - } - { - Options options; - auto args = makeArray("x", "-p", "0", "-fo", "-"); - EXPECT_FAILURE(options.parse(args.size(), args.data())); - } - { - Options options; - auto args = makeArray("-f", "-p", "-o", "-"); - EXPECT_FAILURE(options.parse(args.size(), args.data())); - } -} - -TEST(Options, BadCompressionLevel) { - { - Options options; - auto args = makeArray("x", "-20"); - EXPECT_FAILURE(options.parse(args.size(), args.data())); - } - { - Options options; - auto args = makeArray("x", "--ultra", "-23"); - EXPECT_FAILURE(options.parse(args.size(), args.data())); - } - { - Options options; - auto args = makeArray("x", "--1"); // negative 1? - EXPECT_FAILURE(options.parse(args.size(), args.data())); - } -} - -TEST(Options, InvalidOption) { - { - Options options; - auto args = makeArray("x", "-x"); - EXPECT_FAILURE(options.parse(args.size(), args.data())); - } -} - -TEST(Options, BadOutputFile) { - { - Options options; - auto args = makeArray("notzst", "-d", "-p", "1"); - EXPECT_SUCCESS(options.parse(args.size(), args.data())); - EXPECT_EQ("", options.getOutputFile(options.inputFiles.front())); - } -} - -TEST(Options, BadOptionsWithArguments) { - { - Options options; - auto args = makeArray("x", "-pf"); - EXPECT_FAILURE(options.parse(args.size(), args.data())); - } - { - Options options; - auto args = makeArray("x", "-p", "10f"); - EXPECT_FAILURE(options.parse(args.size(), args.data())); - } - { - Options options; - auto args = makeArray("x", "-p"); - EXPECT_FAILURE(options.parse(args.size(), args.data())); - } - { - Options options; - auto args = makeArray("x", "-o"); - EXPECT_FAILURE(options.parse(args.size(), args.data())); - } - { - Options options; - auto args = makeArray("x", "-o"); - EXPECT_FAILURE(options.parse(args.size(), args.data())); - } -} - -TEST(Options, KeepSource) { - { - Options options; - auto args = makeArray("x", "--rm", "-k"); - EXPECT_SUCCESS(options.parse(args.size(), args.data())); - EXPECT_EQ(true, options.keepSource); - } - { - Options options; - auto args = makeArray("x", "--rm", "--keep"); - EXPECT_SUCCESS(options.parse(args.size(), args.data())); - EXPECT_EQ(true, options.keepSource); - } - { - Options options; - auto args = makeArray("x"); - EXPECT_SUCCESS(options.parse(args.size(), args.data())); - EXPECT_EQ(true, options.keepSource); - } - { - Options options; - auto args = makeArray("x", "--rm"); - EXPECT_SUCCESS(options.parse(args.size(), args.data())); - EXPECT_EQ(false, options.keepSource); - } -} - -TEST(Options, Verbosity) { - { - Options options; - auto args = makeArray("x"); - EXPECT_SUCCESS(options.parse(args.size(), args.data())); - EXPECT_EQ(2, options.verbosity); - } - { - Options options; - auto args = makeArray("--quiet", "-qq", "x"); - EXPECT_SUCCESS(options.parse(args.size(), args.data())); - EXPECT_EQ(-1, options.verbosity); - } - { - Options options; - auto args = makeArray("x", "y"); - EXPECT_SUCCESS(options.parse(args.size(), args.data())); - EXPECT_EQ(1, options.verbosity); - } - { - Options options; - auto args = makeArray("--", "x", "y"); - EXPECT_SUCCESS(options.parse(args.size(), args.data())); - EXPECT_EQ(1, options.verbosity); - } - { - Options options; - auto args = makeArray("-qv", "x", "y"); - EXPECT_SUCCESS(options.parse(args.size(), args.data())); - EXPECT_EQ(1, options.verbosity); - } - { - Options options; - auto args = makeArray("-v", "x", "y"); - EXPECT_SUCCESS(options.parse(args.size(), args.data())); - EXPECT_EQ(3, options.verbosity); - } - { - Options options; - auto args = makeArray("-v", "x"); - EXPECT_SUCCESS(options.parse(args.size(), args.data())); - EXPECT_EQ(3, options.verbosity); - } -} - -TEST(Options, TestMode) { - { - Options options; - auto args = makeArray("x", "-t"); - EXPECT_SUCCESS(options.parse(args.size(), args.data())); - EXPECT_EQ(true, options.keepSource); - EXPECT_EQ(true, options.decompress); - EXPECT_EQ(nullOutput, options.outputFile); - } - { - Options options; - auto args = makeArray("x", "--test", "--rm", "-ohello"); - EXPECT_SUCCESS(options.parse(args.size(), args.data())); - EXPECT_EQ(true, options.keepSource); - EXPECT_EQ(true, options.decompress); - EXPECT_EQ(nullOutput, options.outputFile); - } -} - -TEST(Options, Checksum) { - { - Options options; - auto args = makeArray("x.zst", "--no-check", "-Cd"); - EXPECT_SUCCESS(options.parse(args.size(), args.data())); - EXPECT_EQ(true, options.checksum); - } - { - Options options; - auto args = makeArray("x"); - EXPECT_SUCCESS(options.parse(args.size(), args.data())); - EXPECT_EQ(true, options.checksum); - } - { - Options options; - auto args = makeArray("x", "--no-check", "--check"); - EXPECT_SUCCESS(options.parse(args.size(), args.data())); - EXPECT_EQ(true, options.checksum); - } - { - Options options; - auto args = makeArray("x", "--no-check"); - EXPECT_SUCCESS(options.parse(args.size(), args.data())); - EXPECT_EQ(false, options.checksum); - } -} - -TEST(Options, InputFiles) { - { - Options options; - auto args = makeArray("-cd"); - options.parse(args.size(), args.data()); - EXPECT_EQ(1, options.inputFiles.size()); - EXPECT_EQ("-", options.inputFiles[0]); - EXPECT_EQ("-", options.outputFile); - } - { - Options options; - auto args = makeArray(); - options.parse(args.size(), args.data()); - EXPECT_EQ(1, options.inputFiles.size()); - EXPECT_EQ("-", options.inputFiles[0]); - EXPECT_EQ("-", options.outputFile); - } - { - Options options; - auto args = makeArray("-d"); - options.parse(args.size(), args.data()); - EXPECT_EQ(1, options.inputFiles.size()); - EXPECT_EQ("-", options.inputFiles[0]); - EXPECT_EQ("-", options.outputFile); - } - { - Options options; - auto args = makeArray("x", "-"); - EXPECT_FAILURE(options.parse(args.size(), args.data())); - } -} - -TEST(Options, InvalidOptions) { - { - Options options; - auto args = makeArray("-ibasdf"); - EXPECT_FAILURE(options.parse(args.size(), args.data())); - } - { - Options options; - auto args = makeArray("- "); - EXPECT_FAILURE(options.parse(args.size(), args.data())); - } - { - Options options; - auto args = makeArray("-n15"); - EXPECT_FAILURE(options.parse(args.size(), args.data())); - } - { - Options options; - auto args = makeArray("-0", "x"); - EXPECT_FAILURE(options.parse(args.size(), args.data())); - } -} - -TEST(Options, Extras) { - { - Options options; - auto args = makeArray("-h"); - EXPECT_MESSAGE(options.parse(args.size(), args.data())); - } - { - Options options; - auto args = makeArray("-H"); - EXPECT_MESSAGE(options.parse(args.size(), args.data())); - } - { - Options options; - auto args = makeArray("-V"); - EXPECT_MESSAGE(options.parse(args.size(), args.data())); - } - { - Options options; - auto args = makeArray("--help"); - EXPECT_MESSAGE(options.parse(args.size(), args.data())); - } - { - Options options; - auto args = makeArray("--version"); - EXPECT_MESSAGE(options.parse(args.size(), args.data())); - } -} diff --git a/third_party/zstd/contrib/pzstd/test/PzstdTest.cpp b/third_party/zstd/contrib/pzstd/test/PzstdTest.cpp deleted file mode 100644 index 75453f5f6..000000000 --- a/third_party/zstd/contrib/pzstd/test/PzstdTest.cpp +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under both the BSD-style license (found in the - * LICENSE file in the root directory of this source tree) and the GPLv2 (found - * in the COPYING file in the root directory of this source tree). - */ -#include "Pzstd.h" -extern "C" { -#include "datagen.h" -} -#include "test/RoundTrip.h" -#include "utils/ScopeGuard.h" - -#include -#include -#include -#include -#include - -using namespace std; -using namespace pzstd; - -TEST(Pzstd, SmallSizes) { - unsigned seed = std::random_device{}(); - std::fprintf(stderr, "Pzstd.SmallSizes seed: %u\n", seed); - std::mt19937 gen(seed); - - for (unsigned len = 1; len < 256; ++len) { - if (len % 16 == 0) { - std::fprintf(stderr, "%u / 16\n", len / 16); - } - std::string inputFile = std::tmpnam(nullptr); - auto guard = makeScopeGuard([&] { std::remove(inputFile.c_str()); }); - { - static uint8_t buf[256]; - RDG_genBuffer(buf, len, 0.5, 0.0, gen()); - auto fd = std::fopen(inputFile.c_str(), "wb"); - auto written = std::fwrite(buf, 1, len, fd); - std::fclose(fd); - ASSERT_EQ(written, len); - } - for (unsigned numThreads = 1; numThreads <= 2; ++numThreads) { - for (unsigned level = 1; level <= 4; level *= 4) { - auto errorGuard = makeScopeGuard([&] { - std::fprintf(stderr, "# threads: %u\n", numThreads); - std::fprintf(stderr, "compression level: %u\n", level); - }); - Options options; - options.overwrite = true; - options.inputFiles = {inputFile}; - options.numThreads = numThreads; - options.compressionLevel = level; - options.verbosity = 1; - ASSERT_TRUE(roundTrip(options)); - errorGuard.dismiss(); - } - } - } -} - -TEST(Pzstd, LargeSizes) { - unsigned seed = std::random_device{}(); - std::fprintf(stderr, "Pzstd.LargeSizes seed: %u\n", seed); - std::mt19937 gen(seed); - - for (unsigned len = 1 << 20; len <= (1 << 24); len *= 2) { - std::string inputFile = std::tmpnam(nullptr); - auto guard = makeScopeGuard([&] { std::remove(inputFile.c_str()); }); - { - std::unique_ptr buf(new uint8_t[len]); - RDG_genBuffer(buf.get(), len, 0.5, 0.0, gen()); - auto fd = std::fopen(inputFile.c_str(), "wb"); - auto written = std::fwrite(buf.get(), 1, len, fd); - std::fclose(fd); - ASSERT_EQ(written, len); - } - for (unsigned numThreads = 1; numThreads <= 16; numThreads *= 4) { - for (unsigned level = 1; level <= 4; level *= 4) { - auto errorGuard = makeScopeGuard([&] { - std::fprintf(stderr, "# threads: %u\n", numThreads); - std::fprintf(stderr, "compression level: %u\n", level); - }); - Options options; - options.overwrite = true; - options.inputFiles = {inputFile}; - options.numThreads = std::min(numThreads, options.numThreads); - options.compressionLevel = level; - options.verbosity = 1; - ASSERT_TRUE(roundTrip(options)); - errorGuard.dismiss(); - } - } - } -} - -TEST(Pzstd, DISABLED_ExtremelyLargeSize) { - unsigned seed = std::random_device{}(); - std::fprintf(stderr, "Pzstd.ExtremelyLargeSize seed: %u\n", seed); - std::mt19937 gen(seed); - - std::string inputFile = std::tmpnam(nullptr); - auto guard = makeScopeGuard([&] { std::remove(inputFile.c_str()); }); - - { - // Write 4GB + 64 MB - constexpr size_t kLength = 1 << 26; - std::unique_ptr buf(new uint8_t[kLength]); - auto fd = std::fopen(inputFile.c_str(), "wb"); - auto closeGuard = makeScopeGuard([&] { std::fclose(fd); }); - for (size_t i = 0; i < (1 << 6) + 1; ++i) { - RDG_genBuffer(buf.get(), kLength, 0.5, 0.0, gen()); - auto written = std::fwrite(buf.get(), 1, kLength, fd); - if (written != kLength) { - std::fprintf(stderr, "Failed to write file, skipping test\n"); - return; - } - } - } - - Options options; - options.overwrite = true; - options.inputFiles = {inputFile}; - options.compressionLevel = 1; - if (options.numThreads == 0) { - options.numThreads = 1; - } - ASSERT_TRUE(roundTrip(options)); -} - -TEST(Pzstd, ExtremelyCompressible) { - std::string inputFile = std::tmpnam(nullptr); - auto guard = makeScopeGuard([&] { std::remove(inputFile.c_str()); }); - { - std::unique_ptr buf(new uint8_t[10000]); - std::memset(buf.get(), 'a', 10000); - auto fd = std::fopen(inputFile.c_str(), "wb"); - auto written = std::fwrite(buf.get(), 1, 10000, fd); - std::fclose(fd); - ASSERT_EQ(written, 10000); - } - Options options; - options.overwrite = true; - options.inputFiles = {inputFile}; - options.numThreads = 1; - options.compressionLevel = 1; - ASSERT_TRUE(roundTrip(options)); -} diff --git a/third_party/zstd/contrib/pzstd/test/RoundTrip.h b/third_party/zstd/contrib/pzstd/test/RoundTrip.h deleted file mode 100644 index f777622a3..000000000 --- a/third_party/zstd/contrib/pzstd/test/RoundTrip.h +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under both the BSD-style license (found in the - * LICENSE file in the root directory of this source tree) and the GPLv2 (found - * in the COPYING file in the root directory of this source tree). - */ -#pragma once - -#include "Options.h" -#include "Pzstd.h" -#include "utils/ScopeGuard.h" - -#include -#include -#include -#include - -namespace pzstd { - -inline bool check(std::string source, std::string decompressed) { - std::unique_ptr sBuf(new std::uint8_t[1024]); - std::unique_ptr dBuf(new std::uint8_t[1024]); - - auto sFd = std::fopen(source.c_str(), "rb"); - auto dFd = std::fopen(decompressed.c_str(), "rb"); - auto guard = makeScopeGuard([&] { - std::fclose(sFd); - std::fclose(dFd); - }); - - size_t sRead, dRead; - - do { - sRead = std::fread(sBuf.get(), 1, 1024, sFd); - dRead = std::fread(dBuf.get(), 1, 1024, dFd); - if (std::ferror(sFd) || std::ferror(dFd)) { - return false; - } - if (sRead != dRead) { - return false; - } - - for (size_t i = 0; i < sRead; ++i) { - if (sBuf.get()[i] != dBuf.get()[i]) { - return false; - } - } - } while (sRead == 1024); - if (!std::feof(sFd) || !std::feof(dFd)) { - return false; - } - return true; -} - -inline bool roundTrip(Options& options) { - if (options.inputFiles.size() != 1) { - return false; - } - std::string source = options.inputFiles.front(); - std::string compressedFile = std::tmpnam(nullptr); - std::string decompressedFile = std::tmpnam(nullptr); - auto guard = makeScopeGuard([&] { - std::remove(compressedFile.c_str()); - std::remove(decompressedFile.c_str()); - }); - - { - options.outputFile = compressedFile; - options.decompress = false; - if (pzstdMain(options) != 0) { - return false; - } - } - { - options.decompress = true; - options.inputFiles.front() = compressedFile; - options.outputFile = decompressedFile; - if (pzstdMain(options) != 0) { - return false; - } - } - return check(source, decompressedFile); -} -} diff --git a/third_party/zstd/contrib/pzstd/test/RoundTripTest.cpp b/third_party/zstd/contrib/pzstd/test/RoundTripTest.cpp deleted file mode 100644 index c37646d1c..000000000 --- a/third_party/zstd/contrib/pzstd/test/RoundTripTest.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under both the BSD-style license (found in the - * LICENSE file in the root directory of this source tree) and the GPLv2 (found - * in the COPYING file in the root directory of this source tree). - */ -extern "C" { -#include "datagen.h" -} -#include "Options.h" -#include "test/RoundTrip.h" -#include "utils/ScopeGuard.h" - -#include -#include -#include -#include -#include - -using namespace std; -using namespace pzstd; - -namespace { -string -writeData(size_t size, double matchProba, double litProba, unsigned seed) { - std::unique_ptr buf(new uint8_t[size]); - RDG_genBuffer(buf.get(), size, matchProba, litProba, seed); - string file = tmpnam(nullptr); - auto fd = std::fopen(file.c_str(), "wb"); - auto guard = makeScopeGuard([&] { std::fclose(fd); }); - auto bytesWritten = std::fwrite(buf.get(), 1, size, fd); - if (bytesWritten != size) { - std::abort(); - } - return file; -} - -template -string generateInputFile(Generator& gen) { - // Use inputs ranging from 1 Byte to 2^16 Bytes - std::uniform_int_distribution size{1, 1 << 16}; - std::uniform_real_distribution<> prob{0, 1}; - return writeData(size(gen), prob(gen), prob(gen), gen()); -} - -template -Options generateOptions(Generator& gen, const string& inputFile) { - Options options; - options.inputFiles = {inputFile}; - options.overwrite = true; - - std::uniform_int_distribution numThreads{1, 32}; - std::uniform_int_distribution compressionLevel{1, 10}; - - options.numThreads = numThreads(gen); - options.compressionLevel = compressionLevel(gen); - - return options; -} -} - -int main() { - std::mt19937 gen(std::random_device{}()); - - auto newlineGuard = makeScopeGuard([] { std::fprintf(stderr, "\n"); }); - for (unsigned i = 0; i < 10000; ++i) { - if (i % 100 == 0) { - std::fprintf(stderr, "Progress: %u%%\r", i / 100); - } - auto inputFile = generateInputFile(gen); - auto inputGuard = makeScopeGuard([&] { std::remove(inputFile.c_str()); }); - for (unsigned i = 0; i < 10; ++i) { - auto options = generateOptions(gen, inputFile); - if (!roundTrip(options)) { - std::fprintf(stderr, "numThreads: %u\n", options.numThreads); - std::fprintf(stderr, "level: %u\n", options.compressionLevel); - std::fprintf(stderr, "decompress? %u\n", (unsigned)options.decompress); - std::fprintf(stderr, "file: %s\n", inputFile.c_str()); - return 1; - } - } - } - return 0; -} diff --git a/third_party/zstd/contrib/pzstd/utils/BUCK b/third_party/zstd/contrib/pzstd/utils/BUCK deleted file mode 100644 index e757f4120..000000000 --- a/third_party/zstd/contrib/pzstd/utils/BUCK +++ /dev/null @@ -1,75 +0,0 @@ -cxx_library( - name='buffer', - visibility=['PUBLIC'], - header_namespace='utils', - exported_headers=['Buffer.h'], - deps=[':range'], -) - -cxx_library( - name='file_system', - visibility=['PUBLIC'], - header_namespace='utils', - exported_headers=['FileSystem.h'], - deps=[':range'], -) - -cxx_library( - name='likely', - visibility=['PUBLIC'], - header_namespace='utils', - exported_headers=['Likely.h'], -) - -cxx_library( - name='range', - visibility=['PUBLIC'], - header_namespace='utils', - exported_headers=['Range.h'], - deps=[':likely'], -) - -cxx_library( - name='resource_pool', - visibility=['PUBLIC'], - header_namespace='utils', - exported_headers=['ResourcePool.h'], -) - -cxx_library( - name='scope_guard', - visibility=['PUBLIC'], - header_namespace='utils', - exported_headers=['ScopeGuard.h'], -) - -cxx_library( - name='thread_pool', - visibility=['PUBLIC'], - header_namespace='utils', - exported_headers=['ThreadPool.h'], - deps=[':work_queue'], -) - -cxx_library( - name='work_queue', - visibility=['PUBLIC'], - header_namespace='utils', - exported_headers=['WorkQueue.h'], - deps=[':buffer'], -) - -cxx_library( - name='utils', - visibility=['PUBLIC'], - deps=[ - ':buffer', - ':file_system', - ':likely', - ':range', - ':resource_pool', - ':scope_guard', - ':thread_pool', - ':work_queue', - ], -) diff --git a/third_party/zstd/contrib/pzstd/utils/Buffer.h b/third_party/zstd/contrib/pzstd/utils/Buffer.h deleted file mode 100644 index a85f770ba..000000000 --- a/third_party/zstd/contrib/pzstd/utils/Buffer.h +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under both the BSD-style license (found in the - * LICENSE file in the root directory of this source tree) and the GPLv2 (found - * in the COPYING file in the root directory of this source tree). - */ -#pragma once - -#include "utils/Range.h" - -#include -#include -#include - -namespace pzstd { - -/** - * A `Buffer` has a pointer to a shared buffer, and a range of the buffer that - * it owns. - * The idea is that you can allocate one buffer, and write chunks into it - * and break off those chunks. - * The underlying buffer is reference counted, and will be destroyed when all - * `Buffer`s that reference it are destroyed. - */ -class Buffer { - std::shared_ptr buffer_; - MutableByteRange range_; - - static void delete_buffer(unsigned char* buffer) { - delete[] buffer; - } - - public: - /// Construct an empty buffer that owns no data. - explicit Buffer() {} - - /// Construct a `Buffer` that owns a new underlying buffer of size `size`. - explicit Buffer(std::size_t size) - : buffer_(new unsigned char[size], delete_buffer), - range_(buffer_.get(), buffer_.get() + size) {} - - explicit Buffer(std::shared_ptr buffer, MutableByteRange data) - : buffer_(buffer), range_(data) {} - - Buffer(Buffer&&) = default; - Buffer& operator=(Buffer&&) = default; - - /** - * Splits the data into two pieces: [begin, begin + n), [begin + n, end). - * Their data both points into the same underlying buffer. - * Modifies the original `Buffer` to point to only [begin + n, end). - * - * @param n The offset to split at. - * @returns A buffer that owns the data [begin, begin + n). - */ - Buffer splitAt(std::size_t n) { - auto firstPiece = range_.subpiece(0, n); - range_.advance(n); - return Buffer(buffer_, firstPiece); - } - - /// Modifies the buffer to point to the range [begin + n, end). - void advance(std::size_t n) { - range_.advance(n); - } - - /// Modifies the buffer to point to the range [begin, end - n). - void subtract(std::size_t n) { - range_.subtract(n); - } - - /// Returns a read only `Range` pointing to the `Buffer`s data. - ByteRange range() const { - return range_; - } - /// Returns a mutable `Range` pointing to the `Buffer`s data. - MutableByteRange range() { - return range_; - } - - const unsigned char* data() const { - return range_.data(); - } - - unsigned char* data() { - return range_.data(); - } - - std::size_t size() const { - return range_.size(); - } - - bool empty() const { - return range_.empty(); - } -}; -} diff --git a/third_party/zstd/contrib/pzstd/utils/FileSystem.h b/third_party/zstd/contrib/pzstd/utils/FileSystem.h deleted file mode 100644 index 8d57d05f0..000000000 --- a/third_party/zstd/contrib/pzstd/utils/FileSystem.h +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under both the BSD-style license (found in the - * LICENSE file in the root directory of this source tree) and the GPLv2 (found - * in the COPYING file in the root directory of this source tree). - */ -#pragma once - -#include "utils/Portability.h" -#include "utils/Range.h" - -#include -#include -#include -#include -#include - -// A small subset of `std::filesystem`. -// `std::filesystem` should be a drop in replacement. -// See https://en.cppreference.com/w/cpp/filesystem for documentation. - -namespace pzstd { - -// using file_status = ... causes gcc to emit a false positive warning -#if defined(_MSC_VER) -typedef struct ::_stat64 file_status; -#else -typedef struct ::stat file_status; -#endif - -/// https://en.cppreference.com/w/cpp/filesystem/status -inline file_status status(StringPiece path, std::error_code& ec) noexcept { - file_status status; -#if defined(_MSC_VER) - const auto error = ::_stat64(path.data(), &status); -#else - const auto error = ::stat(path.data(), &status); -#endif - if (error) { - ec.assign(errno, std::generic_category()); - } else { - ec.clear(); - } - return status; -} - -/// https://en.cppreference.com/w/cpp/filesystem/is_regular_file -inline bool is_regular_file(file_status status) noexcept { -#if defined(S_ISREG) - return S_ISREG(status.st_mode); -#elif !defined(S_ISREG) && defined(S_IFMT) && defined(S_IFREG) - return (status.st_mode & S_IFMT) == S_IFREG; -#else - static_assert(false, "No POSIX stat() support."); -#endif -} - -/// https://en.cppreference.com/w/cpp/filesystem/is_regular_file -inline bool is_regular_file(StringPiece path, std::error_code& ec) noexcept { - return is_regular_file(status(path, ec)); -} - -/// https://en.cppreference.com/w/cpp/filesystem/is_directory -inline bool is_directory(file_status status) noexcept { -#if defined(S_ISDIR) - return S_ISDIR(status.st_mode); -#elif !defined(S_ISDIR) && defined(S_IFMT) && defined(S_IFDIR) - return (status.st_mode & S_IFMT) == S_IFDIR; -#else - static_assert(false, "NO POSIX stat() support."); -#endif -} - -/// https://en.cppreference.com/w/cpp/filesystem/is_directory -inline bool is_directory(StringPiece path, std::error_code& ec) noexcept { - return is_directory(status(path, ec)); -} - -/// https://en.cppreference.com/w/cpp/filesystem/file_size -inline std::uintmax_t file_size( - StringPiece path, - std::error_code& ec) noexcept { - auto stat = status(path, ec); - if (ec) { - return std::numeric_limits::max(); - } - if (!is_regular_file(stat)) { - ec.assign(ENOTSUP, std::generic_category()); - return std::numeric_limits::max(); - } - ec.clear(); - return stat.st_size; -} -} diff --git a/third_party/zstd/contrib/pzstd/utils/Likely.h b/third_party/zstd/contrib/pzstd/utils/Likely.h deleted file mode 100644 index 52243a64e..000000000 --- a/third_party/zstd/contrib/pzstd/utils/Likely.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under both the BSD-style license (found in the - * LICENSE file in the root directory of this source tree) and the GPLv2 (found - * in the COPYING file in the root directory of this source tree). - */ - -/** - * Compiler hints to indicate the fast path of an "if" branch: whether - * the if condition is likely to be true or false. - * - * @author Tudor Bosman (tudorb@fb.com) - */ - -#pragma once - -#undef LIKELY -#undef UNLIKELY - -#if defined(__GNUC__) && __GNUC__ >= 4 -#define LIKELY(x) (__builtin_expect((x), 1)) -#define UNLIKELY(x) (__builtin_expect((x), 0)) -#else -#define LIKELY(x) (x) -#define UNLIKELY(x) (x) -#endif diff --git a/third_party/zstd/contrib/pzstd/utils/Portability.h b/third_party/zstd/contrib/pzstd/utils/Portability.h deleted file mode 100644 index ef1f86e51..000000000 --- a/third_party/zstd/contrib/pzstd/utils/Portability.h +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under both the BSD-style license (found in the - * LICENSE file in the root directory of this source tree) and the GPLv2 (found - * in the COPYING file in the root directory of this source tree). - */ - -#pragma once - -#include - -// Required for windows, which defines min/max, but we want the std:: version. -#undef min -#undef max diff --git a/third_party/zstd/contrib/pzstd/utils/Range.h b/third_party/zstd/contrib/pzstd/utils/Range.h deleted file mode 100644 index 0fd8f9f86..000000000 --- a/third_party/zstd/contrib/pzstd/utils/Range.h +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under both the BSD-style license (found in the - * LICENSE file in the root directory of this source tree) and the GPLv2 (found - * in the COPYING file in the root directory of this source tree). - */ - -/** - * A subset of `folly/Range.h`. - * All code copied verbatim modulo formatting - */ -#pragma once - -#include "utils/Likely.h" -#include "utils/Portability.h" - -#include -#include -#include -#include -#include -#include - -namespace pzstd { - -namespace detail { -/* - *Use IsCharPointer::type to enable const char* or char*. - *Use IsCharPointer::const_type to enable only const char*. -*/ -template -struct IsCharPointer {}; - -template <> -struct IsCharPointer { - typedef int type; -}; - -template <> -struct IsCharPointer { - typedef int const_type; - typedef int type; -}; - -} // namespace detail - -template -class Range { - Iter b_; - Iter e_; - - public: - using size_type = std::size_t; - using iterator = Iter; - using const_iterator = Iter; - using value_type = typename std::remove_reference< - typename std::iterator_traits::reference>::type; - using reference = typename std::iterator_traits::reference; - - constexpr Range() : b_(), e_() {} - constexpr Range(Iter begin, Iter end) : b_(begin), e_(end) {} - - constexpr Range(Iter begin, size_type size) : b_(begin), e_(begin + size) {} - - template ::type = 0> - /* implicit */ Range(Iter str) : b_(str), e_(str + std::strlen(str)) {} - - template ::const_type = 0> - /* implicit */ Range(const std::string& str) - : b_(str.data()), e_(b_ + str.size()) {} - - // Allow implicit conversion from Range to Range if From is - // implicitly convertible to To. - template < - class OtherIter, - typename std::enable_if< - (!std::is_same::value && - std::is_convertible::value), - int>::type = 0> - constexpr /* implicit */ Range(const Range& other) - : b_(other.begin()), e_(other.end()) {} - - Range(const Range&) = default; - Range(Range&&) = default; - - Range& operator=(const Range&) = default; - Range& operator=(Range&&) = default; - - constexpr size_type size() const { - return e_ - b_; - } - bool empty() const { - return b_ == e_; - } - Iter data() const { - return b_; - } - Iter begin() const { - return b_; - } - Iter end() const { - return e_; - } - - void advance(size_type n) { - if (UNLIKELY(n > size())) { - throw std::out_of_range("index out of range"); - } - b_ += n; - } - - void subtract(size_type n) { - if (UNLIKELY(n > size())) { - throw std::out_of_range("index out of range"); - } - e_ -= n; - } - - Range subpiece(size_type first, size_type length = std::string::npos) const { - if (UNLIKELY(first > size())) { - throw std::out_of_range("index out of range"); - } - - return Range(b_ + first, std::min(length, size() - first)); - } -}; - -using ByteRange = Range; -using MutableByteRange = Range; -using StringPiece = Range; -} diff --git a/third_party/zstd/contrib/pzstd/utils/ResourcePool.h b/third_party/zstd/contrib/pzstd/utils/ResourcePool.h deleted file mode 100644 index 7c4bb6235..000000000 --- a/third_party/zstd/contrib/pzstd/utils/ResourcePool.h +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under both the BSD-style license (found in the - * LICENSE file in the root directory of this source tree) and the GPLv2 (found - * in the COPYING file in the root directory of this source tree). - */ -#pragma once - -#include -#include -#include -#include -#include - -namespace pzstd { - -/** - * An unbounded pool of resources. - * A `ResourcePool` requires a factory function that takes allocates `T*` and - * a free function that frees a `T*`. - * Calling `ResourcePool::get()` will give you a new `ResourcePool::UniquePtr` - * to a `T`, and when it goes out of scope the resource will be returned to the - * pool. - * The `ResourcePool` *must* survive longer than any resources it hands out. - * Remember that `ResourcePool` hands out mutable `T`s, so make sure to clean - * up the resource before or after every use. - */ -template -class ResourcePool { - public: - class Deleter; - using Factory = std::function; - using Free = std::function; - using UniquePtr = std::unique_ptr; - - private: - std::mutex mutex_; - Factory factory_; - Free free_; - std::vector resources_; - unsigned inUse_; - - public: - /** - * Creates a `ResourcePool`. - * - * @param factory The function to use to create new resources. - * @param free The function to use to free resources created by `factory`. - */ - ResourcePool(Factory factory, Free free) - : factory_(std::move(factory)), free_(std::move(free)), inUse_(0) {} - - /** - * @returns A unique pointer to a resource. The resource is null iff - * there are no available resources and `factory()` returns null. - */ - UniquePtr get() { - std::lock_guard lock(mutex_); - if (!resources_.empty()) { - UniquePtr resource{resources_.back(), Deleter{*this}}; - resources_.pop_back(); - ++inUse_; - return resource; - } - UniquePtr resource{factory_(), Deleter{*this}}; - ++inUse_; - return resource; - } - - ~ResourcePool() noexcept { - assert(inUse_ == 0); - for (const auto resource : resources_) { - free_(resource); - } - } - - class Deleter { - ResourcePool *pool_; - public: - explicit Deleter(ResourcePool &pool) : pool_(&pool) {} - - void operator() (T *resource) { - std::lock_guard lock(pool_->mutex_); - // Make sure we don't put null resources into the pool - if (resource) { - pool_->resources_.push_back(resource); - } - assert(pool_->inUse_ > 0); - --pool_->inUse_; - } - }; -}; - -} diff --git a/third_party/zstd/contrib/pzstd/utils/ScopeGuard.h b/third_party/zstd/contrib/pzstd/utils/ScopeGuard.h deleted file mode 100644 index 911fd9842..000000000 --- a/third_party/zstd/contrib/pzstd/utils/ScopeGuard.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under both the BSD-style license (found in the - * LICENSE file in the root directory of this source tree) and the GPLv2 (found - * in the COPYING file in the root directory of this source tree). - */ -#pragma once - -#include - -namespace pzstd { - -/** - * Dismissable scope guard. - * `Function` must be callable and take no parameters. - * Unless `dismiss()` is called, the callable is executed upon destruction of - * `ScopeGuard`. - * - * Example: - * - * auto guard = makeScopeGuard([&] { cleanup(); }); - */ -template -class ScopeGuard { - Function function; - bool dismissed; - - public: - explicit ScopeGuard(Function&& function) - : function(std::move(function)), dismissed(false) {} - - void dismiss() { - dismissed = true; - } - - ~ScopeGuard() noexcept { - if (!dismissed) { - function(); - } - } -}; - -/// Creates a scope guard from `function`. -template -ScopeGuard makeScopeGuard(Function&& function) { - return ScopeGuard(std::forward(function)); -} -} diff --git a/third_party/zstd/contrib/pzstd/utils/ThreadPool.h b/third_party/zstd/contrib/pzstd/utils/ThreadPool.h deleted file mode 100644 index a087d7c1c..000000000 --- a/third_party/zstd/contrib/pzstd/utils/ThreadPool.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under both the BSD-style license (found in the - * LICENSE file in the root directory of this source tree) and the GPLv2 (found - * in the COPYING file in the root directory of this source tree). - */ -#pragma once - -#include "utils/WorkQueue.h" - -#include -#include -#include -#include - -namespace pzstd { -/// A simple thread pool that pulls tasks off its queue in FIFO order. -class ThreadPool { - std::vector threads_; - - WorkQueue> tasks_; - - public: - /// Constructs a thread pool with `numThreads` threads. - explicit ThreadPool(std::size_t numThreads) { - threads_.reserve(numThreads); - for (std::size_t i = 0; i < numThreads; ++i) { - threads_.emplace_back([this] { - std::function task; - while (tasks_.pop(task)) { - task(); - } - }); - } - } - - /// Finishes all tasks currently in the queue. - ~ThreadPool() { - tasks_.finish(); - for (auto& thread : threads_) { - thread.join(); - } - } - - /** - * Adds `task` to the queue of tasks to execute. Since `task` is a - * `std::function<>`, it cannot be a move only type. So any lambda passed must - * not capture move only types (like `std::unique_ptr`). - * - * @param task The task to execute. - */ - void add(std::function task) { - tasks_.push(std::move(task)); - } -}; -} diff --git a/third_party/zstd/contrib/pzstd/utils/WorkQueue.h b/third_party/zstd/contrib/pzstd/utils/WorkQueue.h deleted file mode 100644 index d7947b814..000000000 --- a/third_party/zstd/contrib/pzstd/utils/WorkQueue.h +++ /dev/null @@ -1,181 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under both the BSD-style license (found in the - * LICENSE file in the root directory of this source tree) and the GPLv2 (found - * in the COPYING file in the root directory of this source tree). - */ -#pragma once - -#include "utils/Buffer.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -namespace pzstd { - -/// Unbounded thread-safe work queue. -template -class WorkQueue { - // Protects all member variable access - std::mutex mutex_; - std::condition_variable readerCv_; - std::condition_variable writerCv_; - std::condition_variable finishCv_; - - std::queue queue_; - bool done_; - std::size_t maxSize_; - - // Must have lock to call this function - bool full() const { - if (maxSize_ == 0) { - return false; - } - return queue_.size() >= maxSize_; - } - - public: - /** - * Constructs an empty work queue with an optional max size. - * If `maxSize == 0` the queue size is unbounded. - * - * @param maxSize The maximum allowed size of the work queue. - */ - WorkQueue(std::size_t maxSize = 0) : done_(false), maxSize_(maxSize) {} - - /** - * Push an item onto the work queue. Notify a single thread that work is - * available. If `finish()` has been called, do nothing and return false. - * If `push()` returns false, then `item` has not been moved from. - * - * @param item Item to push onto the queue. - * @returns True upon success, false if `finish()` has been called. An - * item was pushed iff `push()` returns true. - */ - bool push(T&& item) { - { - std::unique_lock lock(mutex_); - while (full() && !done_) { - writerCv_.wait(lock); - } - if (done_) { - return false; - } - queue_.push(std::move(item)); - } - readerCv_.notify_one(); - return true; - } - - /** - * Attempts to pop an item off the work queue. It will block until data is - * available or `finish()` has been called. - * - * @param[out] item If `pop` returns `true`, it contains the popped item. - * If `pop` returns `false`, it is unmodified. - * @returns True upon success. False if the queue is empty and - * `finish()` has been called. - */ - bool pop(T& item) { - { - std::unique_lock lock(mutex_); - while (queue_.empty() && !done_) { - readerCv_.wait(lock); - } - if (queue_.empty()) { - assert(done_); - return false; - } - item = std::move(queue_.front()); - queue_.pop(); - } - writerCv_.notify_one(); - return true; - } - - /** - * Sets the maximum queue size. If `maxSize == 0` then it is unbounded. - * - * @param maxSize The new maximum queue size. - */ - void setMaxSize(std::size_t maxSize) { - { - std::lock_guard lock(mutex_); - maxSize_ = maxSize; - } - writerCv_.notify_all(); - } - - /** - * Promise that `push()` won't be called again, so once the queue is empty - * there will never any more work. - */ - void finish() { - { - std::lock_guard lock(mutex_); - assert(!done_); - done_ = true; - } - readerCv_.notify_all(); - writerCv_.notify_all(); - finishCv_.notify_all(); - } - - /// Blocks until `finish()` has been called (but the queue may not be empty). - void waitUntilFinished() { - std::unique_lock lock(mutex_); - while (!done_) { - finishCv_.wait(lock); - } - } -}; - -/// Work queue for `Buffer`s that knows the total number of bytes in the queue. -class BufferWorkQueue { - WorkQueue queue_; - std::atomic size_; - - public: - BufferWorkQueue(std::size_t maxSize = 0) : queue_(maxSize), size_(0) {} - - void push(Buffer buffer) { - size_.fetch_add(buffer.size()); - queue_.push(std::move(buffer)); - } - - bool pop(Buffer& buffer) { - bool result = queue_.pop(buffer); - if (result) { - size_.fetch_sub(buffer.size()); - } - return result; - } - - void setMaxSize(std::size_t maxSize) { - queue_.setMaxSize(maxSize); - } - - void finish() { - queue_.finish(); - } - - /** - * Blocks until `finish()` has been called. - * - * @returns The total number of bytes of all the `Buffer`s currently in the - * queue. - */ - std::size_t size() { - queue_.waitUntilFinished(); - return size_.load(); - } -}; -} diff --git a/third_party/zstd/contrib/pzstd/utils/test/BUCK b/third_party/zstd/contrib/pzstd/utils/test/BUCK deleted file mode 100644 index a5113cab6..000000000 --- a/third_party/zstd/contrib/pzstd/utils/test/BUCK +++ /dev/null @@ -1,35 +0,0 @@ -cxx_test( - name='buffer_test', - srcs=['BufferTest.cpp'], - deps=['//contrib/pzstd/utils:buffer'], -) - -cxx_test( - name='range_test', - srcs=['RangeTest.cpp'], - deps=['//contrib/pzstd/utils:range'], -) - -cxx_test( - name='resource_pool_test', - srcs=['ResourcePoolTest.cpp'], - deps=['//contrib/pzstd/utils:resource_pool'], -) - -cxx_test( - name='scope_guard_test', - srcs=['ScopeGuardTest.cpp'], - deps=['//contrib/pzstd/utils:scope_guard'], -) - -cxx_test( - name='thread_pool_test', - srcs=['ThreadPoolTest.cpp'], - deps=['//contrib/pzstd/utils:thread_pool'], -) - -cxx_test( - name='work_queue_test', - srcs=['RangeTest.cpp'], - deps=['//contrib/pzstd/utils:work_queue'], -) diff --git a/third_party/zstd/contrib/pzstd/utils/test/BufferTest.cpp b/third_party/zstd/contrib/pzstd/utils/test/BufferTest.cpp deleted file mode 100644 index 58bf08dcd..000000000 --- a/third_party/zstd/contrib/pzstd/utils/test/BufferTest.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under both the BSD-style license (found in the - * LICENSE file in the root directory of this source tree) and the GPLv2 (found - * in the COPYING file in the root directory of this source tree). - */ -#include "utils/Buffer.h" -#include "utils/Range.h" - -#include -#include - -using namespace pzstd; - -namespace { -void deleter(const unsigned char* buf) { - delete[] buf; -} -} - -TEST(Buffer, Constructors) { - Buffer empty; - EXPECT_TRUE(empty.empty()); - EXPECT_EQ(0, empty.size()); - - Buffer sized(5); - EXPECT_FALSE(sized.empty()); - EXPECT_EQ(5, sized.size()); - - Buffer moved(std::move(sized)); - EXPECT_FALSE(sized.empty()); - EXPECT_EQ(5, sized.size()); - - Buffer assigned; - assigned = std::move(moved); - EXPECT_FALSE(sized.empty()); - EXPECT_EQ(5, sized.size()); -} - -TEST(Buffer, BufferManagement) { - std::shared_ptr buf(new unsigned char[10], deleter); - { - Buffer acquired(buf, MutableByteRange(buf.get(), buf.get() + 10)); - EXPECT_EQ(2, buf.use_count()); - Buffer moved(std::move(acquired)); - EXPECT_EQ(2, buf.use_count()); - Buffer assigned; - assigned = std::move(moved); - EXPECT_EQ(2, buf.use_count()); - - Buffer split = assigned.splitAt(5); - EXPECT_EQ(3, buf.use_count()); - - split.advance(1); - assigned.subtract(1); - EXPECT_EQ(3, buf.use_count()); - } - EXPECT_EQ(1, buf.use_count()); -} - -TEST(Buffer, Modifiers) { - Buffer buf(10); - { - unsigned char i = 0; - for (auto& byte : buf.range()) { - byte = i++; - } - } - - auto prefix = buf.splitAt(2); - - ASSERT_EQ(2, prefix.size()); - EXPECT_EQ(0, *prefix.data()); - - ASSERT_EQ(8, buf.size()); - EXPECT_EQ(2, *buf.data()); - - buf.advance(2); - EXPECT_EQ(4, *buf.data()); - - EXPECT_EQ(9, *(buf.range().end() - 1)); - - buf.subtract(2); - EXPECT_EQ(7, *(buf.range().end() - 1)); - - EXPECT_EQ(4, buf.size()); -} diff --git a/third_party/zstd/contrib/pzstd/utils/test/RangeTest.cpp b/third_party/zstd/contrib/pzstd/utils/test/RangeTest.cpp deleted file mode 100644 index 8b7dee271..000000000 --- a/third_party/zstd/contrib/pzstd/utils/test/RangeTest.cpp +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under both the BSD-style license (found in the - * LICENSE file in the root directory of this source tree) and the GPLv2 (found - * in the COPYING file in the root directory of this source tree). - */ -#include "utils/Range.h" - -#include -#include - -using namespace pzstd; - -// Range is directly copied from folly. -// Just some sanity tests to make sure everything seems to work. - -TEST(Range, Constructors) { - StringPiece empty; - EXPECT_TRUE(empty.empty()); - EXPECT_EQ(0, empty.size()); - - std::string str = "hello"; - { - Range piece(str.begin(), str.end()); - EXPECT_EQ(5, piece.size()); - EXPECT_EQ('h', *piece.data()); - EXPECT_EQ('o', *(piece.end() - 1)); - } - - { - StringPiece piece(str.data(), str.size()); - EXPECT_EQ(5, piece.size()); - EXPECT_EQ('h', *piece.data()); - EXPECT_EQ('o', *(piece.end() - 1)); - } - - { - StringPiece piece(str); - EXPECT_EQ(5, piece.size()); - EXPECT_EQ('h', *piece.data()); - EXPECT_EQ('o', *(piece.end() - 1)); - } - - { - StringPiece piece(str.c_str()); - EXPECT_EQ(5, piece.size()); - EXPECT_EQ('h', *piece.data()); - EXPECT_EQ('o', *(piece.end() - 1)); - } -} - -TEST(Range, Modifiers) { - StringPiece range("hello world"); - ASSERT_EQ(11, range.size()); - - { - auto hello = range.subpiece(0, 5); - EXPECT_EQ(5, hello.size()); - EXPECT_EQ('h', *hello.data()); - EXPECT_EQ('o', *(hello.end() - 1)); - } - { - auto hello = range; - hello.subtract(6); - EXPECT_EQ(5, hello.size()); - EXPECT_EQ('h', *hello.data()); - EXPECT_EQ('o', *(hello.end() - 1)); - } - { - auto world = range; - world.advance(6); - EXPECT_EQ(5, world.size()); - EXPECT_EQ('w', *world.data()); - EXPECT_EQ('d', *(world.end() - 1)); - } - - std::string expected = "hello world"; - EXPECT_EQ(expected, std::string(range.begin(), range.end())); - EXPECT_EQ(expected, std::string(range.data(), range.size())); -} diff --git a/third_party/zstd/contrib/pzstd/utils/test/ResourcePoolTest.cpp b/third_party/zstd/contrib/pzstd/utils/test/ResourcePoolTest.cpp deleted file mode 100644 index 750ee084b..000000000 --- a/third_party/zstd/contrib/pzstd/utils/test/ResourcePoolTest.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under both the BSD-style license (found in the - * LICENSE file in the root directory of this source tree) and the GPLv2 (found - * in the COPYING file in the root directory of this source tree). - */ -#include "utils/ResourcePool.h" - -#include -#include -#include - -using namespace pzstd; - -TEST(ResourcePool, FullTest) { - unsigned numCreated = 0; - unsigned numDeleted = 0; - { - ResourcePool pool( - [&numCreated] { ++numCreated; return new int{5}; }, - [&numDeleted](int *x) { ++numDeleted; delete x; }); - - { - auto i = pool.get(); - EXPECT_EQ(5, *i); - *i = 6; - } - { - auto i = pool.get(); - EXPECT_EQ(6, *i); - auto j = pool.get(); - EXPECT_EQ(5, *j); - *j = 7; - } - { - auto i = pool.get(); - EXPECT_EQ(6, *i); - auto j = pool.get(); - EXPECT_EQ(7, *j); - } - } - EXPECT_EQ(2, numCreated); - EXPECT_EQ(numCreated, numDeleted); -} - -TEST(ResourcePool, ThreadSafe) { - std::atomic numCreated{0}; - std::atomic numDeleted{0}; - { - ResourcePool pool( - [&numCreated] { ++numCreated; return new int{0}; }, - [&numDeleted](int *x) { ++numDeleted; delete x; }); - auto push = [&pool] { - for (int i = 0; i < 100; ++i) { - auto x = pool.get(); - ++*x; - } - }; - std::thread t1{push}; - std::thread t2{push}; - t1.join(); - t2.join(); - - auto x = pool.get(); - auto y = pool.get(); - EXPECT_EQ(200, *x + *y); - } - EXPECT_GE(2, numCreated); - EXPECT_EQ(numCreated, numDeleted); -} diff --git a/third_party/zstd/contrib/pzstd/utils/test/ScopeGuardTest.cpp b/third_party/zstd/contrib/pzstd/utils/test/ScopeGuardTest.cpp deleted file mode 100644 index 0f77cdf38..000000000 --- a/third_party/zstd/contrib/pzstd/utils/test/ScopeGuardTest.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under both the BSD-style license (found in the - * LICENSE file in the root directory of this source tree) and the GPLv2 (found - * in the COPYING file in the root directory of this source tree). - */ -#include "utils/ScopeGuard.h" - -#include - -using namespace pzstd; - -TEST(ScopeGuard, Dismiss) { - { - auto guard = makeScopeGuard([&] { EXPECT_TRUE(false); }); - guard.dismiss(); - } -} - -TEST(ScopeGuard, Executes) { - bool executed = false; - { - auto guard = makeScopeGuard([&] { executed = true; }); - } - EXPECT_TRUE(executed); -} diff --git a/third_party/zstd/contrib/pzstd/utils/test/ThreadPoolTest.cpp b/third_party/zstd/contrib/pzstd/utils/test/ThreadPoolTest.cpp deleted file mode 100644 index a01052e60..000000000 --- a/third_party/zstd/contrib/pzstd/utils/test/ThreadPoolTest.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under both the BSD-style license (found in the - * LICENSE file in the root directory of this source tree) and the GPLv2 (found - * in the COPYING file in the root directory of this source tree). - */ -#include "utils/ThreadPool.h" - -#include -#include -#include -#include -#include - -using namespace pzstd; - -TEST(ThreadPool, Ordering) { - std::vector results; - - { - ThreadPool executor(1); - for (int i = 0; i < 10; ++i) { - executor.add([ &results, i ] { results.push_back(i); }); - } - } - - for (int i = 0; i < 10; ++i) { - EXPECT_EQ(i, results[i]); - } -} - -TEST(ThreadPool, AllJobsFinished) { - std::atomic numFinished{0}; - std::atomic start{false}; - { - std::cerr << "Creating executor" << std::endl; - ThreadPool executor(5); - for (int i = 0; i < 10; ++i) { - executor.add([ &numFinished, &start ] { - while (!start.load()) { - std::this_thread::yield(); - } - ++numFinished; - }); - } - std::cerr << "Starting" << std::endl; - start.store(true); - std::cerr << "Finishing" << std::endl; - } - EXPECT_EQ(10, numFinished.load()); -} - -TEST(ThreadPool, AddJobWhileJoining) { - std::atomic done{false}; - { - ThreadPool executor(1); - executor.add([&executor, &done] { - while (!done.load()) { - std::this_thread::yield(); - } - // Sleep for a second to be sure that we are joining - std::this_thread::sleep_for(std::chrono::seconds(1)); - executor.add([] { - EXPECT_TRUE(false); - }); - }); - done.store(true); - } -} diff --git a/third_party/zstd/contrib/pzstd/utils/test/WorkQueueTest.cpp b/third_party/zstd/contrib/pzstd/utils/test/WorkQueueTest.cpp deleted file mode 100644 index 16600bb60..000000000 --- a/third_party/zstd/contrib/pzstd/utils/test/WorkQueueTest.cpp +++ /dev/null @@ -1,282 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under both the BSD-style license (found in the - * LICENSE file in the root directory of this source tree) and the GPLv2 (found - * in the COPYING file in the root directory of this source tree). - */ -#include "utils/Buffer.h" -#include "utils/WorkQueue.h" - -#include -#include -#include -#include -#include -#include - -using namespace pzstd; - -namespace { -struct Popper { - WorkQueue* queue; - int* results; - std::mutex* mutex; - - void operator()() { - int result; - while (queue->pop(result)) { - std::lock_guard lock(*mutex); - results[result] = result; - } - } -}; -} - -TEST(WorkQueue, SingleThreaded) { - WorkQueue queue; - int result; - - queue.push(5); - EXPECT_TRUE(queue.pop(result)); - EXPECT_EQ(5, result); - - queue.push(1); - queue.push(2); - EXPECT_TRUE(queue.pop(result)); - EXPECT_EQ(1, result); - EXPECT_TRUE(queue.pop(result)); - EXPECT_EQ(2, result); - - queue.push(1); - queue.push(2); - queue.finish(); - EXPECT_TRUE(queue.pop(result)); - EXPECT_EQ(1, result); - EXPECT_TRUE(queue.pop(result)); - EXPECT_EQ(2, result); - EXPECT_FALSE(queue.pop(result)); - - queue.waitUntilFinished(); -} - -TEST(WorkQueue, SPSC) { - WorkQueue queue; - const int max = 100; - - for (int i = 0; i < 10; ++i) { - queue.push(int{i}); - } - - std::thread thread([ &queue, max ] { - int result; - for (int i = 0;; ++i) { - if (!queue.pop(result)) { - EXPECT_EQ(i, max); - break; - } - EXPECT_EQ(i, result); - } - }); - - std::this_thread::yield(); - for (int i = 10; i < max; ++i) { - queue.push(int{i}); - } - queue.finish(); - - thread.join(); -} - -TEST(WorkQueue, SPMC) { - WorkQueue queue; - std::vector results(50, -1); - std::mutex mutex; - std::vector threads; - for (int i = 0; i < 5; ++i) { - threads.emplace_back(Popper{&queue, results.data(), &mutex}); - } - - for (int i = 0; i < 50; ++i) { - queue.push(int{i}); - } - queue.finish(); - - for (auto& thread : threads) { - thread.join(); - } - - for (int i = 0; i < 50; ++i) { - EXPECT_EQ(i, results[i]); - } -} - -TEST(WorkQueue, MPMC) { - WorkQueue queue; - std::vector results(100, -1); - std::mutex mutex; - std::vector popperThreads; - for (int i = 0; i < 4; ++i) { - popperThreads.emplace_back(Popper{&queue, results.data(), &mutex}); - } - - std::vector pusherThreads; - for (int i = 0; i < 2; ++i) { - auto min = i * 50; - auto max = (i + 1) * 50; - pusherThreads.emplace_back( - [ &queue, min, max ] { - for (int i = min; i < max; ++i) { - queue.push(int{i}); - } - }); - } - - for (auto& thread : pusherThreads) { - thread.join(); - } - queue.finish(); - - for (auto& thread : popperThreads) { - thread.join(); - } - - for (int i = 0; i < 100; ++i) { - EXPECT_EQ(i, results[i]); - } -} - -TEST(WorkQueue, BoundedSizeWorks) { - WorkQueue queue(1); - int result; - queue.push(5); - queue.pop(result); - queue.push(5); - queue.pop(result); - queue.push(5); - queue.finish(); - queue.pop(result); - EXPECT_EQ(5, result); -} - -TEST(WorkQueue, BoundedSizePushAfterFinish) { - WorkQueue queue(1); - int result; - queue.push(5); - std::thread pusher([&queue] { - queue.push(6); - }); - // Dirtily try and make sure that pusher has run. - std::this_thread::sleep_for(std::chrono::seconds(1)); - queue.finish(); - EXPECT_TRUE(queue.pop(result)); - EXPECT_EQ(5, result); - EXPECT_FALSE(queue.pop(result)); - - pusher.join(); -} - -TEST(WorkQueue, SetMaxSize) { - WorkQueue queue(2); - int result; - queue.push(5); - queue.push(6); - queue.setMaxSize(1); - std::thread pusher([&queue] { - queue.push(7); - }); - // Dirtily try and make sure that pusher has run. - std::this_thread::sleep_for(std::chrono::seconds(1)); - queue.finish(); - EXPECT_TRUE(queue.pop(result)); - EXPECT_EQ(5, result); - EXPECT_TRUE(queue.pop(result)); - EXPECT_EQ(6, result); - EXPECT_FALSE(queue.pop(result)); - - pusher.join(); -} - -TEST(WorkQueue, BoundedSizeMPMC) { - WorkQueue queue(10); - std::vector results(200, -1); - std::mutex mutex; - std::cerr << "Creating popperThreads" << std::endl; - std::vector popperThreads; - for (int i = 0; i < 4; ++i) { - popperThreads.emplace_back(Popper{&queue, results.data(), &mutex}); - } - - std::cerr << "Creating pusherThreads" << std::endl; - std::vector pusherThreads; - for (int i = 0; i < 2; ++i) { - auto min = i * 100; - auto max = (i + 1) * 100; - pusherThreads.emplace_back( - [ &queue, min, max ] { - for (int i = min; i < max; ++i) { - queue.push(int{i}); - } - }); - } - - std::cerr << "Joining pusherThreads" << std::endl; - for (auto& thread : pusherThreads) { - thread.join(); - } - std::cerr << "Finishing queue" << std::endl; - queue.finish(); - - std::cerr << "Joining popperThreads" << std::endl; - for (auto& thread : popperThreads) { - thread.join(); - } - - std::cerr << "Inspecting results" << std::endl; - for (int i = 0; i < 200; ++i) { - EXPECT_EQ(i, results[i]); - } -} - -TEST(WorkQueue, FailedPush) { - WorkQueue> queue; - std::unique_ptr x(new int{5}); - EXPECT_TRUE(queue.push(std::move(x))); - EXPECT_EQ(nullptr, x); - queue.finish(); - x.reset(new int{6}); - EXPECT_FALSE(queue.push(std::move(x))); - EXPECT_NE(nullptr, x); - EXPECT_EQ(6, *x); -} - -TEST(BufferWorkQueue, SizeCalculatedCorrectly) { - { - BufferWorkQueue queue; - queue.finish(); - EXPECT_EQ(0, queue.size()); - } - { - BufferWorkQueue queue; - queue.push(Buffer(10)); - queue.finish(); - EXPECT_EQ(10, queue.size()); - } - { - BufferWorkQueue queue; - queue.push(Buffer(10)); - queue.push(Buffer(5)); - queue.finish(); - EXPECT_EQ(15, queue.size()); - } - { - BufferWorkQueue queue; - queue.push(Buffer(10)); - queue.push(Buffer(5)); - queue.finish(); - Buffer buffer; - queue.pop(buffer); - EXPECT_EQ(5, queue.size()); - } -} diff --git a/third_party/zstd/contrib/recovery/Makefile b/third_party/zstd/contrib/recovery/Makefile deleted file mode 100644 index be6ea4b0e..000000000 --- a/third_party/zstd/contrib/recovery/Makefile +++ /dev/null @@ -1,35 +0,0 @@ -# ################################################################ -# Copyright (c) Meta Platforms, Inc. and affiliates. -# All rights reserved. -# -# This source code is licensed under both the BSD-style license (found in the -# LICENSE file in the root directory of this source tree) and the GPLv2 (found -# in the COPYING file in the root directory of this source tree). -# ################################################################ - -.PHONY: all -all: recover_directory - -ZSTDLIBDIR ?= ../../lib -PROGRAMDIR ?= ../../programs - -CFLAGS ?= -O3 -CFLAGS += -I$(ZSTDLIBDIR) -I$(PROGRAMDIR) -CFLAGS += -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow \ - -Wstrict-aliasing=1 -Wswitch-enum \ - -Wstrict-prototypes -Wundef \ - -Wvla -Wformat=2 -Winit-self -Wfloat-equal -Wwrite-strings \ - -Wredundant-decls -Wmissing-prototypes -CFLAGS += $(DEBUGFLAGS) $(MOREFLAGS) -FLAGS = $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) - -.PHONY: $(ZSTDLIBDIR)/libzstd.a -$(ZSTDLIBDIR)/libzstd.a: - $(MAKE) -C $(ZSTDLIBDIR) libzstd.a - -recover_directory: recover_directory.c $(ZSTDLIBDIR)/libzstd.a $(PROGRAMDIR)/util.c - $(CC) $(FLAGS) $^ -o $@$(EXT) - -.PHONY: clean -clean: - rm -f recover_directory diff --git a/third_party/zstd/contrib/recovery/recover_directory.c b/third_party/zstd/contrib/recovery/recover_directory.c deleted file mode 100644 index b9bd7ab49..000000000 --- a/third_party/zstd/contrib/recovery/recover_directory.c +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under both the BSD-style license (found in the - * LICENSE file in the root directory of this source tree) and the GPLv2 (found - * in the COPYING file in the root directory of this source tree). - * You may select, at your option, one of the above-listed licenses. - */ - -#include -#include -#include - -#define ZSTD_STATIC_LINKING_ONLY -#include "util.h" -#include "zstd.h" - -#define CHECK(cond, ...) \ - do { \ - if (!(cond)) { \ - fprintf(stderr, "%s:%d CHECK(%s) failed: ", __FILE__, __LINE__, #cond); \ - fprintf(stderr, "" __VA_ARGS__); \ - fprintf(stderr, "\n"); \ - exit(1); \ - } \ - } while (0) - -static void usage(char const *program) { - fprintf(stderr, "USAGE: %s FILE.zst PREFIX\n", program); - fprintf(stderr, "FILE.zst: A zstd compressed file with multiple frames\n"); - fprintf(stderr, "PREFIX: The output prefix. Uncompressed files will be " - "created named ${PREFIX}0 ${PREFIX}1...\n\n"); - fprintf(stderr, "This program takes concatenated zstd frames and " - "decompresses them into individual files.\n"); - fprintf(stderr, "E.g. files created with a command like: zstd -r directory " - "-o file.zst\n"); -} - -typedef struct { - char *data; - size_t size; - size_t frames; - size_t maxFrameSize; -} ZstdFrames; - -static ZstdFrames readFile(char const *fileName) { - U64 const fileSize = UTIL_getFileSize(fileName); - CHECK(fileSize != UTIL_FILESIZE_UNKNOWN, "Unknown file size!"); - - char *const data = (char *)malloc(fileSize); - CHECK(data != NULL, "Allocation failed"); - - FILE *file = fopen(fileName, "rb"); - CHECK(file != NULL, "fopen failed"); - - size_t const readSize = fread(data, 1, fileSize, file); - CHECK(readSize == fileSize, "fread failed"); - - fclose(file); - ZstdFrames frames; - frames.data = (char *)data; - frames.size = fileSize; - frames.frames = 0; - - size_t index; - size_t maxFrameSize = 0; - for (index = 0; index < fileSize;) { - size_t const frameSize = - ZSTD_findFrameCompressedSize(data + index, fileSize - index); - CHECK(!ZSTD_isError(frameSize), "Bad zstd frame: %s", - ZSTD_getErrorName(frameSize)); - if (frameSize > maxFrameSize) - maxFrameSize = frameSize; - frames.frames += 1; - index += frameSize; - } - CHECK(index == fileSize, "Zstd file corrupt!"); - frames.maxFrameSize = maxFrameSize; - - return frames; -} - -static int computePadding(size_t numFrames) { - return snprintf(NULL, 0, "%u", (unsigned)numFrames); -} - -int main(int argc, char **argv) { - if (argc != 3) { - usage(argv[0]); - exit(1); - } - char const *const zstdFile = argv[1]; - char const *const prefix = argv[2]; - - ZstdFrames frames = readFile(zstdFile); - - if (frames.frames <= 1) { - fprintf( - stderr, - "%s only has %u zstd frame. Simply use `zstd -d` to decompress it.\n", - zstdFile, (unsigned)frames.frames); - exit(1); - } - - int const padding = computePadding(frames.frames - 1); - - size_t const outFileNameSize = strlen(prefix) + padding + 1; - char* outFileName = malloc(outFileNameSize); - CHECK(outFileName != NULL, "Allocation failure"); - - size_t const bufferSize = 128 * 1024; - void *buffer = malloc(bufferSize); - CHECK(buffer != NULL, "Allocation failure"); - - ZSTD_DCtx* dctx = ZSTD_createDCtx(); - CHECK(dctx != NULL, "Allocation failure"); - - fprintf(stderr, "Recovering %u files...\n", (unsigned)frames.frames); - - size_t index; - size_t frame = 0; - for (index = 0; index < frames.size; ++frame) { - size_t const frameSize = - ZSTD_findFrameCompressedSize(frames.data + index, frames.size - index); - - int const ret = snprintf(outFileName, outFileNameSize, "%s%0*u", prefix, padding, (unsigned)frame); - CHECK(ret >= 0 && (size_t)ret <= outFileNameSize, "snprintf failed!"); - - FILE* outFile = fopen(outFileName, "wb"); - CHECK(outFile != NULL, "fopen failed"); - - ZSTD_DCtx_reset(dctx, ZSTD_reset_session_only); - ZSTD_inBuffer in = {frames.data + index, frameSize, 0}; - while (in.pos < in.size) { - ZSTD_outBuffer out = {buffer, bufferSize, 0}; - CHECK(!ZSTD_isError(ZSTD_decompressStream(dctx, &out, &in)), "decompression failed"); - size_t const writeSize = fwrite(out.dst, 1, out.pos, outFile); - CHECK(writeSize == out.pos, "fwrite failed"); - } - fclose(outFile); - fprintf(stderr, "Recovered %s\n", outFileName); - index += frameSize; - } - fprintf(stderr, "Complete\n"); - - free(outFileName); - ZSTD_freeDCtx(dctx); - free(buffer); - free(frames.data); - return 0; -} diff --git a/third_party/zstd/contrib/seekable_format/README.md b/third_party/zstd/contrib/seekable_format/README.md deleted file mode 100644 index fedf96bab..000000000 --- a/third_party/zstd/contrib/seekable_format/README.md +++ /dev/null @@ -1,42 +0,0 @@ -# Zstandard Seekable Format - -The seekable format splits compressed data into a series of independent "frames", -each compressed individually, -so that decompression of a section in the middle of an archive -only requires zstd to decompress at most a frame's worth of extra data, -instead of the entire archive. - -The frames are appended, so that the decompression of the entire payload -still regenerates the original content, using any compliant zstd decoder. - -On top of that, the seekable format generates a jump table, -which makes it possible to jump directly to the position of the relevant frame -when requesting only a segment of the data. -The jump table is simply ignored by zstd decoders unaware of the seekable format. - -The format is delivered with an API to create seekable archives -and to retrieve arbitrary segments inside the archive. - -### Maximum Frame Size parameter - -When creating a seekable archive, the main parameter is the maximum frame size. - -At compression time, user can manually select the boundaries between segments, -but they don't have to: long segments will be automatically split -when larger than selected maximum frame size. - -Small frame sizes reduce decompression cost when requesting small segments, -because the decoder will nonetheless have to decompress an entire frame -to recover just a single byte from it. - -A good rule of thumb is to select a maximum frame size roughly equivalent -to the access pattern when it's known. -For example, if the application tends to request 4KB blocks, -then it's a good idea to set a maximum frame size in the vicinity of 4 KB. - -But small frame sizes also reduce compression ratio, -and increase the cost for the jump table, -so there is a balance to find. - -In general, try to avoid really tiny frame sizes (<1 KB), -which would have a large negative impact on compression ratio. diff --git a/third_party/zstd/contrib/seekable_format/examples/.gitignore b/third_party/zstd/contrib/seekable_format/examples/.gitignore deleted file mode 100644 index 0b83f5e11..000000000 --- a/third_party/zstd/contrib/seekable_format/examples/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -seekable_compression -seekable_decompression -seekable_decompression_mem -parallel_processing -parallel_compression diff --git a/third_party/zstd/contrib/seekable_format/examples/Makefile b/third_party/zstd/contrib/seekable_format/examples/Makefile deleted file mode 100644 index fcc04587c..000000000 --- a/third_party/zstd/contrib/seekable_format/examples/Makefile +++ /dev/null @@ -1,53 +0,0 @@ -# ################################################################ -# Copyright (c) Meta Platforms, Inc. and affiliates. -# All rights reserved. -# -# This source code is licensed under both the BSD-style license (found in the -# LICENSE file in the root directory of this source tree) and the GPLv2 (found -# in the COPYING file in the root directory of this source tree). -# ################################################################ - -# This Makefile presumes libzstd is built, using `make` in / or /lib/ - -ZSTDLIB_PATH = ../../../lib -ZSTDLIB_NAME = libzstd.a -ZSTDLIB = $(ZSTDLIB_PATH)/$(ZSTDLIB_NAME) - -CPPFLAGS += -DXXH_NAMESPACE=ZSTD_ -I../ -I../../../lib -I../../../lib/common - -CFLAGS ?= -O3 -CFLAGS += -g - -SEEKABLE_OBJS = ../zstdseek_compress.c ../zstdseek_decompress.c $(ZSTDLIB) - -.PHONY: default all clean test - -default: all - -all: seekable_compression seekable_decompression seekable_decompression_mem \ - parallel_processing - -$(ZSTDLIB): - make -C $(ZSTDLIB_PATH) $(ZSTDLIB_NAME) - -seekable_compression : seekable_compression.c $(SEEKABLE_OBJS) - $(CC) $(CPPFLAGS) $(CFLAGS) $^ $(LDFLAGS) -o $@ - -seekable_decompression : seekable_decompression.c $(SEEKABLE_OBJS) - $(CC) $(CPPFLAGS) $(CFLAGS) $^ $(LDFLAGS) -o $@ - -seekable_decompression_mem : seekable_decompression_mem.c $(SEEKABLE_OBJS) - $(CC) $(CPPFLAGS) $(CFLAGS) $^ $(LDFLAGS) -o $@ - -parallel_processing : parallel_processing.c $(SEEKABLE_OBJS) - $(CC) $(CPPFLAGS) $(CFLAGS) $^ $(LDFLAGS) -o $@ -pthread - -parallel_compression : parallel_compression.c $(SEEKABLE_OBJS) - $(CC) $(CPPFLAGS) $(CFLAGS) $^ $(LDFLAGS) -o $@ -pthread - -clean: - @rm -f core *.o tmp* result* *.zst \ - seekable_compression seekable_decompression \ - seekable_decompression_mem \ - parallel_processing parallel_compression - @echo Cleaning completed diff --git a/third_party/zstd/contrib/seekable_format/examples/parallel_compression.c b/third_party/zstd/contrib/seekable_format/examples/parallel_compression.c deleted file mode 100644 index 4e06fae32..000000000 --- a/third_party/zstd/contrib/seekable_format/examples/parallel_compression.c +++ /dev/null @@ -1,214 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under both the BSD-style license (found in the - * LICENSE file in the root directory of this source tree) and the GPLv2 (found - * in the COPYING file in the root directory of this source tree). - */ - -#include // malloc, free, exit, atoi -#include // fprintf, perror, feof, fopen, etc. -#include // strlen, memset, strcat -#define ZSTD_STATIC_LINKING_ONLY -#include // presumes zstd library is installed -#include -#if defined(WIN32) || defined(_WIN32) -# include -# define SLEEP(x) Sleep(x) -#else -# include -# define SLEEP(x) usleep(x * 1000) -#endif - -#include "xxhash.h" - -#include "pool.h" // use zstd thread pool for demo - -#include "../zstd_seekable.h" - -static void* malloc_orDie(size_t size) -{ - void* const buff = malloc(size); - if (buff) return buff; - /* error */ - perror("malloc:"); - exit(1); -} - -static FILE* fopen_orDie(const char *filename, const char *instruction) -{ - FILE* const inFile = fopen(filename, instruction); - if (inFile) return inFile; - /* error */ - perror(filename); - exit(3); -} - -static size_t fread_orDie(void* buffer, size_t sizeToRead, FILE* file) -{ - size_t const readSize = fread(buffer, 1, sizeToRead, file); - if (readSize == sizeToRead) return readSize; /* good */ - if (feof(file)) return readSize; /* good, reached end of file */ - /* error */ - perror("fread"); - exit(4); -} - -static size_t fwrite_orDie(const void* buffer, size_t sizeToWrite, FILE* file) -{ - size_t const writtenSize = fwrite(buffer, 1, sizeToWrite, file); - if (writtenSize == sizeToWrite) return sizeToWrite; /* good */ - /* error */ - perror("fwrite"); - exit(5); -} - -static size_t fclose_orDie(FILE* file) -{ - if (!fclose(file)) return 0; - /* error */ - perror("fclose"); - exit(6); -} - -static void fseek_orDie(FILE* file, long int offset, int origin) -{ - if (!fseek(file, offset, origin)) { - if (!fflush(file)) return; - } - /* error */ - perror("fseek"); - exit(7); -} - -static long int ftell_orDie(FILE* file) -{ - long int off = ftell(file); - if (off != -1) return off; - /* error */ - perror("ftell"); - exit(8); -} - -struct job { - const void* src; - size_t srcSize; - void* dst; - size_t dstSize; - - unsigned checksum; - - int compressionLevel; - int done; -}; - -static void compressFrame(void* opaque) -{ - struct job* job = opaque; - - job->checksum = XXH64(job->src, job->srcSize, 0); - - size_t ret = ZSTD_compress(job->dst, job->dstSize, job->src, job->srcSize, job->compressionLevel); - if (ZSTD_isError(ret)) { - fprintf(stderr, "ZSTD_compress() error : %s \n", ZSTD_getErrorName(ret)); - exit(20); - } - - job->dstSize = ret; - job->done = 1; -} - -static void compressFile_orDie(const char* fname, const char* outName, int cLevel, unsigned frameSize, int nbThreads) -{ - POOL_ctx* pool = POOL_create(nbThreads, nbThreads); - if (pool == NULL) { fprintf(stderr, "POOL_create() error \n"); exit(9); } - - FILE* const fin = fopen_orDie(fname, "rb"); - FILE* const fout = fopen_orDie(outName, "wb"); - - if (ZSTD_compressBound(frameSize) > 0xFFFFFFFFU) { fprintf(stderr, "Frame size too large \n"); exit(10); } - unsigned dstSize = ZSTD_compressBound(frameSize); - - - fseek_orDie(fin, 0, SEEK_END); - long int length = ftell_orDie(fin); - fseek_orDie(fin, 0, SEEK_SET); - - size_t numFrames = (length + frameSize - 1) / frameSize; - - struct job* jobs = malloc_orDie(sizeof(struct job) * numFrames); - - size_t i; - for(i = 0; i < numFrames; i++) { - void* in = malloc_orDie(frameSize); - void* out = malloc_orDie(dstSize); - - size_t inSize = fread_orDie(in, frameSize, fin); - - jobs[i].src = in; - jobs[i].srcSize = inSize; - jobs[i].dst = out; - jobs[i].dstSize = dstSize; - jobs[i].compressionLevel = cLevel; - jobs[i].done = 0; - POOL_add(pool, compressFrame, &jobs[i]); - } - - ZSTD_frameLog* fl = ZSTD_seekable_createFrameLog(1); - if (fl == NULL) { fprintf(stderr, "ZSTD_seekable_createFrameLog() failed \n"); exit(11); } - for (i = 0; i < numFrames; i++) { - while (!jobs[i].done) SLEEP(5); /* wake up every 5 milliseconds to check */ - fwrite_orDie(jobs[i].dst, jobs[i].dstSize, fout); - free((void*)jobs[i].src); - free(jobs[i].dst); - - size_t ret = ZSTD_seekable_logFrame(fl, jobs[i].dstSize, jobs[i].srcSize, jobs[i].checksum); - if (ZSTD_isError(ret)) { fprintf(stderr, "ZSTD_seekable_logFrame() error : %s \n", ZSTD_getErrorName(ret)); } - } - - { unsigned char seekTableBuff[1024]; - ZSTD_outBuffer out = {seekTableBuff, 1024, 0}; - while (ZSTD_seekable_writeSeekTable(fl, &out) != 0) { - fwrite_orDie(seekTableBuff, out.pos, fout); - out.pos = 0; - } - fwrite_orDie(seekTableBuff, out.pos, fout); - } - - ZSTD_seekable_freeFrameLog(fl); - free(jobs); - fclose_orDie(fout); - fclose_orDie(fin); -} - -static const char* createOutFilename_orDie(const char* filename) -{ - size_t const inL = strlen(filename); - size_t const outL = inL + 5; - void* outSpace = malloc_orDie(outL); - memset(outSpace, 0, outL); - strcat(outSpace, filename); - strcat(outSpace, ".zst"); - return (const char*)outSpace; -} - -int main(int argc, const char** argv) { - const char* const exeName = argv[0]; - if (argc!=4) { - printf("wrong arguments\n"); - printf("usage:\n"); - printf("%s FILE FRAME_SIZE NB_THREADS\n", exeName); - return 1; - } - - { const char* const inFileName = argv[1]; - unsigned const frameSize = (unsigned)atoi(argv[2]); - int const nbThreads = atoi(argv[3]); - - const char* const outFileName = createOutFilename_orDie(inFileName); - compressFile_orDie(inFileName, outFileName, 5, frameSize, nbThreads); - } - - return 0; -} diff --git a/third_party/zstd/contrib/seekable_format/examples/parallel_processing.c b/third_party/zstd/contrib/seekable_format/examples/parallel_processing.c deleted file mode 100644 index 356561e5a..000000000 --- a/third_party/zstd/contrib/seekable_format/examples/parallel_processing.c +++ /dev/null @@ -1,194 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under both the BSD-style license (found in the - * LICENSE file in the root directory of this source tree) and the GPLv2 (found - * in the COPYING file in the root directory of this source tree). - */ - -/* - * A simple demo that sums up all the bytes in the file in parallel using - * seekable decompression and the zstd thread pool - */ - -#include // malloc, exit -#include // fprintf, perror, feof -#include // strerror -#include // errno -#define ZSTD_STATIC_LINKING_ONLY -#include // presumes zstd library is installed -#include -#if defined(WIN32) || defined(_WIN32) -# include -# define SLEEP(x) Sleep(x) -#else -# include -# define SLEEP(x) usleep(x * 1000) -#endif - -#include "pool.h" // use zstd thread pool for demo - -#include "../zstd_seekable.h" - -#define MIN(a, b) ((a) < (b) ? (a) : (b)) - -static void* malloc_orDie(size_t size) -{ - void* const buff = malloc(size); - if (buff) return buff; - /* error */ - perror("malloc"); - exit(1); -} - -static void* realloc_orDie(void* ptr, size_t size) -{ - ptr = realloc(ptr, size); - if (ptr) return ptr; - /* error */ - perror("realloc"); - exit(1); -} - -static FILE* fopen_orDie(const char *filename, const char *instruction) -{ - FILE* const inFile = fopen(filename, instruction); - if (inFile) return inFile; - /* error */ - perror(filename); - exit(3); -} - -static size_t fread_orDie(void* buffer, size_t sizeToRead, FILE* file) -{ - size_t const readSize = fread(buffer, 1, sizeToRead, file); - if (readSize == sizeToRead) return readSize; /* good */ - if (feof(file)) return readSize; /* good, reached end of file */ - /* error */ - perror("fread"); - exit(4); -} - -static size_t fwrite_orDie(const void* buffer, size_t sizeToWrite, FILE* file) -{ - size_t const writtenSize = fwrite(buffer, 1, sizeToWrite, file); - if (writtenSize == sizeToWrite) return sizeToWrite; /* good */ - /* error */ - perror("fwrite"); - exit(5); -} - -static size_t fclose_orDie(FILE* file) -{ - if (!fclose(file)) return 0; - /* error */ - perror("fclose"); - exit(6); -} - -static void fseek_orDie(FILE* file, long int offset, int origin) { - if (!fseek(file, offset, origin)) { - if (!fflush(file)) return; - } - /* error */ - perror("fseek"); - exit(7); -} - -struct sum_job { - const char* fname; - unsigned long long sum; - unsigned frameNb; - int done; -}; - -static void sumFrame(void* opaque) -{ - struct sum_job* job = (struct sum_job*)opaque; - job->done = 0; - - FILE* const fin = fopen_orDie(job->fname, "rb"); - - ZSTD_seekable* const seekable = ZSTD_seekable_create(); - if (seekable==NULL) { fprintf(stderr, "ZSTD_seekable_create() error \n"); exit(10); } - - size_t const initResult = ZSTD_seekable_initFile(seekable, fin); - if (ZSTD_isError(initResult)) { fprintf(stderr, "ZSTD_seekable_init() error : %s \n", ZSTD_getErrorName(initResult)); exit(11); } - - size_t const frameSize = ZSTD_seekable_getFrameDecompressedSize(seekable, job->frameNb); - unsigned char* data = malloc_orDie(frameSize); - - size_t result = ZSTD_seekable_decompressFrame(seekable, data, frameSize, job->frameNb); - if (ZSTD_isError(result)) { fprintf(stderr, "ZSTD_seekable_decompressFrame() error : %s \n", ZSTD_getErrorName(result)); exit(12); } - - unsigned long long sum = 0; - size_t i; - for (i = 0; i < frameSize; i++) { - sum += data[i]; - } - job->sum = sum; - job->done = 1; - - fclose(fin); - ZSTD_seekable_free(seekable); - free(data); -} - -static void sumFile_orDie(const char* fname, int nbThreads) -{ - POOL_ctx* pool = POOL_create(nbThreads, nbThreads); - if (pool == NULL) { fprintf(stderr, "POOL_create() error \n"); exit(9); } - - FILE* const fin = fopen_orDie(fname, "rb"); - - ZSTD_seekable* const seekable = ZSTD_seekable_create(); - if (seekable==NULL) { fprintf(stderr, "ZSTD_seekable_create() error \n"); exit(10); } - - size_t const initResult = ZSTD_seekable_initFile(seekable, fin); - if (ZSTD_isError(initResult)) { fprintf(stderr, "ZSTD_seekable_init() error : %s \n", ZSTD_getErrorName(initResult)); exit(11); } - - unsigned const numFrames = ZSTD_seekable_getNumFrames(seekable); - struct sum_job* jobs = (struct sum_job*)malloc(numFrames * sizeof(struct sum_job)); - - unsigned fnb; - for (fnb = 0; fnb < numFrames; fnb++) { - jobs[fnb] = (struct sum_job){ fname, 0, fnb, 0 }; - POOL_add(pool, sumFrame, &jobs[fnb]); - } - - unsigned long long total = 0; - - for (fnb = 0; fnb < numFrames; fnb++) { - while (!jobs[fnb].done) SLEEP(5); /* wake up every 5 milliseconds to check */ - total += jobs[fnb].sum; - } - - printf("Sum: %llu\n", total); - - POOL_free(pool); - ZSTD_seekable_free(seekable); - fclose(fin); - free(jobs); -} - - -int main(int argc, const char** argv) -{ - const char* const exeName = argv[0]; - - if (argc!=3) { - fprintf(stderr, "wrong arguments\n"); - fprintf(stderr, "usage:\n"); - fprintf(stderr, "%s FILE NB_THREADS\n", exeName); - return 1; - } - - { - const char* const inFilename = argv[1]; - int const nbThreads = atoi(argv[2]); - sumFile_orDie(inFilename, nbThreads); - } - - return 0; -} diff --git a/third_party/zstd/contrib/seekable_format/examples/seekable_compression.c b/third_party/zstd/contrib/seekable_format/examples/seekable_compression.c deleted file mode 100644 index c3d227dd0..000000000 --- a/third_party/zstd/contrib/seekable_format/examples/seekable_compression.c +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under both the BSD-style license (found in the - * LICENSE file in the root directory of this source tree) and the GPLv2 (found - * in the COPYING file in the root directory of this source tree). - */ - -#include // malloc, free, exit, atoi -#include // fprintf, perror, feof, fopen, etc. -#include // strlen, memset, strcat -#define ZSTD_STATIC_LINKING_ONLY -#include // presumes zstd library is installed - -#include "../zstd_seekable.h" - -static void* malloc_orDie(size_t size) -{ - void* const buff = malloc(size); - if (buff) return buff; - /* error */ - perror("malloc:"); - exit(1); -} - -static FILE* fopen_orDie(const char *filename, const char *instruction) -{ - FILE* const inFile = fopen(filename, instruction); - if (inFile) return inFile; - /* error */ - perror(filename); - exit(3); -} - -static size_t fread_orDie(void* buffer, size_t sizeToRead, FILE* file) -{ - size_t const readSize = fread(buffer, 1, sizeToRead, file); - if (readSize == sizeToRead) return readSize; /* good */ - if (feof(file)) return readSize; /* good, reached end of file */ - /* error */ - perror("fread"); - exit(4); -} - -static size_t fwrite_orDie(const void* buffer, size_t sizeToWrite, FILE* file) -{ - size_t const writtenSize = fwrite(buffer, 1, sizeToWrite, file); - if (writtenSize == sizeToWrite) return sizeToWrite; /* good */ - /* error */ - perror("fwrite"); - exit(5); -} - -static size_t fclose_orDie(FILE* file) -{ - if (!fclose(file)) return 0; - /* error */ - perror("fclose"); - exit(6); -} - -static void compressFile_orDie(const char* fname, const char* outName, int cLevel, unsigned frameSize) -{ - FILE* const fin = fopen_orDie(fname, "rb"); - FILE* const fout = fopen_orDie(outName, "wb"); - size_t const buffInSize = ZSTD_CStreamInSize(); /* can always read one full block */ - void* const buffIn = malloc_orDie(buffInSize); - size_t const buffOutSize = ZSTD_CStreamOutSize(); /* can always flush a full block */ - void* const buffOut = malloc_orDie(buffOutSize); - - ZSTD_seekable_CStream* const cstream = ZSTD_seekable_createCStream(); - if (cstream==NULL) { fprintf(stderr, "ZSTD_seekable_createCStream() error \n"); exit(10); } - size_t const initResult = ZSTD_seekable_initCStream(cstream, cLevel, 1, frameSize); - if (ZSTD_isError(initResult)) { fprintf(stderr, "ZSTD_seekable_initCStream() error : %s \n", ZSTD_getErrorName(initResult)); exit(11); } - - size_t read, toRead = buffInSize; - while( (read = fread_orDie(buffIn, toRead, fin)) ) { - ZSTD_inBuffer input = { buffIn, read, 0 }; - while (input.pos < input.size) { - ZSTD_outBuffer output = { buffOut, buffOutSize, 0 }; - toRead = ZSTD_seekable_compressStream(cstream, &output , &input); /* toRead is guaranteed to be <= ZSTD_CStreamInSize() */ - if (ZSTD_isError(toRead)) { fprintf(stderr, "ZSTD_seekable_compressStream() error : %s \n", ZSTD_getErrorName(toRead)); exit(12); } - if (toRead > buffInSize) toRead = buffInSize; /* Safely handle case when `buffInSize` is manually changed to a value < ZSTD_CStreamInSize()*/ - fwrite_orDie(buffOut, output.pos, fout); - } - } - - while (1) { - ZSTD_outBuffer output = { buffOut, buffOutSize, 0 }; - size_t const remainingToFlush = ZSTD_seekable_endStream(cstream, &output); /* close stream */ - if (ZSTD_isError(remainingToFlush)) { fprintf(stderr, "ZSTD_seekable_endStream() error : %s \n", ZSTD_getErrorName(remainingToFlush)); exit(13); } - fwrite_orDie(buffOut, output.pos, fout); - if (!remainingToFlush) break; - } - - ZSTD_seekable_freeCStream(cstream); - fclose_orDie(fout); - fclose_orDie(fin); - free(buffIn); - free(buffOut); -} - -static char* createOutFilename_orDie(const char* filename) -{ - size_t const inL = strlen(filename); - size_t const outL = inL + 5; - void* outSpace = malloc_orDie(outL); - memset(outSpace, 0, outL); - strcat(outSpace, filename); - strcat(outSpace, ".zst"); - return (char*)outSpace; -} - -#define CLEVEL_DEFAULT 5 -int main(int argc, const char** argv) -{ - const char* const exeName = argv[0]; - if (argc<3 || argc>4) { - printf("wrong arguments \n"); - printf("usage: \n"); - printf("%s FILE FRAME_SIZE [LEVEL] \n", exeName); - return 1; - } - - { const char* const inFileName = argv[1]; - unsigned const frameSize = (unsigned)atoi(argv[2]); - int const cLevel = (argc==4) ? atoi(argv[3]) : CLEVEL_DEFAULT; - - char* const outFileName = createOutFilename_orDie(inFileName); - compressFile_orDie(inFileName, outFileName, cLevel, frameSize); - free(outFileName); - } - - return 0; -} diff --git a/third_party/zstd/contrib/seekable_format/examples/seekable_decompression.c b/third_party/zstd/contrib/seekable_format/examples/seekable_decompression.c deleted file mode 100644 index 7edbca87d..000000000 --- a/third_party/zstd/contrib/seekable_format/examples/seekable_decompression.c +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under both the BSD-style license (found in the - * LICENSE file in the root directory of this source tree) and the GPLv2 (found - * in the COPYING file in the root directory of this source tree). - */ - - -#include // malloc, exit -#include // fprintf, perror, feof -#include // strerror -#include // errno -#define ZSTD_STATIC_LINKING_ONLY -#include // presumes zstd library is installed -#include - -#include "../zstd_seekable.h" - -#define MIN(a, b) ((a) < (b) ? (a) : (b)) - -static void* malloc_orDie(size_t size) -{ - void* const buff = malloc(size); - if (buff) return buff; - /* error */ - perror("malloc"); - exit(1); -} - -static void* realloc_orDie(void* ptr, size_t size) -{ - ptr = realloc(ptr, size); - if (ptr) return ptr; - /* error */ - perror("realloc"); - exit(1); -} - -static FILE* fopen_orDie(const char *filename, const char *instruction) -{ - FILE* const inFile = fopen(filename, instruction); - if (inFile) return inFile; - /* error */ - perror(filename); - exit(3); -} - -static size_t fread_orDie(void* buffer, size_t sizeToRead, FILE* file) -{ - size_t const readSize = fread(buffer, 1, sizeToRead, file); - if (readSize == sizeToRead) return readSize; /* good */ - if (feof(file)) return readSize; /* good, reached end of file */ - /* error */ - perror("fread"); - exit(4); -} - -static size_t fwrite_orDie(const void* buffer, size_t sizeToWrite, FILE* file) -{ - size_t const writtenSize = fwrite(buffer, 1, sizeToWrite, file); - if (writtenSize == sizeToWrite) return sizeToWrite; /* good */ - /* error */ - perror("fwrite"); - exit(5); -} - -static size_t fclose_orDie(FILE* file) -{ - if (!fclose(file)) return 0; - /* error */ - perror("fclose"); - exit(6); -} - -static void fseek_orDie(FILE* file, long int offset, int origin) { - if (!fseek(file, offset, origin)) { - if (!fflush(file)) return; - } - /* error */ - perror("fseek"); - exit(7); -} - - -static void decompressFile_orDie(const char* fname, off_t startOffset, off_t endOffset) -{ - FILE* const fin = fopen_orDie(fname, "rb"); - FILE* const fout = stdout; - size_t const buffOutSize = ZSTD_DStreamOutSize(); /* Guarantee to successfully flush at least one complete compressed block in all circumstances. */ - void* const buffOut = malloc_orDie(buffOutSize); - - ZSTD_seekable* const seekable = ZSTD_seekable_create(); - if (seekable==NULL) { fprintf(stderr, "ZSTD_seekable_create() error \n"); exit(10); } - - size_t const initResult = ZSTD_seekable_initFile(seekable, fin); - if (ZSTD_isError(initResult)) { fprintf(stderr, "ZSTD_seekable_init() error : %s \n", ZSTD_getErrorName(initResult)); exit(11); } - - while (startOffset < endOffset) { - size_t const result = ZSTD_seekable_decompress(seekable, buffOut, MIN(endOffset - startOffset, buffOutSize), startOffset); - if (!result) { - break; - } - - if (ZSTD_isError(result)) { - fprintf(stderr, "ZSTD_seekable_decompress() error : %s \n", - ZSTD_getErrorName(result)); - exit(12); - } - fwrite_orDie(buffOut, result, fout); - startOffset += result; - } - - ZSTD_seekable_free(seekable); - fclose_orDie(fin); - fclose_orDie(fout); - free(buffOut); -} - - -int main(int argc, const char** argv) -{ - const char* const exeName = argv[0]; - - if (argc!=4) { - fprintf(stderr, "wrong arguments\n"); - fprintf(stderr, "usage:\n"); - fprintf(stderr, "%s FILE START END\n", exeName); - return 1; - } - - { - const char* const inFilename = argv[1]; - off_t const startOffset = atoll(argv[2]); - off_t const endOffset = atoll(argv[3]); - decompressFile_orDie(inFilename, startOffset, endOffset); - } - - return 0; -} diff --git a/third_party/zstd/contrib/seekable_format/examples/seekable_decompression_mem.c b/third_party/zstd/contrib/seekable_format/examples/seekable_decompression_mem.c deleted file mode 100644 index 44a06fbbf..000000000 --- a/third_party/zstd/contrib/seekable_format/examples/seekable_decompression_mem.c +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under both the BSD-style license (found in the - * LICENSE file in the root directory of this source tree) and the GPLv2 (found - * in the COPYING file in the root directory of this source tree). - */ - - -#include // malloc, exit -#include // fprintf, perror, feof -#include // strerror -#include // errno -#define ZSTD_STATIC_LINKING_ONLY -#include // presumes zstd library is installed -#include - -#include "zstd_seekable.h" - -#define MIN(a, b) ((a) < (b) ? (a) : (b)) - -#define MAX_FILE_SIZE (8 * 1024 * 1024) - -static void* malloc_orDie(size_t size) -{ - void* const buff = malloc(size); - if (buff) return buff; - /* error */ - perror("malloc"); - exit(1); -} - -static void* realloc_orDie(void* ptr, size_t size) -{ - ptr = realloc(ptr, size); - if (ptr) return ptr; - /* error */ - perror("realloc"); - exit(1); -} - -static FILE* fopen_orDie(const char *filename, const char *instruction) -{ - FILE* const inFile = fopen(filename, instruction); - if (inFile) return inFile; - /* error */ - perror(filename); - exit(3); -} - -static size_t fread_orDie(void* buffer, size_t sizeToRead, FILE* file) -{ - size_t const readSize = fread(buffer, 1, sizeToRead, file); - if (readSize == sizeToRead) return readSize; /* good */ - if (feof(file)) return readSize; /* good, reached end of file */ - /* error */ - perror("fread"); - exit(4); -} - -static size_t fwrite_orDie(const void* buffer, size_t sizeToWrite, FILE* file) -{ - size_t const writtenSize = fwrite(buffer, 1, sizeToWrite, file); - if (writtenSize == sizeToWrite) return sizeToWrite; /* good */ - /* error */ - perror("fwrite"); - exit(5); -} - -static size_t fclose_orDie(FILE* file) -{ - if (!fclose(file)) return 0; - /* error */ - perror("fclose"); - exit(6); -} - -static void fseek_orDie(FILE* file, long int offset, int origin) { - if (!fseek(file, offset, origin)) { - if (!fflush(file)) return; - } - /* error */ - perror("fseek"); - exit(7); -} - - -static void decompressFile_orDie(const char* fname, off_t startOffset, off_t endOffset) -{ - FILE* const fin = fopen_orDie(fname, "rb"); - FILE* const fout = stdout; - // Just for demo purposes, assume file is <= MAX_FILE_SIZE - void* const buffIn = malloc_orDie(MAX_FILE_SIZE); - size_t const inSize = fread_orDie(buffIn, MAX_FILE_SIZE, fin); - size_t const buffOutSize = ZSTD_DStreamOutSize(); /* Guarantee to successfully flush at least one complete compressed block in all circumstances. */ - void* const buffOut = malloc_orDie(buffOutSize); - - ZSTD_seekable* const seekable = ZSTD_seekable_create(); - if (seekable==NULL) { fprintf(stderr, "ZSTD_seekable_create() error \n"); exit(10); } - - size_t const initResult = ZSTD_seekable_initBuff(seekable, buffIn, inSize); - if (ZSTD_isError(initResult)) { fprintf(stderr, "ZSTD_seekable_init() error : %s \n", ZSTD_getErrorName(initResult)); exit(11); } - - while (startOffset < endOffset) { - size_t const result = ZSTD_seekable_decompress(seekable, buffOut, MIN(endOffset - startOffset, buffOutSize), startOffset); - if (!result) { - break; - } - - if (ZSTD_isError(result)) { - fprintf(stderr, "ZSTD_seekable_decompress() error : %s \n", - ZSTD_getErrorName(result)); - exit(12); - } - fwrite_orDie(buffOut, result, fout); - startOffset += result; - } - - ZSTD_seekable_free(seekable); - fclose_orDie(fin); - fclose_orDie(fout); - free(buffIn); - free(buffOut); -} - - -int main(int argc, const char** argv) -{ - const char* const exeName = argv[0]; - - if (argc!=4) { - fprintf(stderr, "wrong arguments\n"); - fprintf(stderr, "usage:\n"); - fprintf(stderr, "%s FILE START END\n", exeName); - return 1; - } - - { - const char* const inFilename = argv[1]; - off_t const startOffset = atoll(argv[2]); - off_t const endOffset = atoll(argv[3]); - decompressFile_orDie(inFilename, startOffset, endOffset); - } - - return 0; -} diff --git a/third_party/zstd/contrib/seekable_format/tests/.gitignore b/third_party/zstd/contrib/seekable_format/tests/.gitignore deleted file mode 100644 index f831eaf37..000000000 --- a/third_party/zstd/contrib/seekable_format/tests/.gitignore +++ /dev/null @@ -1 +0,0 @@ -seekable_tests diff --git a/third_party/zstd/contrib/seekable_format/tests/Makefile b/third_party/zstd/contrib/seekable_format/tests/Makefile deleted file mode 100644 index a81f2229f..000000000 --- a/third_party/zstd/contrib/seekable_format/tests/Makefile +++ /dev/null @@ -1,38 +0,0 @@ -# ################################################################ -# Copyright (c) Meta Platforms, Inc. and affiliates. -# All rights reserved. -# -# This source code is licensed under both the BSD-style license (found in the -# LICENSE file in the root directory of this source tree) and the GPLv2 (found -# in the COPYING file in the root directory of this source tree). -# ################################################################ - -# This Makefile presumes libzstd is built, using `make` in / or /lib/ - -ZSTDLIB_PATH = ../../../lib -ZSTDLIB_NAME = libzstd.a -ZSTDLIB = $(ZSTDLIB_PATH)/$(ZSTDLIB_NAME) - -CPPFLAGS += -DXXH_NAMESPACE=ZSTD_ -I../ -I$(ZSTDLIB_PATH) -I$(ZSTDLIB_PATH)/common - -CFLAGS ?= -O3 -CFLAGS += -g -Wall -Wextra -Wcast-qual -Wcast-align -Wconversion \ - -Wformat=2 -Wstrict-aliasing=1 - -SEEKABLE_OBJS = ../zstdseek_compress.c ../zstdseek_decompress.c $(ZSTDLIB) - -.PHONY: default clean test -default: test - -test: seekable_tests - ./seekable_tests - -$(ZSTDLIB): - $(MAKE) -C $(ZSTDLIB_PATH) $(ZSTDLIB_NAME) - -seekable_tests : $(SEEKABLE_OBJS) - -clean: - @$(RM) core *.o tmp* result* *.zst \ - seekable_tests - @echo Cleaning completed diff --git a/third_party/zstd/contrib/seekable_format/tests/seekable_tests.c b/third_party/zstd/contrib/seekable_format/tests/seekable_tests.c deleted file mode 100644 index f89bdc930..000000000 --- a/third_party/zstd/contrib/seekable_format/tests/seekable_tests.c +++ /dev/null @@ -1,363 +0,0 @@ -#include -#include -#include // malloc -#include -#include -#include - -#include "../zstd_seekable.h" - - -/* ZSTD_seekable_customFile implementation that reads/seeks a buffer while keeping track of total bytes read */ -typedef struct { - const void *ptr; - size_t size; - size_t pos; - size_t totalRead; -} buffWrapperWithTotal_t; - -static int readBuffWithTotal(void* opaque, void* buffer, size_t n) -{ - buffWrapperWithTotal_t* const buff = (buffWrapperWithTotal_t*)opaque; - assert(buff != NULL); - if (buff->pos + n > buff->size) return -1; - memcpy(buffer, (const char*)buff->ptr + buff->pos, n); - buff->pos += n; - buff->totalRead += n; - return 0; -} - -static int seekBuffWithTotal(void* opaque, long long offset, int origin) -{ - buffWrapperWithTotal_t* const buff = (buffWrapperWithTotal_t*) opaque; - unsigned long long newOffset; - assert(buff != NULL); - switch (origin) { - case SEEK_SET: - assert(offset >= 0); - newOffset = (unsigned long long)offset; - break; - case SEEK_CUR: - newOffset = (unsigned long long)((long long)buff->pos + offset); - break; - case SEEK_END: - newOffset = (unsigned long long)((long long)buff->size + offset); - break; - default: - assert(0); /* not possible */ - } - if (newOffset > buff->size) { - return -1; - } - buff->pos = newOffset; - return 0; -} - -/* Basic unit tests for zstd seekable format */ -int main(int argc, const char** argv) -{ - unsigned testNb = 1; - (void)argc; (void)argv; - printf("Beginning zstd seekable format tests...\n"); - - printf("Test %u - simple round trip: ", testNb++); - { size_t const inSize = 4000; - void* const inBuffer = malloc(inSize); - assert(inBuffer != NULL); - - size_t const seekCapacity = 5000; - void* const seekBuffer = malloc(seekCapacity); - assert(seekBuffer != NULL); - size_t seekSize; - - size_t const outCapacity = inSize; - void* const outBuffer = malloc(outCapacity); - assert(outBuffer != NULL); - - ZSTD_seekable_CStream* const zscs = ZSTD_seekable_createCStream(); - assert(zscs != NULL); - - { size_t const initStatus = ZSTD_seekable_initCStream(zscs, 9, 0 /* checksumFlag */, (unsigned)inSize /* maxFrameSize */); - assert(!ZSTD_isError(initStatus)); - } - - { ZSTD_outBuffer outb = { .dst=seekBuffer, .pos=0, .size=seekCapacity }; - ZSTD_inBuffer inb = { .src=inBuffer, .pos=0, .size=inSize }; - - size_t const cStatus = ZSTD_seekable_compressStream(zscs, &outb, &inb); - assert(!ZSTD_isError(cStatus)); - assert(inb.pos == inb.size); - - size_t const endStatus = ZSTD_seekable_endStream(zscs, &outb); - assert(!ZSTD_isError(endStatus)); - seekSize = outb.pos; - } - - ZSTD_seekable* const stream = ZSTD_seekable_create(); - assert(stream != NULL); - { size_t const initStatus = ZSTD_seekable_initBuff(stream, seekBuffer, seekSize); - assert(!ZSTD_isError(initStatus)); } - - { size_t const decStatus = ZSTD_seekable_decompress(stream, outBuffer, outCapacity, 0); - assert(decStatus == inSize); } - - /* unit test ZSTD_seekTable functions */ - ZSTD_seekTable* const zst = ZSTD_seekTable_create_fromSeekable(stream); - assert(zst != NULL); - - unsigned const nbFrames = ZSTD_seekTable_getNumFrames(zst); - assert(nbFrames > 0); - - unsigned long long const frame0Offset = ZSTD_seekTable_getFrameCompressedOffset(zst, 0); - assert(frame0Offset == 0); - - unsigned long long const content0Offset = ZSTD_seekTable_getFrameDecompressedOffset(zst, 0); - assert(content0Offset == 0); - - size_t const cSize = ZSTD_seekTable_getFrameCompressedSize(zst, 0); - assert(!ZSTD_isError(cSize)); - assert(cSize <= seekCapacity); - - size_t const origSize = ZSTD_seekTable_getFrameDecompressedSize(zst, 0); - assert(origSize == inSize); - - unsigned const fo1idx = ZSTD_seekTable_offsetToFrameIndex(zst, 1); - assert(fo1idx == 0); - - free(inBuffer); - free(seekBuffer); - free(outBuffer); - ZSTD_seekable_freeCStream(zscs); - ZSTD_seekTable_free(zst); - ZSTD_seekable_free(stream); - } - printf("Success!\n"); - - - printf("Test %u - check that seekable decompress does not hang: ", testNb++); - { /* Github issue #2335 */ - const size_t compressed_size = 17; - const uint8_t compressed_data[17] = { - '^', - '*', - 'M', - '\x18', - '\t', - '\x00', - '\x00', - '\x00', - '\x00', - '\x00', - '\x00', - '\x00', - (uint8_t)('\x03'), - (uint8_t)('\xb1'), - (uint8_t)('\xea'), - (uint8_t)('\x92'), - (uint8_t)('\x8f'), - }; - const size_t uncompressed_size = 32; - uint8_t uncompressed_data[32]; - - ZSTD_seekable* const stream = ZSTD_seekable_create(); - assert(stream != NULL); - { size_t const status = ZSTD_seekable_initBuff(stream, compressed_data, compressed_size); - if (ZSTD_isError(status)) { - ZSTD_seekable_free(stream); - goto _test_error; - } } - - /* Should return an error, but not hang */ - { const size_t offset = 2; - size_t const status = ZSTD_seekable_decompress(stream, uncompressed_data, uncompressed_size, offset); - if (!ZSTD_isError(status)) { - ZSTD_seekable_free(stream); - goto _test_error; - } } - - ZSTD_seekable_free(stream); - } - printf("Success!\n"); - - printf("Test %u - check #2 that seekable decompress does not hang: ", testNb++); - { /* Github issue #FIXME */ - const size_t compressed_size = 27; - const uint8_t compressed_data[27] = { - (uint8_t)'\x28', - (uint8_t)'\xb5', - (uint8_t)'\x2f', - (uint8_t)'\xfd', - (uint8_t)'\x00', - (uint8_t)'\x32', - (uint8_t)'\x91', - (uint8_t)'\x00', - (uint8_t)'\x00', - (uint8_t)'\x00', - (uint8_t)'\x5e', - (uint8_t)'\x2a', - (uint8_t)'\x4d', - (uint8_t)'\x18', - (uint8_t)'\x09', - (uint8_t)'\x00', - (uint8_t)'\x00', - (uint8_t)'\x00', - (uint8_t)'\x00', - (uint8_t)'\x00', - (uint8_t)'\x00', - (uint8_t)'\x00', - (uint8_t)'\x00', - (uint8_t)'\xb1', - (uint8_t)'\xea', - (uint8_t)'\x92', - (uint8_t)'\x8f', - }; - const size_t uncompressed_size = 400; - uint8_t uncompressed_data[400]; - - ZSTD_seekable* stream = ZSTD_seekable_create(); - size_t status = ZSTD_seekable_initBuff(stream, compressed_data, compressed_size); - if (ZSTD_isError(status)) { - ZSTD_seekable_free(stream); - goto _test_error; - } - - const size_t offset = 2; - /* Should return an error, but not hang */ - status = ZSTD_seekable_decompress(stream, uncompressed_data, uncompressed_size, offset); - if (!ZSTD_isError(status)) { - ZSTD_seekable_free(stream); - goto _test_error; - } - - ZSTD_seekable_free(stream); - } - printf("Success!\n"); - - - printf("Test %u - check ZSTD magic in compressing empty string: ", testNb++); - { // compressing empty string should return a zstd header - size_t const capacity = 255; - char* inBuffer = malloc(capacity); - assert(inBuffer != NULL); - inBuffer[0] = '\0'; - void* const outBuffer = malloc(capacity); - assert(outBuffer != NULL); - - ZSTD_seekable_CStream *s = ZSTD_seekable_createCStream(); - ZSTD_seekable_initCStream(s, 1, 1, 255); - - ZSTD_inBuffer input = { .src=inBuffer, .pos=0, .size=0 }; - ZSTD_outBuffer output = { .dst=outBuffer, .pos=0, .size=capacity }; - - ZSTD_seekable_compressStream(s, &output, &input); - ZSTD_seekable_endStream(s, &output); - - if((((char*)output.dst)[0] != '\x28') | (((char*)output.dst)[1] != '\xb5') | (((char*)output.dst)[2] != '\x2f') | (((char*)output.dst)[3] != '\xfd')) { - printf("%#02x %#02x %#02x %#02x\n", ((char*)output.dst)[0], ((char*)output.dst)[1] , ((char*)output.dst)[2] , ((char*)output.dst)[3] ); - - free(inBuffer); - free(outBuffer); - ZSTD_seekable_freeCStream(s); - goto _test_error; - } - - free(inBuffer); - free(outBuffer); - ZSTD_seekable_freeCStream(s); - } - printf("Success!\n"); - - - printf("Test %u - multiple decompress calls: ", testNb++); - { char const inBuffer[] = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt"; - size_t const inSize = sizeof(inBuffer); - - size_t const seekCapacity = 5000; - void* const seekBuffer = malloc(seekCapacity); - assert(seekBuffer != NULL); - size_t seekSize; - - size_t const outCapacity = inSize; - char* const outBuffer = malloc(outCapacity); - assert(outBuffer != NULL); - - ZSTD_seekable_CStream* const zscs = ZSTD_seekable_createCStream(); - assert(zscs != NULL); - - /* compress test data with a small frame size to ensure multiple frames in the output */ - unsigned const maxFrameSize = 40; - { size_t const initStatus = ZSTD_seekable_initCStream(zscs, 9, 0 /* checksumFlag */, maxFrameSize); - assert(!ZSTD_isError(initStatus)); - } - - { ZSTD_outBuffer outb = { .dst=seekBuffer, .pos=0, .size=seekCapacity }; - ZSTD_inBuffer inb = { .src=inBuffer, .pos=0, .size=inSize }; - - while (inb.pos < inb.size) { - size_t const cStatus = ZSTD_seekable_compressStream(zscs, &outb, &inb); - assert(!ZSTD_isError(cStatus)); - } - - size_t const endStatus = ZSTD_seekable_endStream(zscs, &outb); - assert(!ZSTD_isError(endStatus)); - seekSize = outb.pos; - } - - ZSTD_seekable* const stream = ZSTD_seekable_create(); - assert(stream != NULL); - buffWrapperWithTotal_t buffWrapper = {seekBuffer, seekSize, 0, 0}; - { ZSTD_seekable_customFile srcFile = {&buffWrapper, &readBuffWithTotal, &seekBuffWithTotal}; - size_t const initStatus = ZSTD_seekable_initAdvanced(stream, srcFile); - assert(!ZSTD_isError(initStatus)); } - - /* Perform a series of small reads and seeks (repeatedly read 1 byte and skip 1 byte) - and check that we didn't reread input data unnecessarily */ - size_t pos; - for (pos = 0; pos < inSize; pos += 2) { - size_t const decStatus = ZSTD_seekable_decompress(stream, outBuffer, 1, pos); - if (decStatus != 1 || outBuffer[0] != inBuffer[pos]) { - goto _test_error; - } - } - if (buffWrapper.totalRead > seekSize) { - /* We read more than the compressed size, meaning there were some rereads. - This is unneeded because we only seeked forward. */ - printf("Too much data read: %zu read, with compressed size %zu\n", buffWrapper.totalRead, seekSize); - goto _test_error; - } - - /* Perform some reads and seeks to ensure correctness */ - struct { - size_t offset; - size_t size; - } const tests[] = { /* Assume the frame size is 40 */ - {20, 40}, /* read partial data from two frames */ - {60, 10}, /* continue reading from the same offset */ - {50, 20}, /* seek backward within the same frame */ - {10, 10}, /* seek backward to a different frame */ - {25, 10}, /* seek forward within the same frame */ - {60, 10}, /* seek forward to a different frame */ - }; - size_t idx; - for (idx = 0; idx < sizeof(tests) / sizeof(tests[0]); idx++) { - size_t const decStatus = ZSTD_seekable_decompress(stream, outBuffer, tests[idx].size, tests[idx].offset); - if (decStatus != tests[idx].size || memcmp(outBuffer, inBuffer + tests[idx].offset, tests[idx].size) != 0) { - goto _test_error; - } - } - - free(seekBuffer); - free(outBuffer); - ZSTD_seekable_freeCStream(zscs); - ZSTD_seekable_free(stream); - } - printf("Success!\n"); - - /* TODO: Add more tests */ - printf("Finished tests\n"); - return 0; - -_test_error: - printf("test failed! Exiting..\n"); - return 1; -} diff --git a/third_party/zstd/contrib/seekable_format/zstd_seekable.h b/third_party/zstd/contrib/seekable_format/zstd_seekable.h deleted file mode 100644 index a0e5e3573..000000000 --- a/third_party/zstd/contrib/seekable_format/zstd_seekable.h +++ /dev/null @@ -1,226 +0,0 @@ -#ifndef SEEKABLE_H -#define SEEKABLE_H - -#if defined (__cplusplus) -extern "C" { -#endif - -#include -#include "zstd.h" /* ZSTDLIB_API */ - - -#define ZSTD_seekTableFooterSize 9 - -#define ZSTD_SEEKABLE_MAGICNUMBER 0x8F92EAB1 - -#define ZSTD_SEEKABLE_MAXFRAMES 0x8000000U - -/* Limit maximum size to avoid potential issues storing the compressed size */ -#define ZSTD_SEEKABLE_MAX_FRAME_DECOMPRESSED_SIZE 0x40000000U - -/*-**************************************************************************** -* Seekable Format -* -* The seekable format splits the compressed data into a series of "frames", -* each compressed individually so that decompression of a section in the -* middle of an archive only requires zstd to decompress at most a frame's -* worth of extra data, instead of the entire archive. -******************************************************************************/ - -typedef struct ZSTD_seekable_CStream_s ZSTD_seekable_CStream; -typedef struct ZSTD_seekable_s ZSTD_seekable; -typedef struct ZSTD_seekTable_s ZSTD_seekTable; - -/*-**************************************************************************** -* Seekable compression - HowTo -* A ZSTD_seekable_CStream object is required to tracking streaming operation. -* Use ZSTD_seekable_createCStream() and ZSTD_seekable_freeCStream() to create/ -* release resources. -* -* Streaming objects are reusable to avoid allocation and deallocation, -* to start a new compression operation call ZSTD_seekable_initCStream() on the -* compressor. -* -* Data streamed to the seekable compressor will automatically be split into -* frames of size `maxFrameSize` (provided in ZSTD_seekable_initCStream()), -* or if none is provided, will be cut off whenever ZSTD_seekable_endFrame() is -* called or when the default maximum frame size (2GB) is reached. -* -* Use ZSTD_seekable_initCStream() to initialize a ZSTD_seekable_CStream object -* for a new compression operation. -* - `maxFrameSize` indicates the size at which to automatically start a new -* seekable frame. -* `maxFrameSize == 0` implies the default maximum size. -* Smaller frame sizes allow faster decompression of small segments, -* since retrieving a single byte requires decompression of -* the full frame where the byte belongs. -* In general, size the frames to roughly correspond to -* the access granularity (when it's known). -* But small sizes also reduce compression ratio. -* Avoid really tiny frame sizes (< 1 KB), -* that would hurt compression ratio considerably. -* - `checksumFlag` indicates whether or not the seek table should include frame -* checksums on the uncompressed data for verification. -* @return : a size hint for input to provide for compression, or an error code -* checkable with ZSTD_isError() -* -* Use ZSTD_seekable_compressStream() repetitively to consume input stream. -* The function will automatically update both `pos` fields. -* Note that it may not consume the entire input, in which case `pos < size`, -* and it's up to the caller to present again remaining data. -* @return : a size hint, preferred nb of bytes to use as input for next -* function call or an error code, which can be tested using -* ZSTD_isError(). -* Note 1 : it's just a hint, to help latency a little, any other -* value will work fine. -* -* At any time, call ZSTD_seekable_endFrame() to end the current frame and -* start a new one. -* -* ZSTD_seekable_endStream() will end the current frame, and then write the seek -* table so that decompressors can efficiently find compressed frames. -* ZSTD_seekable_endStream() may return a number > 0 if it was unable to flush -* all the necessary data to `output`. In this case, it should be called again -* until all remaining data is flushed out and 0 is returned. -******************************************************************************/ - -/*===== Seekable compressor management =====*/ -ZSTDLIB_API ZSTD_seekable_CStream* ZSTD_seekable_createCStream(void); -ZSTDLIB_API size_t ZSTD_seekable_freeCStream(ZSTD_seekable_CStream* zcs); - -/*===== Seekable compression functions =====*/ -ZSTDLIB_API size_t ZSTD_seekable_initCStream(ZSTD_seekable_CStream* zcs, int compressionLevel, int checksumFlag, unsigned maxFrameSize); -ZSTDLIB_API size_t ZSTD_seekable_compressStream(ZSTD_seekable_CStream* zcs, ZSTD_outBuffer* output, ZSTD_inBuffer* input); -ZSTDLIB_API size_t ZSTD_seekable_endFrame(ZSTD_seekable_CStream* zcs, ZSTD_outBuffer* output); -ZSTDLIB_API size_t ZSTD_seekable_endStream(ZSTD_seekable_CStream* zcs, ZSTD_outBuffer* output); - -/*= Raw seek table API - * These functions allow for the seek table to be constructed directly. - * This table can then be appended to a file of concatenated frames. - * This allows the frames to be compressed independently, even in parallel, - * and compiled together afterward into a seekable archive. - * - * Use ZSTD_seekable_createFrameLog() to allocate and initialize a tracking - * structure. - * - * Call ZSTD_seekable_logFrame() once for each frame in the archive. - * checksum is optional, and will not be used if checksumFlag was 0 when the - * frame log was created. If present, it should be the least significant 32 - * bits of the XXH64 hash of the uncompressed data. - * - * Call ZSTD_seekable_writeSeekTable to serialize the data into a seek table. - * If the entire table was written, the return value will be 0. Otherwise, - * it will be equal to the number of bytes left to write. */ -typedef struct ZSTD_frameLog_s ZSTD_frameLog; -ZSTDLIB_API ZSTD_frameLog* ZSTD_seekable_createFrameLog(int checksumFlag); -ZSTDLIB_API size_t ZSTD_seekable_freeFrameLog(ZSTD_frameLog* fl); -ZSTDLIB_API size_t ZSTD_seekable_logFrame(ZSTD_frameLog* fl, unsigned compressedSize, unsigned decompressedSize, unsigned checksum); -ZSTDLIB_API size_t ZSTD_seekable_writeSeekTable(ZSTD_frameLog* fl, ZSTD_outBuffer* output); - - -/*-**************************************************************************** -* Seekable decompression - HowTo -* A ZSTD_seekable object is required to tracking the seekTable. -* -* Call ZSTD_seekable_init* to initialize a ZSTD_seekable object with the -* the seek table provided in the input. -* There are three modes for ZSTD_seekable_init: -* - ZSTD_seekable_initBuff() : An in-memory API. The data contained in -* `src` should be the entire seekable file, including the seek table. -* `src` should be kept alive and unmodified until the ZSTD_seekable object -* is freed or reset. -* - ZSTD_seekable_initFile() : A simplified file API using stdio. fread and -* fseek will be used to access the required data for building the seek -* table and doing decompression operations. `src` should not be closed -* or modified until the ZSTD_seekable object is freed or reset. -* - ZSTD_seekable_initAdvanced() : A general API allowing the client to -* provide its own read and seek callbacks. -* + ZSTD_seekable_read() : read exactly `n` bytes into `buffer`. -* Premature EOF should be treated as an error. -* + ZSTD_seekable_seek() : seek the read head to `offset` from `origin`, -* where origin is either SEEK_SET (beginning of -* file), or SEEK_END (end of file). -* Both functions should return a non-negative value in case of success, and a -* negative value in case of failure. If implementing using this API and -* stdio, be careful with files larger than 4GB and fseek. All of these -* functions return an error code checkable with ZSTD_isError(). -* -* Call ZSTD_seekable_decompress to decompress `dstSize` bytes at decompressed -* offset `offset`. ZSTD_seekable_decompress may have to decompress the entire -* prefix of the frame before the desired data if it has not already processed -* this section. If ZSTD_seekable_decompress is called multiple times for a -* consecutive range of data, it will efficiently retain the decompressor object -* and avoid redecompressing frame prefixes. The return value is the number of -* bytes decompressed, or an error code checkable with ZSTD_isError(). -* -* The seek table access functions can be used to obtain the data contained -* in the seek table. If frameIndex is larger than the value returned by -* ZSTD_seekable_getNumFrames(), they will return error codes checkable with -* ZSTD_isError(). Note that since the offset access functions return -* unsigned long long instead of size_t, in this case they will instead return -* the value ZSTD_SEEKABLE_FRAMEINDEX_TOOLARGE. -******************************************************************************/ - -/*===== Seekable decompressor management =====*/ -ZSTDLIB_API ZSTD_seekable* ZSTD_seekable_create(void); -ZSTDLIB_API size_t ZSTD_seekable_free(ZSTD_seekable* zs); - -/*===== Seekable decompression functions =====*/ -ZSTDLIB_API size_t ZSTD_seekable_initBuff(ZSTD_seekable* zs, const void* src, size_t srcSize); -ZSTDLIB_API size_t ZSTD_seekable_initFile(ZSTD_seekable* zs, FILE* src); -ZSTDLIB_API size_t ZSTD_seekable_decompress(ZSTD_seekable* zs, void* dst, size_t dstSize, unsigned long long offset); -ZSTDLIB_API size_t ZSTD_seekable_decompressFrame(ZSTD_seekable* zs, void* dst, size_t dstSize, unsigned frameIndex); - -#define ZSTD_SEEKABLE_FRAMEINDEX_TOOLARGE (0ULL-2) -/*===== Seekable seek table access functions =====*/ -ZSTDLIB_API unsigned ZSTD_seekable_getNumFrames(const ZSTD_seekable* zs); -ZSTDLIB_API unsigned long long ZSTD_seekable_getFrameCompressedOffset(const ZSTD_seekable* zs, unsigned frameIndex); -ZSTDLIB_API unsigned long long ZSTD_seekable_getFrameDecompressedOffset(const ZSTD_seekable* zs, unsigned frameIndex); -ZSTDLIB_API size_t ZSTD_seekable_getFrameCompressedSize(const ZSTD_seekable* zs, unsigned frameIndex); -ZSTDLIB_API size_t ZSTD_seekable_getFrameDecompressedSize(const ZSTD_seekable* zs, unsigned frameIndex); -ZSTDLIB_API unsigned ZSTD_seekable_offsetToFrameIndex(const ZSTD_seekable* zs, unsigned long long offset); - - -/*-**************************************************************************** -* Direct exploitation of the seekTable -* -* Memory constrained use cases that manage multiple archives -* benefit from retaining multiple archive seek tables -* without retaining a ZSTD_seekable instance for each. -* -* Below API allow the above-mentioned use cases -* to initialize a ZSTD_seekable, extract its (smaller) ZSTD_seekTable, -* then throw the ZSTD_seekable away to save memory. -* -* Standard ZSTD operations can then be used -* to decompress frames based on seek table offsets. -******************************************************************************/ - -/*===== Independent seek table management =====*/ -ZSTDLIB_API ZSTD_seekTable* ZSTD_seekTable_create_fromSeekable(const ZSTD_seekable* zs); -ZSTDLIB_API size_t ZSTD_seekTable_free(ZSTD_seekTable* st); - -/*===== Direct seek table access functions =====*/ -ZSTDLIB_API unsigned ZSTD_seekTable_getNumFrames(const ZSTD_seekTable* st); -ZSTDLIB_API unsigned long long ZSTD_seekTable_getFrameCompressedOffset(const ZSTD_seekTable* st, unsigned frameIndex); -ZSTDLIB_API unsigned long long ZSTD_seekTable_getFrameDecompressedOffset(const ZSTD_seekTable* st, unsigned frameIndex); -ZSTDLIB_API size_t ZSTD_seekTable_getFrameCompressedSize(const ZSTD_seekTable* st, unsigned frameIndex); -ZSTDLIB_API size_t ZSTD_seekTable_getFrameDecompressedSize(const ZSTD_seekTable* st, unsigned frameIndex); -ZSTDLIB_API unsigned ZSTD_seekTable_offsetToFrameIndex(const ZSTD_seekTable* st, unsigned long long offset); - - -/*===== Seekable advanced I/O API =====*/ -typedef int(ZSTD_seekable_read)(void* opaque, void* buffer, size_t n); -typedef int(ZSTD_seekable_seek)(void* opaque, long long offset, int origin); -typedef struct { - void* opaque; - ZSTD_seekable_read* read; - ZSTD_seekable_seek* seek; -} ZSTD_seekable_customFile; -ZSTDLIB_API size_t ZSTD_seekable_initAdvanced(ZSTD_seekable* zs, ZSTD_seekable_customFile src); - -#if defined (__cplusplus) -} -#endif - -#endif diff --git a/third_party/zstd/contrib/seekable_format/zstd_seekable_compression_format.md b/third_party/zstd/contrib/seekable_format/zstd_seekable_compression_format.md deleted file mode 100644 index 7bd0790e8..000000000 --- a/third_party/zstd/contrib/seekable_format/zstd_seekable_compression_format.md +++ /dev/null @@ -1,116 +0,0 @@ -# Zstandard Seekable Format - -### Notices - -Copyright (c) Meta Platforms, Inc. and affiliates. - -Permission is granted to copy and distribute this document -for any purpose and without charge, -including translations into other languages -and incorporation into compilations, -provided that the copyright notice and this notice are preserved, -and that any substantive changes or deletions from the original -are clearly marked. -Distribution of this document is unlimited. - -### Version -0.1.0 (11/04/17) - -## Introduction -This document defines a format for compressed data to be stored so that subranges of the data can be efficiently decompressed without requiring the entire document to be decompressed. -This is done by splitting up the input data into frames, -each of which are compressed independently, -and so can be decompressed independently. -Decompression then takes advantage of a provided 'seek table', which allows the decompressor to immediately jump to the desired data. This is done in a way that is compatible with the original Zstandard format by placing the seek table in a Zstandard skippable frame. - -### Overall conventions -In this document: -- square brackets i.e. `[` and `]` are used to indicate optional fields or parameters. -- the naming convention for identifiers is `Mixed_Case_With_Underscores` -- All numeric fields are little-endian unless specified otherwise - -## Format - -The format consists of a number of frames (Zstandard compressed frames and skippable frames), followed by a final skippable frame at the end containing the seek table. - -### Seek Table Format -The structure of the seek table frame is as follows: - -|`Skippable_Magic_Number`|`Frame_Size`|`[Seek_Table_Entries]`|`Seek_Table_Footer`| -|------------------------|------------|----------------------|-------------------| -| 4 bytes | 4 bytes | 8-12 bytes each | 9 bytes | - -__`Skippable_Magic_Number`__ - -Value : 0x184D2A5E. -This is for compatibility with [Zstandard skippable frames]. -Since it is legal for other Zstandard skippable frames to use the same -magic number, it is not recommended for a decoder to recognize frames -solely on this. - -__`Frame_Size`__ - -The total size of the skippable frame, not including the `Skippable_Magic_Number` or `Frame_Size`. -This is for compatibility with [Zstandard skippable frames]. - -[Zstandard skippable frames]: https://github.com/facebook/zstd/blob/release/doc/zstd_compression_format.md#skippable-frames - -#### `Seek_Table_Footer` -The seek table footer format is as follows: - -|`Number_Of_Frames`|`Seek_Table_Descriptor`|`Seekable_Magic_Number`| -|------------------|-----------------------|-----------------------| -| 4 bytes | 1 byte | 4 bytes | - -__`Seekable_Magic_Number`__ - -Value : 0x8F92EAB1. -This value must be the last bytes present in the compressed file so that decoders -can efficiently find it and determine if there is an actual seek table present. - -__`Number_Of_Frames`__ - -The number of stored frames in the data. - -__`Seek_Table_Descriptor`__ - -A bitfield describing the format of the seek table. - -| Bit number | Field name | -| ---------- | ---------- | -| 7 | `Checksum_Flag` | -| 6-2 | `Reserved_Bits` | -| 1-0 | `Unused_Bits` | - -While only `Checksum_Flag` currently exists, there are 7 other bits in this field that can be used for future changes to the format, -for example the addition of inline dictionaries. - -__`Checksum_Flag`__ - -If the checksum flag is set, each of the seek table entries contains a 4 byte checksum of the uncompressed data contained in its frame. - -`Reserved_Bits` are not currently used but may be used in the future for breaking changes, so a compliant decoder should ensure they are set to 0. `Unused_Bits` may be used in the future for non-breaking changes, so a compliant decoder should not interpret these bits. - -#### __`Seek_Table_Entries`__ - -`Seek_Table_Entries` consists of `Number_Of_Frames` (one for each frame in the data, not including the seek table frame) entries of the following form, in sequence: - -|`Compressed_Size`|`Decompressed_Size`|`[Checksum]`| -|-----------------|-------------------|------------| -| 4 bytes | 4 bytes | 4 bytes | - -__`Compressed_Size`__ - -The compressed size of the frame. -The cumulative sum of the `Compressed_Size` fields of frames `0` to `i` gives the offset in the compressed file of frame `i+1`. - -__`Decompressed_Size`__ - -The size of the decompressed data contained in the frame. For skippable or otherwise empty frames, this value is 0. - -__`Checksum`__ - -Only present if `Checksum_Flag` is set in the `Seek_Table_Descriptor`. Value : the least significant 32 bits of the XXH64 digest of the uncompressed data, stored in little-endian format. - -## Version Changes -- 0.1.0: initial version diff --git a/third_party/zstd/contrib/seekable_format/zstdseek_compress.c b/third_party/zstd/contrib/seekable_format/zstdseek_compress.c deleted file mode 100644 index 4997807d2..000000000 --- a/third_party/zstd/contrib/seekable_format/zstdseek_compress.c +++ /dev/null @@ -1,365 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under both the BSD-style license (found in the - * LICENSE file in the root directory of this source tree) and the GPLv2 (found - * in the COPYING file in the root directory of this source tree). - */ - -#include /* malloc, free */ -#include /* UINT_MAX */ -#include - -#define XXH_STATIC_LINKING_ONLY -#include "xxhash.h" - -#define ZSTD_STATIC_LINKING_ONLY -#include "zstd.h" -#include "zstd_errors.h" -#include "mem.h" - -#include "zstd_seekable.h" - -#define CHECK_Z(f) { size_t const ret = (f); if (ret != 0) return ret; } - -#undef ERROR -#define ERROR(name) ((size_t)-ZSTD_error_##name) - -#undef MIN -#undef MAX -#define MIN(a, b) ((a) < (b) ? (a) : (b)) -#define MAX(a, b) ((a) > (b) ? (a) : (b)) - -typedef struct { - U32 cSize; - U32 dSize; - U32 checksum; -} framelogEntry_t; - -struct ZSTD_frameLog_s { - framelogEntry_t* entries; - U32 size; - U32 capacity; - - int checksumFlag; - - /* for use when streaming out the seek table */ - U32 seekTablePos; - U32 seekTableIndex; -} framelog_t; - -struct ZSTD_seekable_CStream_s { - ZSTD_CStream* cstream; - ZSTD_frameLog framelog; - - U32 frameCSize; - U32 frameDSize; - - XXH64_state_t xxhState; - - U32 maxFrameSize; - - int writingSeekTable; -}; - -static size_t ZSTD_seekable_frameLog_allocVec(ZSTD_frameLog* fl) -{ - /* allocate some initial space */ - size_t const FRAMELOG_STARTING_CAPACITY = 16; - fl->entries = (framelogEntry_t*)malloc( - sizeof(framelogEntry_t) * FRAMELOG_STARTING_CAPACITY); - if (fl->entries == NULL) return ERROR(memory_allocation); - fl->capacity = (U32)FRAMELOG_STARTING_CAPACITY; - return 0; -} - -static size_t ZSTD_seekable_frameLog_freeVec(ZSTD_frameLog* fl) -{ - if (fl != NULL) free(fl->entries); - return 0; -} - -ZSTD_frameLog* ZSTD_seekable_createFrameLog(int checksumFlag) -{ - ZSTD_frameLog* const fl = (ZSTD_frameLog*)malloc(sizeof(ZSTD_frameLog)); - if (fl == NULL) return NULL; - - if (ZSTD_isError(ZSTD_seekable_frameLog_allocVec(fl))) { - free(fl); - return NULL; - } - - fl->checksumFlag = checksumFlag; - fl->seekTablePos = 0; - fl->seekTableIndex = 0; - fl->size = 0; - - return fl; -} - -size_t ZSTD_seekable_freeFrameLog(ZSTD_frameLog* fl) -{ - ZSTD_seekable_frameLog_freeVec(fl); - free(fl); - return 0; -} - -ZSTD_seekable_CStream* ZSTD_seekable_createCStream(void) -{ - ZSTD_seekable_CStream* const zcs = (ZSTD_seekable_CStream*)malloc(sizeof(ZSTD_seekable_CStream)); - if (zcs == NULL) return NULL; - - memset(zcs, 0, sizeof(*zcs)); - - zcs->cstream = ZSTD_createCStream(); - if (zcs->cstream == NULL) goto failed1; - - if (ZSTD_isError(ZSTD_seekable_frameLog_allocVec(&zcs->framelog))) goto failed2; - - return zcs; - -failed2: - ZSTD_freeCStream(zcs->cstream); -failed1: - free(zcs); - return NULL; -} - -size_t ZSTD_seekable_freeCStream(ZSTD_seekable_CStream* zcs) -{ - if (zcs == NULL) return 0; /* support free on null */ - ZSTD_freeCStream(zcs->cstream); - ZSTD_seekable_frameLog_freeVec(&zcs->framelog); - free(zcs); - return 0; -} - -size_t ZSTD_seekable_initCStream(ZSTD_seekable_CStream* zcs, - int compressionLevel, - int checksumFlag, - unsigned maxFrameSize) -{ - zcs->framelog.size = 0; - zcs->frameCSize = 0; - zcs->frameDSize = 0; - - /* make sure maxFrameSize has a reasonable value */ - if (maxFrameSize > ZSTD_SEEKABLE_MAX_FRAME_DECOMPRESSED_SIZE) { - return ERROR(frameParameter_unsupported); - } - - zcs->maxFrameSize = maxFrameSize ? - maxFrameSize : ZSTD_SEEKABLE_MAX_FRAME_DECOMPRESSED_SIZE; - - zcs->framelog.checksumFlag = checksumFlag; - if (zcs->framelog.checksumFlag) { - XXH64_reset(&zcs->xxhState, 0); - } - - zcs->framelog.seekTablePos = 0; - zcs->framelog.seekTableIndex = 0; - zcs->writingSeekTable = 0; - - return ZSTD_initCStream(zcs->cstream, compressionLevel); -} - -size_t ZSTD_seekable_logFrame(ZSTD_frameLog* fl, - unsigned compressedSize, - unsigned decompressedSize, - unsigned checksum) -{ - if (fl->size == ZSTD_SEEKABLE_MAXFRAMES) - return ERROR(frameIndex_tooLarge); - - /* grow the buffer if required */ - if (fl->size == fl->capacity) { - /* exponential size increase for constant amortized runtime */ - size_t const newCapacity = fl->capacity * 2; - framelogEntry_t* const newEntries = (framelogEntry_t*)realloc(fl->entries, - sizeof(framelogEntry_t) * newCapacity); - - if (newEntries == NULL) return ERROR(memory_allocation); - - fl->entries = newEntries; - assert(newCapacity <= UINT_MAX); - fl->capacity = (U32)newCapacity; - } - - fl->entries[fl->size] = (framelogEntry_t){ - compressedSize, decompressedSize, checksum - }; - fl->size++; - - return 0; -} - -size_t ZSTD_seekable_endFrame(ZSTD_seekable_CStream* zcs, ZSTD_outBuffer* output) -{ - size_t const prevOutPos = output->pos; - /* end the frame */ - size_t ret = ZSTD_endStream(zcs->cstream, output); - - zcs->frameCSize += (U32)(output->pos - prevOutPos); - - /* need to flush before doing the rest */ - if (ret) return ret; - - /* frame done */ - - /* store the frame data for later */ - ret = ZSTD_seekable_logFrame( - &zcs->framelog, zcs->frameCSize, zcs->frameDSize, - zcs->framelog.checksumFlag - ? XXH64_digest(&zcs->xxhState) & 0xFFFFFFFFU - : 0); - if (ret) return ret; - - /* reset for the next frame */ - zcs->frameCSize = 0; - zcs->frameDSize = 0; - - ZSTD_CCtx_reset(zcs->cstream, ZSTD_reset_session_only); - if (zcs->framelog.checksumFlag) XXH64_reset(&zcs->xxhState, 0); - - return 0; -} - -size_t ZSTD_seekable_compressStream(ZSTD_seekable_CStream* zcs, ZSTD_outBuffer* output, ZSTD_inBuffer* input) -{ - const BYTE* const inBase = (const BYTE*) input->src + input->pos; - size_t inLen = input->size - input->pos; - - assert(zcs->maxFrameSize < INT_MAX); - ZSTD_CCtx_setParameter(zcs->cstream, ZSTD_c_srcSizeHint, (int)zcs->maxFrameSize); - inLen = MIN(inLen, (size_t)(zcs->maxFrameSize - zcs->frameDSize)); - - /* if we haven't finished flushing the last frame, don't start writing a new one */ - if (inLen > 0) { - ZSTD_inBuffer inTmp = { inBase, inLen, 0 }; - size_t const prevOutPos = output->pos; - - size_t const ret = ZSTD_compressStream(zcs->cstream, output, &inTmp); - - if (zcs->framelog.checksumFlag) { - XXH64_update(&zcs->xxhState, inBase, inTmp.pos); - } - - zcs->frameCSize += (U32)(output->pos - prevOutPos); - zcs->frameDSize += (U32)inTmp.pos; - - input->pos += inTmp.pos; - - if (ZSTD_isError(ret)) return ret; - } - - if (zcs->maxFrameSize == zcs->frameDSize) { - /* log the frame and start over */ - size_t const ret = ZSTD_seekable_endFrame(zcs, output); - if (ZSTD_isError(ret)) return ret; - - /* get the client ready for the next frame */ - return (size_t)zcs->maxFrameSize; - } - - return (size_t)(zcs->maxFrameSize - zcs->frameDSize); -} - -static inline size_t ZSTD_seekable_seekTableSize(const ZSTD_frameLog* fl) -{ - size_t const sizePerFrame = 8 + (fl->checksumFlag?4:0); - size_t const seekTableLen = ZSTD_SKIPPABLEHEADERSIZE + - sizePerFrame * fl->size + - ZSTD_seekTableFooterSize; - - return seekTableLen; -} - -static inline size_t ZSTD_stwrite32(ZSTD_frameLog* fl, - ZSTD_outBuffer* output, U32 const value, - U32 const offset) -{ - if (fl->seekTablePos < offset + 4) { - BYTE tmp[4]; /* so that we can work with buffers too small to write a whole word to */ - size_t const lenWrite = - MIN(output->size - output->pos, offset + 4 - fl->seekTablePos); - MEM_writeLE32(tmp, value); - memcpy((BYTE*)output->dst + output->pos, - tmp + (fl->seekTablePos - offset), lenWrite); - output->pos += lenWrite; - fl->seekTablePos += (U32)lenWrite; - - if (lenWrite < 4) return ZSTD_seekable_seekTableSize(fl) - fl->seekTablePos; - } - return 0; -} - -size_t ZSTD_seekable_writeSeekTable(ZSTD_frameLog* fl, ZSTD_outBuffer* output) -{ - /* seekTableIndex: the current index in the table and - * seekTableSize: the amount of the table written so far - * - * This function is written this way so that if it has to return early - * because of a small buffer, it can keep going where it left off. - */ - - size_t const sizePerFrame = 8 + (fl->checksumFlag?4:0); - size_t const seekTableLen = ZSTD_seekable_seekTableSize(fl); - - CHECK_Z(ZSTD_stwrite32(fl, output, ZSTD_MAGIC_SKIPPABLE_START | 0xE, 0)); - assert(seekTableLen <= (size_t)UINT_MAX); - CHECK_Z(ZSTD_stwrite32(fl, output, (U32)seekTableLen - ZSTD_SKIPPABLEHEADERSIZE, 4)); - - while (fl->seekTableIndex < fl->size) { - unsigned long long const start = ZSTD_SKIPPABLEHEADERSIZE + sizePerFrame * fl->seekTableIndex; - assert(start + 8 <= UINT_MAX); - CHECK_Z(ZSTD_stwrite32(fl, output, - fl->entries[fl->seekTableIndex].cSize, - (U32)start + 0)); - - CHECK_Z(ZSTD_stwrite32(fl, output, - fl->entries[fl->seekTableIndex].dSize, - (U32)start + 4)); - - if (fl->checksumFlag) { - CHECK_Z(ZSTD_stwrite32( - fl, output, fl->entries[fl->seekTableIndex].checksum, - (U32)start + 8)); - } - - fl->seekTableIndex++; - } - - assert(seekTableLen <= UINT_MAX); - CHECK_Z(ZSTD_stwrite32(fl, output, fl->size, - (U32)seekTableLen - ZSTD_seekTableFooterSize)); - - if (output->size - output->pos < 1) return seekTableLen - fl->seekTablePos; - if (fl->seekTablePos < seekTableLen - 4) { - BYTE const sfd = (BYTE)((fl->checksumFlag) << 7); - - ((BYTE*)output->dst)[output->pos] = sfd; - output->pos++; - fl->seekTablePos++; - } - - CHECK_Z(ZSTD_stwrite32(fl, output, ZSTD_SEEKABLE_MAGICNUMBER, - (U32)seekTableLen - 4)); - - if (fl->seekTablePos != seekTableLen) return ERROR(GENERIC); - return 0; -} - -size_t ZSTD_seekable_endStream(ZSTD_seekable_CStream* zcs, ZSTD_outBuffer* output) -{ - if (!zcs->writingSeekTable) { - const size_t endFrame = ZSTD_seekable_endFrame(zcs, output); - if (ZSTD_isError(endFrame)) return endFrame; - /* return an accurate size hint */ - if (endFrame) return endFrame + ZSTD_seekable_seekTableSize(&zcs->framelog); - } - - zcs->writingSeekTable = 1; - - return ZSTD_seekable_writeSeekTable(&zcs->framelog, output); -} diff --git a/third_party/zstd/contrib/seekable_format/zstdseek_decompress.c b/third_party/zstd/contrib/seekable_format/zstdseek_decompress.c deleted file mode 100644 index 4fefc5f2e..000000000 --- a/third_party/zstd/contrib/seekable_format/zstdseek_decompress.c +++ /dev/null @@ -1,595 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under both the BSD-style license (found in the - * LICENSE file in the root directory of this source tree) and the GPLv2 (found - * in the COPYING file in the root directory of this source tree). - * You may select, at your option, one of the above-listed licenses. - */ - -/* ********************************************************* -* Turn on Large Files support (>4GB) for 32-bit Linux/Unix -***********************************************************/ -#if !defined(__64BIT__) || defined(__MINGW32__) /* No point defining Large file for 64 bit but MinGW-w64 requires it */ -# if !defined(_FILE_OFFSET_BITS) -# define _FILE_OFFSET_BITS 64 /* turn off_t into a 64-bit type for ftello, fseeko */ -# endif -# if !defined(_LARGEFILE_SOURCE) /* obsolete macro, replaced with _FILE_OFFSET_BITS */ -# define _LARGEFILE_SOURCE 1 /* Large File Support extension (LFS) - fseeko, ftello */ -# endif -# if defined(_AIX) || defined(__hpux) -# define _LARGE_FILES /* Large file support on 32-bits AIX and HP-UX */ -# endif -#endif - -/* ************************************************************ -* Detect POSIX version -* PLATFORM_POSIX_VERSION = 0 for non-Unix e.g. Windows -* PLATFORM_POSIX_VERSION = 1 for Unix-like but non-POSIX -* PLATFORM_POSIX_VERSION > 1 is equal to found _POSIX_VERSION -* Value of PLATFORM_POSIX_VERSION can be forced on command line -***************************************************************/ -#ifndef PLATFORM_POSIX_VERSION - -# if (defined(__APPLE__) && defined(__MACH__)) || defined(__SVR4) || defined(_AIX) || defined(__hpux) /* POSIX.1-2001 (SUSv3) conformant */ \ - || defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) /* BSD distros */ - /* exception rule : force posix version to 200112L, - * note: it's better to use unistd.h's _POSIX_VERSION whenever possible */ -# define PLATFORM_POSIX_VERSION 200112L - -/* try to determine posix version through official unistd.h's _POSIX_VERSION (https://pubs.opengroup.org/onlinepubs/7908799/xsh/unistd.h.html). - * note : there is no simple way to know in advance if is present or not on target system, - * Posix specification mandates its presence and its content, but target system must respect this spec. - * It's necessary to _not_ #include whenever target OS is not unix-like - * otherwise it will block preprocessing stage. - * The following list of build macros tries to "guess" if target OS is likely unix-like, and therefore can #include - */ -# elif !defined(_WIN32) \ - && ( defined(__unix__) || defined(__unix) \ - || defined(__midipix__) || defined(__VMS) || defined(__HAIKU__) ) - -# if defined(__linux__) || defined(__linux) || defined(__CYGWIN__) -# ifndef _POSIX_C_SOURCE -# define _POSIX_C_SOURCE 200809L /* feature test macro : https://www.gnu.org/software/libc/manual/html_node/Feature-Test-Macros.html */ -# endif -# endif -# include /* declares _POSIX_VERSION */ -# if defined(_POSIX_VERSION) /* POSIX compliant */ -# define PLATFORM_POSIX_VERSION _POSIX_VERSION -# else -# define PLATFORM_POSIX_VERSION 1 -# endif - -# ifdef __UCLIBC__ -# ifndef __USE_MISC -# define __USE_MISC /* enable st_mtim on uclibc */ -# endif -# endif - -# else /* non-unix target platform (like Windows) */ -# define PLATFORM_POSIX_VERSION 0 -# endif - -#endif /* PLATFORM_POSIX_VERSION */ - - -/* ************************************************************ -* Avoid fseek()'s 2GiB barrier with MSVC, macOS, *BSD, MinGW -***************************************************************/ -#if defined(_MSC_VER) && _MSC_VER >= 1400 -# define LONG_SEEK _fseeki64 -#elif !defined(__64BIT__) && (PLATFORM_POSIX_VERSION >= 200112L) /* No point defining Large file for 64 bit */ -# define LONG_SEEK fseeko -#elif defined(__MINGW32__) && !defined(__STRICT_ANSI__) && !defined(__NO_MINGW_LFS) && defined(__MSVCRT__) -# define LONG_SEEK fseeko64 -#elif defined(_WIN32) && !defined(__DJGPP__) -# include - static int LONG_SEEK(FILE* file, __int64 offset, int origin) { - LARGE_INTEGER off; - DWORD method; - off.QuadPart = offset; - if (origin == SEEK_END) - method = FILE_END; - else if (origin == SEEK_CUR) - method = FILE_CURRENT; - else - method = FILE_BEGIN; - - if (SetFilePointerEx((HANDLE) _get_osfhandle(_fileno(file)), off, NULL, method)) - return 0; - else - return -1; - } -#else -# define LONG_SEEK fseek -#endif - -#include /* malloc, free */ -#include /* FILE* */ -#include /* UNIT_MAX */ -#include - -#define XXH_STATIC_LINKING_ONLY -#include "xxhash.h" - -#define ZSTD_STATIC_LINKING_ONLY -#include "zstd.h" -#include "zstd_errors.h" -#include "mem.h" -#include "zstd_seekable.h" - -#undef ERROR -#define ERROR(name) ((size_t)-ZSTD_error_##name) - -#define CHECK_IO(f) { int const errcod = (f); if (errcod < 0) return ERROR(seekableIO); } - -#undef MIN -#undef MAX -#define MIN(a, b) ((a) < (b) ? (a) : (b)) -#define MAX(a, b) ((a) > (b) ? (a) : (b)) - -#define ZSTD_SEEKABLE_NO_OUTPUT_PROGRESS_MAX 16 - -/* Special-case callbacks for FILE* and in-memory modes, so that we can treat - * them the same way as the advanced API */ -static int ZSTD_seekable_read_FILE(void* opaque, void* buffer, size_t n) -{ - size_t const result = fread(buffer, 1, n, (FILE*)opaque); - if (result != n) { - return -1; - } - return 0; -} - -static int ZSTD_seekable_seek_FILE(void* opaque, long long offset, int origin) -{ - int const ret = LONG_SEEK((FILE*)opaque, offset, origin); - if (ret) return ret; - return fflush((FILE*)opaque); -} - -typedef struct { - const void *ptr; - size_t size; - size_t pos; -} buffWrapper_t; - -static int ZSTD_seekable_read_buff(void* opaque, void* buffer, size_t n) -{ - buffWrapper_t* const buff = (buffWrapper_t*)opaque; - assert(buff != NULL); - if (buff->pos + n > buff->size) return -1; - memcpy(buffer, (const BYTE*)buff->ptr + buff->pos, n); - buff->pos += n; - return 0; -} - -static int ZSTD_seekable_seek_buff(void* opaque, long long offset, int origin) -{ - buffWrapper_t* const buff = (buffWrapper_t*) opaque; - unsigned long long newOffset; - assert(buff != NULL); - switch (origin) { - case SEEK_SET: - assert(offset >= 0); - newOffset = (unsigned long long)offset; - break; - case SEEK_CUR: - newOffset = (unsigned long long)((long long)buff->pos + offset); - break; - case SEEK_END: - newOffset = (unsigned long long)((long long)buff->size + offset); - break; - default: - assert(0); /* not possible */ - } - if (newOffset > buff->size) { - return -1; - } - buff->pos = newOffset; - return 0; -} - -typedef struct { - U64 cOffset; - U64 dOffset; - U32 checksum; -} seekEntry_t; - -struct ZSTD_seekTable_s { - seekEntry_t* entries; - size_t tableLen; - - int checksumFlag; -}; - -#define SEEKABLE_BUFF_SIZE ZSTD_BLOCKSIZE_MAX - -struct ZSTD_seekable_s { - ZSTD_DStream* dstream; - ZSTD_seekTable seekTable; - ZSTD_seekable_customFile src; - - U64 decompressedOffset; - U32 curFrame; - - BYTE inBuff[SEEKABLE_BUFF_SIZE]; /* need to do our own input buffering */ - BYTE outBuff[SEEKABLE_BUFF_SIZE]; /* so we can efficiently decompress the - starts of chunks before we get to the - desired section */ - ZSTD_inBuffer in; /* maintain continuity across ZSTD_seekable_decompress operations */ - buffWrapper_t buffWrapper; /* for `src.opaque` in in-memory mode */ - - XXH64_state_t xxhState; -}; - -ZSTD_seekable* ZSTD_seekable_create(void) -{ - ZSTD_seekable* const zs = (ZSTD_seekable*)malloc(sizeof(ZSTD_seekable)); - if (zs == NULL) return NULL; - - /* also initializes stage to zsds_init */ - memset(zs, 0, sizeof(*zs)); - - zs->dstream = ZSTD_createDStream(); - if (zs->dstream == NULL) { - free(zs); - return NULL; - } - - return zs; -} - -size_t ZSTD_seekable_free(ZSTD_seekable* zs) -{ - if (zs == NULL) return 0; /* support free on null */ - ZSTD_freeDStream(zs->dstream); - free(zs->seekTable.entries); - free(zs); - return 0; -} - -ZSTD_seekTable* ZSTD_seekTable_create_fromSeekable(const ZSTD_seekable* zs) -{ - ZSTD_seekTable* const st = (ZSTD_seekTable*)malloc(sizeof(ZSTD_seekTable)); - if (st==NULL) return NULL; - - st->checksumFlag = zs->seekTable.checksumFlag; - st->tableLen = zs->seekTable.tableLen; - - /* Allocate an extra entry at the end to match logic of initial allocation */ - size_t const entriesSize = sizeof(seekEntry_t) * (zs->seekTable.tableLen + 1); - seekEntry_t* const entries = (seekEntry_t*)malloc(entriesSize); - if (entries==NULL) { - free(st); - return NULL; - } - - memcpy(entries, zs->seekTable.entries, entriesSize); - st->entries = entries; - return st; -} - -size_t ZSTD_seekTable_free(ZSTD_seekTable* st) -{ - if (st == NULL) return 0; /* support free on null */ - free(st->entries); - free(st); - return 0; -} - -/** ZSTD_seekable_offsetToFrameIndex() : - * Performs a binary search to find the last frame with a decompressed offset - * <= pos - * @return : the frame's index */ -unsigned ZSTD_seekable_offsetToFrameIndex(const ZSTD_seekable* zs, unsigned long long pos) -{ - return ZSTD_seekTable_offsetToFrameIndex(&zs->seekTable, pos); -} - -unsigned ZSTD_seekTable_offsetToFrameIndex(const ZSTD_seekTable* st, unsigned long long pos) -{ - U32 lo = 0; - U32 hi = (U32)st->tableLen; - assert(st->tableLen <= UINT_MAX); - - if (pos >= st->entries[st->tableLen].dOffset) { - return (unsigned)st->tableLen; - } - - while (lo + 1 < hi) { - U32 const mid = lo + ((hi - lo) >> 1); - if (st->entries[mid].dOffset <= pos) { - lo = mid; - } else { - hi = mid; - } - } - return lo; -} - -unsigned ZSTD_seekable_getNumFrames(const ZSTD_seekable* zs) -{ - return ZSTD_seekTable_getNumFrames(&zs->seekTable); -} - -unsigned ZSTD_seekTable_getNumFrames(const ZSTD_seekTable* st) -{ - assert(st->tableLen <= UINT_MAX); - return (unsigned)st->tableLen; -} - -unsigned long long ZSTD_seekable_getFrameCompressedOffset(const ZSTD_seekable* zs, unsigned frameIndex) -{ - return ZSTD_seekTable_getFrameCompressedOffset(&zs->seekTable, frameIndex); -} - -unsigned long long ZSTD_seekTable_getFrameCompressedOffset(const ZSTD_seekTable* st, unsigned frameIndex) -{ - if (frameIndex >= st->tableLen) return ZSTD_SEEKABLE_FRAMEINDEX_TOOLARGE; - return st->entries[frameIndex].cOffset; -} - -unsigned long long ZSTD_seekable_getFrameDecompressedOffset(const ZSTD_seekable* zs, unsigned frameIndex) -{ - return ZSTD_seekTable_getFrameDecompressedOffset(&zs->seekTable, frameIndex); -} - -unsigned long long ZSTD_seekTable_getFrameDecompressedOffset(const ZSTD_seekTable* st, unsigned frameIndex) -{ - if (frameIndex >= st->tableLen) return ZSTD_SEEKABLE_FRAMEINDEX_TOOLARGE; - return st->entries[frameIndex].dOffset; -} - -size_t ZSTD_seekable_getFrameCompressedSize(const ZSTD_seekable* zs, unsigned frameIndex) -{ - return ZSTD_seekTable_getFrameCompressedSize(&zs->seekTable, frameIndex); -} - -size_t ZSTD_seekTable_getFrameCompressedSize(const ZSTD_seekTable* st, unsigned frameIndex) -{ - if (frameIndex >= st->tableLen) return ERROR(frameIndex_tooLarge); - return st->entries[frameIndex + 1].cOffset - - st->entries[frameIndex].cOffset; -} - -size_t ZSTD_seekable_getFrameDecompressedSize(const ZSTD_seekable* zs, unsigned frameIndex) -{ - return ZSTD_seekTable_getFrameDecompressedSize(&zs->seekTable, frameIndex); -} - -size_t ZSTD_seekTable_getFrameDecompressedSize(const ZSTD_seekTable* st, unsigned frameIndex) -{ - if (frameIndex > st->tableLen) return ERROR(frameIndex_tooLarge); - return st->entries[frameIndex + 1].dOffset - - st->entries[frameIndex].dOffset; -} - -static size_t ZSTD_seekable_loadSeekTable(ZSTD_seekable* zs) -{ - int checksumFlag; - ZSTD_seekable_customFile src = zs->src; - /* read the footer, fixed size */ - CHECK_IO(src.seek(src.opaque, -(int)ZSTD_seekTableFooterSize, SEEK_END)); - CHECK_IO(src.read(src.opaque, zs->inBuff, ZSTD_seekTableFooterSize)); - - if (MEM_readLE32(zs->inBuff + 5) != ZSTD_SEEKABLE_MAGICNUMBER) { - return ERROR(prefix_unknown); - } - - { BYTE const sfd = zs->inBuff[4]; - checksumFlag = sfd >> 7; - - /* check reserved bits */ - if ((sfd >> 2) & 0x1f) { - return ERROR(corruption_detected); - } } - - { U32 const numFrames = MEM_readLE32(zs->inBuff); - U32 const sizePerEntry = 8 + (checksumFlag?4:0); - U32 const tableSize = sizePerEntry * numFrames; - U32 const frameSize = tableSize + ZSTD_seekTableFooterSize + ZSTD_SKIPPABLEHEADERSIZE; - - U32 remaining = frameSize - ZSTD_seekTableFooterSize; /* don't need to re-read footer */ - { U32 const toRead = MIN(remaining, SEEKABLE_BUFF_SIZE); - CHECK_IO(src.seek(src.opaque, -(S64)frameSize, SEEK_END)); - CHECK_IO(src.read(src.opaque, zs->inBuff, toRead)); - remaining -= toRead; - } - - if (MEM_readLE32(zs->inBuff) != (ZSTD_MAGIC_SKIPPABLE_START | 0xE)) { - return ERROR(prefix_unknown); - } - if (MEM_readLE32(zs->inBuff+4) + ZSTD_SKIPPABLEHEADERSIZE != frameSize) { - return ERROR(prefix_unknown); - } - - { /* Allocate an extra entry at the end so that we can do size - * computations on the last element without special case */ - seekEntry_t* const entries = (seekEntry_t*)malloc(sizeof(seekEntry_t) * (numFrames + 1)); - - U32 idx = 0; - U32 pos = 8; - - U64 cOffset = 0; - U64 dOffset = 0; - - if (entries == NULL) return ERROR(memory_allocation); - - /* compute cumulative positions */ - for (; idx < numFrames; idx++) { - if (pos + sizePerEntry > SEEKABLE_BUFF_SIZE) { - U32 const offset = SEEKABLE_BUFF_SIZE - pos; - U32 const toRead = MIN(remaining, SEEKABLE_BUFF_SIZE - offset); - memmove(zs->inBuff, zs->inBuff + pos, offset); /* move any data we haven't read yet */ - CHECK_IO(src.read(src.opaque, zs->inBuff+offset, toRead)); - remaining -= toRead; - pos = 0; - } - entries[idx].cOffset = cOffset; - entries[idx].dOffset = dOffset; - - cOffset += MEM_readLE32(zs->inBuff + pos); - pos += 4; - dOffset += MEM_readLE32(zs->inBuff + pos); - pos += 4; - if (checksumFlag) { - entries[idx].checksum = MEM_readLE32(zs->inBuff + pos); - pos += 4; - } - } - entries[numFrames].cOffset = cOffset; - entries[numFrames].dOffset = dOffset; - - zs->seekTable.entries = entries; - zs->seekTable.tableLen = numFrames; - zs->seekTable.checksumFlag = checksumFlag; - return 0; - } - } -} - -size_t ZSTD_seekable_initBuff(ZSTD_seekable* zs, const void* src, size_t srcSize) -{ - zs->buffWrapper = (buffWrapper_t){src, srcSize, 0}; - { ZSTD_seekable_customFile srcFile = {&zs->buffWrapper, - &ZSTD_seekable_read_buff, - &ZSTD_seekable_seek_buff}; - return ZSTD_seekable_initAdvanced(zs, srcFile); } -} - -size_t ZSTD_seekable_initFile(ZSTD_seekable* zs, FILE* src) -{ - ZSTD_seekable_customFile srcFile = {src, &ZSTD_seekable_read_FILE, - &ZSTD_seekable_seek_FILE}; - return ZSTD_seekable_initAdvanced(zs, srcFile); -} - -size_t ZSTD_seekable_initAdvanced(ZSTD_seekable* zs, ZSTD_seekable_customFile src) -{ - zs->src = src; - - { const size_t seekTableInit = ZSTD_seekable_loadSeekTable(zs); - if (ZSTD_isError(seekTableInit)) return seekTableInit; } - - zs->decompressedOffset = (U64)-1; - zs->curFrame = (U32)-1; - - { const size_t dstreamInit = ZSTD_initDStream(zs->dstream); - if (ZSTD_isError(dstreamInit)) return dstreamInit; } - return 0; -} - -size_t ZSTD_seekable_decompress(ZSTD_seekable* zs, void* dst, size_t len, unsigned long long offset) -{ - unsigned long long const eos = zs->seekTable.entries[zs->seekTable.tableLen].dOffset; - if (offset + len > eos) { - len = eos - offset; - } - - U32 targetFrame = ZSTD_seekable_offsetToFrameIndex(zs, offset); - U32 noOutputProgressCount = 0; - size_t srcBytesRead = 0; - do { - /* check if we can continue from a previous decompress job */ - if (targetFrame != zs->curFrame || offset < zs->decompressedOffset) { - zs->decompressedOffset = zs->seekTable.entries[targetFrame].dOffset; - zs->curFrame = targetFrame; - - assert(zs->seekTable.entries[targetFrame].cOffset < LLONG_MAX); - CHECK_IO(zs->src.seek(zs->src.opaque, - (long long)zs->seekTable.entries[targetFrame].cOffset, - SEEK_SET)); - zs->in = (ZSTD_inBuffer){zs->inBuff, 0, 0}; - XXH64_reset(&zs->xxhState, 0); - ZSTD_DCtx_reset(zs->dstream, ZSTD_reset_session_only); - if (zs->buffWrapper.size && srcBytesRead > zs->buffWrapper.size) { - return ERROR(seekableIO); - } - } - - while (zs->decompressedOffset < offset + len) { - size_t toRead; - ZSTD_outBuffer outTmp; - size_t prevOutPos; - size_t prevInPos; - size_t forwardProgress; - if (zs->decompressedOffset < offset) { - /* dummy decompressions until we get to the target offset */ - outTmp = (ZSTD_outBuffer){zs->outBuff, (size_t) (MIN(SEEKABLE_BUFF_SIZE, offset - zs->decompressedOffset)), 0}; - } else { - outTmp = (ZSTD_outBuffer){dst, len, (size_t) (zs->decompressedOffset - offset)}; - } - - prevOutPos = outTmp.pos; - prevInPos = zs->in.pos; - toRead = ZSTD_decompressStream(zs->dstream, &outTmp, &zs->in); - if (ZSTD_isError(toRead)) { - return toRead; - } - - if (zs->seekTable.checksumFlag) { - XXH64_update(&zs->xxhState, (BYTE*)outTmp.dst + prevOutPos, - outTmp.pos - prevOutPos); - } - forwardProgress = outTmp.pos - prevOutPos; - if (forwardProgress == 0) { - if (noOutputProgressCount++ > ZSTD_SEEKABLE_NO_OUTPUT_PROGRESS_MAX) { - return ERROR(seekableIO); - } - } else { - noOutputProgressCount = 0; - } - zs->decompressedOffset += forwardProgress; - srcBytesRead += zs->in.pos - prevInPos; - - if (toRead == 0) { - /* frame complete */ - - /* verify checksum */ - if (zs->seekTable.checksumFlag && - (XXH64_digest(&zs->xxhState) & 0xFFFFFFFFU) != - zs->seekTable.entries[targetFrame].checksum) { - return ERROR(corruption_detected); - } - - if (zs->decompressedOffset < offset + len) { - /* go back to the start and force a reset of the stream */ - targetFrame = ZSTD_seekable_offsetToFrameIndex(zs, zs->decompressedOffset); - /* in this case it will fail later with corruption_detected, since last block does not have checksum */ - assert(targetFrame != zs->seekTable.tableLen); - } - break; - } - - /* read in more data if we're done with this buffer */ - if (zs->in.pos == zs->in.size) { - toRead = MIN(toRead, SEEKABLE_BUFF_SIZE); - CHECK_IO(zs->src.read(zs->src.opaque, zs->inBuff, toRead)); - zs->in.size = toRead; - zs->in.pos = 0; - } - } /* while (zs->decompressedOffset < offset + len) */ - } while (zs->decompressedOffset != offset + len); - - return len; -} - -size_t ZSTD_seekable_decompressFrame(ZSTD_seekable* zs, void* dst, size_t dstSize, unsigned frameIndex) -{ - if (frameIndex >= zs->seekTable.tableLen) { - return ERROR(frameIndex_tooLarge); - } - - { size_t const decompressedSize = - zs->seekTable.entries[frameIndex + 1].dOffset - - zs->seekTable.entries[frameIndex].dOffset; - if (dstSize < decompressedSize) { - return ERROR(dstSize_tooSmall); - } - return ZSTD_seekable_decompress( - zs, dst, decompressedSize, - zs->seekTable.entries[frameIndex].dOffset); - } -} diff --git a/third_party/zstd/contrib/seqBench/Makefile b/third_party/zstd/contrib/seqBench/Makefile deleted file mode 100644 index e7f08a42c..000000000 --- a/third_party/zstd/contrib/seqBench/Makefile +++ /dev/null @@ -1,58 +0,0 @@ -# ################################################################ -# Copyright (c) Meta Platforms, Inc. and affiliates. -# All rights reserved. -# -# This source code is licensed under both the BSD-style license (found in the -# LICENSE file in the root directory of this source tree) and the GPLv2 (found -# in the COPYING file in the root directory of this source tree). -# ################################################################ - -PROGDIR = ../../programs -LIBDIR = ../../lib - -LIBZSTD = $(LIBDIR)/libzstd.a - -CPPFLAGS+= -I$(LIBDIR) -I$(LIBDIR)/common -I$(LIBDIR)/dictBuilder -I$(PROGDIR) - -CFLAGS ?= -O3 -g -CFLAGS += -std=gnu99 -DEBUGFLAGS= -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow \ - -Wstrict-aliasing=1 -Wswitch-enum \ - -Wstrict-prototypes -Wundef -Wpointer-arith \ - -Wvla -Wformat=2 -Winit-self -Wfloat-equal -Wwrite-strings \ - -Wredundant-decls -CFLAGS += $(DEBUGFLAGS) $(MOREFLAGS) - - -default: seqBench - -all : seqBench - -seqBench: util.o timefn.o benchfn.o datagen.o xxhash.o seqBench.c $(LIBZSTD) - $(CC) $(CPPFLAGS) $(CFLAGS) $^ $(LDFLAGS) -o $@ - -.PHONY: $(LIBZSTD) -$(LIBZSTD): - $(MAKE) -C $(LIBDIR) libzstd.a CFLAGS="$(CFLAGS)" - -benchfn.o: $(PROGDIR)/benchfn.c - $(CC) $(CPPFLAGS) $(CFLAGS) $^ -c - -timefn.o: $(PROGDIR)/timefn.c - $(CC) $(CPPFLAGS) $(CFLAGS) $^ -c - -datagen.o: $(PROGDIR)/datagen.c - $(CC) $(CPPFLAGS) $(CFLAGS) $^ -c - -util.o: $(PROGDIR)/util.c - $(CC) $(CPPFLAGS) $(CFLAGS) $^ -c - - -xxhash.o : $(LIBDIR)/common/xxhash.c - $(CC) $(CPPFLAGS) $(CFLAGS) $^ -c - - -clean: - $(RM) *.o - $(MAKE) -C $(LIBDIR) clean > /dev/null - $(RM) seqBench diff --git a/third_party/zstd/contrib/seqBench/seqBench.c b/third_party/zstd/contrib/seqBench/seqBench.c deleted file mode 100644 index 7efebec7b..000000000 --- a/third_party/zstd/contrib/seqBench/seqBench.c +++ /dev/null @@ -1,53 +0,0 @@ -#define ZSTD_STATIC_LINKING_ONLY -#include -#include -#include -#include -#include - -int main(int argc, char *argv[]) { - ZSTD_CCtx* zc = ZSTD_createCCtx(); - - if (argc != 2) { - printf("Usage: seqBench \n"); // TODO provide the block delim option here - return 1; - } - - FILE *f = fopen(argv[1], "rb"); - fseek(f, 0, SEEK_END); - long inBufSize = ftell(f); - fseek(f, 0, SEEK_SET); - - char *inBuf = malloc(inBufSize + 1); - fread(inBuf, inBufSize, 1, f); - fclose(f); - - size_t seqsSize = ZSTD_sequenceBound(inBufSize); - ZSTD_Sequence *seqs = (ZSTD_Sequence*)malloc(seqsSize * sizeof(ZSTD_Sequence)); - char *outBuf = malloc(ZSTD_compressBound(inBufSize)); - - ZSTD_generateSequences(zc, seqs, seqsSize, inBuf, inBufSize); - ZSTD_CCtx_setParameter(zc, ZSTD_c_blockDelimiters, ZSTD_sf_explicitBlockDelimiters); - size_t outBufSize = ZSTD_compressSequences(zc, outBuf, inBufSize, seqs, seqsSize, inBuf, inBufSize); - if (ZSTD_isError(outBufSize)) { - printf("ERROR: %lu\n", outBufSize); - return 1; - } - - char *validationBuf = malloc(inBufSize); - ZSTD_decompress(validationBuf, inBufSize, outBuf, outBufSize); - - if (memcmp(inBuf, validationBuf, inBufSize) == 0) { - printf("Compression and decompression were successful!\n"); - } else { - printf("ERROR: input and validation buffers don't match!\n"); - for (int i = 0; i < inBufSize; i++) { - if (inBuf[i] != validationBuf[i]) { - printf("First bad index: %d\n", i); - break; - } - } - } - - return 0; -} diff --git a/third_party/zstd/contrib/snap/snapcraft.yaml b/third_party/zstd/contrib/snap/snapcraft.yaml deleted file mode 100644 index 0a77946ae..000000000 --- a/third_party/zstd/contrib/snap/snapcraft.yaml +++ /dev/null @@ -1,28 +0,0 @@ -name: zstd -version: git -summary: Zstandard - Fast real-time compression algorithm -description: | - Zstandard, or zstd as short version, is a fast lossless compression - algorithm, targeting real-time compression scenarios at zlib-level and better - compression ratios. It's backed by a very fast entropy stage, provided by - Huff0 and FSE library - -grade: devel # must be 'stable' to release into candidate/stable channels -confinement: devmode # use 'strict' once you have the right plugs and slots - -apps: - zstd: - command: usr/local/bin/zstd - plugs: [home, removable-media] - zstdgrep: - command: usr/local/bin/zstdgrep - plugs: [home, removable-media] - zstdless: - command: usr/local/bin/zstdless - plugs: [home, removable-media] - -parts: - zstd: - source: . - plugin: make - build-packages: [g++] diff --git a/third_party/zstd/doc/README.md b/third_party/zstd/doc/README.md deleted file mode 100644 index 8f3babcdb..000000000 --- a/third_party/zstd/doc/README.md +++ /dev/null @@ -1,26 +0,0 @@ -Zstandard Documentation -======================= - -This directory contains material defining the Zstandard format, -as well as detailed instructions to use `zstd` library. - -__`zstd_manual.html`__ : Documentation of `zstd.h` API, in html format. -Unfortunately, Github doesn't display `html` files in parsed format, just as source code. -For a readable display of html API documentation of latest release, -use this link: [https://raw.githack.com/facebook/zstd/release/doc/zstd_manual.html](https://raw.githack.com/facebook/zstd/release/doc/zstd_manual.html) . - -__`zstd_compression_format.md`__ : This document defines the Zstandard compression format. -Compliant decoders must adhere to this document, -and compliant encoders must generate data that follows it. - -Should you look for resources to develop your own port of Zstandard algorithm, -you may find the following resources useful : - -__`educational_decoder`__ : This directory contains an implementation of a Zstandard decoder, -compliant with the Zstandard compression format. -It can be used, for example, to better understand the format, -or as the basis for a separate implementation of Zstandard decoder. - -[__`decode_corpus`__](https://github.com/facebook/zstd/tree/dev/tests#decodecorpus---tool-to-generate-zstandard-frames-for-decoder-testing) : -This tool, stored in `/tests` directory, is able to generate random valid frames, -which is useful if you wish to test your decoder and verify it fully supports the specification. diff --git a/third_party/zstd/doc/decompressor_errata.md b/third_party/zstd/doc/decompressor_errata.md deleted file mode 100644 index 83d4071cb..000000000 --- a/third_party/zstd/doc/decompressor_errata.md +++ /dev/null @@ -1,127 +0,0 @@ -Decompressor Errata -=================== - -This document captures known decompressor bugs, where the decompressor rejects a valid zstd frame. -Each entry will contain: -1. The last affected decompressor versions. -2. The decompressor components affected. -2. Whether the compressed frame could ever be produced by the reference compressor. -3. An example frame (hexadecimal string when it can be short enough, link to golden file otherwise) -4. A description of the bug. - -The document is in reverse chronological order, with the bugs that affect the most recent zstd decompressor versions listed first. - - -No sequence using the 2-bytes format ------------------------------------------------- - -**Last affected version**: v1.5.5 - -**Affected decompressor component(s)**: Library & CLI - -**Produced by the reference compressor**: No - -**Example Frame**: see zstd/tests/golden-decompression/zeroSeq_2B.zst - -The zstd decoder incorrectly expects FSE tables when there are 0 sequences present in the block -if the value 0 is encoded using the 2-bytes format. -Instead, it should immediately end the sequence section, and move on to next block. - -This situation was never generated by the reference compressor, -because representing 0 sequences with the 2-bytes format is inefficient -(the 1-byte format is always used in this case). - - -Compressed block with a size of exactly 128 KB ------------------------------------------------- - -**Last affected version**: v1.5.2 - -**Affected decompressor component(s)**: Library & CLI - -**Produced by the reference compressor**: No - -**Example Frame**: see zstd/tests/golden-decompression/block-128k.zst - -The zstd decoder incorrectly rejected blocks of type `Compressed_Block` when their size was exactly 128 KB. -Note that `128 KB - 1` was accepted, and `128 KB + 1` is forbidden by the spec. - -This type of block was never generated by the reference compressor. - -These blocks used to be disallowed by the spec up until spec version 0.3.2 when the restriction was lifted by [PR#1689](https://github.com/facebook/zstd/pull/1689). - -> A Compressed_Block has the extra restriction that Block_Size is always strictly less than the decompressed size. If this condition cannot be respected, the block must be sent uncompressed instead (Raw_Block). - - -Compressed block with 0 literals and 0 sequences ------------------------------------------------- - -**Last affected version**: v1.5.2 - -**Affected decompressor component(s)**: Library & CLI - -**Produced by the reference compressor**: No - -**Example Frame**: `28b5 2ffd 2000 1500 0000 00` - -The zstd decoder incorrectly rejected blocks of type `Compressed_Block` that encodes literals as `Raw_Literals_Block` with no literals, and has no sequences. - -This type of block was never generated by the reference compressor. - -Additionally, these blocks were disallowed by the spec up until spec version 0.3.2 when the restriction was lifted by [PR#1689](https://github.com/facebook/zstd/pull/1689). - -> A Compressed_Block has the extra restriction that Block_Size is always strictly less than the decompressed size. If this condition cannot be respected, the block must be sent uncompressed instead (Raw_Block). - - -First block is RLE block ------------------------- - -**Last affected version**: v1.4.3 - -**Affected decompressor component(s)**: CLI only - -**Produced by the reference compressor**: No - -**Example Frame**: `28b5 2ffd a001 0002 0002 0010 000b 0000 00` - -The zstd CLI decompressor rejected cases where the first block was an RLE block whose `Block_Size` is 131072, and the frame contains more than one block. -This only affected the zstd CLI, and not the library. - -The example is an RLE block with 131072 bytes, followed by a second RLE block with 1 byte. - -The compressor currently works around this limitation by explicitly avoiding producing RLE blocks as the first -block. - -https://github.com/facebook/zstd/blob/8814aa5bfa74f05a86e55e9d508da177a893ceeb/lib/compress/zstd_compress.c#L3527-L3535 - - -Tiny FSE Table & Block ----------------------- - -**Last affected version**: v1.3.4 - -**Affected decompressor component(s)**: Library & CLI - -**Produced by the reference compressor**: Possibly until version v1.3.4, but probably never - -**Example Frame**: `28b5 2ffd 2027 c500 0080 f3f1 f0ec ebc6 c5c7 f09d 4300 0000 e0e0 0658 0100 603e 52` - -The zstd library rejected blocks of type `Compressed_Block` whose offset of the last table with type `FSE_Compressed_Mode` was less than 4 bytes from the end of the block. - -In more depth, let `Last_Table_Offset` be the offset in the compressed block (excluding the header) that -the last table with type `FSE_Compressed_Mode` started. If `Block_Content - Last_Table_Offset < 4` then -the buggy zstd decompressor would reject the block. This occurs when the last serialized table is 2 bytes -and the bitstream size is 1 byte. - -For example: -* There is 1 sequence in the block -* `Literals_Lengths_Mode` is `FSE_Compressed_Mode` & the serialized table size is 2 bytes -* `Offsets_Mode` is `Predefined_Mode` -* `Match_Lengths_Mode` is `Predefined_Mode` -* The bitstream is 1 byte. E.g. there is only one sequence and it fits in 1 byte. - -The total `Block_Content` is `5` bytes, and `Last_Table_Offset` is `2`. - -See the compressor workaround code: - -https://github.com/facebook/zstd/blob/8814aa5bfa74f05a86e55e9d508da177a893ceeb/lib/compress/zstd_compress.c#L2667-L2682 diff --git a/third_party/zstd/doc/educational_decoder/.gitignore b/third_party/zstd/doc/educational_decoder/.gitignore deleted file mode 100644 index b801306fa..000000000 --- a/third_party/zstd/doc/educational_decoder/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# Build artifacts -harness diff --git a/third_party/zstd/doc/educational_decoder/Makefile b/third_party/zstd/doc/educational_decoder/Makefile deleted file mode 100644 index f6deeb13d..000000000 --- a/third_party/zstd/doc/educational_decoder/Makefile +++ /dev/null @@ -1,62 +0,0 @@ -# ################################################################ -# Copyright (c) Meta Platforms, Inc. and affiliates. -# All rights reserved. -# -# This source code is licensed under both the BSD-style license (found in the -# LICENSE file in the root directory of this source tree) and the GPLv2 (found -# in the COPYING file in the root directory of this source tree). -# You may select, at your option, one of the above-listed licenses. -# ################################################################ - -ZSTD ?= zstd # note: requires zstd installation on local system - -UNAME?= $(shell uname) -ifeq ($(UNAME), SunOS) -DIFF ?= gdiff -else -DIFF ?= diff -endif - -HARNESS_FILES=*.c - -MULTITHREAD_LDFLAGS = -pthread -DEBUGFLAGS= -g -DZSTD_DEBUG=1 -CPPFLAGS += -I$(ZSTDDIR) -I$(ZSTDDIR)/common -I$(ZSTDDIR)/compress \ - -I$(ZSTDDIR)/dictBuilder -I$(ZSTDDIR)/deprecated -I$(PRGDIR) -CFLAGS ?= -O2 -CFLAGS += -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow \ - -Wstrict-aliasing=1 -Wswitch-enum \ - -Wredundant-decls -Wstrict-prototypes -Wundef \ - -Wvla -Wformat=2 -Winit-self -Wfloat-equal -Wwrite-strings \ - -std=c99 -CFLAGS += $(DEBUGFLAGS) -CFLAGS += $(MOREFLAGS) -FLAGS = $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(MULTITHREAD_LDFLAGS) - -harness: $(HARNESS_FILES) - $(CC) $(FLAGS) $^ -o $@ - -clean: - @$(RM) harness *.o - @$(RM) -rf harness.dSYM # MacOS specific - -test: harness - # - # Testing single-file decompression with educational decoder - # - @$(ZSTD) -f README.md -o tmp.zst - @./harness tmp.zst tmp - @$(DIFF) -s tmp README.md - @$(RM) tmp* - # - # Testing dictionary decompression with education decoder - # - # note : files are presented multiple for training, to reach minimum threshold - @$(ZSTD) --train harness.c zstd_decompress.c zstd_decompress.h README.md \ - harness.c zstd_decompress.c zstd_decompress.h README.md \ - harness.c zstd_decompress.c zstd_decompress.h README.md \ - -o dictionary - @$(ZSTD) -f README.md -D dictionary -o tmp.zst - @./harness tmp.zst tmp dictionary - @$(DIFF) -s tmp README.md - @$(RM) tmp* dictionary diff --git a/third_party/zstd/doc/educational_decoder/README.md b/third_party/zstd/doc/educational_decoder/README.md deleted file mode 100644 index c89451ca0..000000000 --- a/third_party/zstd/doc/educational_decoder/README.md +++ /dev/null @@ -1,36 +0,0 @@ -Educational Decoder -=================== - -`zstd_decompress.c` is a self-contained implementation in C99 of a decoder, -according to the [Zstandard format specification]. -While it does not implement as many features as the reference decoder, -such as the streaming API or content checksums, it is written to be easy to -follow and understand, to help understand how the Zstandard format works. -It's laid out to match the [format specification], -so it can be used to understand how complex segments could be implemented. -It also contains implementations of Huffman and FSE table decoding. - -[Zstandard format specification]: https://github.com/facebook/zstd/blob/dev/doc/zstd_compression_format.md -[format specification]: https://github.com/facebook/zstd/blob/dev/doc/zstd_compression_format.md - -While the library's primary objective is code clarity, -it also happens to compile into a small object file. -The object file can be made even smaller by removing error messages, -using the macro directive `ZDEC_NO_MESSAGE` at compilation time. -This can be reduced even further by foregoing dictionary support, -by defining `ZDEC_NO_DICTIONARY`. - -`harness.c` provides a simple test harness around the decoder: - - harness [dictionary] - -As an additional resource to be used with this decoder, -see the `decodecorpus` tool in the [tests] directory. -It generates valid Zstandard frames that can be used to verify -a Zstandard decoder implementation. -Note that to use the tool to verify this decoder implementation, -the --content-size flag should be set, -as this decoder does not handle streaming decoding, -and so it must know the decompressed size in advance. - -[tests]: https://github.com/facebook/zstd/blob/dev/tests/ diff --git a/third_party/zstd/doc/educational_decoder/harness.c b/third_party/zstd/doc/educational_decoder/harness.c deleted file mode 100644 index 12c5a801b..000000000 --- a/third_party/zstd/doc/educational_decoder/harness.c +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under both the BSD-style license (found in the - * LICENSE file in the root directory of this source tree) and the GPLv2 (found - * in the COPYING file in the root directory of this source tree). - * You may select, at your option, one of the above-listed licenses. - */ - -#include -#include - -#include "zstd_decompress.h" - -typedef unsigned char u8; - -// If the data doesn't have decompressed size with it, fallback on assuming the -// compression ratio is at most 16 -#define MAX_COMPRESSION_RATIO (16) - -// Protect against allocating too much memory for output -#define MAX_OUTPUT_SIZE ((size_t)1024 * 1024 * 1024) - -// Error message then exit -#define ERR_OUT(...) { fprintf(stderr, __VA_ARGS__); exit(1); } - - -typedef struct { - u8* address; - size_t size; -} buffer_s; - -static void freeBuffer(buffer_s b) { free(b.address); } - -static buffer_s read_file(const char *path) -{ - FILE* const f = fopen(path, "rb"); - if (!f) ERR_OUT("failed to open file %s \n", path); - - fseek(f, 0L, SEEK_END); - size_t const size = (size_t)ftell(f); - rewind(f); - - void* const ptr = malloc(size); - if (!ptr) ERR_OUT("failed to allocate memory to hold %s \n", path); - - size_t const read = fread(ptr, 1, size, f); - if (read != size) ERR_OUT("error while reading file %s \n", path); - - fclose(f); - buffer_s const b = { ptr, size }; - return b; -} - -static void write_file(const char* path, const u8* ptr, size_t size) -{ - FILE* const f = fopen(path, "wb"); - if (!f) ERR_OUT("failed to open file %s \n", path); - - size_t written = 0; - while (written < size) { - written += fwrite(ptr+written, 1, size, f); - if (ferror(f)) ERR_OUT("error while writing file %s\n", path); - } - - fclose(f); -} - -int main(int argc, char **argv) -{ - if (argc < 3) - ERR_OUT("usage: %s [dictionary] \n", argv[0]); - - buffer_s const input = read_file(argv[1]); - - buffer_s dict = { NULL, 0 }; - if (argc >= 4) { - dict = read_file(argv[3]); - } - - size_t out_capacity = ZSTD_get_decompressed_size(input.address, input.size); - if (out_capacity == (size_t)-1) { - out_capacity = MAX_COMPRESSION_RATIO * input.size; - fprintf(stderr, "WARNING: Compressed data does not contain " - "decompressed size, going to assume the compression " - "ratio is at most %d (decompressed size of at most " - "%u) \n", - MAX_COMPRESSION_RATIO, (unsigned)out_capacity); - } - if (out_capacity > MAX_OUTPUT_SIZE) - ERR_OUT("Required output size too large for this implementation \n"); - - u8* const output = malloc(out_capacity); - if (!output) ERR_OUT("failed to allocate memory \n"); - - dictionary_t* const parsed_dict = create_dictionary(); - if (dict.size) { -#if defined (ZDEC_NO_DICTIONARY) - printf("dict.size = %zu \n", dict.size); - ERR_OUT("no dictionary support \n"); -#else - parse_dictionary(parsed_dict, dict.address, dict.size); -#endif - } - size_t const decompressed_size = - ZSTD_decompress_with_dict(output, out_capacity, - input.address, input.size, - parsed_dict); - - free_dictionary(parsed_dict); - - write_file(argv[2], output, decompressed_size); - - freeBuffer(input); - freeBuffer(dict); - free(output); - return 0; -} diff --git a/third_party/zstd/doc/educational_decoder/zstd_decompress.c b/third_party/zstd/doc/educational_decoder/zstd_decompress.c deleted file mode 100644 index 921c8f54c..000000000 --- a/third_party/zstd/doc/educational_decoder/zstd_decompress.c +++ /dev/null @@ -1,2323 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under both the BSD-style license (found in the - * LICENSE file in the root directory of this source tree) and the GPLv2 (found - * in the COPYING file in the root directory of this source tree). - * You may select, at your option, one of the above-listed licenses. - */ - -/// Zstandard educational decoder implementation -/// See https://github.com/facebook/zstd/blob/dev/doc/zstd_compression_format.md - -#include // uint8_t, etc. -#include // malloc, free, exit -#include // fprintf -#include // memset, memcpy -#include "zstd_decompress.h" - - -/******* IMPORTANT CONSTANTS *********************************************/ - -// Zstandard frame -// "Magic_Number -// 4 Bytes, little-endian format. Value : 0xFD2FB528" -#define ZSTD_MAGIC_NUMBER 0xFD2FB528U - -// The size of `Block_Content` is limited by `Block_Maximum_Size`, -#define ZSTD_BLOCK_SIZE_MAX ((size_t)128 * 1024) - -// literal blocks can't be larger than their block -#define MAX_LITERALS_SIZE ZSTD_BLOCK_SIZE_MAX - - -/******* UTILITY MACROS AND TYPES *********************************************/ -#define MAX(a, b) ((a) > (b) ? (a) : (b)) -#define MIN(a, b) ((a) < (b) ? (a) : (b)) - -#if defined(ZDEC_NO_MESSAGE) -#define MESSAGE(...) -#else -#define MESSAGE(...) fprintf(stderr, "" __VA_ARGS__) -#endif - -/// This decoder calls exit(1) when it encounters an error, however a production -/// library should propagate error codes -#define ERROR(s) \ - do { \ - MESSAGE("Error: %s\n", s); \ - exit(1); \ - } while (0) -#define INP_SIZE() \ - ERROR("Input buffer smaller than it should be or input is " \ - "corrupted") -#define OUT_SIZE() ERROR("Output buffer too small for output") -#define CORRUPTION() ERROR("Corruption detected while decompressing") -#define BAD_ALLOC() ERROR("Memory allocation error") -#define IMPOSSIBLE() ERROR("An impossibility has occurred") - -typedef uint8_t u8; -typedef uint16_t u16; -typedef uint32_t u32; -typedef uint64_t u64; - -typedef int8_t i8; -typedef int16_t i16; -typedef int32_t i32; -typedef int64_t i64; -/******* END UTILITY MACROS AND TYPES *****************************************/ - -/******* IMPLEMENTATION PRIMITIVE PROTOTYPES **********************************/ -/// The implementations for these functions can be found at the bottom of this -/// file. They implement low-level functionality needed for the higher level -/// decompression functions. - -/*** IO STREAM OPERATIONS *************/ - -/// ostream_t/istream_t are used to wrap the pointers/length data passed into -/// ZSTD_decompress, so that all IO operations are safely bounds checked -/// They are written/read forward, and reads are treated as little-endian -/// They should be used opaquely to ensure safety -typedef struct { - u8 *ptr; - size_t len; -} ostream_t; - -typedef struct { - const u8 *ptr; - size_t len; - - // Input often reads a few bits at a time, so maintain an internal offset - int bit_offset; -} istream_t; - -/// The following two functions are the only ones that allow the istream to be -/// non-byte aligned - -/// Reads `num` bits from a bitstream, and updates the internal offset -static inline u64 IO_read_bits(istream_t *const in, const int num_bits); -/// Backs-up the stream by `num` bits so they can be read again -static inline void IO_rewind_bits(istream_t *const in, const int num_bits); -/// If the remaining bits in a byte will be unused, advance to the end of the -/// byte -static inline void IO_align_stream(istream_t *const in); - -/// Write the given byte into the output stream -static inline void IO_write_byte(ostream_t *const out, u8 symb); - -/// Returns the number of bytes left to be read in this stream. The stream must -/// be byte aligned. -static inline size_t IO_istream_len(const istream_t *const in); - -/// Advances the stream by `len` bytes, and returns a pointer to the chunk that -/// was skipped. The stream must be byte aligned. -static inline const u8 *IO_get_read_ptr(istream_t *const in, size_t len); -/// Advances the stream by `len` bytes, and returns a pointer to the chunk that -/// was skipped so it can be written to. -static inline u8 *IO_get_write_ptr(ostream_t *const out, size_t len); - -/// Advance the inner state by `len` bytes. The stream must be byte aligned. -static inline void IO_advance_input(istream_t *const in, size_t len); - -/// Returns an `ostream_t` constructed from the given pointer and length. -static inline ostream_t IO_make_ostream(u8 *out, size_t len); -/// Returns an `istream_t` constructed from the given pointer and length. -static inline istream_t IO_make_istream(const u8 *in, size_t len); - -/// Returns an `istream_t` with the same base as `in`, and length `len`. -/// Then, advance `in` to account for the consumed bytes. -/// `in` must be byte aligned. -static inline istream_t IO_make_sub_istream(istream_t *const in, size_t len); -/*** END IO STREAM OPERATIONS *********/ - -/*** BITSTREAM OPERATIONS *************/ -/// Read `num` bits (up to 64) from `src + offset`, where `offset` is in bits, -/// and return them interpreted as a little-endian unsigned integer. -static inline u64 read_bits_LE(const u8 *src, const int num_bits, - const size_t offset); - -/// Read bits from the end of a HUF or FSE bitstream. `offset` is in bits, so -/// it updates `offset` to `offset - bits`, and then reads `bits` bits from -/// `src + offset`. If the offset becomes negative, the extra bits at the -/// bottom are filled in with `0` bits instead of reading from before `src`. -static inline u64 STREAM_read_bits(const u8 *src, const int bits, - i64 *const offset); -/*** END BITSTREAM OPERATIONS *********/ - -/*** BIT COUNTING OPERATIONS **********/ -/// Returns the index of the highest set bit in `num`, or `-1` if `num == 0` -static inline int highest_set_bit(const u64 num); -/*** END BIT COUNTING OPERATIONS ******/ - -/*** HUFFMAN PRIMITIVES ***************/ -// Table decode method uses exponential memory, so we need to limit depth -#define HUF_MAX_BITS (16) - -// Limit the maximum number of symbols to 256 so we can store a symbol in a byte -#define HUF_MAX_SYMBS (256) - -/// Structure containing all tables necessary for efficient Huffman decoding -typedef struct { - u8 *symbols; - u8 *num_bits; - int max_bits; -} HUF_dtable; - -/// Decode a single symbol and read in enough bits to refresh the state -static inline u8 HUF_decode_symbol(const HUF_dtable *const dtable, - u16 *const state, const u8 *const src, - i64 *const offset); -/// Read in a full state's worth of bits to initialize it -static inline void HUF_init_state(const HUF_dtable *const dtable, - u16 *const state, const u8 *const src, - i64 *const offset); - -/// Decompresses a single Huffman stream, returns the number of bytes decoded. -/// `src_len` must be the exact length of the Huffman-coded block. -static size_t HUF_decompress_1stream(const HUF_dtable *const dtable, - ostream_t *const out, istream_t *const in); -/// Same as previous but decodes 4 streams, formatted as in the Zstandard -/// specification. -/// `src_len` must be the exact length of the Huffman-coded block. -static size_t HUF_decompress_4stream(const HUF_dtable *const dtable, - ostream_t *const out, istream_t *const in); - -/// Initialize a Huffman decoding table using the table of bit counts provided -static void HUF_init_dtable(HUF_dtable *const table, const u8 *const bits, - const int num_symbs); -/// Initialize a Huffman decoding table using the table of weights provided -/// Weights follow the definition provided in the Zstandard specification -static void HUF_init_dtable_usingweights(HUF_dtable *const table, - const u8 *const weights, - const int num_symbs); - -/// Free the malloc'ed parts of a decoding table -static void HUF_free_dtable(HUF_dtable *const dtable); -/*** END HUFFMAN PRIMITIVES ***********/ - -/*** FSE PRIMITIVES *******************/ -/// For more description of FSE see -/// https://github.com/Cyan4973/FiniteStateEntropy/ - -// FSE table decoding uses exponential memory, so limit the maximum accuracy -#define FSE_MAX_ACCURACY_LOG (15) -// Limit the maximum number of symbols so they can be stored in a single byte -#define FSE_MAX_SYMBS (256) - -/// The tables needed to decode FSE encoded streams -typedef struct { - u8 *symbols; - u8 *num_bits; - u16 *new_state_base; - int accuracy_log; -} FSE_dtable; - -/// Return the symbol for the current state -static inline u8 FSE_peek_symbol(const FSE_dtable *const dtable, - const u16 state); -/// Read the number of bits necessary to update state, update, and shift offset -/// back to reflect the bits read -static inline void FSE_update_state(const FSE_dtable *const dtable, - u16 *const state, const u8 *const src, - i64 *const offset); - -/// Combine peek and update: decode a symbol and update the state -static inline u8 FSE_decode_symbol(const FSE_dtable *const dtable, - u16 *const state, const u8 *const src, - i64 *const offset); - -/// Read bits from the stream to initialize the state and shift offset back -static inline void FSE_init_state(const FSE_dtable *const dtable, - u16 *const state, const u8 *const src, - i64 *const offset); - -/// Decompress two interleaved bitstreams (e.g. compressed Huffman weights) -/// using an FSE decoding table. `src_len` must be the exact length of the -/// block. -static size_t FSE_decompress_interleaved2(const FSE_dtable *const dtable, - ostream_t *const out, - istream_t *const in); - -/// Initialize a decoding table using normalized frequencies. -static void FSE_init_dtable(FSE_dtable *const dtable, - const i16 *const norm_freqs, const int num_symbs, - const int accuracy_log); - -/// Decode an FSE header as defined in the Zstandard format specification and -/// use the decoded frequencies to initialize a decoding table. -static void FSE_decode_header(FSE_dtable *const dtable, istream_t *const in, - const int max_accuracy_log); - -/// Initialize an FSE table that will always return the same symbol and consume -/// 0 bits per symbol, to be used for RLE mode in sequence commands -static void FSE_init_dtable_rle(FSE_dtable *const dtable, const u8 symb); - -/// Free the malloc'ed parts of a decoding table -static void FSE_free_dtable(FSE_dtable *const dtable); -/*** END FSE PRIMITIVES ***************/ - -/******* END IMPLEMENTATION PRIMITIVE PROTOTYPES ******************************/ - -/******* ZSTD HELPER STRUCTS AND PROTOTYPES ***********************************/ - -/// A small structure that can be reused in various places that need to access -/// frame header information -typedef struct { - // The size of window that we need to be able to contiguously store for - // references - size_t window_size; - // The total output size of this compressed frame - size_t frame_content_size; - - // The dictionary id if this frame uses one - u32 dictionary_id; - - // Whether or not the content of this frame has a checksum - int content_checksum_flag; - // Whether or not the output for this frame is in a single segment - int single_segment_flag; -} frame_header_t; - -/// The context needed to decode blocks in a frame -typedef struct { - frame_header_t header; - - // The total amount of data available for backreferences, to determine if an - // offset too large to be correct - size_t current_total_output; - - const u8 *dict_content; - size_t dict_content_len; - - // Entropy encoding tables so they can be repeated by future blocks instead - // of retransmitting - HUF_dtable literals_dtable; - FSE_dtable ll_dtable; - FSE_dtable ml_dtable; - FSE_dtable of_dtable; - - // The last 3 offsets for the special "repeat offsets". - u64 previous_offsets[3]; -} frame_context_t; - -/// The decoded contents of a dictionary so that it doesn't have to be repeated -/// for each frame that uses it -struct dictionary_s { - // Entropy tables - HUF_dtable literals_dtable; - FSE_dtable ll_dtable; - FSE_dtable ml_dtable; - FSE_dtable of_dtable; - - // Raw content for backreferences - u8 *content; - size_t content_size; - - // Offset history to prepopulate the frame's history - u64 previous_offsets[3]; - - u32 dictionary_id; -}; - -/// A tuple containing the parts necessary to decode and execute a ZSTD sequence -/// command -typedef struct { - u32 literal_length; - u32 match_length; - u32 offset; -} sequence_command_t; - -/// The decoder works top-down, starting at the high level like Zstd frames, and -/// working down to lower more technical levels such as blocks, literals, and -/// sequences. The high-level functions roughly follow the outline of the -/// format specification: -/// https://github.com/facebook/zstd/blob/dev/doc/zstd_compression_format.md - -/// Before the implementation of each high-level function declared here, the -/// prototypes for their helper functions are defined and explained - -/// Decode a single Zstd frame, or error if the input is not a valid frame. -/// Accepts a dict argument, which may be NULL indicating no dictionary. -/// See -/// https://github.com/facebook/zstd/blob/dev/doc/zstd_compression_format.md#frame-concatenation -static void decode_frame(ostream_t *const out, istream_t *const in, - const dictionary_t *const dict); - -// Decode data in a compressed block -static void decompress_block(frame_context_t *const ctx, ostream_t *const out, - istream_t *const in); - -// Decode the literals section of a block -static size_t decode_literals(frame_context_t *const ctx, istream_t *const in, - u8 **const literals); - -// Decode the sequences part of a block -static size_t decode_sequences(frame_context_t *const ctx, istream_t *const in, - sequence_command_t **const sequences); - -// Execute the decoded sequences on the literals block -static void execute_sequences(frame_context_t *const ctx, ostream_t *const out, - const u8 *const literals, - const size_t literals_len, - const sequence_command_t *const sequences, - const size_t num_sequences); - -// Copies literals and returns the total literal length that was copied -static u32 copy_literals(const size_t seq, istream_t *litstream, - ostream_t *const out); - -// Given an offset code from a sequence command (either an actual offset value -// or an index for previous offset), computes the correct offset and updates -// the offset history -static size_t compute_offset(sequence_command_t seq, u64 *const offset_hist); - -// Given an offset, match length, and total output, as well as the frame -// context for the dictionary, determines if the dictionary is used and -// executes the copy operation -static void execute_match_copy(frame_context_t *const ctx, size_t offset, - size_t match_length, size_t total_output, - ostream_t *const out); - -/******* END ZSTD HELPER STRUCTS AND PROTOTYPES *******************************/ - -size_t ZSTD_decompress(void *const dst, const size_t dst_len, - const void *const src, const size_t src_len) { - dictionary_t* const uninit_dict = create_dictionary(); - size_t const decomp_size = ZSTD_decompress_with_dict(dst, dst_len, src, - src_len, uninit_dict); - free_dictionary(uninit_dict); - return decomp_size; -} - -size_t ZSTD_decompress_with_dict(void *const dst, const size_t dst_len, - const void *const src, const size_t src_len, - dictionary_t* parsed_dict) { - - istream_t in = IO_make_istream(src, src_len); - ostream_t out = IO_make_ostream(dst, dst_len); - - // "A content compressed by Zstandard is transformed into a Zstandard frame. - // Multiple frames can be appended into a single file or stream. A frame is - // totally independent, has a defined beginning and end, and a set of - // parameters which tells the decoder how to decompress it." - - /* this decoder assumes decompression of a single frame */ - decode_frame(&out, &in, parsed_dict); - - return (size_t)(out.ptr - (u8 *)dst); -} - -/******* FRAME DECODING ******************************************************/ - -static void decode_data_frame(ostream_t *const out, istream_t *const in, - const dictionary_t *const dict); -static void init_frame_context(frame_context_t *const context, - istream_t *const in, - const dictionary_t *const dict); -static void free_frame_context(frame_context_t *const context); -static void parse_frame_header(frame_header_t *const header, - istream_t *const in); -static void frame_context_apply_dict(frame_context_t *const ctx, - const dictionary_t *const dict); - -static void decompress_data(frame_context_t *const ctx, ostream_t *const out, - istream_t *const in); - -static void decode_frame(ostream_t *const out, istream_t *const in, - const dictionary_t *const dict) { - const u32 magic_number = (u32)IO_read_bits(in, 32); - if (magic_number == ZSTD_MAGIC_NUMBER) { - // ZSTD frame - decode_data_frame(out, in, dict); - - return; - } - - // not a real frame or a skippable frame - ERROR("Tried to decode non-ZSTD frame"); -} - -/// Decode a frame that contains compressed data. Not all frames do as there -/// are skippable frames. -/// See -/// https://github.com/facebook/zstd/blob/dev/doc/zstd_compression_format.md#general-structure-of-zstandard-frame-format -static void decode_data_frame(ostream_t *const out, istream_t *const in, - const dictionary_t *const dict) { - frame_context_t ctx; - - // Initialize the context that needs to be carried from block to block - init_frame_context(&ctx, in, dict); - - if (ctx.header.frame_content_size != 0 && - ctx.header.frame_content_size > out->len) { - OUT_SIZE(); - } - - decompress_data(&ctx, out, in); - - free_frame_context(&ctx); -} - -/// Takes the information provided in the header and dictionary, and initializes -/// the context for this frame -static void init_frame_context(frame_context_t *const context, - istream_t *const in, - const dictionary_t *const dict) { - // Most fields in context are correct when initialized to 0 - memset(context, 0, sizeof(frame_context_t)); - - // Parse data from the frame header - parse_frame_header(&context->header, in); - - // Set up the offset history for the repeat offset commands - context->previous_offsets[0] = 1; - context->previous_offsets[1] = 4; - context->previous_offsets[2] = 8; - - // Apply details from the dict if it exists - frame_context_apply_dict(context, dict); -} - -static void free_frame_context(frame_context_t *const context) { - HUF_free_dtable(&context->literals_dtable); - - FSE_free_dtable(&context->ll_dtable); - FSE_free_dtable(&context->ml_dtable); - FSE_free_dtable(&context->of_dtable); - - memset(context, 0, sizeof(frame_context_t)); -} - -static void parse_frame_header(frame_header_t *const header, - istream_t *const in) { - // "The first header's byte is called the Frame_Header_Descriptor. It tells - // which other fields are present. Decoding this byte is enough to tell the - // size of Frame_Header. - // - // Bit number Field name - // 7-6 Frame_Content_Size_flag - // 5 Single_Segment_flag - // 4 Unused_bit - // 3 Reserved_bit - // 2 Content_Checksum_flag - // 1-0 Dictionary_ID_flag" - const u8 descriptor = (u8)IO_read_bits(in, 8); - - // decode frame header descriptor into flags - const u8 frame_content_size_flag = descriptor >> 6; - const u8 single_segment_flag = (descriptor >> 5) & 1; - const u8 reserved_bit = (descriptor >> 3) & 1; - const u8 content_checksum_flag = (descriptor >> 2) & 1; - const u8 dictionary_id_flag = descriptor & 3; - - if (reserved_bit != 0) { - CORRUPTION(); - } - - header->single_segment_flag = single_segment_flag; - header->content_checksum_flag = content_checksum_flag; - - // decode window size - if (!single_segment_flag) { - // "Provides guarantees on maximum back-reference distance that will be - // used within compressed data. This information is important for - // decoders to allocate enough memory. - // - // Bit numbers 7-3 2-0 - // Field name Exponent Mantissa" - u8 window_descriptor = (u8)IO_read_bits(in, 8); - u8 exponent = window_descriptor >> 3; - u8 mantissa = window_descriptor & 7; - - // Use the algorithm from the specification to compute window size - // https://github.com/facebook/zstd/blob/dev/doc/zstd_compression_format.md#window_descriptor - size_t window_base = (size_t)1 << (10 + exponent); - size_t window_add = (window_base / 8) * mantissa; - header->window_size = window_base + window_add; - } - - // decode dictionary id if it exists - if (dictionary_id_flag) { - // "This is a variable size field, which contains the ID of the - // dictionary required to properly decode the frame. Note that this - // field is optional. When it's not present, it's up to the caller to - // make sure it uses the correct dictionary. Format is little-endian." - const int bytes_array[] = {0, 1, 2, 4}; - const int bytes = bytes_array[dictionary_id_flag]; - - header->dictionary_id = (u32)IO_read_bits(in, bytes * 8); - } else { - header->dictionary_id = 0; - } - - // decode frame content size if it exists - if (single_segment_flag || frame_content_size_flag) { - // "This is the original (uncompressed) size. This information is - // optional. The Field_Size is provided according to value of - // Frame_Content_Size_flag. The Field_Size can be equal to 0 (not - // present), 1, 2, 4 or 8 bytes. Format is little-endian." - // - // if frame_content_size_flag == 0 but single_segment_flag is set, we - // still have a 1 byte field - const int bytes_array[] = {1, 2, 4, 8}; - const int bytes = bytes_array[frame_content_size_flag]; - - header->frame_content_size = IO_read_bits(in, bytes * 8); - if (bytes == 2) { - // "When Field_Size is 2, the offset of 256 is added." - header->frame_content_size += 256; - } - } else { - header->frame_content_size = 0; - } - - if (single_segment_flag) { - // "The Window_Descriptor byte is optional. It is absent when - // Single_Segment_flag is set. In this case, the maximum back-reference - // distance is the content size itself, which can be any value from 1 to - // 2^64-1 bytes (16 EB)." - header->window_size = header->frame_content_size; - } -} - -/// Decompress the data from a frame block by block -static void decompress_data(frame_context_t *const ctx, ostream_t *const out, - istream_t *const in) { - // "A frame encapsulates one or multiple blocks. Each block can be - // compressed or not, and has a guaranteed maximum content size, which - // depends on frame parameters. Unlike frames, each block depends on - // previous blocks for proper decoding. However, each block can be - // decompressed without waiting for its successor, allowing streaming - // operations." - int last_block = 0; - do { - // "Last_Block - // - // The lowest bit signals if this block is the last one. Frame ends - // right after this block. - // - // Block_Type and Block_Size - // - // The next 2 bits represent the Block_Type, while the remaining 21 bits - // represent the Block_Size. Format is little-endian." - last_block = (int)IO_read_bits(in, 1); - const int block_type = (int)IO_read_bits(in, 2); - const size_t block_len = IO_read_bits(in, 21); - - switch (block_type) { - case 0: { - // "Raw_Block - this is an uncompressed block. Block_Size is the - // number of bytes to read and copy." - const u8 *const read_ptr = IO_get_read_ptr(in, block_len); - u8 *const write_ptr = IO_get_write_ptr(out, block_len); - - // Copy the raw data into the output - memcpy(write_ptr, read_ptr, block_len); - - ctx->current_total_output += block_len; - break; - } - case 1: { - // "RLE_Block - this is a single byte, repeated N times. In which - // case, Block_Size is the size to regenerate, while the - // "compressed" block is just 1 byte (the byte to repeat)." - const u8 *const read_ptr = IO_get_read_ptr(in, 1); - u8 *const write_ptr = IO_get_write_ptr(out, block_len); - - // Copy `block_len` copies of `read_ptr[0]` to the output - memset(write_ptr, read_ptr[0], block_len); - - ctx->current_total_output += block_len; - break; - } - case 2: { - // "Compressed_Block - this is a Zstandard compressed block, - // detailed in another section of this specification. Block_Size is - // the compressed size. - - // Create a sub-stream for the block - istream_t block_stream = IO_make_sub_istream(in, block_len); - decompress_block(ctx, out, &block_stream); - break; - } - case 3: - // "Reserved - this is not a block. This value cannot be used with - // current version of this specification." - CORRUPTION(); - break; - default: - IMPOSSIBLE(); - } - } while (!last_block); - - if (ctx->header.content_checksum_flag) { - // This program does not support checking the checksum, so skip over it - // if it's present - IO_advance_input(in, 4); - } -} -/******* END FRAME DECODING ***************************************************/ - -/******* BLOCK DECOMPRESSION **************************************************/ -static void decompress_block(frame_context_t *const ctx, ostream_t *const out, - istream_t *const in) { - // "A compressed block consists of 2 sections : - // - // Literals_Section - // Sequences_Section" - - - // Part 1: decode the literals block - u8 *literals = NULL; - const size_t literals_size = decode_literals(ctx, in, &literals); - - // Part 2: decode the sequences block - sequence_command_t *sequences = NULL; - const size_t num_sequences = - decode_sequences(ctx, in, &sequences); - - // Part 3: combine literals and sequence commands to generate output - execute_sequences(ctx, out, literals, literals_size, sequences, - num_sequences); - free(literals); - free(sequences); -} -/******* END BLOCK DECOMPRESSION **********************************************/ - -/******* LITERALS DECODING ****************************************************/ -static size_t decode_literals_simple(istream_t *const in, u8 **const literals, - const int block_type, - const int size_format); -static size_t decode_literals_compressed(frame_context_t *const ctx, - istream_t *const in, - u8 **const literals, - const int block_type, - const int size_format); -static void decode_huf_table(HUF_dtable *const dtable, istream_t *const in); -static void fse_decode_hufweights(ostream_t *weights, istream_t *const in, - int *const num_symbs); - -static size_t decode_literals(frame_context_t *const ctx, istream_t *const in, - u8 **const literals) { - // "Literals can be stored uncompressed or compressed using Huffman prefix - // codes. When compressed, an optional tree description can be present, - // followed by 1 or 4 streams." - // - // "Literals_Section_Header - // - // Header is in charge of describing how literals are packed. It's a - // byte-aligned variable-size bitfield, ranging from 1 to 5 bytes, using - // little-endian convention." - // - // "Literals_Block_Type - // - // This field uses 2 lowest bits of first byte, describing 4 different block - // types" - // - // size_format takes between 1 and 2 bits - int block_type = (int)IO_read_bits(in, 2); - int size_format = (int)IO_read_bits(in, 2); - - if (block_type <= 1) { - // Raw or RLE literals block - return decode_literals_simple(in, literals, block_type, - size_format); - } else { - // Huffman compressed literals - return decode_literals_compressed(ctx, in, literals, block_type, - size_format); - } -} - -/// Decodes literals blocks in raw or RLE form -static size_t decode_literals_simple(istream_t *const in, u8 **const literals, - const int block_type, - const int size_format) { - size_t size; - switch (size_format) { - // These cases are in the form ?0 - // In this case, the ? bit is actually part of the size field - case 0: - case 2: - // "Size_Format uses 1 bit. Regenerated_Size uses 5 bits (0-31)." - IO_rewind_bits(in, 1); - size = IO_read_bits(in, 5); - break; - case 1: - // "Size_Format uses 2 bits. Regenerated_Size uses 12 bits (0-4095)." - size = IO_read_bits(in, 12); - break; - case 3: - // "Size_Format uses 2 bits. Regenerated_Size uses 20 bits (0-1048575)." - size = IO_read_bits(in, 20); - break; - default: - // Size format is in range 0-3 - IMPOSSIBLE(); - } - - if (size > MAX_LITERALS_SIZE) { - CORRUPTION(); - } - - *literals = malloc(size); - if (!*literals) { - BAD_ALLOC(); - } - - switch (block_type) { - case 0: { - // "Raw_Literals_Block - Literals are stored uncompressed." - const u8 *const read_ptr = IO_get_read_ptr(in, size); - memcpy(*literals, read_ptr, size); - break; - } - case 1: { - // "RLE_Literals_Block - Literals consist of a single byte value repeated N times." - const u8 *const read_ptr = IO_get_read_ptr(in, 1); - memset(*literals, read_ptr[0], size); - break; - } - default: - IMPOSSIBLE(); - } - - return size; -} - -/// Decodes Huffman compressed literals -static size_t decode_literals_compressed(frame_context_t *const ctx, - istream_t *const in, - u8 **const literals, - const int block_type, - const int size_format) { - size_t regenerated_size, compressed_size; - // Only size_format=0 has 1 stream, so default to 4 - int num_streams = 4; - switch (size_format) { - case 0: - // "A single stream. Both Compressed_Size and Regenerated_Size use 10 - // bits (0-1023)." - num_streams = 1; - // Fall through as it has the same size format - /* fallthrough */ - case 1: - // "4 streams. Both Compressed_Size and Regenerated_Size use 10 bits - // (0-1023)." - regenerated_size = IO_read_bits(in, 10); - compressed_size = IO_read_bits(in, 10); - break; - case 2: - // "4 streams. Both Compressed_Size and Regenerated_Size use 14 bits - // (0-16383)." - regenerated_size = IO_read_bits(in, 14); - compressed_size = IO_read_bits(in, 14); - break; - case 3: - // "4 streams. Both Compressed_Size and Regenerated_Size use 18 bits - // (0-262143)." - regenerated_size = IO_read_bits(in, 18); - compressed_size = IO_read_bits(in, 18); - break; - default: - // Impossible - IMPOSSIBLE(); - } - if (regenerated_size > MAX_LITERALS_SIZE) { - CORRUPTION(); - } - - *literals = malloc(regenerated_size); - if (!*literals) { - BAD_ALLOC(); - } - - ostream_t lit_stream = IO_make_ostream(*literals, regenerated_size); - istream_t huf_stream = IO_make_sub_istream(in, compressed_size); - - if (block_type == 2) { - // Decode the provided Huffman table - // "This section is only present when Literals_Block_Type type is - // Compressed_Literals_Block (2)." - - HUF_free_dtable(&ctx->literals_dtable); - decode_huf_table(&ctx->literals_dtable, &huf_stream); - } else { - // If the previous Huffman table is being repeated, ensure it exists - if (!ctx->literals_dtable.symbols) { - CORRUPTION(); - } - } - - size_t symbols_decoded; - if (num_streams == 1) { - symbols_decoded = HUF_decompress_1stream(&ctx->literals_dtable, &lit_stream, &huf_stream); - } else { - symbols_decoded = HUF_decompress_4stream(&ctx->literals_dtable, &lit_stream, &huf_stream); - } - - if (symbols_decoded != regenerated_size) { - CORRUPTION(); - } - - return regenerated_size; -} - -// Decode the Huffman table description -static void decode_huf_table(HUF_dtable *const dtable, istream_t *const in) { - // "All literal values from zero (included) to last present one (excluded) - // are represented by Weight with values from 0 to Max_Number_of_Bits." - - // "This is a single byte value (0-255), which describes how to decode the list of weights." - const u8 header = IO_read_bits(in, 8); - - u8 weights[HUF_MAX_SYMBS]; - memset(weights, 0, sizeof(weights)); - - int num_symbs; - - if (header >= 128) { - // "This is a direct representation, where each Weight is written - // directly as a 4 bits field (0-15). The full representation occupies - // ((Number_of_Symbols+1)/2) bytes, meaning it uses a last full byte - // even if Number_of_Symbols is odd. Number_of_Symbols = headerByte - - // 127" - num_symbs = header - 127; - const size_t bytes = (num_symbs + 1) / 2; - - const u8 *const weight_src = IO_get_read_ptr(in, bytes); - - for (int i = 0; i < num_symbs; i++) { - // "They are encoded forward, 2 - // weights to a byte with the first weight taking the top four bits - // and the second taking the bottom four (e.g. the following - // operations could be used to read the weights: Weight[0] = - // (Byte[0] >> 4), Weight[1] = (Byte[0] & 0xf), etc.)." - if (i % 2 == 0) { - weights[i] = weight_src[i / 2] >> 4; - } else { - weights[i] = weight_src[i / 2] & 0xf; - } - } - } else { - // The weights are FSE encoded, decode them before we can construct the - // table - istream_t fse_stream = IO_make_sub_istream(in, header); - ostream_t weight_stream = IO_make_ostream(weights, HUF_MAX_SYMBS); - fse_decode_hufweights(&weight_stream, &fse_stream, &num_symbs); - } - - // Construct the table using the decoded weights - HUF_init_dtable_usingweights(dtable, weights, num_symbs); -} - -static void fse_decode_hufweights(ostream_t *weights, istream_t *const in, - int *const num_symbs) { - const int MAX_ACCURACY_LOG = 7; - - FSE_dtable dtable; - - // "An FSE bitstream starts by a header, describing probabilities - // distribution. It will create a Decoding Table. For a list of Huffman - // weights, maximum accuracy is 7 bits." - FSE_decode_header(&dtable, in, MAX_ACCURACY_LOG); - - // Decode the weights - *num_symbs = FSE_decompress_interleaved2(&dtable, weights, in); - - FSE_free_dtable(&dtable); -} -/******* END LITERALS DECODING ************************************************/ - -/******* SEQUENCE DECODING ****************************************************/ -/// The combination of FSE states needed to decode sequences -typedef struct { - FSE_dtable ll_table; - FSE_dtable of_table; - FSE_dtable ml_table; - - u16 ll_state; - u16 of_state; - u16 ml_state; -} sequence_states_t; - -/// Different modes to signal to decode_seq_tables what to do -typedef enum { - seq_literal_length = 0, - seq_offset = 1, - seq_match_length = 2, -} seq_part_t; - -typedef enum { - seq_predefined = 0, - seq_rle = 1, - seq_fse = 2, - seq_repeat = 3, -} seq_mode_t; - -/// The predefined FSE distribution tables for `seq_predefined` mode -static const i16 SEQ_LITERAL_LENGTH_DEFAULT_DIST[36] = { - 4, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 3, 2, 1, 1, 1, 1, 1, -1, -1, -1, -1}; -static const i16 SEQ_OFFSET_DEFAULT_DIST[29] = { - 1, 1, 1, 1, 1, 1, 2, 2, 2, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1}; -static const i16 SEQ_MATCH_LENGTH_DEFAULT_DIST[53] = { - 1, 4, 3, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1}; - -/// The sequence decoding baseline and number of additional bits to read/add -/// https://github.com/facebook/zstd/blob/dev/doc/zstd_compression_format.md#the-codes-for-literals-lengths-match-lengths-and-offsets -static const u32 SEQ_LITERAL_LENGTH_BASELINES[36] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, - 12, 13, 14, 15, 16, 18, 20, 22, 24, 28, 32, 40, - 48, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536}; -static const u8 SEQ_LITERAL_LENGTH_EXTRA_BITS[36] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, - 1, 1, 2, 2, 3, 3, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}; - -static const u32 SEQ_MATCH_LENGTH_BASELINES[53] = { - 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, - 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, - 31, 32, 33, 34, 35, 37, 39, 41, 43, 47, 51, 59, 67, 83, - 99, 131, 259, 515, 1027, 2051, 4099, 8195, 16387, 32771, 65539}; -static const u8 SEQ_MATCH_LENGTH_EXTRA_BITS[53] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, - 2, 2, 3, 3, 4, 4, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}; - -/// Offset decoding is simpler so we just need a maximum code value -static const u8 SEQ_MAX_CODES[3] = {35, (u8)-1, 52}; - -static void decompress_sequences(frame_context_t *const ctx, - istream_t *const in, - sequence_command_t *const sequences, - const size_t num_sequences); -static sequence_command_t decode_sequence(sequence_states_t *const state, - const u8 *const src, - i64 *const offset, - int lastSequence); -static void decode_seq_table(FSE_dtable *const table, istream_t *const in, - const seq_part_t type, const seq_mode_t mode); - -static size_t decode_sequences(frame_context_t *const ctx, istream_t *in, - sequence_command_t **const sequences) { - // "A compressed block is a succession of sequences . A sequence is a - // literal copy command, followed by a match copy command. A literal copy - // command specifies a length. It is the number of bytes to be copied (or - // extracted) from the literal section. A match copy command specifies an - // offset and a length. The offset gives the position to copy from, which - // can be within a previous block." - - size_t num_sequences; - - // "Number_of_Sequences - // - // This is a variable size field using between 1 and 3 bytes. Let's call its - // first byte byte0." - u8 header = IO_read_bits(in, 8); - if (header < 128) { - // "Number_of_Sequences = byte0 . Uses 1 byte." - num_sequences = header; - } else if (header < 255) { - // "Number_of_Sequences = ((byte0-128) << 8) + byte1 . Uses 2 bytes." - num_sequences = ((header - 128) << 8) + IO_read_bits(in, 8); - } else { - // "Number_of_Sequences = byte1 + (byte2<<8) + 0x7F00 . Uses 3 bytes." - num_sequences = IO_read_bits(in, 16) + 0x7F00; - } - - if (num_sequences == 0) { - // "There are no sequences. The sequence section stops there." - *sequences = NULL; - return 0; - } - - *sequences = malloc(num_sequences * sizeof(sequence_command_t)); - if (!*sequences) { - BAD_ALLOC(); - } - - decompress_sequences(ctx, in, *sequences, num_sequences); - return num_sequences; -} - -/// Decompress the FSE encoded sequence commands -static void decompress_sequences(frame_context_t *const ctx, istream_t *in, - sequence_command_t *const sequences, - const size_t num_sequences) { - // "The Sequences_Section regroup all symbols required to decode commands. - // There are 3 symbol types : literals lengths, offsets and match lengths. - // They are encoded together, interleaved, in a single bitstream." - - // "Symbol compression modes - // - // This is a single byte, defining the compression mode of each symbol - // type." - // - // Bit number : Field name - // 7-6 : Literals_Lengths_Mode - // 5-4 : Offsets_Mode - // 3-2 : Match_Lengths_Mode - // 1-0 : Reserved - u8 compression_modes = IO_read_bits(in, 8); - - if ((compression_modes & 3) != 0) { - // Reserved bits set - CORRUPTION(); - } - - // "Following the header, up to 3 distribution tables can be described. When - // present, they are in this order : - // - // Literals lengths - // Offsets - // Match Lengths" - // Update the tables we have stored in the context - decode_seq_table(&ctx->ll_dtable, in, seq_literal_length, - (compression_modes >> 6) & 3); - - decode_seq_table(&ctx->of_dtable, in, seq_offset, - (compression_modes >> 4) & 3); - - decode_seq_table(&ctx->ml_dtable, in, seq_match_length, - (compression_modes >> 2) & 3); - - - sequence_states_t states; - - // Initialize the decoding tables - { - states.ll_table = ctx->ll_dtable; - states.of_table = ctx->of_dtable; - states.ml_table = ctx->ml_dtable; - } - - const size_t len = IO_istream_len(in); - const u8 *const src = IO_get_read_ptr(in, len); - - // "After writing the last bit containing information, the compressor writes - // a single 1-bit and then fills the byte with 0-7 0 bits of padding." - const int padding = 8 - highest_set_bit(src[len - 1]); - // The offset starts at the end because FSE streams are read backwards - i64 bit_offset = (i64)(len * 8 - (size_t)padding); - - // "The bitstream starts with initial state values, each using the required - // number of bits in their respective accuracy, decoded previously from - // their normalized distribution. - // - // It starts by Literals_Length_State, followed by Offset_State, and finally - // Match_Length_State." - FSE_init_state(&states.ll_table, &states.ll_state, src, &bit_offset); - FSE_init_state(&states.of_table, &states.of_state, src, &bit_offset); - FSE_init_state(&states.ml_table, &states.ml_state, src, &bit_offset); - - for (size_t i = 0; i < num_sequences; i++) { - // Decode sequences one by one - sequences[i] = decode_sequence(&states, src, &bit_offset, i==num_sequences-1); - } - - if (bit_offset != 0) { - CORRUPTION(); - } -} - -// Decode a single sequence and update the state -static sequence_command_t decode_sequence(sequence_states_t *const states, - const u8 *const src, - i64 *const offset, - int lastSequence) { - // "Each symbol is a code in its own context, which specifies Baseline and - // Number_of_Bits to add. Codes are FSE compressed, and interleaved with raw - // additional bits in the same bitstream." - - // Decode symbols, but don't update states - const u8 of_code = FSE_peek_symbol(&states->of_table, states->of_state); - const u8 ll_code = FSE_peek_symbol(&states->ll_table, states->ll_state); - const u8 ml_code = FSE_peek_symbol(&states->ml_table, states->ml_state); - - // Offset doesn't need a max value as it's not decoded using a table - if (ll_code > SEQ_MAX_CODES[seq_literal_length] || - ml_code > SEQ_MAX_CODES[seq_match_length]) { - CORRUPTION(); - } - - // Read the interleaved bits - sequence_command_t seq; - // "Decoding starts by reading the Number_of_Bits required to decode Offset. - // It then does the same for Match_Length, and then for Literals_Length." - seq.offset = ((u32)1 << of_code) + STREAM_read_bits(src, of_code, offset); - - seq.match_length = - SEQ_MATCH_LENGTH_BASELINES[ml_code] + - STREAM_read_bits(src, SEQ_MATCH_LENGTH_EXTRA_BITS[ml_code], offset); - - seq.literal_length = - SEQ_LITERAL_LENGTH_BASELINES[ll_code] + - STREAM_read_bits(src, SEQ_LITERAL_LENGTH_EXTRA_BITS[ll_code], offset); - - // "If it is not the last sequence in the block, the next operation is to - // update states. Using the rules pre-calculated in the decoding tables, - // Literals_Length_State is updated, followed by Match_Length_State, and - // then Offset_State." - // If the stream is complete don't read bits to update state - if (!lastSequence) { - FSE_update_state(&states->ll_table, &states->ll_state, src, offset); - FSE_update_state(&states->ml_table, &states->ml_state, src, offset); - FSE_update_state(&states->of_table, &states->of_state, src, offset); - } - - return seq; -} - -/// Given a sequence part and table mode, decode the FSE distribution -/// Errors if the mode is `seq_repeat` without a pre-existing table in `table` -static void decode_seq_table(FSE_dtable *const table, istream_t *const in, - const seq_part_t type, const seq_mode_t mode) { - // Constant arrays indexed by seq_part_t - const i16 *const default_distributions[] = {SEQ_LITERAL_LENGTH_DEFAULT_DIST, - SEQ_OFFSET_DEFAULT_DIST, - SEQ_MATCH_LENGTH_DEFAULT_DIST}; - const size_t default_distribution_lengths[] = {36, 29, 53}; - const size_t default_distribution_accuracies[] = {6, 5, 6}; - - const size_t max_accuracies[] = {9, 8, 9}; - - if (mode != seq_repeat) { - // Free old one before overwriting - FSE_free_dtable(table); - } - - switch (mode) { - case seq_predefined: { - // "Predefined_Mode : uses a predefined distribution table." - const i16 *distribution = default_distributions[type]; - const size_t symbs = default_distribution_lengths[type]; - const size_t accuracy_log = default_distribution_accuracies[type]; - - FSE_init_dtable(table, distribution, symbs, accuracy_log); - break; - } - case seq_rle: { - // "RLE_Mode : it's a single code, repeated Number_of_Sequences times." - const u8 symb = IO_get_read_ptr(in, 1)[0]; - FSE_init_dtable_rle(table, symb); - break; - } - case seq_fse: { - // "FSE_Compressed_Mode : standard FSE compression. A distribution table - // will be present " - FSE_decode_header(table, in, max_accuracies[type]); - break; - } - case seq_repeat: - // "Repeat_Mode : re-use distribution table from previous compressed - // block." - // Nothing to do here, table will be unchanged - if (!table->symbols) { - // This mode is invalid if we don't already have a table - CORRUPTION(); - } - break; - default: - // Impossible, as mode is from 0-3 - IMPOSSIBLE(); - break; - } - -} -/******* END SEQUENCE DECODING ************************************************/ - -/******* SEQUENCE EXECUTION ***************************************************/ -static void execute_sequences(frame_context_t *const ctx, ostream_t *const out, - const u8 *const literals, - const size_t literals_len, - const sequence_command_t *const sequences, - const size_t num_sequences) { - istream_t litstream = IO_make_istream(literals, literals_len); - - u64 *const offset_hist = ctx->previous_offsets; - size_t total_output = ctx->current_total_output; - - for (size_t i = 0; i < num_sequences; i++) { - const sequence_command_t seq = sequences[i]; - { - const u32 literals_size = copy_literals(seq.literal_length, &litstream, out); - total_output += literals_size; - } - - size_t const offset = compute_offset(seq, offset_hist); - - size_t const match_length = seq.match_length; - - execute_match_copy(ctx, offset, match_length, total_output, out); - - total_output += match_length; - } - - // Copy any leftover literals - { - size_t len = IO_istream_len(&litstream); - copy_literals(len, &litstream, out); - total_output += len; - } - - ctx->current_total_output = total_output; -} - -static u32 copy_literals(const size_t literal_length, istream_t *litstream, - ostream_t *const out) { - // If the sequence asks for more literals than are left, the - // sequence must be corrupted - if (literal_length > IO_istream_len(litstream)) { - CORRUPTION(); - } - - u8 *const write_ptr = IO_get_write_ptr(out, literal_length); - const u8 *const read_ptr = - IO_get_read_ptr(litstream, literal_length); - // Copy literals to output - memcpy(write_ptr, read_ptr, literal_length); - - return literal_length; -} - -static size_t compute_offset(sequence_command_t seq, u64 *const offset_hist) { - size_t offset; - // Offsets are special, we need to handle the repeat offsets - if (seq.offset <= 3) { - // "The first 3 values define a repeated offset and we will call - // them Repeated_Offset1, Repeated_Offset2, and Repeated_Offset3. - // They are sorted in recency order, with Repeated_Offset1 meaning - // 'most recent one'". - - // Use 0 indexing for the array - u32 idx = seq.offset - 1; - if (seq.literal_length == 0) { - // "There is an exception though, when current sequence's - // literals length is 0. In this case, repeated offsets are - // shifted by one, so Repeated_Offset1 becomes Repeated_Offset2, - // Repeated_Offset2 becomes Repeated_Offset3, and - // Repeated_Offset3 becomes Repeated_Offset1 - 1_byte." - idx++; - } - - if (idx == 0) { - offset = offset_hist[0]; - } else { - // If idx == 3 then literal length was 0 and the offset was 3, - // as per the exception listed above - offset = idx < 3 ? offset_hist[idx] : offset_hist[0] - 1; - - // If idx == 1 we don't need to modify offset_hist[2], since - // we're using the second-most recent code - if (idx > 1) { - offset_hist[2] = offset_hist[1]; - } - offset_hist[1] = offset_hist[0]; - offset_hist[0] = offset; - } - } else { - // When it's not a repeat offset: - // "if (Offset_Value > 3) offset = Offset_Value - 3;" - offset = seq.offset - 3; - - // Shift back history - offset_hist[2] = offset_hist[1]; - offset_hist[1] = offset_hist[0]; - offset_hist[0] = offset; - } - return offset; -} - -static void execute_match_copy(frame_context_t *const ctx, size_t offset, - size_t match_length, size_t total_output, - ostream_t *const out) { - u8 *write_ptr = IO_get_write_ptr(out, match_length); - if (total_output <= ctx->header.window_size) { - // In this case offset might go back into the dictionary - if (offset > total_output + ctx->dict_content_len) { - // The offset goes beyond even the dictionary - CORRUPTION(); - } - - if (offset > total_output) { - // "The rest of the dictionary is its content. The content act - // as a "past" in front of data to compress or decompress, so it - // can be referenced in sequence commands." - const size_t dict_copy = - MIN(offset - total_output, match_length); - const size_t dict_offset = - ctx->dict_content_len - (offset - total_output); - - memcpy(write_ptr, ctx->dict_content + dict_offset, dict_copy); - write_ptr += dict_copy; - match_length -= dict_copy; - } - } else if (offset > ctx->header.window_size) { - CORRUPTION(); - } - - // We must copy byte by byte because the match length might be larger - // than the offset - // ex: if the output so far was "abc", a command with offset=3 and - // match_length=6 would produce "abcabcabc" as the new output - for (size_t j = 0; j < match_length; j++) { - *write_ptr = *(write_ptr - offset); - write_ptr++; - } -} -/******* END SEQUENCE EXECUTION ***********************************************/ - -/******* OUTPUT SIZE COUNTING *************************************************/ -/// Get the decompressed size of an input stream so memory can be allocated in -/// advance. -/// This implementation assumes `src` points to a single ZSTD-compressed frame -size_t ZSTD_get_decompressed_size(const void *src, const size_t src_len) { - istream_t in = IO_make_istream(src, src_len); - - // get decompressed size from ZSTD frame header - { - const u32 magic_number = (u32)IO_read_bits(&in, 32); - - if (magic_number == ZSTD_MAGIC_NUMBER) { - // ZSTD frame - frame_header_t header; - parse_frame_header(&header, &in); - - if (header.frame_content_size == 0 && !header.single_segment_flag) { - // Content size not provided, we can't tell - return (size_t)-1; - } - - return header.frame_content_size; - } else { - // not a real frame or skippable frame - ERROR("ZSTD frame magic number did not match"); - } - } -} -/******* END OUTPUT SIZE COUNTING *********************************************/ - -/******* DICTIONARY PARSING ***************************************************/ -dictionary_t* create_dictionary(void) { - dictionary_t* const dict = calloc(1, sizeof(dictionary_t)); - if (!dict) { - BAD_ALLOC(); - } - return dict; -} - -/// Free an allocated dictionary -void free_dictionary(dictionary_t *const dict) { - HUF_free_dtable(&dict->literals_dtable); - FSE_free_dtable(&dict->ll_dtable); - FSE_free_dtable(&dict->of_dtable); - FSE_free_dtable(&dict->ml_dtable); - - free(dict->content); - - memset(dict, 0, sizeof(dictionary_t)); - - free(dict); -} - - -#if !defined(ZDEC_NO_DICTIONARY) -#define DICT_SIZE_ERROR() ERROR("Dictionary size cannot be less than 8 bytes") -#define NULL_SRC() ERROR("Tried to create dictionary with pointer to null src"); - -static void init_dictionary_content(dictionary_t *const dict, - istream_t *const in); - -void parse_dictionary(dictionary_t *const dict, const void *src, - size_t src_len) { - const u8 *byte_src = (const u8 *)src; - memset(dict, 0, sizeof(dictionary_t)); - if (src == NULL) { /* cannot initialize dictionary with null src */ - NULL_SRC(); - } - if (src_len < 8) { - DICT_SIZE_ERROR(); - } - - istream_t in = IO_make_istream(byte_src, src_len); - - const u32 magic_number = IO_read_bits(&in, 32); - if (magic_number != 0xEC30A437) { - // raw content dict - IO_rewind_bits(&in, 32); - init_dictionary_content(dict, &in); - return; - } - - dict->dictionary_id = IO_read_bits(&in, 32); - - // "Entropy_Tables : following the same format as the tables in compressed - // blocks. They are stored in following order : Huffman tables for literals, - // FSE table for offsets, FSE table for match lengths, and FSE table for - // literals lengths. It's finally followed by 3 offset values, populating - // recent offsets (instead of using {1,4,8}), stored in order, 4-bytes - // little-endian each, for a total of 12 bytes. Each recent offset must have - // a value < dictionary size." - decode_huf_table(&dict->literals_dtable, &in); - decode_seq_table(&dict->of_dtable, &in, seq_offset, seq_fse); - decode_seq_table(&dict->ml_dtable, &in, seq_match_length, seq_fse); - decode_seq_table(&dict->ll_dtable, &in, seq_literal_length, seq_fse); - - // Read in the previous offset history - dict->previous_offsets[0] = IO_read_bits(&in, 32); - dict->previous_offsets[1] = IO_read_bits(&in, 32); - dict->previous_offsets[2] = IO_read_bits(&in, 32); - - // Ensure the provided offsets aren't too large - // "Each recent offset must have a value < dictionary size." - for (int i = 0; i < 3; i++) { - if (dict->previous_offsets[i] > src_len) { - ERROR("Dictionary corrupted"); - } - } - - // "Content : The rest of the dictionary is its content. The content act as - // a "past" in front of data to compress or decompress, so it can be - // referenced in sequence commands." - init_dictionary_content(dict, &in); -} - -static void init_dictionary_content(dictionary_t *const dict, - istream_t *const in) { - // Copy in the content - dict->content_size = IO_istream_len(in); - dict->content = malloc(dict->content_size); - if (!dict->content) { - BAD_ALLOC(); - } - - const u8 *const content = IO_get_read_ptr(in, dict->content_size); - - memcpy(dict->content, content, dict->content_size); -} - -static void HUF_copy_dtable(HUF_dtable *const dst, - const HUF_dtable *const src) { - if (src->max_bits == 0) { - memset(dst, 0, sizeof(HUF_dtable)); - return; - } - - const size_t size = (size_t)1 << src->max_bits; - dst->max_bits = src->max_bits; - - dst->symbols = malloc(size); - dst->num_bits = malloc(size); - if (!dst->symbols || !dst->num_bits) { - BAD_ALLOC(); - } - - memcpy(dst->symbols, src->symbols, size); - memcpy(dst->num_bits, src->num_bits, size); -} - -static void FSE_copy_dtable(FSE_dtable *const dst, const FSE_dtable *const src) { - if (src->accuracy_log == 0) { - memset(dst, 0, sizeof(FSE_dtable)); - return; - } - - size_t size = (size_t)1 << src->accuracy_log; - dst->accuracy_log = src->accuracy_log; - - dst->symbols = malloc(size); - dst->num_bits = malloc(size); - dst->new_state_base = malloc(size * sizeof(u16)); - if (!dst->symbols || !dst->num_bits || !dst->new_state_base) { - BAD_ALLOC(); - } - - memcpy(dst->symbols, src->symbols, size); - memcpy(dst->num_bits, src->num_bits, size); - memcpy(dst->new_state_base, src->new_state_base, size * sizeof(u16)); -} - -/// A dictionary acts as initializing values for the frame context before -/// decompression, so we implement it by applying it's predetermined -/// tables and content to the context before beginning decompression -static void frame_context_apply_dict(frame_context_t *const ctx, - const dictionary_t *const dict) { - // If the content pointer is NULL then it must be an empty dict - if (!dict || !dict->content) - return; - - // If the requested dictionary_id is non-zero, the correct dictionary must - // be present - if (ctx->header.dictionary_id != 0 && - ctx->header.dictionary_id != dict->dictionary_id) { - ERROR("Wrong dictionary provided"); - } - - // Copy the dict content to the context for references during sequence - // execution - ctx->dict_content = dict->content; - ctx->dict_content_len = dict->content_size; - - // If it's a formatted dict copy the precomputed tables in so they can - // be used in the table repeat modes - if (dict->dictionary_id != 0) { - // Deep copy the entropy tables so they can be freed independently of - // the dictionary struct - HUF_copy_dtable(&ctx->literals_dtable, &dict->literals_dtable); - FSE_copy_dtable(&ctx->ll_dtable, &dict->ll_dtable); - FSE_copy_dtable(&ctx->of_dtable, &dict->of_dtable); - FSE_copy_dtable(&ctx->ml_dtable, &dict->ml_dtable); - - // Copy the repeated offsets - memcpy(ctx->previous_offsets, dict->previous_offsets, - sizeof(ctx->previous_offsets)); - } -} - -#else // ZDEC_NO_DICTIONARY is defined - -static void frame_context_apply_dict(frame_context_t *const ctx, - const dictionary_t *const dict) { - (void)ctx; - if (dict && dict->content) ERROR("dictionary not supported"); -} - -#endif -/******* END DICTIONARY PARSING ***********************************************/ - -/******* IO STREAM OPERATIONS *************************************************/ - -/// Reads `num` bits from a bitstream, and updates the internal offset -static inline u64 IO_read_bits(istream_t *const in, const int num_bits) { - if (num_bits > 64 || num_bits <= 0) { - ERROR("Attempt to read an invalid number of bits"); - } - - const size_t bytes = (num_bits + in->bit_offset + 7) / 8; - const size_t full_bytes = (num_bits + in->bit_offset) / 8; - if (bytes > in->len) { - INP_SIZE(); - } - - const u64 result = read_bits_LE(in->ptr, num_bits, in->bit_offset); - - in->bit_offset = (num_bits + in->bit_offset) % 8; - in->ptr += full_bytes; - in->len -= full_bytes; - - return result; -} - -/// If a non-zero number of bits have been read from the current byte, advance -/// the offset to the next byte -static inline void IO_rewind_bits(istream_t *const in, int num_bits) { - if (num_bits < 0) { - ERROR("Attempting to rewind stream by a negative number of bits"); - } - - // move the offset back by `num_bits` bits - const int new_offset = in->bit_offset - num_bits; - // determine the number of whole bytes we have to rewind, rounding up to an - // integer number (e.g. if `new_offset == -5`, `bytes == 1`) - const i64 bytes = -(new_offset - 7) / 8; - - in->ptr -= bytes; - in->len += bytes; - // make sure the resulting `bit_offset` is positive, as mod in C does not - // convert numbers from negative to positive (e.g. -22 % 8 == -6) - in->bit_offset = ((new_offset % 8) + 8) % 8; -} - -/// If the remaining bits in a byte will be unused, advance to the end of the -/// byte -static inline void IO_align_stream(istream_t *const in) { - if (in->bit_offset != 0) { - if (in->len == 0) { - INP_SIZE(); - } - in->ptr++; - in->len--; - in->bit_offset = 0; - } -} - -/// Write the given byte into the output stream -static inline void IO_write_byte(ostream_t *const out, u8 symb) { - if (out->len == 0) { - OUT_SIZE(); - } - - out->ptr[0] = symb; - out->ptr++; - out->len--; -} - -/// Returns the number of bytes left to be read in this stream. The stream must -/// be byte aligned. -static inline size_t IO_istream_len(const istream_t *const in) { - return in->len; -} - -/// Returns a pointer where `len` bytes can be read, and advances the internal -/// state. The stream must be byte aligned. -static inline const u8 *IO_get_read_ptr(istream_t *const in, size_t len) { - if (len > in->len) { - INP_SIZE(); - } - if (in->bit_offset != 0) { - ERROR("Attempting to operate on a non-byte aligned stream"); - } - const u8 *const ptr = in->ptr; - in->ptr += len; - in->len -= len; - - return ptr; -} -/// Returns a pointer to write `len` bytes to, and advances the internal state -static inline u8 *IO_get_write_ptr(ostream_t *const out, size_t len) { - if (len > out->len) { - OUT_SIZE(); - } - u8 *const ptr = out->ptr; - out->ptr += len; - out->len -= len; - - return ptr; -} - -/// Advance the inner state by `len` bytes -static inline void IO_advance_input(istream_t *const in, size_t len) { - if (len > in->len) { - INP_SIZE(); - } - if (in->bit_offset != 0) { - ERROR("Attempting to operate on a non-byte aligned stream"); - } - - in->ptr += len; - in->len -= len; -} - -/// Returns an `ostream_t` constructed from the given pointer and length -static inline ostream_t IO_make_ostream(u8 *out, size_t len) { - return (ostream_t) { out, len }; -} - -/// Returns an `istream_t` constructed from the given pointer and length -static inline istream_t IO_make_istream(const u8 *in, size_t len) { - return (istream_t) { in, len, 0 }; -} - -/// Returns an `istream_t` with the same base as `in`, and length `len` -/// Then, advance `in` to account for the consumed bytes -/// `in` must be byte aligned -static inline istream_t IO_make_sub_istream(istream_t *const in, size_t len) { - // Consume `len` bytes of the parent stream - const u8 *const ptr = IO_get_read_ptr(in, len); - - // Make a substream using the pointer to those `len` bytes - return IO_make_istream(ptr, len); -} -/******* END IO STREAM OPERATIONS *********************************************/ - -/******* BITSTREAM OPERATIONS *************************************************/ -/// Read `num` bits (up to 64) from `src + offset`, where `offset` is in bits -static inline u64 read_bits_LE(const u8 *src, const int num_bits, - const size_t offset) { - if (num_bits > 64) { - ERROR("Attempt to read an invalid number of bits"); - } - - // Skip over bytes that aren't in range - src += offset / 8; - size_t bit_offset = offset % 8; - u64 res = 0; - - int shift = 0; - int left = num_bits; - while (left > 0) { - u64 mask = left >= 8 ? 0xff : (((u64)1 << left) - 1); - // Read the next byte, shift it to account for the offset, and then mask - // out the top part if we don't need all the bits - res += (((u64)*src++ >> bit_offset) & mask) << shift; - shift += 8 - bit_offset; - left -= 8 - bit_offset; - bit_offset = 0; - } - - return res; -} - -/// Read bits from the end of a HUF or FSE bitstream. `offset` is in bits, so -/// it updates `offset` to `offset - bits`, and then reads `bits` bits from -/// `src + offset`. If the offset becomes negative, the extra bits at the -/// bottom are filled in with `0` bits instead of reading from before `src`. -static inline u64 STREAM_read_bits(const u8 *const src, const int bits, - i64 *const offset) { - *offset = *offset - bits; - size_t actual_off = *offset; - size_t actual_bits = bits; - // Don't actually read bits from before the start of src, so if `*offset < - // 0` fix actual_off and actual_bits to reflect the quantity to read - if (*offset < 0) { - actual_bits += *offset; - actual_off = 0; - } - u64 res = read_bits_LE(src, actual_bits, actual_off); - - if (*offset < 0) { - // Fill in the bottom "overflowed" bits with 0's - res = -*offset >= 64 ? 0 : (res << -*offset); - } - return res; -} -/******* END BITSTREAM OPERATIONS *********************************************/ - -/******* BIT COUNTING OPERATIONS **********************************************/ -/// Returns `x`, where `2^x` is the largest power of 2 less than or equal to -/// `num`, or `-1` if `num == 0`. -static inline int highest_set_bit(const u64 num) { - for (int i = 63; i >= 0; i--) { - if (((u64)1 << i) <= num) { - return i; - } - } - return -1; -} -/******* END BIT COUNTING OPERATIONS ******************************************/ - -/******* HUFFMAN PRIMITIVES ***************************************************/ -static inline u8 HUF_decode_symbol(const HUF_dtable *const dtable, - u16 *const state, const u8 *const src, - i64 *const offset) { - // Look up the symbol and number of bits to read - const u8 symb = dtable->symbols[*state]; - const u8 bits = dtable->num_bits[*state]; - const u16 rest = STREAM_read_bits(src, bits, offset); - // Shift `bits` bits out of the state, keeping the low order bits that - // weren't necessary to determine this symbol. Then add in the new bits - // read from the stream. - *state = ((*state << bits) + rest) & (((u16)1 << dtable->max_bits) - 1); - - return symb; -} - -static inline void HUF_init_state(const HUF_dtable *const dtable, - u16 *const state, const u8 *const src, - i64 *const offset) { - // Read in a full `dtable->max_bits` bits to initialize the state - const u8 bits = dtable->max_bits; - *state = STREAM_read_bits(src, bits, offset); -} - -static size_t HUF_decompress_1stream(const HUF_dtable *const dtable, - ostream_t *const out, - istream_t *const in) { - const size_t len = IO_istream_len(in); - if (len == 0) { - INP_SIZE(); - } - const u8 *const src = IO_get_read_ptr(in, len); - - // "Each bitstream must be read backward, that is starting from the end down - // to the beginning. Therefore it's necessary to know the size of each - // bitstream. - // - // It's also necessary to know exactly which bit is the latest. This is - // detected by a final bit flag : the highest bit of latest byte is a - // final-bit-flag. Consequently, a last byte of 0 is not possible. And the - // final-bit-flag itself is not part of the useful bitstream. Hence, the - // last byte contains between 0 and 7 useful bits." - const int padding = 8 - highest_set_bit(src[len - 1]); - - // Offset starts at the end because HUF streams are read backwards - i64 bit_offset = len * 8 - padding; - u16 state; - - HUF_init_state(dtable, &state, src, &bit_offset); - - size_t symbols_written = 0; - while (bit_offset > -dtable->max_bits) { - // Iterate over the stream, decoding one symbol at a time - IO_write_byte(out, HUF_decode_symbol(dtable, &state, src, &bit_offset)); - symbols_written++; - } - // "The process continues up to reading the required number of symbols per - // stream. If a bitstream is not entirely and exactly consumed, hence - // reaching exactly its beginning position with all bits consumed, the - // decoding process is considered faulty." - - // When all symbols have been decoded, the final state value shouldn't have - // any data from the stream, so it should have "read" dtable->max_bits from - // before the start of `src` - // Therefore `offset`, the edge to start reading new bits at, should be - // dtable->max_bits before the start of the stream - if (bit_offset != -dtable->max_bits) { - CORRUPTION(); - } - - return symbols_written; -} - -static size_t HUF_decompress_4stream(const HUF_dtable *const dtable, - ostream_t *const out, istream_t *const in) { - // "Compressed size is provided explicitly : in the 4-streams variant, - // bitstreams are preceded by 3 unsigned little-endian 16-bits values. Each - // value represents the compressed size of one stream, in order. The last - // stream size is deducted from total compressed size and from previously - // decoded stream sizes" - const size_t csize1 = IO_read_bits(in, 16); - const size_t csize2 = IO_read_bits(in, 16); - const size_t csize3 = IO_read_bits(in, 16); - - istream_t in1 = IO_make_sub_istream(in, csize1); - istream_t in2 = IO_make_sub_istream(in, csize2); - istream_t in3 = IO_make_sub_istream(in, csize3); - istream_t in4 = IO_make_sub_istream(in, IO_istream_len(in)); - - size_t total_output = 0; - // Decode each stream independently for simplicity - // If we wanted to we could decode all 4 at the same time for speed, - // utilizing more execution units - total_output += HUF_decompress_1stream(dtable, out, &in1); - total_output += HUF_decompress_1stream(dtable, out, &in2); - total_output += HUF_decompress_1stream(dtable, out, &in3); - total_output += HUF_decompress_1stream(dtable, out, &in4); - - return total_output; -} - -/// Initializes a Huffman table using canonical Huffman codes -/// For more explanation on canonical Huffman codes see -/// https://www.cs.scranton.edu/~mccloske/courses/cmps340/huff_canonical_dec2015.html -/// Codes within a level are allocated in symbol order (i.e. smaller symbols get -/// earlier codes) -static void HUF_init_dtable(HUF_dtable *const table, const u8 *const bits, - const int num_symbs) { - memset(table, 0, sizeof(HUF_dtable)); - if (num_symbs > HUF_MAX_SYMBS) { - ERROR("Too many symbols for Huffman"); - } - - u8 max_bits = 0; - u16 rank_count[HUF_MAX_BITS + 1]; - memset(rank_count, 0, sizeof(rank_count)); - - // Count the number of symbols for each number of bits, and determine the - // depth of the tree - for (int i = 0; i < num_symbs; i++) { - if (bits[i] > HUF_MAX_BITS) { - ERROR("Huffman table depth too large"); - } - max_bits = MAX(max_bits, bits[i]); - rank_count[bits[i]]++; - } - - const size_t table_size = 1 << max_bits; - table->max_bits = max_bits; - table->symbols = malloc(table_size); - table->num_bits = malloc(table_size); - - if (!table->symbols || !table->num_bits) { - free(table->symbols); - free(table->num_bits); - BAD_ALLOC(); - } - - // "Symbols are sorted by Weight. Within same Weight, symbols keep natural - // order. Symbols with a Weight of zero are removed. Then, starting from - // lowest weight, prefix codes are distributed in order." - - u32 rank_idx[HUF_MAX_BITS + 1]; - // Initialize the starting codes for each rank (number of bits) - rank_idx[max_bits] = 0; - for (int i = max_bits; i >= 1; i--) { - rank_idx[i - 1] = rank_idx[i] + rank_count[i] * (1 << (max_bits - i)); - // The entire range takes the same number of bits so we can memset it - memset(&table->num_bits[rank_idx[i]], i, rank_idx[i - 1] - rank_idx[i]); - } - - if (rank_idx[0] != table_size) { - CORRUPTION(); - } - - // Allocate codes and fill in the table - for (int i = 0; i < num_symbs; i++) { - if (bits[i] != 0) { - // Allocate a code for this symbol and set its range in the table - const u16 code = rank_idx[bits[i]]; - // Since the code doesn't care about the bottom `max_bits - bits[i]` - // bits of state, it gets a range that spans all possible values of - // the lower bits - const u16 len = 1 << (max_bits - bits[i]); - memset(&table->symbols[code], i, len); - rank_idx[bits[i]] += len; - } - } -} - -static void HUF_init_dtable_usingweights(HUF_dtable *const table, - const u8 *const weights, - const int num_symbs) { - // +1 because the last weight is not transmitted in the header - if (num_symbs + 1 > HUF_MAX_SYMBS) { - ERROR("Too many symbols for Huffman"); - } - - u8 bits[HUF_MAX_SYMBS]; - - u64 weight_sum = 0; - for (int i = 0; i < num_symbs; i++) { - // Weights are in the same range as bit count - if (weights[i] > HUF_MAX_BITS) { - CORRUPTION(); - } - weight_sum += weights[i] > 0 ? (u64)1 << (weights[i] - 1) : 0; - } - - // Find the first power of 2 larger than the sum - const int max_bits = highest_set_bit(weight_sum) + 1; - const u64 left_over = ((u64)1 << max_bits) - weight_sum; - // If the left over isn't a power of 2, the weights are invalid - if (left_over & (left_over - 1)) { - CORRUPTION(); - } - - // left_over is used to find the last weight as it's not transmitted - // by inverting 2^(weight - 1) we can determine the value of last_weight - const int last_weight = highest_set_bit(left_over) + 1; - - for (int i = 0; i < num_symbs; i++) { - // "Number_of_Bits = Number_of_Bits ? Max_Number_of_Bits + 1 - Weight : 0" - bits[i] = weights[i] > 0 ? (max_bits + 1 - weights[i]) : 0; - } - bits[num_symbs] = - max_bits + 1 - last_weight; // Last weight is always non-zero - - HUF_init_dtable(table, bits, num_symbs + 1); -} - -static void HUF_free_dtable(HUF_dtable *const dtable) { - free(dtable->symbols); - free(dtable->num_bits); - memset(dtable, 0, sizeof(HUF_dtable)); -} -/******* END HUFFMAN PRIMITIVES ***********************************************/ - -/******* FSE PRIMITIVES *******************************************************/ -/// For more description of FSE see -/// https://github.com/Cyan4973/FiniteStateEntropy/ - -/// Allow a symbol to be decoded without updating state -static inline u8 FSE_peek_symbol(const FSE_dtable *const dtable, - const u16 state) { - return dtable->symbols[state]; -} - -/// Consumes bits from the input and uses the current state to determine the -/// next state -static inline void FSE_update_state(const FSE_dtable *const dtable, - u16 *const state, const u8 *const src, - i64 *const offset) { - const u8 bits = dtable->num_bits[*state]; - const u16 rest = STREAM_read_bits(src, bits, offset); - *state = dtable->new_state_base[*state] + rest; -} - -/// Decodes a single FSE symbol and updates the offset -static inline u8 FSE_decode_symbol(const FSE_dtable *const dtable, - u16 *const state, const u8 *const src, - i64 *const offset) { - const u8 symb = FSE_peek_symbol(dtable, *state); - FSE_update_state(dtable, state, src, offset); - return symb; -} - -static inline void FSE_init_state(const FSE_dtable *const dtable, - u16 *const state, const u8 *const src, - i64 *const offset) { - // Read in a full `accuracy_log` bits to initialize the state - const u8 bits = dtable->accuracy_log; - *state = STREAM_read_bits(src, bits, offset); -} - -static size_t FSE_decompress_interleaved2(const FSE_dtable *const dtable, - ostream_t *const out, - istream_t *const in) { - const size_t len = IO_istream_len(in); - if (len == 0) { - INP_SIZE(); - } - const u8 *const src = IO_get_read_ptr(in, len); - - // "Each bitstream must be read backward, that is starting from the end down - // to the beginning. Therefore it's necessary to know the size of each - // bitstream. - // - // It's also necessary to know exactly which bit is the latest. This is - // detected by a final bit flag : the highest bit of latest byte is a - // final-bit-flag. Consequently, a last byte of 0 is not possible. And the - // final-bit-flag itself is not part of the useful bitstream. Hence, the - // last byte contains between 0 and 7 useful bits." - const int padding = 8 - highest_set_bit(src[len - 1]); - i64 offset = len * 8 - padding; - - u16 state1, state2; - // "The first state (State1) encodes the even indexed symbols, and the - // second (State2) encodes the odd indexes. State1 is initialized first, and - // then State2, and they take turns decoding a single symbol and updating - // their state." - FSE_init_state(dtable, &state1, src, &offset); - FSE_init_state(dtable, &state2, src, &offset); - - // Decode until we overflow the stream - // Since we decode in reverse order, overflowing the stream is offset going - // negative - size_t symbols_written = 0; - while (1) { - // "The number of symbols to decode is determined by tracking bitStream - // overflow condition: If updating state after decoding a symbol would - // require more bits than remain in the stream, it is assumed the extra - // bits are 0. Then, the symbols for each of the final states are - // decoded and the process is complete." - IO_write_byte(out, FSE_decode_symbol(dtable, &state1, src, &offset)); - symbols_written++; - if (offset < 0) { - // There's still a symbol to decode in state2 - IO_write_byte(out, FSE_peek_symbol(dtable, state2)); - symbols_written++; - break; - } - - IO_write_byte(out, FSE_decode_symbol(dtable, &state2, src, &offset)); - symbols_written++; - if (offset < 0) { - // There's still a symbol to decode in state1 - IO_write_byte(out, FSE_peek_symbol(dtable, state1)); - symbols_written++; - break; - } - } - - return symbols_written; -} - -static void FSE_init_dtable(FSE_dtable *const dtable, - const i16 *const norm_freqs, const int num_symbs, - const int accuracy_log) { - if (accuracy_log > FSE_MAX_ACCURACY_LOG) { - ERROR("FSE accuracy too large"); - } - if (num_symbs > FSE_MAX_SYMBS) { - ERROR("Too many symbols for FSE"); - } - - dtable->accuracy_log = accuracy_log; - - const size_t size = (size_t)1 << accuracy_log; - dtable->symbols = malloc(size * sizeof(u8)); - dtable->num_bits = malloc(size * sizeof(u8)); - dtable->new_state_base = malloc(size * sizeof(u16)); - - if (!dtable->symbols || !dtable->num_bits || !dtable->new_state_base) { - BAD_ALLOC(); - } - - // Used to determine how many bits need to be read for each state, - // and where the destination range should start - // Needs to be u16 because max value is 2 * max number of symbols, - // which can be larger than a byte can store - u16 state_desc[FSE_MAX_SYMBS]; - - // "Symbols are scanned in their natural order for "less than 1" - // probabilities. Symbols with this probability are being attributed a - // single cell, starting from the end of the table. These symbols define a - // full state reset, reading Accuracy_Log bits." - int high_threshold = size; - for (int s = 0; s < num_symbs; s++) { - // Scan for low probability symbols to put at the top - if (norm_freqs[s] == -1) { - dtable->symbols[--high_threshold] = s; - state_desc[s] = 1; - } - } - - // "All remaining symbols are sorted in their natural order. Starting from - // symbol 0 and table position 0, each symbol gets attributed as many cells - // as its probability. Cell allocation is spread, not linear." - // Place the rest in the table - const u16 step = (size >> 1) + (size >> 3) + 3; - const u16 mask = size - 1; - u16 pos = 0; - for (int s = 0; s < num_symbs; s++) { - if (norm_freqs[s] <= 0) { - continue; - } - - state_desc[s] = norm_freqs[s]; - - for (int i = 0; i < norm_freqs[s]; i++) { - // Give `norm_freqs[s]` states to symbol s - dtable->symbols[pos] = s; - // "A position is skipped if already occupied, typically by a "less - // than 1" probability symbol." - do { - pos = (pos + step) & mask; - } while (pos >= - high_threshold); - // Note: no other collision checking is necessary as `step` is - // coprime to `size`, so the cycle will visit each position exactly - // once - } - } - if (pos != 0) { - CORRUPTION(); - } - - // Now we can fill baseline and num bits - for (size_t i = 0; i < size; i++) { - u8 symbol = dtable->symbols[i]; - u16 next_state_desc = state_desc[symbol]++; - // Fills in the table appropriately, next_state_desc increases by symbol - // over time, decreasing number of bits - dtable->num_bits[i] = (u8)(accuracy_log - highest_set_bit(next_state_desc)); - // Baseline increases until the bit threshold is passed, at which point - // it resets to 0 - dtable->new_state_base[i] = - ((u16)next_state_desc << dtable->num_bits[i]) - size; - } -} - -/// Decode an FSE header as defined in the Zstandard format specification and -/// use the decoded frequencies to initialize a decoding table. -static void FSE_decode_header(FSE_dtable *const dtable, istream_t *const in, - const int max_accuracy_log) { - // "An FSE distribution table describes the probabilities of all symbols - // from 0 to the last present one (included) on a normalized scale of 1 << - // Accuracy_Log . - // - // It's a bitstream which is read forward, in little-endian fashion. It's - // not necessary to know its exact size, since it will be discovered and - // reported by the decoding process. - if (max_accuracy_log > FSE_MAX_ACCURACY_LOG) { - ERROR("FSE accuracy too large"); - } - - // The bitstream starts by reporting on which scale it operates. - // Accuracy_Log = low4bits + 5. Note that maximum Accuracy_Log for literal - // and match lengths is 9, and for offsets is 8. Higher values are - // considered errors." - const int accuracy_log = 5 + IO_read_bits(in, 4); - if (accuracy_log > max_accuracy_log) { - ERROR("FSE accuracy too large"); - } - - // "Then follows each symbol value, from 0 to last present one. The number - // of bits used by each field is variable. It depends on : - // - // Remaining probabilities + 1 : example : Presuming an Accuracy_Log of 8, - // and presuming 100 probabilities points have already been distributed, the - // decoder may read any value from 0 to 255 - 100 + 1 == 156 (inclusive). - // Therefore, it must read log2sup(156) == 8 bits. - // - // Value decoded : small values use 1 less bit : example : Presuming values - // from 0 to 156 (inclusive) are possible, 255-156 = 99 values are remaining - // in an 8-bits field. They are used this way : first 99 values (hence from - // 0 to 98) use only 7 bits, values from 99 to 156 use 8 bits. " - - i32 remaining = 1 << accuracy_log; - i16 frequencies[FSE_MAX_SYMBS]; - - int symb = 0; - while (remaining > 0 && symb < FSE_MAX_SYMBS) { - // Log of the number of possible values we could read - int bits = highest_set_bit(remaining + 1) + 1; - - u16 val = IO_read_bits(in, bits); - - // Try to mask out the lower bits to see if it qualifies for the "small - // value" threshold - const u16 lower_mask = ((u16)1 << (bits - 1)) - 1; - const u16 threshold = ((u16)1 << bits) - 1 - (remaining + 1); - - if ((val & lower_mask) < threshold) { - IO_rewind_bits(in, 1); - val = val & lower_mask; - } else if (val > lower_mask) { - val = val - threshold; - } - - // "Probability is obtained from Value decoded by following formula : - // Proba = value - 1" - const i16 proba = (i16)val - 1; - - // "It means value 0 becomes negative probability -1. -1 is a special - // probability, which means "less than 1". Its effect on distribution - // table is described in next paragraph. For the purpose of calculating - // cumulated distribution, it counts as one." - remaining -= proba < 0 ? -proba : proba; - - frequencies[symb] = proba; - symb++; - - // "When a symbol has a probability of zero, it is followed by a 2-bits - // repeat flag. This repeat flag tells how many probabilities of zeroes - // follow the current one. It provides a number ranging from 0 to 3. If - // it is a 3, another 2-bits repeat flag follows, and so on." - if (proba == 0) { - // Read the next two bits to see how many more 0s - int repeat = IO_read_bits(in, 2); - - while (1) { - for (int i = 0; i < repeat && symb < FSE_MAX_SYMBS; i++) { - frequencies[symb++] = 0; - } - if (repeat == 3) { - repeat = IO_read_bits(in, 2); - } else { - break; - } - } - } - } - IO_align_stream(in); - - // "When last symbol reaches cumulated total of 1 << Accuracy_Log, decoding - // is complete. If the last symbol makes cumulated total go above 1 << - // Accuracy_Log, distribution is considered corrupted." - if (remaining != 0 || symb >= FSE_MAX_SYMBS) { - CORRUPTION(); - } - - // Initialize the decoding table using the determined weights - FSE_init_dtable(dtable, frequencies, symb, accuracy_log); -} - -static void FSE_init_dtable_rle(FSE_dtable *const dtable, const u8 symb) { - dtable->symbols = malloc(sizeof(u8)); - dtable->num_bits = malloc(sizeof(u8)); - dtable->new_state_base = malloc(sizeof(u16)); - - if (!dtable->symbols || !dtable->num_bits || !dtable->new_state_base) { - BAD_ALLOC(); - } - - // This setup will always have a state of 0, always return symbol `symb`, - // and never consume any bits - dtable->symbols[0] = symb; - dtable->num_bits[0] = 0; - dtable->new_state_base[0] = 0; - dtable->accuracy_log = 0; -} - -static void FSE_free_dtable(FSE_dtable *const dtable) { - free(dtable->symbols); - free(dtable->num_bits); - free(dtable->new_state_base); - memset(dtable, 0, sizeof(FSE_dtable)); -} -/******* END FSE PRIMITIVES ***************************************************/ diff --git a/third_party/zstd/doc/educational_decoder/zstd_decompress.h b/third_party/zstd/doc/educational_decoder/zstd_decompress.h deleted file mode 100644 index c13c8134d..000000000 --- a/third_party/zstd/doc/educational_decoder/zstd_decompress.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under both the BSD-style license (found in the - * LICENSE file in the root directory of this source tree) and the GPLv2 (found - * in the COPYING file in the root directory of this source tree). - * You may select, at your option, one of the above-listed licenses. - */ - -#include /* size_t */ - -/******* EXPOSED TYPES ********************************************************/ -/* -* Contains the parsed contents of a dictionary -* This includes Huffman and FSE tables used for decoding and data on offsets -*/ -typedef struct dictionary_s dictionary_t; -/******* END EXPOSED TYPES ****************************************************/ - -/******* DECOMPRESSION FUNCTIONS **********************************************/ -/// Zstandard decompression functions. -/// `dst` must point to a space at least as large as the reconstructed output. -size_t ZSTD_decompress(void *const dst, const size_t dst_len, - const void *const src, const size_t src_len); - -/// If `dict != NULL` and `dict_len >= 8`, does the same thing as -/// `ZSTD_decompress` but uses the provided dict -size_t ZSTD_decompress_with_dict(void *const dst, const size_t dst_len, - const void *const src, const size_t src_len, - dictionary_t* parsed_dict); - -/// Get the decompressed size of an input stream so memory can be allocated in -/// advance -/// Returns -1 if the size can't be determined -/// Assumes decompression of a single frame -size_t ZSTD_get_decompressed_size(const void *const src, const size_t src_len); -/******* END DECOMPRESSION FUNCTIONS ******************************************/ - -/******* DICTIONARY MANAGEMENT ***********************************************/ -/* - * Return a valid dictionary_t pointer for use with dictionary initialization - * or decompression - */ -dictionary_t* create_dictionary(void); - -/* - * Parse a provided dictionary blob for use in decompression - * `src` -- must point to memory space representing the dictionary - * `src_len` -- must provide the dictionary size - * `dict` -- will contain the parsed contents of the dictionary and - * can be used for decompression - */ -void parse_dictionary(dictionary_t *const dict, const void *src, - size_t src_len); - -/* - * Free internal Huffman tables, FSE tables, and dictionary content - */ -void free_dictionary(dictionary_t *const dict); -/******* END DICTIONARY MANAGEMENT *******************************************/ diff --git a/third_party/zstd/doc/images/CSpeed2.png b/third_party/zstd/doc/images/CSpeed2.png deleted file mode 100644 index 42affa46e..000000000 Binary files a/third_party/zstd/doc/images/CSpeed2.png and /dev/null differ diff --git a/third_party/zstd/doc/images/DCspeed5.png b/third_party/zstd/doc/images/DCspeed5.png deleted file mode 100644 index 900b0242f..000000000 Binary files a/third_party/zstd/doc/images/DCspeed5.png and /dev/null differ diff --git a/third_party/zstd/doc/images/DSpeed3.png b/third_party/zstd/doc/images/DSpeed3.png deleted file mode 100644 index 4818b1118..000000000 Binary files a/third_party/zstd/doc/images/DSpeed3.png and /dev/null differ diff --git a/third_party/zstd/doc/images/cdict_v136.png b/third_party/zstd/doc/images/cdict_v136.png deleted file mode 100644 index 4a6d45620..000000000 Binary files a/third_party/zstd/doc/images/cdict_v136.png and /dev/null differ diff --git a/third_party/zstd/doc/images/dict-cr.png b/third_party/zstd/doc/images/dict-cr.png deleted file mode 100644 index 6da34da46..000000000 Binary files a/third_party/zstd/doc/images/dict-cr.png and /dev/null differ diff --git a/third_party/zstd/doc/images/dict-cs.png b/third_party/zstd/doc/images/dict-cs.png deleted file mode 100644 index a0d8d2505..000000000 Binary files a/third_party/zstd/doc/images/dict-cs.png and /dev/null differ diff --git a/third_party/zstd/doc/images/dict-ds.png b/third_party/zstd/doc/images/dict-ds.png deleted file mode 100644 index 5b9c360c9..000000000 Binary files a/third_party/zstd/doc/images/dict-ds.png and /dev/null differ diff --git a/third_party/zstd/doc/images/zstd_cdict_v1_3_5.png b/third_party/zstd/doc/images/zstd_cdict_v1_3_5.png deleted file mode 100644 index cce67c83a..000000000 Binary files a/third_party/zstd/doc/images/zstd_cdict_v1_3_5.png and /dev/null differ diff --git a/third_party/zstd/doc/images/zstd_logo86.png b/third_party/zstd/doc/images/zstd_logo86.png deleted file mode 100644 index 8abefe21b..000000000 Binary files a/third_party/zstd/doc/images/zstd_logo86.png and /dev/null differ diff --git a/third_party/zstd/doc/zstd_compression_format.md b/third_party/zstd/doc/zstd_compression_format.md deleted file mode 100644 index cd7308de1..000000000 --- a/third_party/zstd/doc/zstd_compression_format.md +++ /dev/null @@ -1,1725 +0,0 @@ -Zstandard Compression Format -============================ - -### Notices - -Copyright (c) Meta Platforms, Inc. and affiliates. - -Permission is granted to copy and distribute this document -for any purpose and without charge, -including translations into other languages -and incorporation into compilations, -provided that the copyright notice and this notice are preserved, -and that any substantive changes or deletions from the original -are clearly marked. -Distribution of this document is unlimited. - -### Version - -0.4.0 (2023-06-05) - - -Introduction ------------- - -The purpose of this document is to define a lossless compressed data format, -that is independent of CPU type, operating system, -file system and character set, suitable for -file compression, pipe and streaming compression, -using the [Zstandard algorithm](https://facebook.github.io/zstd/). -The text of the specification assumes a basic background in programming -at the level of bits and other primitive data representations. - -The data can be produced or consumed, -even for an arbitrarily long sequentially presented input data stream, -using only an a priori bounded amount of intermediate storage, -and hence can be used in data communications. -The format uses the Zstandard compression method, -and optional [xxHash-64 checksum method](https://cyan4973.github.io/xxHash/), -for detection of data corruption. - -The data format defined by this specification -does not attempt to allow random access to compressed data. - -Unless otherwise indicated below, -a compliant compressor must produce data sets -that conform to the specifications presented here. -It doesn’t need to support all options though. - -A compliant decompressor must be able to decompress -at least one working set of parameters -that conforms to the specifications presented here. -It may also ignore informative fields, such as checksum. -Whenever it does not support a parameter defined in the compressed stream, -it must produce a non-ambiguous error code and associated error message -explaining which parameter is unsupported. - -This specification is intended for use by implementers of software -to compress data into Zstandard format and/or decompress data from Zstandard format. -The Zstandard format is supported by an open source reference implementation, -written in portable C, and available at : https://github.com/facebook/zstd . - - -### Overall conventions -In this document: -- square brackets i.e. `[` and `]` are used to indicate optional fields or parameters. -- the naming convention for identifiers is `Mixed_Case_With_Underscores` - -### Definitions -Content compressed by Zstandard is transformed into a Zstandard __frame__. -Multiple frames can be appended into a single file or stream. -A frame is completely independent, has a defined beginning and end, -and a set of parameters which tells the decoder how to decompress it. - -A frame encapsulates one or multiple __blocks__. -Each block contains arbitrary content, which is described by its header, -and has a guaranteed maximum content size, which depends on frame parameters. -Unlike frames, each block depends on previous blocks for proper decoding. -However, each block can be decompressed without waiting for its successor, -allowing streaming operations. - -Overview ---------- -- [Frames](#frames) - - [Zstandard frames](#zstandard-frames) - - [Blocks](#blocks) - - [Literals Section](#literals-section) - - [Sequences Section](#sequences-section) - - [Sequence Execution](#sequence-execution) - - [Skippable frames](#skippable-frames) -- [Entropy Encoding](#entropy-encoding) - - [FSE](#fse) - - [Huffman Coding](#huffman-coding) -- [Dictionary Format](#dictionary-format) - -Frames ------- -Zstandard compressed data is made of one or more __frames__. -Each frame is independent and can be decompressed independently of other frames. -The decompressed content of multiple concatenated frames is the concatenation of -each frame decompressed content. - -There are two frame formats defined by Zstandard: - Zstandard frames and Skippable frames. -Zstandard frames contain compressed data, while -skippable frames contain custom user metadata. - -## Zstandard frames -The structure of a single Zstandard frame is following: - -| `Magic_Number` | `Frame_Header` |`Data_Block`| [More data blocks] | [`Content_Checksum`] | -|:--------------:|:--------------:|:----------:| ------------------ |:--------------------:| -| 4 bytes | 2-14 bytes | n bytes | | 0-4 bytes | - -__`Magic_Number`__ - -4 Bytes, __little-endian__ format. -Value : 0xFD2FB528 -Note: This value was selected to be less probable to find at the beginning of some random file. -It avoids trivial patterns (0x00, 0xFF, repeated bytes, increasing bytes, etc.), -contains byte values outside of ASCII range, -and doesn't map into UTF8 space. -It reduces the chances that a text file represent this value by accident. - -__`Frame_Header`__ - -2 to 14 Bytes, detailed in [`Frame_Header`](#frame_header). - -__`Data_Block`__ - -Detailed in [`Blocks`](#blocks). -That’s where compressed data is stored. - -__`Content_Checksum`__ - -An optional 32-bit checksum, only present if `Content_Checksum_flag` is set. -The content checksum is the result -of [xxh64() hash function](https://cyan4973.github.io/xxHash/) -digesting the original (decoded) data as input, and a seed of zero. -The low 4 bytes of the checksum are stored in __little-endian__ format. - -### `Frame_Header` - -The `Frame_Header` has a variable size, with a minimum of 2 bytes, -and up to 14 bytes depending on optional parameters. -The structure of `Frame_Header` is following: - -| `Frame_Header_Descriptor` | [`Window_Descriptor`] | [`Dictionary_ID`] | [`Frame_Content_Size`] | -| ------------------------- | --------------------- | ----------------- | ---------------------- | -| 1 byte | 0-1 byte | 0-4 bytes | 0-8 bytes | - -#### `Frame_Header_Descriptor` - -The first header's byte is called the `Frame_Header_Descriptor`. -It describes which other fields are present. -Decoding this byte is enough to tell the size of `Frame_Header`. - -| Bit number | Field name | -| ---------- | ---------- | -| 7-6 | `Frame_Content_Size_flag` | -| 5 | `Single_Segment_flag` | -| 4 | `Unused_bit` | -| 3 | `Reserved_bit` | -| 2 | `Content_Checksum_flag` | -| 1-0 | `Dictionary_ID_flag` | - -In this table, bit 7 is the highest bit, while bit 0 is the lowest one. - -__`Frame_Content_Size_flag`__ - -This is a 2-bits flag (`= Frame_Header_Descriptor >> 6`), -specifying if `Frame_Content_Size` (the decompressed data size) -is provided within the header. -`Flag_Value` provides `FCS_Field_Size`, -which is the number of bytes used by `Frame_Content_Size` -according to the following table: - -| `Flag_Value` | 0 | 1 | 2 | 3 | -| -------------- | ------ | --- | --- | --- | -|`FCS_Field_Size`| 0 or 1 | 2 | 4 | 8 | - -When `Flag_Value` is `0`, `FCS_Field_Size` depends on `Single_Segment_flag` : -if `Single_Segment_flag` is set, `FCS_Field_Size` is 1. -Otherwise, `FCS_Field_Size` is 0 : `Frame_Content_Size` is not provided. - -__`Single_Segment_flag`__ - -If this flag is set, -data must be regenerated within a single continuous memory segment. - -In this case, `Window_Descriptor` byte is skipped, -but `Frame_Content_Size` is necessarily present. -As a consequence, the decoder must allocate a memory segment -of size equal or larger than `Frame_Content_Size`. - -In order to preserve the decoder from unreasonable memory requirements, -a decoder is allowed to reject a compressed frame -which requests a memory size beyond decoder's authorized range. - -For broader compatibility, decoders are recommended to support -memory sizes of at least 8 MB. -This is only a recommendation, -each decoder is free to support higher or lower limits, -depending on local limitations. - -__`Unused_bit`__ - -A decoder compliant with this specification version shall not interpret this bit. -It might be used in any future version, -to signal a property which is transparent to properly decode the frame. -An encoder compliant with this specification version must set this bit to zero. - -__`Reserved_bit`__ - -This bit is reserved for some future feature. -Its value _must be zero_. -A decoder compliant with this specification version must ensure it is not set. -This bit may be used in a future revision, -to signal a feature that must be interpreted to decode the frame correctly. - -__`Content_Checksum_flag`__ - -If this flag is set, a 32-bits `Content_Checksum` will be present at frame's end. -See `Content_Checksum` paragraph. - -__`Dictionary_ID_flag`__ - -This is a 2-bits flag (`= FHD & 3`), -telling if a dictionary ID is provided within the header. -It also specifies the size of this field as `DID_Field_Size`. - -|`Flag_Value` | 0 | 1 | 2 | 3 | -| -------------- | --- | --- | --- | --- | -|`DID_Field_Size`| 0 | 1 | 2 | 4 | - -#### `Window_Descriptor` - -Provides guarantees on minimum memory buffer required to decompress a frame. -This information is important for decoders to allocate enough memory. - -The `Window_Descriptor` byte is optional. -When `Single_Segment_flag` is set, `Window_Descriptor` is not present. -In this case, `Window_Size` is `Frame_Content_Size`, -which can be any value from 0 to 2^64-1 bytes (16 ExaBytes). - -| Bit numbers | 7-3 | 2-0 | -| ----------- | ---------- | ---------- | -| Field name | `Exponent` | `Mantissa` | - -The minimum memory buffer size is called `Window_Size`. -It is described by the following formulas : -``` -windowLog = 10 + Exponent; -windowBase = 1 << windowLog; -windowAdd = (windowBase / 8) * Mantissa; -Window_Size = windowBase + windowAdd; -``` -The minimum `Window_Size` is 1 KB. -The maximum `Window_Size` is `(1<<41) + 7*(1<<38)` bytes, which is 3.75 TB. - -In general, larger `Window_Size` tend to improve compression ratio, -but at the cost of memory usage. - -To properly decode compressed data, -a decoder will need to allocate a buffer of at least `Window_Size` bytes. - -In order to preserve decoder from unreasonable memory requirements, -a decoder is allowed to reject a compressed frame -which requests a memory size beyond decoder's authorized range. - -For improved interoperability, -it's recommended for decoders to support `Window_Size` of up to 8 MB, -and it's recommended for encoders to not generate frame requiring `Window_Size` larger than 8 MB. -It's merely a recommendation though, -decoders are free to support larger or lower limits, -depending on local limitations. - -#### `Dictionary_ID` - -This is a variable size field, which contains -the ID of the dictionary required to properly decode the frame. -`Dictionary_ID` field is optional. When it's not present, -it's up to the decoder to know which dictionary to use. - -`Dictionary_ID` field size is provided by `DID_Field_Size`. -`DID_Field_Size` is directly derived from value of `Dictionary_ID_flag`. -1 byte can represent an ID 0-255. -2 bytes can represent an ID 0-65535. -4 bytes can represent an ID 0-4294967295. -Format is __little-endian__. - -It's allowed to represent a small ID (for example `13`) -with a large 4-bytes dictionary ID, even if it is less efficient. - -A value of `0` has same meaning as no `Dictionary_ID`, -in which case the frame may or may not need a dictionary to be decoded, -and the ID of such a dictionary is not specified. -The decoder must know this information by other means. - -#### `Frame_Content_Size` - -This is the original (uncompressed) size. This information is optional. -`Frame_Content_Size` uses a variable number of bytes, provided by `FCS_Field_Size`. -`FCS_Field_Size` is provided by the value of `Frame_Content_Size_flag`. -`FCS_Field_Size` can be equal to 0 (not present), 1, 2, 4 or 8 bytes. - -| `FCS_Field_Size` | Range | -| ---------------- | ---------- | -| 0 | unknown | -| 1 | 0 - 255 | -| 2 | 256 - 65791| -| 4 | 0 - 2^32-1 | -| 8 | 0 - 2^64-1 | - -`Frame_Content_Size` format is __little-endian__. -When `FCS_Field_Size` is 1, 4 or 8 bytes, the value is read directly. -When `FCS_Field_Size` is 2, _the offset of 256 is added_. -It's allowed to represent a small size (for example `18`) using any compatible variant. - - -Blocks -------- - -After `Magic_Number` and `Frame_Header`, there are some number of blocks. -Each frame must have at least one block, -but there is no upper limit on the number of blocks per frame. - -The structure of a block is as follows: - -| `Block_Header` | `Block_Content` | -|:--------------:|:---------------:| -| 3 bytes | n bytes | - -__`Block_Header`__ - -`Block_Header` uses 3 bytes, written using __little-endian__ convention. -It contains 3 fields : - -| `Last_Block` | `Block_Type` | `Block_Size` | -|:------------:|:------------:|:------------:| -| bit 0 | bits 1-2 | bits 3-23 | - -__`Last_Block`__ - -The lowest bit signals if this block is the last one. -The frame will end after this last block. -It may be followed by an optional `Content_Checksum` -(see [Zstandard Frames](#zstandard-frames)). - -__`Block_Type`__ - -The next 2 bits represent the `Block_Type`. -`Block_Type` influences the meaning of `Block_Size`. -There are 4 block types : - -| Value | 0 | 1 | 2 | 3 | -| ------------ | ----------- | ----------- | ------------------ | --------- | -| `Block_Type` | `Raw_Block` | `RLE_Block` | `Compressed_Block` | `Reserved`| - -- `Raw_Block` - this is an uncompressed block. - `Block_Content` contains `Block_Size` bytes. - -- `RLE_Block` - this is a single byte, repeated `Block_Size` times. - `Block_Content` consists of a single byte. - On the decompression side, this byte must be repeated `Block_Size` times. - -- `Compressed_Block` - this is a [Zstandard compressed block](#compressed-blocks), - explained later on. - `Block_Size` is the length of `Block_Content`, the compressed data. - The decompressed size is not known, - but its maximum possible value is guaranteed (see below) - -- `Reserved` - this is not a block. - This value cannot be used with current version of this specification. - If such a value is present, it is considered corrupted data. - -__`Block_Size`__ - -The upper 21 bits of `Block_Header` represent the `Block_Size`. - -When `Block_Type` is `Compressed_Block` or `Raw_Block`, -`Block_Size` is the size of `Block_Content` (hence excluding `Block_Header`). - -When `Block_Type` is `RLE_Block`, since `Block_Content`’s size is always 1, -`Block_Size` represents the number of times this byte must be repeated. - -`Block_Size` is limited by `Block_Maximum_Size` (see below). - -__`Block_Content`__ and __`Block_Maximum_Size`__ - -The size of `Block_Content` is limited by `Block_Maximum_Size`, -which is the smallest of: -- `Window_Size` -- 128 KB - -`Block_Maximum_Size` is constant for a given frame. -This maximum is applicable to both the decompressed size -and the compressed size of any block in the frame. - -The reasoning for this limit is that a decoder can read this information -at the beginning of a frame and use it to allocate buffers. -The guarantees on the size of blocks ensure that -the buffers will be large enough for any following block of the valid frame. - - -Compressed Blocks ------------------ -To decompress a compressed block, the compressed size must be provided -from `Block_Size` field within `Block_Header`. - -A compressed block consists of 2 sections : -- [Literals Section](#literals-section) -- [Sequences Section](#sequences-section) - -The results of the two sections are then combined to produce the decompressed -data in [Sequence Execution](#sequence-execution) - -#### Prerequisites -To decode a compressed block, the following elements are necessary : -- Previous decoded data, up to a distance of `Window_Size`, - or beginning of the Frame, whichever is smaller. -- List of "recent offsets" from previous `Compressed_Block`. -- The previous Huffman tree, required by `Treeless_Literals_Block` type -- Previous FSE decoding tables, required by `Repeat_Mode` - for each symbol type (literals lengths, match lengths, offsets) - -Note that decoding tables aren't always from the previous `Compressed_Block`. - -- Every decoding table can come from a dictionary. -- The Huffman tree comes from the previous `Compressed_Literals_Block`. - -Literals Section ----------------- -All literals are regrouped in the first part of the block. -They can be decoded first, and then copied during [Sequence Execution], -or they can be decoded on the flow during [Sequence Execution]. - -Literals can be stored uncompressed or compressed using Huffman prefix codes. -When compressed, a tree description may optionally be present, -followed by 1 or 4 streams. - -| `Literals_Section_Header` | [`Huffman_Tree_Description`] | [jumpTable] | Stream1 | [Stream2] | [Stream3] | [Stream4] | -| ------------------------- | ---------------------------- | ----------- | ------- | --------- | --------- | --------- | - - -### `Literals_Section_Header` - -Header is in charge of describing how literals are packed. -It's a byte-aligned variable-size bitfield, ranging from 1 to 5 bytes, -using __little-endian__ convention. - -| `Literals_Block_Type` | `Size_Format` | `Regenerated_Size` | [`Compressed_Size`] | -| --------------------- | ------------- | ------------------ | ------------------- | -| 2 bits | 1 - 2 bits | 5 - 20 bits | 0 - 18 bits | - -In this representation, bits on the left are the lowest bits. - -__`Literals_Block_Type`__ - -This field uses 2 lowest bits of first byte, describing 4 different block types : - -| `Literals_Block_Type` | Value | -| --------------------------- | ----- | -| `Raw_Literals_Block` | 0 | -| `RLE_Literals_Block` | 1 | -| `Compressed_Literals_Block` | 2 | -| `Treeless_Literals_Block` | 3 | - -- `Raw_Literals_Block` - Literals are stored uncompressed. -- `RLE_Literals_Block` - Literals consist of a single byte value - repeated `Regenerated_Size` times. -- `Compressed_Literals_Block` - This is a standard Huffman-compressed block, - starting with a Huffman tree description. - In this mode, there are at least 2 different literals represented in the Huffman tree description. - See details below. -- `Treeless_Literals_Block` - This is a Huffman-compressed block, - using Huffman tree _from previous Huffman-compressed literals block_. - `Huffman_Tree_Description` will be skipped. - Note: If this mode is triggered without any previous Huffman-table in the frame - (or [dictionary](#dictionary-format)), this should be treated as data corruption. - -__`Size_Format`__ - -`Size_Format` is divided into 2 families : - -- For `Raw_Literals_Block` and `RLE_Literals_Block`, - it's only necessary to decode `Regenerated_Size`. - There is no `Compressed_Size` field. -- For `Compressed_Block` and `Treeless_Literals_Block`, - it's required to decode both `Compressed_Size` - and `Regenerated_Size` (the decompressed size). - It's also necessary to decode the number of streams (1 or 4). - -For values spanning several bytes, convention is __little-endian__. - -__`Size_Format` for `Raw_Literals_Block` and `RLE_Literals_Block`__ : - -`Size_Format` uses 1 _or_ 2 bits. -Its value is : `Size_Format = (Literals_Section_Header[0]>>2) & 3` - -- `Size_Format` == 00 or 10 : `Size_Format` uses 1 bit. - `Regenerated_Size` uses 5 bits (0-31). - `Literals_Section_Header` uses 1 byte. - `Regenerated_Size = Literals_Section_Header[0]>>3` -- `Size_Format` == 01 : `Size_Format` uses 2 bits. - `Regenerated_Size` uses 12 bits (0-4095). - `Literals_Section_Header` uses 2 bytes. - `Regenerated_Size = (Literals_Section_Header[0]>>4) + (Literals_Section_Header[1]<<4)` -- `Size_Format` == 11 : `Size_Format` uses 2 bits. - `Regenerated_Size` uses 20 bits (0-1048575). - `Literals_Section_Header` uses 3 bytes. - `Regenerated_Size = (Literals_Section_Header[0]>>4) + (Literals_Section_Header[1]<<4) + (Literals_Section_Header[2]<<12)` - -Only Stream1 is present for these cases. -Note : it's allowed to represent a short value (for example `27`) -using a long format, even if it's less efficient. - -__`Size_Format` for `Compressed_Literals_Block` and `Treeless_Literals_Block`__ : - -`Size_Format` always uses 2 bits. - -- `Size_Format` == 00 : _A single stream_. - Both `Regenerated_Size` and `Compressed_Size` use 10 bits (0-1023). - `Literals_Section_Header` uses 3 bytes. -- `Size_Format` == 01 : 4 streams. - Both `Regenerated_Size` and `Compressed_Size` use 10 bits (6-1023). - `Literals_Section_Header` uses 3 bytes. -- `Size_Format` == 10 : 4 streams. - Both `Regenerated_Size` and `Compressed_Size` use 14 bits (6-16383). - `Literals_Section_Header` uses 4 bytes. -- `Size_Format` == 11 : 4 streams. - Both `Regenerated_Size` and `Compressed_Size` use 18 bits (6-262143). - `Literals_Section_Header` uses 5 bytes. - -Both `Compressed_Size` and `Regenerated_Size` fields follow __little-endian__ convention. -Note: `Compressed_Size` __includes__ the size of the Huffman Tree description -_when_ it is present. -Note 2: `Compressed_Size` can never be `==0`. -Even in single-stream scenario, assuming an empty content, it must be `>=1`, -since it contains at least the final end bit flag. -In 4-streams scenario, a valid `Compressed_Size` is necessarily `>= 10` -(6 bytes for the jump table, + 4x1 bytes for the 4 streams). - -4 streams is faster than 1 stream in decompression speed, -by exploiting instruction level parallelism. -But it's also more expensive, -costing on average ~7.3 bytes more than the 1 stream mode, mostly from the jump table. - -In general, use the 4 streams mode when there are more literals to decode, -to favor higher decompression speeds. -Note that beyond >1KB of literals, the 4 streams mode is compulsory. - -Note that a minimum of 6 bytes is required for the 4 streams mode. -That's a technical minimum, but it's not recommended to employ the 4 streams mode -for such a small quantity, that would be wasteful. -A more practical lower bound would be around ~256 bytes. - -#### Raw Literals Block -The data in Stream1 is `Regenerated_Size` bytes long, -it contains the raw literals data to be used during [Sequence Execution]. - -#### RLE Literals Block -Stream1 consists of a single byte which should be repeated `Regenerated_Size` times -to generate the decoded literals. - -#### Compressed Literals Block and Treeless Literals Block -Both of these modes contain Huffman encoded data. - -For `Treeless_Literals_Block`, -the Huffman table comes from previously compressed literals block, -or from a dictionary. - - -### `Huffman_Tree_Description` -This section is only present when `Literals_Block_Type` type is `Compressed_Literals_Block` (`2`). -The tree describes the weights of all literals symbols that can be present in the literals block, at least 2 and up to 256. -The format of the Huffman tree description can be found at [Huffman Tree description](#huffman-tree-description). -The size of `Huffman_Tree_Description` is determined during decoding process, -it must be used to determine where streams begin. -`Total_Streams_Size = Compressed_Size - Huffman_Tree_Description_Size`. - - -### Jump Table -The Jump Table is only present when there are 4 Huffman-coded streams. - -Reminder : Huffman compressed data consists of either 1 or 4 streams. - -If only one stream is present, it is a single bitstream occupying the entire -remaining portion of the literals block, encoded as described in -[Huffman-Coded Streams](#huffman-coded-streams). - -If there are four streams, `Literals_Section_Header` only provided -enough information to know the decompressed and compressed sizes -of all four streams _combined_. -The decompressed size of _each_ stream is equal to `(Regenerated_Size+3)/4`, -except for the last stream which may be up to 3 bytes smaller, -to reach a total decompressed size as specified in `Regenerated_Size`. - -The compressed size of each stream is provided explicitly in the Jump Table. -Jump Table is 6 bytes long, and consists of three 2-byte __little-endian__ fields, -describing the compressed sizes of the first three streams. -`Stream4_Size` is computed from `Total_Streams_Size` minus sizes of other streams: - -`Stream4_Size = Total_Streams_Size - 6 - Stream1_Size - Stream2_Size - Stream3_Size`. - -`Stream4_Size` is necessarily `>= 1`. Therefore, -if `Total_Streams_Size < Stream1_Size + Stream2_Size + Stream3_Size + 6 + 1`, -data is considered corrupted. - -Each of these 4 bitstreams is then decoded independently as a Huffman-Coded stream, -as described in [Huffman-Coded Streams](#huffman-coded-streams) - - -Sequences Section ------------------ -A compressed block is a succession of _sequences_ . -A sequence is a literal copy command, followed by a match copy command. -A literal copy command specifies a length. -It is the number of bytes to be copied (or extracted) from the Literals Section. -A match copy command specifies an offset and a length. - -When all _sequences_ are decoded, -if there are literals left in the _literals section_, -these bytes are added at the end of the block. - -This is described in more detail in [Sequence Execution](#sequence-execution). - -The `Sequences_Section` regroup all symbols required to decode commands. -There are 3 symbol types : literals lengths, offsets and match lengths. -They are encoded together, interleaved, in a single _bitstream_. - -The `Sequences_Section` starts by a header, -followed by optional probability tables for each symbol type, -followed by the bitstream. - -| `Sequences_Section_Header` | [`Literals_Length_Table`] | [`Offset_Table`] | [`Match_Length_Table`] | bitStream | -| -------------------------- | ------------------------- | ---------------- | ---------------------- | --------- | - -To decode the `Sequences_Section`, it's required to know its size. -Its size is deduced from the size of `Literals_Section`: -`Sequences_Section_Size = Block_Size - Literals_Section_Size`. - - -#### `Sequences_Section_Header` - -Consists of 2 items: -- `Number_of_Sequences` -- Symbol compression modes - -__`Number_of_Sequences`__ - -This is a variable size field using between 1 and 3 bytes. -Let's call its first byte `byte0`. -- `if (byte0 < 128)` : `Number_of_Sequences = byte0` . Uses 1 byte. -- `if (byte0 < 255)` : `Number_of_Sequences = ((byte0 - 0x80) << 8) + byte1`. Uses 2 bytes. - Note that the 2 bytes format fully overlaps the 1 byte format. -- `if (byte0 == 255)`: `Number_of_Sequences = byte1 + (byte2<<8) + 0x7F00`. Uses 3 bytes. - -`if (Number_of_Sequences == 0)` : there are no sequences. - The sequence section stops immediately, - FSE tables used in `Repeat_Mode` aren't updated. - Block's decompressed content is defined solely by the Literals Section content. - -__Symbol compression modes__ - -This is a single byte, defining the compression mode of each symbol type. - -|Bit number| 7-6 | 5-4 | 3-2 | 1-0 | -| -------- | ----------------------- | -------------- | -------------------- | ---------- | -|Field name| `Literals_Lengths_Mode` | `Offsets_Mode` | `Match_Lengths_Mode` | `Reserved` | - -The last field, `Reserved`, must be all-zeroes. - -`Literals_Lengths_Mode`, `Offsets_Mode` and `Match_Lengths_Mode` define the `Compression_Mode` of -literals lengths, offsets, and match lengths symbols respectively. - -They follow the same enumeration : - -| Value | 0 | 1 | 2 | 3 | -| ------------------ | ----------------- | ---------- | --------------------- | ------------- | -| `Compression_Mode` | `Predefined_Mode` | `RLE_Mode` | `FSE_Compressed_Mode` | `Repeat_Mode` | - -- `Predefined_Mode` : A predefined FSE distribution table is used, defined in - [default distributions](#default-distributions). - No distribution table will be present. -- `RLE_Mode` : The table description consists of a single byte, which contains the symbol's value. - This symbol will be used for all sequences. -- `FSE_Compressed_Mode` : standard FSE compression. - A distribution table will be present. - The format of this distribution table is described in [FSE Table Description](#fse-table-description). - Note that the maximum allowed accuracy log for literals length and match length tables is 9, - and the maximum accuracy log for the offsets table is 8. - `FSE_Compressed_Mode` must not be used when only one symbol is present, - `RLE_Mode` should be used instead (although any other mode will work). -- `Repeat_Mode` : The table used in the previous `Compressed_Block` with `Number_of_Sequences > 0` will be used again, - or if this is the first block, table in the dictionary will be used. - Note that this includes `RLE_mode`, so if `Repeat_Mode` follows `RLE_Mode`, the same symbol will be repeated. - It also includes `Predefined_Mode`, in which case `Repeat_Mode` will have same outcome as `Predefined_Mode`. - No distribution table will be present. - If this mode is used without any previous sequence table in the frame - (nor [dictionary](#dictionary-format)) to repeat, this should be treated as corruption. - -#### The codes for literals lengths, match lengths, and offsets. - -Each symbol is a _code_ in its own context, -which specifies `Baseline` and `Number_of_Bits` to add. -_Codes_ are FSE compressed, -and interleaved with raw additional bits in the same bitstream. - -##### Literals length codes - -Literals length codes are values ranging from `0` to `35` included. -They define lengths from 0 to 131071 bytes. -The literals length is equal to the decoded `Baseline` plus -the result of reading `Number_of_Bits` bits from the bitstream, -as a __little-endian__ value. - -| `Literals_Length_Code` | 0-15 | -| ---------------------- | ---------------------- | -| length | `Literals_Length_Code` | -| `Number_of_Bits` | 0 | - -| `Literals_Length_Code` | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -| ---------------------- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | -| `Baseline` | 16 | 18 | 20 | 22 | 24 | 28 | 32 | 40 | -| `Number_of_Bits` | 1 | 1 | 1 | 1 | 2 | 2 | 3 | 3 | - -| `Literals_Length_Code` | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -| ---------------------- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | -| `Baseline` | 48 | 64 | 128 | 256 | 512 | 1024 | 2048 | 4096 | -| `Number_of_Bits` | 4 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | - -| `Literals_Length_Code` | 32 | 33 | 34 | 35 | -| ---------------------- | ---- | ---- | ---- | ---- | -| `Baseline` | 8192 |16384 |32768 |65536 | -| `Number_of_Bits` | 13 | 14 | 15 | 16 | - - -##### Match length codes - -Match length codes are values ranging from `0` to `52` included. -They define lengths from 3 to 131074 bytes. -The match length is equal to the decoded `Baseline` plus -the result of reading `Number_of_Bits` bits from the bitstream, -as a __little-endian__ value. - -| `Match_Length_Code` | 0-31 | -| ------------------- | ----------------------- | -| value | `Match_Length_Code` + 3 | -| `Number_of_Bits` | 0 | - -| `Match_Length_Code` | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -| ------------------- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | -| `Baseline` | 35 | 37 | 39 | 41 | 43 | 47 | 51 | 59 | -| `Number_of_Bits` | 1 | 1 | 1 | 1 | 2 | 2 | 3 | 3 | - -| `Match_Length_Code` | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -| ------------------- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | -| `Baseline` | 67 | 83 | 99 | 131 | 259 | 515 | 1027 | 2051 | -| `Number_of_Bits` | 4 | 4 | 5 | 7 | 8 | 9 | 10 | 11 | - -| `Match_Length_Code` | 48 | 49 | 50 | 51 | 52 | -| ------------------- | ---- | ---- | ---- | ---- | ---- | -| `Baseline` | 4099 | 8195 |16387 |32771 |65539 | -| `Number_of_Bits` | 12 | 13 | 14 | 15 | 16 | - -##### Offset codes - -Offset codes are values ranging from `0` to `N`. - -A decoder is free to limit its maximum `N` supported. -Recommendation is to support at least up to `22`. -For information, at the time of this writing. -the reference decoder supports a maximum `N` value of `31`. - -An offset code is also the number of additional bits to read in __little-endian__ fashion, -and can be translated into an `Offset_Value` using the following formulas : - -``` -Offset_Value = (1 << offsetCode) + readNBits(offsetCode); -if (Offset_Value > 3) offset = Offset_Value - 3; -``` -It means that maximum `Offset_Value` is `(2^(N+1))-1` -supporting back-reference distances up to `(2^(N+1))-4`, -but is limited by [maximum back-reference distance](#window_descriptor). - -`Offset_Value` from 1 to 3 are special : they define "repeat codes". -This is described in more detail in [Repeat Offsets](#repeat-offsets). - -#### Decoding Sequences -FSE bitstreams are read in reverse direction than written. In zstd, -the compressor writes bits forward into a block and the decompressor -must read the bitstream _backwards_. - -To find the start of the bitstream it is therefore necessary to -know the offset of the last byte of the block which can be found -by counting `Block_Size` bytes after the block header. - -After writing the last bit containing information, the compressor -writes a single `1`-bit and then fills the byte with 0-7 `0` bits of -padding. The last byte of the compressed bitstream cannot be `0` for -that reason. - -When decompressing, the last byte containing the padding is the first -byte to read. The decompressor needs to skip 0-7 initial `0`-bits and -the first `1`-bit it occurs. Afterwards, the useful part of the bitstream -begins. - -FSE decoding requires a 'state' to be carried from symbol to symbol. -For more explanation on FSE decoding, see the [FSE section](#fse). - -For sequence decoding, a separate state keeps track of each -literal lengths, offsets, and match lengths symbols. -Some FSE primitives are also used. -For more details on the operation of these primitives, see the [FSE section](#fse). - -##### Starting states -The bitstream starts with initial FSE state values, -each using the required number of bits in their respective _accuracy_, -decoded previously from their normalized distribution. - -It starts by `Literals_Length_State`, -followed by `Offset_State`, -and finally `Match_Length_State`. - -Reminder : always keep in mind that all values are read _backward_, -so the 'start' of the bitstream is at the highest position in memory, -immediately before the last `1`-bit for padding. - -After decoding the starting states, a single sequence is decoded -`Number_Of_Sequences` times. -These sequences are decoded in order from first to last. -Since the compressor writes the bitstream in the forward direction, -this means the compressor must encode the sequences starting with the last -one and ending with the first. - -##### Decoding a sequence -For each of the symbol types, the FSE state can be used to determine the appropriate code. -The code then defines the `Baseline` and `Number_of_Bits` to read for each type. -See the [description of the codes] for how to determine these values. - -[description of the codes]: #the-codes-for-literals-lengths-match-lengths-and-offsets - -Decoding starts by reading the `Number_of_Bits` required to decode `Offset`. -It then does the same for `Match_Length`, and then for `Literals_Length`. -This sequence is then used for [sequence execution](#sequence-execution). - -If it is not the last sequence in the block, -the next operation is to update states. -Using the rules pre-calculated in the decoding tables, -`Literals_Length_State` is updated, -followed by `Match_Length_State`, -and then `Offset_State`. -See the [FSE section](#fse) for details on how to update states from the bitstream. - -This operation will be repeated `Number_of_Sequences` times. -At the end, the bitstream shall be entirely consumed, -otherwise the bitstream is considered corrupted. - -#### Default Distributions -If `Predefined_Mode` is selected for a symbol type, -its FSE decoding table is generated from a predefined distribution table defined here. -For details on how to convert this distribution into a decoding table, see the [FSE section]. - -[FSE section]: #from-normalized-distribution-to-decoding-tables - -##### Literals Length -The decoding table uses an accuracy log of 6 bits (64 states). -``` -short literalsLength_defaultDistribution[36] = - { 4, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 2, 1, 1, 1, 1, 1, - -1,-1,-1,-1 }; -``` - -##### Match Length -The decoding table uses an accuracy log of 6 bits (64 states). -``` -short matchLengths_defaultDistribution[53] = - { 1, 4, 3, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,-1,-1, - -1,-1,-1,-1,-1 }; -``` - -##### Offset Codes -The decoding table uses an accuracy log of 5 bits (32 states), -and supports a maximum `N` value of 28, allowing offset values up to 536,870,908 . - -If any sequence in the compressed block requires a larger offset than this, -it's not possible to use the default distribution to represent it. -``` -short offsetCodes_defaultDistribution[29] = - { 1, 1, 1, 1, 1, 1, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1,-1,-1,-1,-1,-1 }; -``` - - -Sequence Execution ------------------- -Once literals and sequences have been decoded, -they are combined to produce the decoded content of a block. - -Each sequence consists of a tuple of (`literals_length`, `offset_value`, `match_length`), -decoded as described in the [Sequences Section](#sequences-section). -To execute a sequence, first copy `literals_length` bytes -from the decoded literals to the output. - -Then `match_length` bytes are copied from previous decoded data. -The offset to copy from is determined by `offset_value`: -if `offset_value > 3`, then the offset is `offset_value - 3`. -If `offset_value` is from 1-3, the offset is a special repeat offset value. -See the [repeat offset](#repeat-offsets) section for how the offset is determined -in this case. - -The offset is defined as from the current position, so an offset of 6 -and a match length of 3 means that 3 bytes should be copied from 6 bytes back. -Note that all offsets leading to previously decoded data -must be smaller than `Window_Size` defined in `Frame_Header_Descriptor`. - -#### Repeat offsets -As seen in [Sequence Execution](#sequence-execution), -the first 3 values define a repeated offset and we will call them -`Repeated_Offset1`, `Repeated_Offset2`, and `Repeated_Offset3`. -They are sorted in recency order, with `Repeated_Offset1` meaning "most recent one". - -If `offset_value == 1`, then the offset used is `Repeated_Offset1`, etc. - -There is an exception though, when current sequence's `literals_length = 0`. -In this case, repeated offsets are shifted by one, -so an `offset_value` of 1 means `Repeated_Offset2`, -an `offset_value` of 2 means `Repeated_Offset3`, -and an `offset_value` of 3 means `Repeated_Offset1 - 1_byte`. - -For the first block, the starting offset history is populated with following values : -`Repeated_Offset1`=1, `Repeated_Offset2`=4, `Repeated_Offset3`=8, -unless a dictionary is used, in which case they come from the dictionary. - -Then each block gets its starting offset history from the ending values of the most recent `Compressed_Block`. -Note that blocks which are not `Compressed_Block` are skipped, they do not contribute to offset history. - -[Offset Codes]: #offset-codes - -###### Offset updates rules - -During the execution of the sequences of a `Compressed_Block`, the -`Repeated_Offsets`' values are kept up to date, so that they always represent -the three most-recently used offsets. In order to achieve that, they are -updated after executing each sequence in the following way: - -When the sequence's `offset_value` does not refer to one of the -`Repeated_Offsets`--when it has value greater than 3, or when it has value 3 -and the sequence's `literals_length` is zero--the `Repeated_Offsets`' values -are shifted back one, and `Repeated_Offset1` takes on the value of the -just-used offset. - -Otherwise, when the sequence's `offset_value` refers to one of the -`Repeated_Offsets`--when it has value 1 or 2, or when it has value 3 and the -sequence's `literals_length` is non-zero--the `Repeated_Offsets` are re-ordered -so that `Repeated_Offset1` takes on the value of the used Repeated_Offset, and -the existing values are pushed back from the first `Repeated_Offset` through to -the `Repeated_Offset` selected by the `offset_value`. This effectively performs -a single-stepped wrapping rotation of the values of these offsets, so that -their order again reflects the recency of their use. - -The following table shows the values of the `Repeated_Offsets` as a series of -sequences are applied to them: - -| `offset_value` | `literals_length` | `Repeated_Offset1` | `Repeated_Offset2` | `Repeated_Offset3` | Comment | -|:--------------:|:-----------------:|:------------------:|:------------------:|:------------------:|:-----------------------:| -| | | 1 | 4 | 8 | starting values | -| 1114 | 11 | 1111 | 1 | 4 | non-repeat | -| 1 | 22 | 1111 | 1 | 4 | repeat 1: no change | -| 2225 | 22 | 2222 | 1111 | 1 | non-repeat | -| 1114 | 111 | 1111 | 2222 | 1111 | non-repeat | -| 3336 | 33 | 3333 | 1111 | 2222 | non-repeat | -| 2 | 22 | 1111 | 3333 | 2222 | repeat 2: swap 1 & 2 | -| 3 | 33 | 2222 | 1111 | 3333 | repeat 3: rotate 3 to 1 | -| 3 | 0 | 2221 | 2222 | 1111 | special case : insert `repeat1 - 1` | -| 1 | 0 | 2222 | 2221 | 1111 | == repeat 2 | - - -Skippable Frames ----------------- - -| `Magic_Number` | `Frame_Size` | `User_Data` | -|:--------------:|:------------:|:-----------:| -| 4 bytes | 4 bytes | n bytes | - -Skippable frames allow the insertion of user-defined metadata -into a flow of concatenated frames. - -Skippable frames defined in this specification are compatible with [LZ4] ones. - -[LZ4]:https://lz4.github.io/lz4/ - -From a compliant decoder perspective, skippable frames need just be skipped, -and their content ignored, resuming decoding after the skippable frame. - -It can be noted that a skippable frame -can be used to watermark a stream of concatenated frames -embedding any kind of tracking information (even just a UUID). -Users wary of such possibility should scan the stream of concatenated frames -in an attempt to detect such frame for analysis or removal. - -__`Magic_Number`__ - -4 Bytes, __little-endian__ format. -Value : 0x184D2A5?, which means any value from 0x184D2A50 to 0x184D2A5F. -All 16 values are valid to identify a skippable frame. -This specification doesn't detail any specific tagging for skippable frames. - -__`Frame_Size`__ - -This is the size, in bytes, of the following `User_Data` -(without including the magic number nor the size field itself). -This field is represented using 4 Bytes, __little-endian__ format, unsigned 32-bits. -This means `User_Data` can’t be bigger than (2^32-1) bytes. - -__`User_Data`__ - -The `User_Data` can be anything. Data will just be skipped by the decoder. - - - -Entropy Encoding ----------------- -Two types of entropy encoding are used by the Zstandard format: -FSE, and Huffman coding. -Huffman is used to compress literals, -while FSE is used for all other symbols -(`Literals_Length_Code`, `Match_Length_Code`, offset codes) -and to compress Huffman headers. - - -FSE ---- -FSE, short for Finite State Entropy, is an entropy codec based on [ANS]. -FSE encoding/decoding involves a state that is carried over between symbols, -so decoding must be done in the opposite direction as encoding. -Therefore, all FSE bitstreams are read from end to beginning. -Note that the order of the bits in the stream is not reversed, -we just read the elements in the reverse order they are written. - -For additional details on FSE, see [Finite State Entropy]. - -[Finite State Entropy]:https://github.com/Cyan4973/FiniteStateEntropy/ - -FSE decoding involves a decoding table which has a power of 2 size, and contain three elements: -`Symbol`, `Num_Bits`, and `Baseline`. -The `log2` of the table size is its `Accuracy_Log`. -An FSE state value represents an index in this table. - -To obtain the initial state value, consume `Accuracy_Log` bits from the stream as a __little-endian__ value. -The next symbol in the stream is the `Symbol` indicated in the table for that state. -To obtain the next state value, -the decoder should consume `Num_Bits` bits from the stream as a __little-endian__ value and add it to `Baseline`. - -[ANS]: https://en.wikipedia.org/wiki/Asymmetric_Numeral_Systems - -### FSE Table Description -To decode FSE streams, it is necessary to construct the decoding table. -The Zstandard format encodes FSE table descriptions as follows: - -An FSE distribution table describes the probabilities of all symbols -from `0` to the last present one (included) -on a normalized scale of `1 << Accuracy_Log` . -Note that there must be two or more symbols with nonzero probability. - -It's a bitstream which is read forward, in __little-endian__ fashion. -It's not necessary to know bitstream exact size, -it will be discovered and reported by the decoding process. - -The bitstream starts by reporting on which scale it operates. -Let's `low4Bits` designate the lowest 4 bits of the first byte : -`Accuracy_Log = low4bits + 5`. - -Then follows each symbol value, from `0` to last present one. -The number of bits used by each field is variable. -It depends on : - -- Remaining probabilities + 1 : - __example__ : - Presuming an `Accuracy_Log` of 8, - and presuming 100 probabilities points have already been distributed, - the decoder may read any value from `0` to `256 - 100 + 1 == 157` (inclusive). - Therefore, it must read `log2sup(157) == 8` bits. - -- Value decoded : small values use 1 less bit : - __example__ : - Presuming values from 0 to 157 (inclusive) are possible, - 255-157 = 98 values are remaining in an 8-bits field. - They are used this way : - first 98 values (hence from 0 to 97) use only 7 bits, - values from 98 to 157 use 8 bits. - This is achieved through this scheme : - - | Value read | Value decoded | Number of bits used | - | ---------- | ------------- | ------------------- | - | 0 - 97 | 0 - 97 | 7 | - | 98 - 127 | 98 - 127 | 8 | - | 128 - 225 | 0 - 97 | 7 | - | 226 - 255 | 128 - 157 | 8 | - -Symbols probabilities are read one by one, in order. - -Probability is obtained from Value decoded by following formula : -`Proba = value - 1` - -It means value `0` becomes negative probability `-1`. -`-1` is a special probability, which means "less than 1". -Its effect on distribution table is described in the [next section]. -For the purpose of calculating total allocated probability points, it counts as one. - -[next section]:#from-normalized-distribution-to-decoding-tables - -When a symbol has a __probability__ of `zero`, -it is followed by a 2-bits repeat flag. -This repeat flag tells how many probabilities of zeroes follow the current one. -It provides a number ranging from 0 to 3. -If it is a 3, another 2-bits repeat flag follows, and so on. - -When last symbol reaches cumulated total of `1 << Accuracy_Log`, -decoding is complete. -If the last symbol makes cumulated total go above `1 << Accuracy_Log`, -distribution is considered corrupted. - -Then the decoder can tell how many bytes were used in this process, -and how many symbols are present. -The bitstream consumes a round number of bytes. -Any remaining bit within the last byte is just unused. - -#### From normalized distribution to decoding tables - -The distribution of normalized probabilities is enough -to create a unique decoding table. - -It follows the following build rule : - -The table has a size of `Table_Size = 1 << Accuracy_Log`. -Each cell describes the symbol decoded, -and instructions to get the next state (`Number_of_Bits` and `Baseline`). - -Symbols are scanned in their natural order for "less than 1" probabilities. -Symbols with this probability are being attributed a single cell, -starting from the end of the table and retreating. -These symbols define a full state reset, reading `Accuracy_Log` bits. - -Then, all remaining symbols, sorted in natural order, are allocated cells. -Starting from symbol `0` (if it exists), and table position `0`, -each symbol gets allocated as many cells as its probability. -Cell allocation is spread, not linear : -each successor position follows this rule : - -``` -position += (tableSize>>1) + (tableSize>>3) + 3; -position &= tableSize-1; -``` - -A position is skipped if already occupied by a "less than 1" probability symbol. -`position` does not reset between symbols, it simply iterates through -each position in the table, switching to the next symbol when enough -states have been allocated to the current one. - -The process guarantees that the table is entirely filled. -Each cell corresponds to a state value, which contains the symbol being decoded. - -To add the `Number_of_Bits` and `Baseline` required to retrieve next state, -it's first necessary to sort all occurrences of each symbol in state order. -Lower states will need 1 more bit than higher ones. -The process is repeated for each symbol. - -__Example__ : -Presuming a symbol has a probability of 5, -it receives 5 cells, corresponding to 5 state values. -These state values are then sorted in natural order. - -Next power of 2 after 5 is 8. -Space of probabilities must be divided into 8 equal parts. -Presuming the `Accuracy_Log` is 7, it defines a space of 128 states. -Divided by 8, each share is 16 large. - -In order to reach 8 shares, 8-5=3 lowest states will count "double", -doubling their shares (32 in width), hence requiring one more bit. - -Baseline is assigned starting from the higher states using fewer bits, -increasing at each state, then resuming at the first state, -each state takes its allocated width from Baseline. - -| state value | 1 | 39 | 77 | 84 | 122 | -| state order | 0 | 1 | 2 | 3 | 4 | -| ---------------- | ----- | ----- | ------ | ---- | ------ | -| width | 32 | 32 | 32 | 16 | 16 | -| `Number_of_Bits` | 5 | 5 | 5 | 4 | 4 | -| range number | 2 | 4 | 6 | 0 | 1 | -| `Baseline` | 32 | 64 | 96 | 0 | 16 | -| range | 32-63 | 64-95 | 96-127 | 0-15 | 16-31 | - -During decoding, the next state value is determined from current state value, -by reading the required `Number_of_Bits`, and adding the specified `Baseline`. - -See [Appendix A] for the results of this process applied to the default distributions. - -[Appendix A]: #appendix-a---decoding-tables-for-predefined-codes - - -Huffman Coding --------------- -Zstandard Huffman-coded streams are read backwards, -similar to the FSE bitstreams. -Therefore, to find the start of the bitstream, it is required to -know the offset of the last byte of the Huffman-coded stream. - -After writing the last bit containing information, the compressor -writes a single `1`-bit and then fills the byte with 0-7 `0` bits of -padding. The last byte of the compressed bitstream cannot be `0` for -that reason. - -When decompressing, the last byte containing the padding is the first -byte to read. The decompressor needs to skip 0-7 initial `0`-bits and -the first `1`-bit it occurs. Afterwards, the useful part of the bitstream -begins. - -The bitstream contains Huffman-coded symbols in __little-endian__ order, -with the codes defined by the method below. - -### Huffman Tree Description - -Prefix coding represents symbols from an a priori known alphabet -by bit sequences (codewords), one codeword for each symbol, -in a manner such that different symbols may be represented -by bit sequences of different lengths, -but a parser can always parse an encoded string -unambiguously symbol-by-symbol. - -Given an alphabet with known symbol frequencies, -the Huffman algorithm allows the construction of an optimal prefix code -using the fewest bits of any possible prefix codes for that alphabet. - -Prefix code must not exceed a maximum code length. -More bits improve accuracy but cost more header size, -and require more memory or more complex decoding operations. -This specification limits maximum code length to 11 bits. - -#### Representation - -All literal values from zero (included) to last present one (excluded) -are represented by `Weight` with values from `0` to `Max_Number_of_Bits`. -Transformation from `Weight` to `Number_of_Bits` follows this formula : -``` -Number_of_Bits = Weight ? (Max_Number_of_Bits + 1 - Weight) : 0 -``` -When a literal value is not present, it receives a `Weight` of 0. -The least frequent symbol receives a `Weight` of 1. -Consequently, the `Weight` 1 is necessarily present. -The most frequent symbol receives a `Weight` anywhere between 1 and 11 (max). -The last symbol's `Weight` is deduced from previously retrieved Weights, -by completing to the nearest power of 2. It's necessarily non 0. -If it's not possible to reach a clean power of 2 with a single `Weight` value, -the Huffman Tree Description is considered invalid. -This final power of 2 gives `Max_Number_of_Bits`, the depth of the current tree. -`Max_Number_of_Bits` must be <= 11, -otherwise the representation is considered corrupted. - -__Example__ : -Let's presume the following Huffman tree must be described : - -| literal value | 0 | 1 | 2 | 3 | 4 | 5 | -| ---------------- | --- | --- | --- | --- | --- | --- | -| `Number_of_Bits` | 1 | 2 | 3 | 0 | 4 | 4 | - -The tree depth is 4, since its longest elements uses 4 bits -(longest elements are the one with smallest frequency). -Literal value `5` will not be listed, as it can be determined from previous values 0-4, -nor will values above `5` as they are all 0. -Values from `0` to `4` will be listed using `Weight` instead of `Number_of_Bits`. -Weight formula is : -``` -Weight = Number_of_Bits ? (Max_Number_of_Bits + 1 - Number_of_Bits) : 0 -``` -It gives the following series of weights : - -| literal value | 0 | 1 | 2 | 3 | 4 | -| ------------- | --- | --- | --- | --- | --- | -| `Weight` | 4 | 3 | 2 | 0 | 1 | - -The decoder will do the inverse operation : -having collected weights of literal symbols from `0` to `4`, -it knows the last literal, `5`, is present with a non-zero `Weight`. -The `Weight` of `5` can be determined by advancing to the next power of 2. -The sum of `2^(Weight-1)` (excluding 0's) is : -`8 + 4 + 2 + 0 + 1 = 15`. -Nearest larger power of 2 value is 16. -Therefore, `Max_Number_of_Bits = 4` and `Weight[5] = log_2(16 - 15) + 1 = 1`. - -#### Huffman Tree header - -This is a single byte value (0-255), -which describes how the series of weights is encoded. - -- if `headerByte` < 128 : - the series of weights is compressed using FSE (see below). - The length of the FSE-compressed series is equal to `headerByte` (0-127). - -- if `headerByte` >= 128 : - + the series of weights uses a direct representation, - where each `Weight` is encoded directly as a 4 bits field (0-15). - + They are encoded forward, 2 weights to a byte, - first weight taking the top four bits and second one taking the bottom four. - * e.g. the following operations could be used to read the weights: - `Weight[0] = (Byte[0] >> 4), Weight[1] = (Byte[0] & 0xf)`, etc. - + The full representation occupies `Ceiling(Number_of_Weights/2)` bytes, - meaning it uses only full bytes even if `Number_of_Weights` is odd. - + `Number_of_Weights = headerByte - 127`. - * Note that maximum `Number_of_Weights` is 255-127 = 128, - therefore, only up to 128 `Weight` can be encoded using direct representation. - * Since the last non-zero `Weight` is _not_ encoded, - this scheme is compatible with alphabet sizes of up to 129 symbols, - hence including literal symbol 128. - * If any literal symbol > 128 has a non-zero `Weight`, - direct representation is not possible. - In such case, it's necessary to use FSE compression. - - -#### Finite State Entropy (FSE) compression of Huffman weights - -In this case, the series of Huffman weights is compressed using FSE compression. -It's a single bitstream with 2 interleaved states, -sharing a single distribution table. - -To decode an FSE bitstream, it is necessary to know its compressed size. -Compressed size is provided by `headerByte`. -It's also necessary to know its _maximum possible_ decompressed size, -which is `255`, since literal values span from `0` to `255`, -and last symbol's `Weight` is not represented. - -An FSE bitstream starts by a header, describing probabilities distribution. -It will create a Decoding Table. -For a list of Huffman weights, the maximum accuracy log is 6 bits. -For more description see the [FSE header description](#fse-table-description) - -The Huffman header compression uses 2 states, -which share the same FSE distribution table. -The first state (`State1`) encodes the even indexed symbols, -and the second (`State2`) encodes the odd indexed symbols. -`State1` is initialized first, and then `State2`, and they take turns -decoding a single symbol and updating their state. -For more details on these FSE operations, see the [FSE section](#fse). - -The number of symbols to decode is determined -by tracking bitStream overflow condition: -If updating state after decoding a symbol would require more bits than -remain in the stream, it is assumed that extra bits are 0. Then, -symbols for each of the final states are decoded and the process is complete. - -#### Conversion from weights to Huffman prefix codes - -All present symbols shall now have a `Weight` value. -It is possible to transform weights into `Number_of_Bits`, using this formula: -``` -Number_of_Bits = (Weight>0) ? Max_Number_of_Bits + 1 - Weight : 0 -``` -Symbols are sorted by `Weight`. -Within same `Weight`, symbols keep natural sequential order. -Symbols with a `Weight` of zero are removed. -Then, starting from lowest `Weight`, prefix codes are distributed in sequential order. - -__Example__ : -Let's presume the following list of weights has been decoded : - -| Literal | 0 | 1 | 2 | 3 | 4 | 5 | -| -------- | --- | --- | --- | --- | --- | --- | -| `Weight` | 4 | 3 | 2 | 0 | 1 | 1 | - -Sorted by weight and then natural sequential order, -it gives the following distribution : - -| Literal | 3 | 4 | 5 | 2 | 1 | 0 | -| ---------------- | --- | --- | --- | --- | --- | ---- | -| `Weight` | 0 | 1 | 1 | 2 | 3 | 4 | -| `Number_of_Bits` | 0 | 4 | 4 | 3 | 2 | 1 | -| prefix codes | N/A | 0000| 0001| 001 | 01 | 1 | - -### Huffman-coded Streams - -Given a Huffman decoding table, -it's possible to decode a Huffman-coded stream. - -Each bitstream must be read _backward_, -that is starting from the end down to the beginning. -Therefore it's necessary to know the size of each bitstream. - -It's also necessary to know exactly which _bit_ is the last one. -This is detected by a final bit flag : -the highest bit of latest byte is a final-bit-flag. -Consequently, a last byte of `0` is not possible. -And the final-bit-flag itself is not part of the useful bitstream. -Hence, the last byte contains between 0 and 7 useful bits. - -Starting from the end, -it's possible to read the bitstream in a __little-endian__ fashion, -keeping track of already used bits. Since the bitstream is encoded in reverse -order, starting from the end read symbols in forward order. - -For example, if the literal sequence "0145" was encoded using above prefix code, -it would be encoded (in reverse order) as: - -|Symbol | 5 | 4 | 1 | 0 | Padding | -|--------|------|------|----|---|---------| -|Encoding|`0000`|`0001`|`01`|`1`| `00001` | - -Resulting in following 2-bytes bitstream : -``` -00010000 00001101 -``` - -Here is an alternative representation with the symbol codes separated by underscore: -``` -0001_0000 00001_1_01 -``` - -Reading highest `Max_Number_of_Bits` bits, -it's possible to compare extracted value to decoding table, -determining the symbol to decode and number of bits to discard. - -The process continues up to reading the required number of symbols per stream. -If a bitstream is not entirely and exactly consumed, -hence reaching exactly its beginning position with _all_ bits consumed, -the decoding process is considered faulty. - - -Dictionary Format ------------------ - -Zstandard is compatible with "raw content" dictionaries, -free of any format restriction, except that they must be at least 8 bytes. -These dictionaries function as if they were just the `Content` part -of a formatted dictionary. - -But dictionaries created by `zstd --train` follow a format, described here. - -__Pre-requisites__ : a dictionary has a size, - defined either by a buffer limit, or a file size. - -| `Magic_Number` | `Dictionary_ID` | `Entropy_Tables` | `Content` | -| -------------- | --------------- | ---------------- | --------- | - -__`Magic_Number`__ : 4 bytes ID, value 0xEC30A437, __little-endian__ format - -__`Dictionary_ID`__ : 4 bytes, stored in __little-endian__ format. - `Dictionary_ID` can be any value, except 0 (which means no `Dictionary_ID`). - It's used by decoders to check if they use the correct dictionary. - -_Reserved ranges :_ -If the dictionary is going to be distributed in a public environment, -the following ranges of `Dictionary_ID` are reserved for some future registrar -and shall not be used : - - - low range : <= 32767 - - high range : >= (2^31) - -Outside of these ranges, any value of `Dictionary_ID` -which is both `>= 32768` and `< (1<<31)` can be used freely, -even in public environment. - - -__`Entropy_Tables`__ : follow the same format as tables in [compressed blocks]. - See the relevant [FSE](#fse-table-description) - and [Huffman](#huffman-tree-description) sections for how to decode these tables. - They are stored in following order : - Huffman tables for literals, FSE table for offsets, - FSE table for match lengths, and FSE table for literals lengths. - These tables populate the Repeat Stats literals mode and - Repeat distribution mode for sequence decoding. - It's finally followed by 3 offset values, populating recent offsets (instead of using `{1,4,8}`), - stored in order, 4-bytes __little-endian__ each, for a total of 12 bytes. - Each recent offset must have a value <= dictionary content size, and cannot equal 0. - -__`Content`__ : The rest of the dictionary is its content. - The content act as a "past" in front of data to compress or decompress, - so it can be referenced in sequence commands. - As long as the amount of data decoded from this frame is less than or - equal to `Window_Size`, sequence commands may specify offsets longer - than the total length of decoded output so far to reference back to the - dictionary, even parts of the dictionary with offsets larger than `Window_Size`. - After the total output has surpassed `Window_Size` however, - this is no longer allowed and the dictionary is no longer accessible. - -[compressed blocks]: #the-format-of-compressed_block - -If a dictionary is provided by an external source, -it should be loaded with great care, its content considered untrusted. - - - -Appendix A - Decoding tables for predefined codes -------------------------------------------------- - -This appendix contains FSE decoding tables -for the predefined literal length, match length, and offset codes. -The tables have been constructed using the algorithm as given above in chapter -"from normalized distribution to decoding tables". -The tables here can be used as examples -to crosscheck that an implementation build its decoding tables correctly. - -#### Literal Length Code: - -| State | Symbol | Number_Of_Bits | Base | -| ----- | ------ | -------------- | ---- | -| 0 | 0 | 4 | 0 | -| 1 | 0 | 4 | 16 | -| 2 | 1 | 5 | 32 | -| 3 | 3 | 5 | 0 | -| 4 | 4 | 5 | 0 | -| 5 | 6 | 5 | 0 | -| 6 | 7 | 5 | 0 | -| 7 | 9 | 5 | 0 | -| 8 | 10 | 5 | 0 | -| 9 | 12 | 5 | 0 | -| 10 | 14 | 6 | 0 | -| 11 | 16 | 5 | 0 | -| 12 | 18 | 5 | 0 | -| 13 | 19 | 5 | 0 | -| 14 | 21 | 5 | 0 | -| 15 | 22 | 5 | 0 | -| 16 | 24 | 5 | 0 | -| 17 | 25 | 5 | 32 | -| 18 | 26 | 5 | 0 | -| 19 | 27 | 6 | 0 | -| 20 | 29 | 6 | 0 | -| 21 | 31 | 6 | 0 | -| 22 | 0 | 4 | 32 | -| 23 | 1 | 4 | 0 | -| 24 | 2 | 5 | 0 | -| 25 | 4 | 5 | 32 | -| 26 | 5 | 5 | 0 | -| 27 | 7 | 5 | 32 | -| 28 | 8 | 5 | 0 | -| 29 | 10 | 5 | 32 | -| 30 | 11 | 5 | 0 | -| 31 | 13 | 6 | 0 | -| 32 | 16 | 5 | 32 | -| 33 | 17 | 5 | 0 | -| 34 | 19 | 5 | 32 | -| 35 | 20 | 5 | 0 | -| 36 | 22 | 5 | 32 | -| 37 | 23 | 5 | 0 | -| 38 | 25 | 4 | 0 | -| 39 | 25 | 4 | 16 | -| 40 | 26 | 5 | 32 | -| 41 | 28 | 6 | 0 | -| 42 | 30 | 6 | 0 | -| 43 | 0 | 4 | 48 | -| 44 | 1 | 4 | 16 | -| 45 | 2 | 5 | 32 | -| 46 | 3 | 5 | 32 | -| 47 | 5 | 5 | 32 | -| 48 | 6 | 5 | 32 | -| 49 | 8 | 5 | 32 | -| 50 | 9 | 5 | 32 | -| 51 | 11 | 5 | 32 | -| 52 | 12 | 5 | 32 | -| 53 | 15 | 6 | 0 | -| 54 | 17 | 5 | 32 | -| 55 | 18 | 5 | 32 | -| 56 | 20 | 5 | 32 | -| 57 | 21 | 5 | 32 | -| 58 | 23 | 5 | 32 | -| 59 | 24 | 5 | 32 | -| 60 | 35 | 6 | 0 | -| 61 | 34 | 6 | 0 | -| 62 | 33 | 6 | 0 | -| 63 | 32 | 6 | 0 | - -#### Match Length Code: - -| State | Symbol | Number_Of_Bits | Base | -| ----- | ------ | -------------- | ---- | -| 0 | 0 | 6 | 0 | -| 1 | 1 | 4 | 0 | -| 2 | 2 | 5 | 32 | -| 3 | 3 | 5 | 0 | -| 4 | 5 | 5 | 0 | -| 5 | 6 | 5 | 0 | -| 6 | 8 | 5 | 0 | -| 7 | 10 | 6 | 0 | -| 8 | 13 | 6 | 0 | -| 9 | 16 | 6 | 0 | -| 10 | 19 | 6 | 0 | -| 11 | 22 | 6 | 0 | -| 12 | 25 | 6 | 0 | -| 13 | 28 | 6 | 0 | -| 14 | 31 | 6 | 0 | -| 15 | 33 | 6 | 0 | -| 16 | 35 | 6 | 0 | -| 17 | 37 | 6 | 0 | -| 18 | 39 | 6 | 0 | -| 19 | 41 | 6 | 0 | -| 20 | 43 | 6 | 0 | -| 21 | 45 | 6 | 0 | -| 22 | 1 | 4 | 16 | -| 23 | 2 | 4 | 0 | -| 24 | 3 | 5 | 32 | -| 25 | 4 | 5 | 0 | -| 26 | 6 | 5 | 32 | -| 27 | 7 | 5 | 0 | -| 28 | 9 | 6 | 0 | -| 29 | 12 | 6 | 0 | -| 30 | 15 | 6 | 0 | -| 31 | 18 | 6 | 0 | -| 32 | 21 | 6 | 0 | -| 33 | 24 | 6 | 0 | -| 34 | 27 | 6 | 0 | -| 35 | 30 | 6 | 0 | -| 36 | 32 | 6 | 0 | -| 37 | 34 | 6 | 0 | -| 38 | 36 | 6 | 0 | -| 39 | 38 | 6 | 0 | -| 40 | 40 | 6 | 0 | -| 41 | 42 | 6 | 0 | -| 42 | 44 | 6 | 0 | -| 43 | 1 | 4 | 32 | -| 44 | 1 | 4 | 48 | -| 45 | 2 | 4 | 16 | -| 46 | 4 | 5 | 32 | -| 47 | 5 | 5 | 32 | -| 48 | 7 | 5 | 32 | -| 49 | 8 | 5 | 32 | -| 50 | 11 | 6 | 0 | -| 51 | 14 | 6 | 0 | -| 52 | 17 | 6 | 0 | -| 53 | 20 | 6 | 0 | -| 54 | 23 | 6 | 0 | -| 55 | 26 | 6 | 0 | -| 56 | 29 | 6 | 0 | -| 57 | 52 | 6 | 0 | -| 58 | 51 | 6 | 0 | -| 59 | 50 | 6 | 0 | -| 60 | 49 | 6 | 0 | -| 61 | 48 | 6 | 0 | -| 62 | 47 | 6 | 0 | -| 63 | 46 | 6 | 0 | - -#### Offset Code: - -| State | Symbol | Number_Of_Bits | Base | -| ----- | ------ | -------------- | ---- | -| 0 | 0 | 5 | 0 | -| 1 | 6 | 4 | 0 | -| 2 | 9 | 5 | 0 | -| 3 | 15 | 5 | 0 | -| 4 | 21 | 5 | 0 | -| 5 | 3 | 5 | 0 | -| 6 | 7 | 4 | 0 | -| 7 | 12 | 5 | 0 | -| 8 | 18 | 5 | 0 | -| 9 | 23 | 5 | 0 | -| 10 | 5 | 5 | 0 | -| 11 | 8 | 4 | 0 | -| 12 | 14 | 5 | 0 | -| 13 | 20 | 5 | 0 | -| 14 | 2 | 5 | 0 | -| 15 | 7 | 4 | 16 | -| 16 | 11 | 5 | 0 | -| 17 | 17 | 5 | 0 | -| 18 | 22 | 5 | 0 | -| 19 | 4 | 5 | 0 | -| 20 | 8 | 4 | 16 | -| 21 | 13 | 5 | 0 | -| 22 | 19 | 5 | 0 | -| 23 | 1 | 5 | 0 | -| 24 | 6 | 4 | 16 | -| 25 | 10 | 5 | 0 | -| 26 | 16 | 5 | 0 | -| 27 | 28 | 5 | 0 | -| 28 | 27 | 5 | 0 | -| 29 | 26 | 5 | 0 | -| 30 | 25 | 5 | 0 | -| 31 | 24 | 5 | 0 | - - - -Appendix B - Resources for implementers -------------------------------------------------- - -An open source reference implementation is available on : -https://github.com/facebook/zstd - -The project contains a frame generator, called [decodeCorpus], -which can be used by any 3rd-party implementation -to verify that a tested decoder is compliant with the specification. - -[decodeCorpus]: https://github.com/facebook/zstd/tree/v1.3.4/tests#decodecorpus---tool-to-generate-zstandard-frames-for-decoder-testing - -`decodeCorpus` generates random valid frames. -A compliant decoder should be able to decode them all, -or at least provide a meaningful error code explaining for which reason it cannot -(memory limit restrictions for example). - - -Version changes ---------------- -- 0.4.0 : fixed imprecise behavior for nbSeq==0, detected by Igor Pavlov -- 0.3.9 : clarifications for Huffman-compressed literal sizes. -- 0.3.8 : clarifications for Huffman Blocks and Huffman Tree descriptions. -- 0.3.7 : clarifications for Repeat_Offsets, matching RFC8878 -- 0.3.6 : clarifications for Dictionary_ID -- 0.3.5 : clarifications for Block_Maximum_Size -- 0.3.4 : clarifications for FSE decoding table -- 0.3.3 : clarifications for field Block_Size -- 0.3.2 : remove additional block size restriction on compressed blocks -- 0.3.1 : minor clarification regarding offset history update rules -- 0.3.0 : minor edits to match RFC8478 -- 0.2.9 : clarifications for huffman weights direct representation, by Ulrich Kunitz -- 0.2.8 : clarifications for IETF RFC discuss -- 0.2.7 : clarifications from IETF RFC review, by Vijay Gurbani and Nick Terrell -- 0.2.6 : fixed an error in huffman example, by Ulrich Kunitz -- 0.2.5 : minor typos and clarifications -- 0.2.4 : section restructuring, by Sean Purcell -- 0.2.3 : clarified several details, by Sean Purcell -- 0.2.2 : added predefined codes, by Johannes Rudolph -- 0.2.1 : clarify field names, by Przemyslaw Skibinski -- 0.2.0 : numerous format adjustments for zstd v0.8+ -- 0.1.2 : limit Huffman tree depth to 11 bits -- 0.1.1 : reserved dictID ranges -- 0.1.0 : initial release diff --git a/third_party/zstd/doc/zstd_manual.html b/third_party/zstd/doc/zstd_manual.html deleted file mode 100644 index dcc10208d..000000000 --- a/third_party/zstd/doc/zstd_manual.html +++ /dev/null @@ -1,2125 +0,0 @@ - - - -zstd 1.5.5 Manual - - -

zstd 1.5.5 Manual

-
-

Contents

-
    -
  1. Introduction
  2. -
  3. Version
  4. -
  5. Simple API
  6. -
  7. Explicit context
  8. -
  9. Advanced compression API (Requires v1.4.0+)
  10. -
  11. Advanced decompression API (Requires v1.4.0+)
  12. -
  13. Streaming
  14. -
  15. Streaming compression - HowTo
  16. -
  17. Streaming decompression - HowTo
  18. -
  19. Simple dictionary API
  20. -
  21. Bulk processing dictionary API
  22. -
  23. Dictionary helper functions
  24. -
  25. Advanced dictionary and prefix API (Requires v1.4.0+)
  26. -
  27. experimental API (static linking only)
  28. -
  29. Frame header and size functions
  30. -
  31. Memory management
  32. -
  33. Advanced compression functions
  34. -
  35. Advanced decompression functions
  36. -
  37. Advanced streaming functions
  38. -
  39. Buffer-less and synchronous inner streaming functions (DEPRECATED)
  40. -
  41. Buffer-less streaming compression (synchronous mode)
  42. -
  43. Buffer-less streaming decompression (synchronous mode)
  44. -
  45. Block level API (DEPRECATED)
  46. -
-
-

Introduction

-  zstd, short for Zstandard, is a fast lossless compression algorithm, targeting
-  real-time compression scenarios at zlib-level and better compression ratios.
-  The zstd compression library provides in-memory compression and decompression
-  functions.
-
-  The library supports regular compression levels from 1 up to ZSTD_maxCLevel(),
-  which is currently 22. Levels >= 20, labeled `--ultra`, should be used with
-  caution, as they require more memory. The library also offers negative
-  compression levels, which extend the range of speed vs. ratio preferences.
-  The lower the level, the faster the speed (at the cost of compression).
-
-  Compression can be done in:
-    - a single step (described as Simple API)
-    - a single step, reusing a context (described as Explicit context)
-    - unbounded multiple steps (described as Streaming compression)
-
-  The compression ratio achievable on small data can be highly improved using
-  a dictionary. Dictionary compression can be performed in:
-    - a single step (described as Simple dictionary API)
-    - a single step, reusing a dictionary (described as Bulk-processing
-      dictionary API)
-
-  Advanced experimental functions can be accessed using
-  `#define ZSTD_STATIC_LINKING_ONLY` before including zstd.h.
-
-  Advanced experimental APIs should never be used with a dynamically-linked
-  library. They are not "stable"; their definitions or signatures may change in
-  the future. Only static linking is allowed.
-
- -

Version


-
-
unsigned ZSTD_versionNumber(void);
-

Return runtime library version, the value is (MAJOR*100*100 + MINOR*100 + RELEASE). -


- -
const char* ZSTD_versionString(void);
-

Return runtime library version, like "1.4.5". Requires v1.3.0+. -


- -

Simple API


-
-
size_t ZSTD_compress( void* dst, size_t dstCapacity,
-                const void* src, size_t srcSize,
-                      int compressionLevel);
-

Compresses `src` content as a single zstd compressed frame into already allocated `dst`. - NOTE: Providing `dstCapacity >= ZSTD_compressBound(srcSize)` guarantees that zstd will have - enough space to successfully compress the data. - @return : compressed size written into `dst` (<= `dstCapacity), - or an error code if it fails (which can be tested using ZSTD_isError()). -


- -
size_t ZSTD_decompress( void* dst, size_t dstCapacity,
-                  const void* src, size_t compressedSize);
-

`compressedSize` : must be the _exact_ size of some number of compressed and/or skippable frames. - `dstCapacity` is an upper bound of originalSize to regenerate. - If user cannot imply a maximum upper bound, it's better to use streaming mode to decompress data. - @return : the number of bytes decompressed into `dst` (<= `dstCapacity`), - or an errorCode if it fails (which can be tested using ZSTD_isError()). -


- -
#define ZSTD_CONTENTSIZE_UNKNOWN (0ULL - 1)
-#define ZSTD_CONTENTSIZE_ERROR   (0ULL - 2)
-unsigned long long ZSTD_getFrameContentSize(const void *src, size_t srcSize);
-

`src` should point to the start of a ZSTD encoded frame. - `srcSize` must be at least as large as the frame header. - hint : any size >= `ZSTD_frameHeaderSize_max` is large enough. - @return : - decompressed size of `src` frame content, if known - - ZSTD_CONTENTSIZE_UNKNOWN if the size cannot be determined - - ZSTD_CONTENTSIZE_ERROR if an error occurred (e.g. invalid magic number, srcSize too small) - note 1 : a 0 return value means the frame is valid but "empty". - note 2 : decompressed size is an optional field, it may not be present, typically in streaming mode. - When `return==ZSTD_CONTENTSIZE_UNKNOWN`, data to decompress could be any size. - In which case, it's necessary to use streaming mode to decompress data. - Optionally, application can rely on some implicit limit, - as ZSTD_decompress() only needs an upper bound of decompressed size. - (For example, data could be necessarily cut into blocks <= 16 KB). - note 3 : decompressed size is always present when compression is completed using single-pass functions, - such as ZSTD_compress(), ZSTD_compressCCtx() ZSTD_compress_usingDict() or ZSTD_compress_usingCDict(). - note 4 : decompressed size can be very large (64-bits value), - potentially larger than what local system can handle as a single memory segment. - In which case, it's necessary to use streaming mode to decompress data. - note 5 : If source is untrusted, decompressed size could be wrong or intentionally modified. - Always ensure return value fits within application's authorized limits. - Each application can set its own limits. - note 6 : This function replaces ZSTD_getDecompressedSize() -


- -
ZSTD_DEPRECATED("Replaced by ZSTD_getFrameContentSize")
-ZSTDLIB_API
-unsigned long long ZSTD_getDecompressedSize(const void* src, size_t srcSize);
-

NOTE: This function is now obsolete, in favor of ZSTD_getFrameContentSize(). - Both functions work the same way, but ZSTD_getDecompressedSize() blends - "empty", "unknown" and "error" results to the same return value (0), - while ZSTD_getFrameContentSize() gives them separate return values. - @return : decompressed size of `src` frame content _if known and not empty_, 0 otherwise. -


- -
size_t ZSTD_findFrameCompressedSize(const void* src, size_t srcSize);
-

`src` should point to the start of a ZSTD frame or skippable frame. - `srcSize` must be >= first frame size - @return : the compressed size of the first frame starting at `src`, - suitable to pass as `srcSize` to `ZSTD_decompress` or similar, - or an error code if input is invalid -


- -

Helper functions

/* ZSTD_compressBound() :
- * maximum compressed size in worst case single-pass scenario.
- * When invoking `ZSTD_compress()` or any other one-pass compression function,
- * it's recommended to provide @dstCapacity >= ZSTD_compressBound(srcSize)
- * as it eliminates one potential failure scenario,
- * aka not enough room in dst buffer to write the compressed frame.
- * Note : ZSTD_compressBound() itself can fail, if @srcSize > ZSTD_MAX_INPUT_SIZE .
- *        In which case, ZSTD_compressBound() will return an error code
- *        which can be tested using ZSTD_isError().
- *
- * ZSTD_COMPRESSBOUND() :
- * same as ZSTD_compressBound(), but as a macro.
- * It can be used to produce constants, which can be useful for static allocation,
- * for example to size a static array on stack.
- * Will produce constant value 0 if srcSize too large.
- */
-#define ZSTD_MAX_INPUT_SIZE ((sizeof(size_t)==8) ? 0xFF00FF00FF00FF00LLU : 0xFF00FF00U)
-#define ZSTD_COMPRESSBOUND(srcSize)   (((size_t)(srcSize) >= ZSTD_MAX_INPUT_SIZE) ? 0 : (srcSize) + ((srcSize)>>8) + (((srcSize) < (128<<10)) ? (((128<<10) - (srcSize)) >> 11) /* margin, from 64 to 0 */ : 0))  /* this formula ensures that bound(A) + bound(B) <= bound(A+B) as long as A and B >= 128 KB */
-size_t ZSTD_compressBound(size_t srcSize); /*!< maximum compressed size in worst case single-pass scenario */
-/* ZSTD_isError() :
- * Most ZSTD_* functions returning a size_t value can be tested for error,
- * using ZSTD_isError().
- * @return 1 if error, 0 otherwise
- */
-unsigned    ZSTD_isError(size_t code);          /*!< tells if a `size_t` function result is an error code */
-const char* ZSTD_getErrorName(size_t code);     /*!< provides readable string from an error code */
-int         ZSTD_minCLevel(void);               /*!< minimum negative compression level allowed, requires v1.4.0+ */
-int         ZSTD_maxCLevel(void);               /*!< maximum compression level available */
-int         ZSTD_defaultCLevel(void);           /*!< default compression level, specified by ZSTD_CLEVEL_DEFAULT, requires v1.5.0+ */
-

-

Explicit context


-
-

Compression context

  When compressing many times,
-  it is recommended to allocate a context just once,
-  and re-use it for each successive compression operation.
-  This will make workload friendlier for system's memory.
-  Note : re-using context is just a speed / resource optimization.
-         It doesn't change the compression ratio, which remains identical.
-  Note 2 : In multi-threaded environments,
-         use one different context per thread for parallel execution.
- 
-
typedef struct ZSTD_CCtx_s ZSTD_CCtx;
-ZSTD_CCtx* ZSTD_createCCtx(void);
-size_t     ZSTD_freeCCtx(ZSTD_CCtx* cctx);  /* accept NULL pointer */
-

-
size_t ZSTD_compressCCtx(ZSTD_CCtx* cctx,
-                         void* dst, size_t dstCapacity,
-                   const void* src, size_t srcSize,
-                         int compressionLevel);
-

Same as ZSTD_compress(), using an explicit ZSTD_CCtx. - Important : in order to behave similarly to `ZSTD_compress()`, - this function compresses at requested compression level, - __ignoring any other parameter__ . - If any advanced parameter was set using the advanced API, - they will all be reset. Only `compressionLevel` remains. - -


- -

Decompression context

  When decompressing many times,
-  it is recommended to allocate a context only once,
-  and re-use it for each successive compression operation.
-  This will make workload friendlier for system's memory.
-  Use one context per thread for parallel execution. 
-
typedef struct ZSTD_DCtx_s ZSTD_DCtx;
-ZSTD_DCtx* ZSTD_createDCtx(void);
-size_t     ZSTD_freeDCtx(ZSTD_DCtx* dctx);  /* accept NULL pointer */
-

-
size_t ZSTD_decompressDCtx(ZSTD_DCtx* dctx,
-                           void* dst, size_t dstCapacity,
-                     const void* src, size_t srcSize);
-

Same as ZSTD_decompress(), - requires an allocated ZSTD_DCtx. - Compatible with sticky parameters. - -


- -

Advanced compression API (Requires v1.4.0+)


-
-
typedef enum { ZSTD_fast=1,
-               ZSTD_dfast=2,
-               ZSTD_greedy=3,
-               ZSTD_lazy=4,
-               ZSTD_lazy2=5,
-               ZSTD_btlazy2=6,
-               ZSTD_btopt=7,
-               ZSTD_btultra=8,
-               ZSTD_btultra2=9
-               /* note : new strategies _might_ be added in the future.
-                         Only the order (from fast to strong) is guaranteed */
-} ZSTD_strategy;
-

-
typedef enum {
-
-    /* compression parameters
-     * Note: When compressing with a ZSTD_CDict these parameters are superseded
-     * by the parameters used to construct the ZSTD_CDict.
-     * See ZSTD_CCtx_refCDict() for more info (superseded-by-cdict). */
-    ZSTD_c_compressionLevel=100, /* Set compression parameters according to pre-defined cLevel table.
-                              * Note that exact compression parameters are dynamically determined,
-                              * depending on both compression level and srcSize (when known).
-                              * Default level is ZSTD_CLEVEL_DEFAULT==3.
-                              * Special: value 0 means default, which is controlled by ZSTD_CLEVEL_DEFAULT.
-                              * Note 1 : it's possible to pass a negative compression level.
-                              * Note 2 : setting a level does not automatically set all other compression parameters
-                              *   to default. Setting this will however eventually dynamically impact the compression
-                              *   parameters which have not been manually set. The manually set
-                              *   ones will 'stick'. */
-    /* Advanced compression parameters :
-     * It's possible to pin down compression parameters to some specific values.
-     * In which case, these values are no longer dynamically selected by the compressor */
-    ZSTD_c_windowLog=101,    /* Maximum allowed back-reference distance, expressed as power of 2.
-                              * This will set a memory budget for streaming decompression,
-                              * with larger values requiring more memory
-                              * and typically compressing more.
-                              * Must be clamped between ZSTD_WINDOWLOG_MIN and ZSTD_WINDOWLOG_MAX.
-                              * Special: value 0 means "use default windowLog".
-                              * Note: Using a windowLog greater than ZSTD_WINDOWLOG_LIMIT_DEFAULT
-                              *       requires explicitly allowing such size at streaming decompression stage. */
-    ZSTD_c_hashLog=102,      /* Size of the initial probe table, as a power of 2.
-                              * Resulting memory usage is (1 << (hashLog+2)).
-                              * Must be clamped between ZSTD_HASHLOG_MIN and ZSTD_HASHLOG_MAX.
-                              * Larger tables improve compression ratio of strategies <= dFast,
-                              * and improve speed of strategies > dFast.
-                              * Special: value 0 means "use default hashLog". */
-    ZSTD_c_chainLog=103,     /* Size of the multi-probe search table, as a power of 2.
-                              * Resulting memory usage is (1 << (chainLog+2)).
-                              * Must be clamped between ZSTD_CHAINLOG_MIN and ZSTD_CHAINLOG_MAX.
-                              * Larger tables result in better and slower compression.
-                              * This parameter is useless for "fast" strategy.
-                              * It's still useful when using "dfast" strategy,
-                              * in which case it defines a secondary probe table.
-                              * Special: value 0 means "use default chainLog". */
-    ZSTD_c_searchLog=104,    /* Number of search attempts, as a power of 2.
-                              * More attempts result in better and slower compression.
-                              * This parameter is useless for "fast" and "dFast" strategies.
-                              * Special: value 0 means "use default searchLog". */
-    ZSTD_c_minMatch=105,     /* Minimum size of searched matches.
-                              * Note that Zstandard can still find matches of smaller size,
-                              * it just tweaks its search algorithm to look for this size and larger.
-                              * Larger values increase compression and decompression speed, but decrease ratio.
-                              * Must be clamped between ZSTD_MINMATCH_MIN and ZSTD_MINMATCH_MAX.
-                              * Note that currently, for all strategies < btopt, effective minimum is 4.
-                              *                    , for all strategies > fast, effective maximum is 6.
-                              * Special: value 0 means "use default minMatchLength". */
-    ZSTD_c_targetLength=106, /* Impact of this field depends on strategy.
-                              * For strategies btopt, btultra & btultra2:
-                              *     Length of Match considered "good enough" to stop search.
-                              *     Larger values make compression stronger, and slower.
-                              * For strategy fast:
-                              *     Distance between match sampling.
-                              *     Larger values make compression faster, and weaker.
-                              * Special: value 0 means "use default targetLength". */
-    ZSTD_c_strategy=107,     /* See ZSTD_strategy enum definition.
-                              * The higher the value of selected strategy, the more complex it is,
-                              * resulting in stronger and slower compression.
-                              * Special: value 0 means "use default strategy". */
-    /* LDM mode parameters */
-    ZSTD_c_enableLongDistanceMatching=160, /* Enable long distance matching.
-                                     * This parameter is designed to improve compression ratio
-                                     * for large inputs, by finding large matches at long distance.
-                                     * It increases memory usage and window size.
-                                     * Note: enabling this parameter increases default ZSTD_c_windowLog to 128 MB
-                                     * except when expressly set to a different value.
-                                     * Note: will be enabled by default if ZSTD_c_windowLog >= 128 MB and
-                                     * compression strategy >= ZSTD_btopt (== compression level 16+) */
-    ZSTD_c_ldmHashLog=161,   /* Size of the table for long distance matching, as a power of 2.
-                              * Larger values increase memory usage and compression ratio,
-                              * but decrease compression speed.
-                              * Must be clamped between ZSTD_HASHLOG_MIN and ZSTD_HASHLOG_MAX
-                              * default: windowlog - 7.
-                              * Special: value 0 means "automatically determine hashlog". */
-    ZSTD_c_ldmMinMatch=162,  /* Minimum match size for long distance matcher.
-                              * Larger/too small values usually decrease compression ratio.
-                              * Must be clamped between ZSTD_LDM_MINMATCH_MIN and ZSTD_LDM_MINMATCH_MAX.
-                              * Special: value 0 means "use default value" (default: 64). */
-    ZSTD_c_ldmBucketSizeLog=163, /* Log size of each bucket in the LDM hash table for collision resolution.
-                              * Larger values improve collision resolution but decrease compression speed.
-                              * The maximum value is ZSTD_LDM_BUCKETSIZELOG_MAX.
-                              * Special: value 0 means "use default value" (default: 3). */
-    ZSTD_c_ldmHashRateLog=164, /* Frequency of inserting/looking up entries into the LDM hash table.
-                              * Must be clamped between 0 and (ZSTD_WINDOWLOG_MAX - ZSTD_HASHLOG_MIN).
-                              * Default is MAX(0, (windowLog - ldmHashLog)), optimizing hash table usage.
-                              * Larger values improve compression speed.
-                              * Deviating far from default value will likely result in a compression ratio decrease.
-                              * Special: value 0 means "automatically determine hashRateLog". */
-
-    /* frame parameters */
-    ZSTD_c_contentSizeFlag=200, /* Content size will be written into frame header _whenever known_ (default:1)
-                              * Content size must be known at the beginning of compression.
-                              * This is automatically the case when using ZSTD_compress2(),
-                              * For streaming scenarios, content size must be provided with ZSTD_CCtx_setPledgedSrcSize() */
-    ZSTD_c_checksumFlag=201, /* A 32-bits checksum of content is written at end of frame (default:0) */
-    ZSTD_c_dictIDFlag=202,   /* When applicable, dictionary's ID is written into frame header (default:1) */
-
-    /* multi-threading parameters */
-    /* These parameters are only active if multi-threading is enabled (compiled with build macro ZSTD_MULTITHREAD).
-     * Otherwise, trying to set any other value than default (0) will be a no-op and return an error.
-     * In a situation where it's unknown if the linked library supports multi-threading or not,
-     * setting ZSTD_c_nbWorkers to any value >= 1 and consulting the return value provides a quick way to check this property.
-     */
-    ZSTD_c_nbWorkers=400,    /* Select how many threads will be spawned to compress in parallel.
-                              * When nbWorkers >= 1, triggers asynchronous mode when invoking ZSTD_compressStream*() :
-                              * ZSTD_compressStream*() consumes input and flush output if possible, but immediately gives back control to caller,
-                              * while compression is performed in parallel, within worker thread(s).
-                              * (note : a strong exception to this rule is when first invocation of ZSTD_compressStream2() sets ZSTD_e_end :
-                              *  in which case, ZSTD_compressStream2() delegates to ZSTD_compress2(), which is always a blocking call).
-                              * More workers improve speed, but also increase memory usage.
-                              * Default value is `0`, aka "single-threaded mode" : no worker is spawned,
-                              * compression is performed inside Caller's thread, and all invocations are blocking */
-    ZSTD_c_jobSize=401,      /* Size of a compression job. This value is enforced only when nbWorkers >= 1.
-                              * Each compression job is completed in parallel, so this value can indirectly impact the nb of active threads.
-                              * 0 means default, which is dynamically determined based on compression parameters.
-                              * Job size must be a minimum of overlap size, or ZSTDMT_JOBSIZE_MIN (= 512 KB), whichever is largest.
-                              * The minimum size is automatically and transparently enforced. */
-    ZSTD_c_overlapLog=402,   /* Control the overlap size, as a fraction of window size.
-                              * The overlap size is an amount of data reloaded from previous job at the beginning of a new job.
-                              * It helps preserve compression ratio, while each job is compressed in parallel.
-                              * This value is enforced only when nbWorkers >= 1.
-                              * Larger values increase compression ratio, but decrease speed.
-                              * Possible values range from 0 to 9 :
-                              * - 0 means "default" : value will be determined by the library, depending on strategy
-                              * - 1 means "no overlap"
-                              * - 9 means "full overlap", using a full window size.
-                              * Each intermediate rank increases/decreases load size by a factor 2 :
-                              * 9: full window;  8: w/2;  7: w/4;  6: w/8;  5:w/16;  4: w/32;  3:w/64;  2:w/128;  1:no overlap;  0:default
-                              * default value varies between 6 and 9, depending on strategy */
-
-    /* note : additional experimental parameters are also available
-     * within the experimental section of the API.
-     * At the time of this writing, they include :
-     * ZSTD_c_rsyncable
-     * ZSTD_c_format
-     * ZSTD_c_forceMaxWindow
-     * ZSTD_c_forceAttachDict
-     * ZSTD_c_literalCompressionMode
-     * ZSTD_c_targetCBlockSize
-     * ZSTD_c_srcSizeHint
-     * ZSTD_c_enableDedicatedDictSearch
-     * ZSTD_c_stableInBuffer
-     * ZSTD_c_stableOutBuffer
-     * ZSTD_c_blockDelimiters
-     * ZSTD_c_validateSequences
-     * ZSTD_c_useBlockSplitter
-     * ZSTD_c_useRowMatchFinder
-     * ZSTD_c_prefetchCDictTables
-     * ZSTD_c_enableSeqProducerFallback
-     * ZSTD_c_maxBlockSize
-     * Because they are not stable, it's necessary to define ZSTD_STATIC_LINKING_ONLY to access them.
-     * note : never ever use experimentalParam? names directly;
-     *        also, the enums values themselves are unstable and can still change.
-     */
-     ZSTD_c_experimentalParam1=500,
-     ZSTD_c_experimentalParam2=10,
-     ZSTD_c_experimentalParam3=1000,
-     ZSTD_c_experimentalParam4=1001,
-     ZSTD_c_experimentalParam5=1002,
-     ZSTD_c_experimentalParam6=1003,
-     ZSTD_c_experimentalParam7=1004,
-     ZSTD_c_experimentalParam8=1005,
-     ZSTD_c_experimentalParam9=1006,
-     ZSTD_c_experimentalParam10=1007,
-     ZSTD_c_experimentalParam11=1008,
-     ZSTD_c_experimentalParam12=1009,
-     ZSTD_c_experimentalParam13=1010,
-     ZSTD_c_experimentalParam14=1011,
-     ZSTD_c_experimentalParam15=1012,
-     ZSTD_c_experimentalParam16=1013,
-     ZSTD_c_experimentalParam17=1014,
-     ZSTD_c_experimentalParam18=1015,
-     ZSTD_c_experimentalParam19=1016
-} ZSTD_cParameter;
-

-
typedef struct {
-    size_t error;
-    int lowerBound;
-    int upperBound;
-} ZSTD_bounds;
-

-
ZSTD_bounds ZSTD_cParam_getBounds(ZSTD_cParameter cParam);
-

All parameters must belong to an interval with lower and upper bounds, - otherwise they will either trigger an error or be automatically clamped. - @return : a structure, ZSTD_bounds, which contains - - an error status field, which must be tested using ZSTD_isError() - - lower and upper bounds, both inclusive - -


- -
size_t ZSTD_CCtx_setParameter(ZSTD_CCtx* cctx, ZSTD_cParameter param, int value);
-

Set one compression parameter, selected by enum ZSTD_cParameter. - All parameters have valid bounds. Bounds can be queried using ZSTD_cParam_getBounds(). - Providing a value beyond bound will either clamp it, or trigger an error (depending on parameter). - Setting a parameter is generally only possible during frame initialization (before starting compression). - Exception : when using multi-threading mode (nbWorkers >= 1), - the following parameters can be updated _during_ compression (within same frame): - => compressionLevel, hashLog, chainLog, searchLog, minMatch, targetLength and strategy. - new parameters will be active for next job only (after a flush()). - @return : an error code (which can be tested using ZSTD_isError()). - -


- -
size_t ZSTD_CCtx_setPledgedSrcSize(ZSTD_CCtx* cctx, unsigned long long pledgedSrcSize);
-

Total input data size to be compressed as a single frame. - Value will be written in frame header, unless if explicitly forbidden using ZSTD_c_contentSizeFlag. - This value will also be controlled at end of frame, and trigger an error if not respected. - @result : 0, or an error code (which can be tested with ZSTD_isError()). - Note 1 : pledgedSrcSize==0 actually means zero, aka an empty frame. - In order to mean "unknown content size", pass constant ZSTD_CONTENTSIZE_UNKNOWN. - ZSTD_CONTENTSIZE_UNKNOWN is default value for any new frame. - Note 2 : pledgedSrcSize is only valid once, for the next frame. - It's discarded at the end of the frame, and replaced by ZSTD_CONTENTSIZE_UNKNOWN. - Note 3 : Whenever all input data is provided and consumed in a single round, - for example with ZSTD_compress2(), - or invoking immediately ZSTD_compressStream2(,,,ZSTD_e_end), - this value is automatically overridden by srcSize instead. - -


- -
typedef enum {
-    ZSTD_reset_session_only = 1,
-    ZSTD_reset_parameters = 2,
-    ZSTD_reset_session_and_parameters = 3
-} ZSTD_ResetDirective;
-

-
size_t ZSTD_CCtx_reset(ZSTD_CCtx* cctx, ZSTD_ResetDirective reset);
-

There are 2 different things that can be reset, independently or jointly : - - The session : will stop compressing current frame, and make CCtx ready to start a new one. - Useful after an error, or to interrupt any ongoing compression. - Any internal data not yet flushed is cancelled. - Compression parameters and dictionary remain unchanged. - They will be used to compress next frame. - Resetting session never fails. - - The parameters : changes all parameters back to "default". - This also removes any reference to any dictionary or external sequence producer. - Parameters can only be changed between 2 sessions (i.e. no compression is currently ongoing) - otherwise the reset fails, and function returns an error value (which can be tested using ZSTD_isError()) - - Both : similar to resetting the session, followed by resetting parameters. - -


- -
size_t ZSTD_compress2( ZSTD_CCtx* cctx,
-                       void* dst, size_t dstCapacity,
-                 const void* src, size_t srcSize);
-

Behave the same as ZSTD_compressCCtx(), but compression parameters are set using the advanced API. - ZSTD_compress2() always starts a new frame. - Should cctx hold data from a previously unfinished frame, everything about it is forgotten. - - Compression parameters are pushed into CCtx before starting compression, using ZSTD_CCtx_set*() - - The function is always blocking, returns when compression is completed. - NOTE: Providing `dstCapacity >= ZSTD_compressBound(srcSize)` guarantees that zstd will have - enough space to successfully compress the data, though it is possible it fails for other reasons. - @return : compressed size written into `dst` (<= `dstCapacity), - or an error code if it fails (which can be tested using ZSTD_isError()). - -


- -

Advanced decompression API (Requires v1.4.0+)


-
-
typedef enum {
-
-    ZSTD_d_windowLogMax=100, /* Select a size limit (in power of 2) beyond which
-                              * the streaming API will refuse to allocate memory buffer
-                              * in order to protect the host from unreasonable memory requirements.
-                              * This parameter is only useful in streaming mode, since no internal buffer is allocated in single-pass mode.
-                              * By default, a decompression context accepts window sizes <= (1 << ZSTD_WINDOWLOG_LIMIT_DEFAULT).
-                              * Special: value 0 means "use default maximum windowLog". */
-
-    /* note : additional experimental parameters are also available
-     * within the experimental section of the API.
-     * At the time of this writing, they include :
-     * ZSTD_d_format
-     * ZSTD_d_stableOutBuffer
-     * ZSTD_d_forceIgnoreChecksum
-     * ZSTD_d_refMultipleDDicts
-     * ZSTD_d_disableHuffmanAssembly
-     * Because they are not stable, it's necessary to define ZSTD_STATIC_LINKING_ONLY to access them.
-     * note : never ever use experimentalParam? names directly
-     */
-     ZSTD_d_experimentalParam1=1000,
-     ZSTD_d_experimentalParam2=1001,
-     ZSTD_d_experimentalParam3=1002,
-     ZSTD_d_experimentalParam4=1003,
-     ZSTD_d_experimentalParam5=1004
-
-} ZSTD_dParameter;
-

-
ZSTD_bounds ZSTD_dParam_getBounds(ZSTD_dParameter dParam);
-

All parameters must belong to an interval with lower and upper bounds, - otherwise they will either trigger an error or be automatically clamped. - @return : a structure, ZSTD_bounds, which contains - - an error status field, which must be tested using ZSTD_isError() - - both lower and upper bounds, inclusive - -


- -
size_t ZSTD_DCtx_setParameter(ZSTD_DCtx* dctx, ZSTD_dParameter param, int value);
-

Set one compression parameter, selected by enum ZSTD_dParameter. - All parameters have valid bounds. Bounds can be queried using ZSTD_dParam_getBounds(). - Providing a value beyond bound will either clamp it, or trigger an error (depending on parameter). - Setting a parameter is only possible during frame initialization (before starting decompression). - @return : 0, or an error code (which can be tested using ZSTD_isError()). - -


- -
size_t ZSTD_DCtx_reset(ZSTD_DCtx* dctx, ZSTD_ResetDirective reset);
-

Return a DCtx to clean state. - Session and parameters can be reset jointly or separately. - Parameters can only be reset when no active frame is being decompressed. - @return : 0, or an error code, which can be tested with ZSTD_isError() - -


- -

Streaming


-
-
typedef struct ZSTD_inBuffer_s {
-  const void* src;    /**< start of input buffer */
-  size_t size;        /**< size of input buffer */
-  size_t pos;         /**< position where reading stopped. Will be updated. Necessarily 0 <= pos <= size */
-} ZSTD_inBuffer;
-

-
typedef struct ZSTD_outBuffer_s {
-  void*  dst;         /**< start of output buffer */
-  size_t size;        /**< size of output buffer */
-  size_t pos;         /**< position where writing stopped. Will be updated. Necessarily 0 <= pos <= size */
-} ZSTD_outBuffer;
-

-

Streaming compression - HowTo

-  A ZSTD_CStream object is required to track streaming operation.
-  Use ZSTD_createCStream() and ZSTD_freeCStream() to create/release resources.
-  ZSTD_CStream objects can be reused multiple times on consecutive compression operations.
-  It is recommended to re-use ZSTD_CStream since it will play nicer with system's memory, by re-using already allocated memory.
-
-  For parallel execution, use one separate ZSTD_CStream per thread.
-
-  note : since v1.3.0, ZSTD_CStream and ZSTD_CCtx are the same thing.
-
-  Parameters are sticky : when starting a new compression on the same context,
-  it will re-use the same sticky parameters as previous compression session.
-  When in doubt, it's recommended to fully initialize the context before usage.
-  Use ZSTD_CCtx_reset() to reset the context and ZSTD_CCtx_setParameter(),
-  ZSTD_CCtx_setPledgedSrcSize(), or ZSTD_CCtx_loadDictionary() and friends to
-  set more specific parameters, the pledged source size, or load a dictionary.
-
-  Use ZSTD_compressStream2() with ZSTD_e_continue as many times as necessary to
-  consume input stream. The function will automatically update both `pos`
-  fields within `input` and `output`.
-  Note that the function may not consume the entire input, for example, because
-  the output buffer is already full, in which case `input.pos < input.size`.
-  The caller must check if input has been entirely consumed.
-  If not, the caller must make some room to receive more compressed data,
-  and then present again remaining input data.
-  note: ZSTD_e_continue is guaranteed to make some forward progress when called,
-        but doesn't guarantee maximal forward progress. This is especially relevant
-        when compressing with multiple threads. The call won't block if it can
-        consume some input, but if it can't it will wait for some, but not all,
-        output to be flushed.
- @return : provides a minimum amount of data remaining to be flushed from internal buffers
-           or an error code, which can be tested using ZSTD_isError().
-
-  At any moment, it's possible to flush whatever data might remain stuck within internal buffer,
-  using ZSTD_compressStream2() with ZSTD_e_flush. `output->pos` will be updated.
-  Note that, if `output->size` is too small, a single invocation with ZSTD_e_flush might not be enough (return code > 0).
-  In which case, make some room to receive more compressed data, and call again ZSTD_compressStream2() with ZSTD_e_flush.
-  You must continue calling ZSTD_compressStream2() with ZSTD_e_flush until it returns 0, at which point you can change the
-  operation.
-  note: ZSTD_e_flush will flush as much output as possible, meaning when compressing with multiple threads, it will
-        block until the flush is complete or the output buffer is full.
-  @return : 0 if internal buffers are entirely flushed,
-            >0 if some data still present within internal buffer (the value is minimal estimation of remaining size),
-            or an error code, which can be tested using ZSTD_isError().
-
-  Calling ZSTD_compressStream2() with ZSTD_e_end instructs to finish a frame.
-  It will perform a flush and write frame epilogue.
-  The epilogue is required for decoders to consider a frame completed.
-  flush operation is the same, and follows same rules as calling ZSTD_compressStream2() with ZSTD_e_flush.
-  You must continue calling ZSTD_compressStream2() with ZSTD_e_end until it returns 0, at which point you are free to
-  start a new frame.
-  note: ZSTD_e_end will flush as much output as possible, meaning when compressing with multiple threads, it will
-        block until the flush is complete or the output buffer is full.
-  @return : 0 if frame fully completed and fully flushed,
-            >0 if some data still present within internal buffer (the value is minimal estimation of remaining size),
-            or an error code, which can be tested using ZSTD_isError().
-
- 
-
- -
typedef ZSTD_CCtx ZSTD_CStream;  /**< CCtx and CStream are now effectively same object (>= v1.3.0) */
-

-

ZSTD_CStream management functions

ZSTD_CStream* ZSTD_createCStream(void);
-size_t ZSTD_freeCStream(ZSTD_CStream* zcs);  /* accept NULL pointer */
-

-

Streaming compression functions

typedef enum {
-    ZSTD_e_continue=0, /* collect more data, encoder decides when to output compressed result, for optimal compression ratio */
-    ZSTD_e_flush=1,    /* flush any data provided so far,
-                        * it creates (at least) one new block, that can be decoded immediately on reception;
-                        * frame will continue: any future data can still reference previously compressed data, improving compression.
-                        * note : multithreaded compression will block to flush as much output as possible. */
-    ZSTD_e_end=2       /* flush any remaining data _and_ close current frame.
-                        * note that frame is only closed after compressed data is fully flushed (return value == 0).
-                        * After that point, any additional data starts a new frame.
-                        * note : each frame is independent (does not reference any content from previous frame).
-                        : note : multithreaded compression will block to flush as much output as possible. */
-} ZSTD_EndDirective;
-

-
size_t ZSTD_compressStream2( ZSTD_CCtx* cctx,
-                             ZSTD_outBuffer* output,
-                             ZSTD_inBuffer* input,
-                             ZSTD_EndDirective endOp);
-

Behaves about the same as ZSTD_compressStream, with additional control on end directive. - - Compression parameters are pushed into CCtx before starting compression, using ZSTD_CCtx_set*() - - Compression parameters cannot be changed once compression is started (save a list of exceptions in multi-threading mode) - - output->pos must be <= dstCapacity, input->pos must be <= srcSize - - output->pos and input->pos will be updated. They are guaranteed to remain below their respective limit. - - endOp must be a valid directive - - When nbWorkers==0 (default), function is blocking : it completes its job before returning to caller. - - When nbWorkers>=1, function is non-blocking : it copies a portion of input, distributes jobs to internal worker threads, flush to output whatever is available, - and then immediately returns, just indicating that there is some data remaining to be flushed. - The function nonetheless guarantees forward progress : it will return only after it reads or write at least 1+ byte. - - Exception : if the first call requests a ZSTD_e_end directive and provides enough dstCapacity, the function delegates to ZSTD_compress2() which is always blocking. - - @return provides a minimum amount of data remaining to be flushed from internal buffers - or an error code, which can be tested using ZSTD_isError(). - if @return != 0, flush is not fully completed, there is still some data left within internal buffers. - This is useful for ZSTD_e_flush, since in this case more flushes are necessary to empty all buffers. - For ZSTD_e_end, @return == 0 when internal buffers are fully flushed and frame is completed. - - after a ZSTD_e_end directive, if internal buffer is not fully flushed (@return != 0), - only ZSTD_e_end or ZSTD_e_flush operations are allowed. - Before starting a new compression job, or changing compression parameters, - it is required to fully flush internal buffers. - -


- -
size_t ZSTD_CStreamInSize(void);    /**< recommended size for input buffer */
-

-
size_t ZSTD_CStreamOutSize(void);   /**< recommended size for output buffer. Guarantee to successfully flush at least one complete compressed block. */
-

-
size_t ZSTD_initCStream(ZSTD_CStream* zcs, int compressionLevel);
-/*!
- * Alternative for ZSTD_compressStream2(zcs, output, input, ZSTD_e_continue).
- * NOTE: The return value is different. ZSTD_compressStream() returns a hint for
- * the next read size (if non-zero and not an error). ZSTD_compressStream2()
- * returns the minimum nb of bytes left to flush (if non-zero and not an error).
- */
-size_t ZSTD_compressStream(ZSTD_CStream* zcs, ZSTD_outBuffer* output, ZSTD_inBuffer* input);
-/*! Equivalent to ZSTD_compressStream2(zcs, output, &emptyInput, ZSTD_e_flush). */
-size_t ZSTD_flushStream(ZSTD_CStream* zcs, ZSTD_outBuffer* output);
-/*! Equivalent to ZSTD_compressStream2(zcs, output, &emptyInput, ZSTD_e_end). */
-size_t ZSTD_endStream(ZSTD_CStream* zcs, ZSTD_outBuffer* output);
-

- ZSTD_CCtx_reset(zcs, ZSTD_reset_session_only); - ZSTD_CCtx_refCDict(zcs, NULL); // clear the dictionary (if any) - ZSTD_CCtx_setParameter(zcs, ZSTD_c_compressionLevel, compressionLevel); - - Note that ZSTD_initCStream() clears any previously set dictionary. Use the new API - to compress with a dictionary. - -


- -

Streaming decompression - HowTo

-  A ZSTD_DStream object is required to track streaming operations.
-  Use ZSTD_createDStream() and ZSTD_freeDStream() to create/release resources.
-  ZSTD_DStream objects can be re-used multiple times.
-
-  Use ZSTD_initDStream() to start a new decompression operation.
- @return : recommended first input size
-  Alternatively, use advanced API to set specific properties.
-
-  Use ZSTD_decompressStream() repetitively to consume your input.
-  The function will update both `pos` fields.
-  If `input.pos < input.size`, some input has not been consumed.
-  It's up to the caller to present again remaining data.
-  The function tries to flush all data decoded immediately, respecting output buffer size.
-  If `output.pos < output.size`, decoder has flushed everything it could.
-  But if `output.pos == output.size`, there might be some data left within internal buffers.,
-  In which case, call ZSTD_decompressStream() again to flush whatever remains in the buffer.
-  Note : with no additional input provided, amount of data flushed is necessarily <= ZSTD_BLOCKSIZE_MAX.
- @return : 0 when a frame is completely decoded and fully flushed,
-        or an error code, which can be tested using ZSTD_isError(),
-        or any other value > 0, which means there is still some decoding or flushing to do to complete current frame :
-                                the return value is a suggested next input size (just a hint for better latency)
-                                that will never request more than the remaining frame size.
- 
-
- -
typedef ZSTD_DCtx ZSTD_DStream;  /**< DCtx and DStream are now effectively same object (>= v1.3.0) */
-

-

ZSTD_DStream management functions

ZSTD_DStream* ZSTD_createDStream(void);
-size_t ZSTD_freeDStream(ZSTD_DStream* zds);  /* accept NULL pointer */
-

-

Streaming decompression functions


-
size_t ZSTD_initDStream(ZSTD_DStream* zds);
-

Initialize/reset DStream state for new decompression operation. - Call before new decompression operation using same DStream. - - Note : This function is redundant with the advanced API and equivalent to: - ZSTD_DCtx_reset(zds, ZSTD_reset_session_only); - ZSTD_DCtx_refDDict(zds, NULL); - -


- -
size_t ZSTD_decompressStream(ZSTD_DStream* zds, ZSTD_outBuffer* output, ZSTD_inBuffer* input);
-

Streaming decompression function. - Call repetitively to consume full input updating it as necessary. - Function will update both input and output `pos` fields exposing current state via these fields: - - `input.pos < input.size`, some input remaining and caller should provide remaining input - on the next call. - - `output.pos < output.size`, decoder finished and flushed all remaining buffers. - - `output.pos == output.size`, potentially uncflushed data present in the internal buffers, - call ZSTD_decompressStream() again to flush remaining data to output. - Note : with no additional input, amount of data flushed <= ZSTD_BLOCKSIZE_MAX. - - @return : 0 when a frame is completely decoded and fully flushed, - or an error code, which can be tested using ZSTD_isError(), - or any other value > 0, which means there is some decoding or flushing to do to complete current frame. - -


- -
size_t ZSTD_DStreamInSize(void);    /*!< recommended size for input buffer */
-

-
size_t ZSTD_DStreamOutSize(void);   /*!< recommended size for output buffer. Guarantee to successfully flush at least one complete block in all circumstances. */
-

-

Simple dictionary API


-
-
size_t ZSTD_compress_usingDict(ZSTD_CCtx* ctx,
-                               void* dst, size_t dstCapacity,
-                         const void* src, size_t srcSize,
-                         const void* dict,size_t dictSize,
-                               int compressionLevel);
-

Compression at an explicit compression level using a Dictionary. - A dictionary can be any arbitrary data segment (also called a prefix), - or a buffer with specified information (see zdict.h). - Note : This function loads the dictionary, resulting in significant startup delay. - It's intended for a dictionary used only once. - Note 2 : When `dict == NULL || dictSize < 8` no dictionary is used. -


- -
size_t ZSTD_decompress_usingDict(ZSTD_DCtx* dctx,
-                                 void* dst, size_t dstCapacity,
-                           const void* src, size_t srcSize,
-                           const void* dict,size_t dictSize);
-

Decompression using a known Dictionary. - Dictionary must be identical to the one used during compression. - Note : This function loads the dictionary, resulting in significant startup delay. - It's intended for a dictionary used only once. - Note : When `dict == NULL || dictSize < 8` no dictionary is used. -


- -

Bulk processing dictionary API


-
-
ZSTD_CDict* ZSTD_createCDict(const void* dictBuffer, size_t dictSize,
-                             int compressionLevel);
-

When compressing multiple messages or blocks using the same dictionary, - it's recommended to digest the dictionary only once, since it's a costly operation. - ZSTD_createCDict() will create a state from digesting a dictionary. - The resulting state can be used for future compression operations with very limited startup cost. - ZSTD_CDict can be created once and shared by multiple threads concurrently, since its usage is read-only. - @dictBuffer can be released after ZSTD_CDict creation, because its content is copied within CDict. - Note 1 : Consider experimental function `ZSTD_createCDict_byReference()` if you prefer to not duplicate @dictBuffer content. - Note 2 : A ZSTD_CDict can be created from an empty @dictBuffer, - in which case the only thing that it transports is the @compressionLevel. - This can be useful in a pipeline featuring ZSTD_compress_usingCDict() exclusively, - expecting a ZSTD_CDict parameter with any data, including those without a known dictionary. -


- -
size_t      ZSTD_freeCDict(ZSTD_CDict* CDict);
-

Function frees memory allocated by ZSTD_createCDict(). - If a NULL pointer is passed, no operation is performed. -


- -
size_t ZSTD_compress_usingCDict(ZSTD_CCtx* cctx,
-                                void* dst, size_t dstCapacity,
-                          const void* src, size_t srcSize,
-                          const ZSTD_CDict* cdict);
-

Compression using a digested Dictionary. - Recommended when same dictionary is used multiple times. - Note : compression level is _decided at dictionary creation time_, - and frame parameters are hardcoded (dictID=yes, contentSize=yes, checksum=no) -


- -
ZSTD_DDict* ZSTD_createDDict(const void* dictBuffer, size_t dictSize);
-

Create a digested dictionary, ready to start decompression operation without startup delay. - dictBuffer can be released after DDict creation, as its content is copied inside DDict. -


- -
size_t      ZSTD_freeDDict(ZSTD_DDict* ddict);
-

Function frees memory allocated with ZSTD_createDDict() - If a NULL pointer is passed, no operation is performed. -


- -
size_t ZSTD_decompress_usingDDict(ZSTD_DCtx* dctx,
-                                  void* dst, size_t dstCapacity,
-                            const void* src, size_t srcSize,
-                            const ZSTD_DDict* ddict);
-

Decompression using a digested Dictionary. - Recommended when same dictionary is used multiple times. -


- -

Dictionary helper functions


-
-
unsigned ZSTD_getDictID_fromDict(const void* dict, size_t dictSize);
-

Provides the dictID stored within dictionary. - if @return == 0, the dictionary is not conformant with Zstandard specification. - It can still be loaded, but as a content-only dictionary. -


- -
unsigned ZSTD_getDictID_fromCDict(const ZSTD_CDict* cdict);
-

Provides the dictID of the dictionary loaded into `cdict`. - If @return == 0, the dictionary is not conformant to Zstandard specification, or empty. - Non-conformant dictionaries can still be loaded, but as content-only dictionaries. -


- -
unsigned ZSTD_getDictID_fromDDict(const ZSTD_DDict* ddict);
-

Provides the dictID of the dictionary loaded into `ddict`. - If @return == 0, the dictionary is not conformant to Zstandard specification, or empty. - Non-conformant dictionaries can still be loaded, but as content-only dictionaries. -


- -
unsigned ZSTD_getDictID_fromFrame(const void* src, size_t srcSize);
-

Provides the dictID required to decompressed the frame stored within `src`. - If @return == 0, the dictID could not be decoded. - This could for one of the following reasons : - - The frame does not require a dictionary to be decoded (most common case). - - The frame was built with dictID intentionally removed. Whatever dictionary is necessary is a hidden piece of information. - Note : this use case also happens when using a non-conformant dictionary. - - `srcSize` is too small, and as a result, the frame header could not be decoded (only possible if `srcSize < ZSTD_FRAMEHEADERSIZE_MAX`). - - This is not a Zstandard frame. - When identifying the exact failure cause, it's possible to use ZSTD_getFrameHeader(), which will provide a more precise error code. -


- -

Advanced dictionary and prefix API (Requires v1.4.0+)

- This API allows dictionaries to be used with ZSTD_compress2(),
- ZSTD_compressStream2(), and ZSTD_decompressDCtx().
- Dictionaries are sticky, they remain valid when same context is re-used,
- they only reset when the context is reset
- with ZSTD_reset_parameters or ZSTD_reset_session_and_parameters.
- In contrast, Prefixes are single-use.
-
- -
size_t ZSTD_CCtx_loadDictionary(ZSTD_CCtx* cctx, const void* dict, size_t dictSize);
-

Create an internal CDict from `dict` buffer. - Decompression will have to use same dictionary. - @result : 0, or an error code (which can be tested with ZSTD_isError()). - Special: Loading a NULL (or 0-size) dictionary invalidates previous dictionary, - meaning "return to no-dictionary mode". - Note 1 : Dictionary is sticky, it will be used for all future compressed frames, - until parameters are reset, a new dictionary is loaded, or the dictionary - is explicitly invalidated by loading a NULL dictionary. - Note 2 : Loading a dictionary involves building tables. - It's also a CPU consuming operation, with non-negligible impact on latency. - Tables are dependent on compression parameters, and for this reason, - compression parameters can no longer be changed after loading a dictionary. - Note 3 :`dict` content will be copied internally. - Use experimental ZSTD_CCtx_loadDictionary_byReference() to reference content instead. - In such a case, dictionary buffer must outlive its users. - Note 4 : Use ZSTD_CCtx_loadDictionary_advanced() - to precisely select how dictionary content must be interpreted. - Note 5 : This method does not benefit from LDM (long distance mode). - If you want to employ LDM on some large dictionary content, - prefer employing ZSTD_CCtx_refPrefix() described below. - -


- -
size_t ZSTD_CCtx_refCDict(ZSTD_CCtx* cctx, const ZSTD_CDict* cdict);
-

Reference a prepared dictionary, to be used for all future compressed frames. - Note that compression parameters are enforced from within CDict, - and supersede any compression parameter previously set within CCtx. - The parameters ignored are labelled as "superseded-by-cdict" in the ZSTD_cParameter enum docs. - The ignored parameters will be used again if the CCtx is returned to no-dictionary mode. - The dictionary will remain valid for future compressed frames using same CCtx. - @result : 0, or an error code (which can be tested with ZSTD_isError()). - Special : Referencing a NULL CDict means "return to no-dictionary mode". - Note 1 : Currently, only one dictionary can be managed. - Referencing a new dictionary effectively "discards" any previous one. - Note 2 : CDict is just referenced, its lifetime must outlive its usage within CCtx. -


- -
size_t ZSTD_CCtx_refPrefix(ZSTD_CCtx* cctx,
-                     const void* prefix, size_t prefixSize);
-

Reference a prefix (single-usage dictionary) for next compressed frame. - A prefix is **only used once**. Tables are discarded at end of frame (ZSTD_e_end). - Decompression will need same prefix to properly regenerate data. - Compressing with a prefix is similar in outcome as performing a diff and compressing it, - but performs much faster, especially during decompression (compression speed is tunable with compression level). - This method is compatible with LDM (long distance mode). - @result : 0, or an error code (which can be tested with ZSTD_isError()). - Special: Adding any prefix (including NULL) invalidates any previous prefix or dictionary - Note 1 : Prefix buffer is referenced. It **must** outlive compression. - Its content must remain unmodified during compression. - Note 2 : If the intention is to diff some large src data blob with some prior version of itself, - ensure that the window size is large enough to contain the entire source. - See ZSTD_c_windowLog. - Note 3 : Referencing a prefix involves building tables, which are dependent on compression parameters. - It's a CPU consuming operation, with non-negligible impact on latency. - If there is a need to use the same prefix multiple times, consider loadDictionary instead. - Note 4 : By default, the prefix is interpreted as raw content (ZSTD_dct_rawContent). - Use experimental ZSTD_CCtx_refPrefix_advanced() to alter dictionary interpretation. -


- -
size_t ZSTD_DCtx_loadDictionary(ZSTD_DCtx* dctx, const void* dict, size_t dictSize);
-

Create an internal DDict from dict buffer, to be used to decompress all future frames. - The dictionary remains valid for all future frames, until explicitly invalidated, or - a new dictionary is loaded. - @result : 0, or an error code (which can be tested with ZSTD_isError()). - Special : Adding a NULL (or 0-size) dictionary invalidates any previous dictionary, - meaning "return to no-dictionary mode". - Note 1 : Loading a dictionary involves building tables, - which has a non-negligible impact on CPU usage and latency. - It's recommended to "load once, use many times", to amortize the cost - Note 2 :`dict` content will be copied internally, so `dict` can be released after loading. - Use ZSTD_DCtx_loadDictionary_byReference() to reference dictionary content instead. - Note 3 : Use ZSTD_DCtx_loadDictionary_advanced() to take control of - how dictionary content is loaded and interpreted. - -


- -
size_t ZSTD_DCtx_refDDict(ZSTD_DCtx* dctx, const ZSTD_DDict* ddict);
-

Reference a prepared dictionary, to be used to decompress next frames. - The dictionary remains active for decompression of future frames using same DCtx. - - If called with ZSTD_d_refMultipleDDicts enabled, repeated calls of this function - will store the DDict references in a table, and the DDict used for decompression - will be determined at decompression time, as per the dict ID in the frame. - The memory for the table is allocated on the first call to refDDict, and can be - freed with ZSTD_freeDCtx(). - - If called with ZSTD_d_refMultipleDDicts disabled (the default), only one dictionary - will be managed, and referencing a dictionary effectively "discards" any previous one. - - @result : 0, or an error code (which can be tested with ZSTD_isError()). - Special: referencing a NULL DDict means "return to no-dictionary mode". - Note 2 : DDict is just referenced, its lifetime must outlive its usage from DCtx. - -


- -
size_t ZSTD_DCtx_refPrefix(ZSTD_DCtx* dctx,
-                     const void* prefix, size_t prefixSize);
-

Reference a prefix (single-usage dictionary) to decompress next frame. - This is the reverse operation of ZSTD_CCtx_refPrefix(), - and must use the same prefix as the one used during compression. - Prefix is **only used once**. Reference is discarded at end of frame. - End of frame is reached when ZSTD_decompressStream() returns 0. - @result : 0, or an error code (which can be tested with ZSTD_isError()). - Note 1 : Adding any prefix (including NULL) invalidates any previously set prefix or dictionary - Note 2 : Prefix buffer is referenced. It **must** outlive decompression. - Prefix buffer must remain unmodified up to the end of frame, - reached when ZSTD_decompressStream() returns 0. - Note 3 : By default, the prefix is treated as raw content (ZSTD_dct_rawContent). - Use ZSTD_CCtx_refPrefix_advanced() to alter dictMode (Experimental section) - Note 4 : Referencing a raw content prefix has almost no cpu nor memory cost. - A full dictionary is more costly, as it requires building tables. - -


- -
size_t ZSTD_sizeof_CCtx(const ZSTD_CCtx* cctx);
-size_t ZSTD_sizeof_DCtx(const ZSTD_DCtx* dctx);
-size_t ZSTD_sizeof_CStream(const ZSTD_CStream* zcs);
-size_t ZSTD_sizeof_DStream(const ZSTD_DStream* zds);
-size_t ZSTD_sizeof_CDict(const ZSTD_CDict* cdict);
-size_t ZSTD_sizeof_DDict(const ZSTD_DDict* ddict);
-

These functions give the _current_ memory usage of selected object. - Note that object memory usage can evolve (increase or decrease) over time. -


- -

experimental API (static linking only)

- The following symbols and constants
- are not planned to join "stable API" status in the near future.
- They can still change in future versions.
- Some of them are planned to remain in the static_only section indefinitely.
- Some of them might be removed in the future (especially when redundant with existing stable functions)
- 
-
- -
typedef struct {
-    unsigned int offset;      /* The offset of the match. (NOT the same as the offset code)
-                               * If offset == 0 and matchLength == 0, this sequence represents the last
-                               * literals in the block of litLength size.
-                               */
-
-    unsigned int litLength;   /* Literal length of the sequence. */
-    unsigned int matchLength; /* Match length of the sequence. */
-
-                              /* Note: Users of this API may provide a sequence with matchLength == litLength == offset == 0.
-                               * In this case, we will treat the sequence as a marker for a block boundary.
-                               */
-
-    unsigned int rep;         /* Represents which repeat offset is represented by the field 'offset'.
-                               * Ranges from [0, 3].
-                               *
-                               * Repeat offsets are essentially previous offsets from previous sequences sorted in
-                               * recency order. For more detail, see doc/zstd_compression_format.md
-                               *
-                               * If rep == 0, then 'offset' does not contain a repeat offset.
-                               * If rep > 0:
-                               *  If litLength != 0:
-                               *      rep == 1 --> offset == repeat_offset_1
-                               *      rep == 2 --> offset == repeat_offset_2
-                               *      rep == 3 --> offset == repeat_offset_3
-                               *  If litLength == 0:
-                               *      rep == 1 --> offset == repeat_offset_2
-                               *      rep == 2 --> offset == repeat_offset_3
-                               *      rep == 3 --> offset == repeat_offset_1 - 1
-                               *
-                               * Note: This field is optional. ZSTD_generateSequences() will calculate the value of
-                               * 'rep', but repeat offsets do not necessarily need to be calculated from an external
-                               * sequence provider's perspective. For example, ZSTD_compressSequences() does not
-                               * use this 'rep' field at all (as of now).
-                               */
-} ZSTD_Sequence;
-

-
typedef struct {
-    unsigned windowLog;       /**< largest match distance : larger == more compression, more memory needed during decompression */
-    unsigned chainLog;        /**< fully searched segment : larger == more compression, slower, more memory (useless for fast) */
-    unsigned hashLog;         /**< dispatch table : larger == faster, more memory */
-    unsigned searchLog;       /**< nb of searches : larger == more compression, slower */
-    unsigned minMatch;        /**< match length searched : larger == faster decompression, sometimes less compression */
-    unsigned targetLength;    /**< acceptable match size for optimal parser (only) : larger == more compression, slower */
-    ZSTD_strategy strategy;   /**< see ZSTD_strategy definition above */
-} ZSTD_compressionParameters;
-

-
typedef struct {
-    int contentSizeFlag; /**< 1: content size will be in frame header (when known) */
-    int checksumFlag;    /**< 1: generate a 32-bits checksum using XXH64 algorithm at end of frame, for error detection */
-    int noDictIDFlag;    /**< 1: no dictID will be saved into frame header (dictID is only useful for dictionary compression) */
-} ZSTD_frameParameters;
-

-
typedef struct {
-    ZSTD_compressionParameters cParams;
-    ZSTD_frameParameters fParams;
-} ZSTD_parameters;
-

-
typedef enum {
-    ZSTD_dct_auto = 0,       /* dictionary is "full" when starting with ZSTD_MAGIC_DICTIONARY, otherwise it is "rawContent" */
-    ZSTD_dct_rawContent = 1, /* ensures dictionary is always loaded as rawContent, even if it starts with ZSTD_MAGIC_DICTIONARY */
-    ZSTD_dct_fullDict = 2    /* refuses to load a dictionary if it does not respect Zstandard's specification, starting with ZSTD_MAGIC_DICTIONARY */
-} ZSTD_dictContentType_e;
-

-
typedef enum {
-    ZSTD_dlm_byCopy = 0,  /**< Copy dictionary content internally */
-    ZSTD_dlm_byRef = 1    /**< Reference dictionary content -- the dictionary buffer must outlive its users. */
-} ZSTD_dictLoadMethod_e;
-

-
typedef enum {
-    ZSTD_f_zstd1 = 0,           /* zstd frame format, specified in zstd_compression_format.md (default) */
-    ZSTD_f_zstd1_magicless = 1  /* Variant of zstd frame format, without initial 4-bytes magic number.
-                                 * Useful to save 4 bytes per generated frame.
-                                 * Decoder cannot recognise automatically this format, requiring this instruction. */
-} ZSTD_format_e;
-

-
typedef enum {
-    /* Note: this enum controls ZSTD_d_forceIgnoreChecksum */
-    ZSTD_d_validateChecksum = 0,
-    ZSTD_d_ignoreChecksum = 1
-} ZSTD_forceIgnoreChecksum_e;
-

-
typedef enum {
-    /* Note: this enum controls ZSTD_d_refMultipleDDicts */
-    ZSTD_rmd_refSingleDDict = 0,
-    ZSTD_rmd_refMultipleDDicts = 1
-} ZSTD_refMultipleDDicts_e;
-

-
typedef enum {
-    /* Note: this enum and the behavior it controls are effectively internal
-     * implementation details of the compressor. They are expected to continue
-     * to evolve and should be considered only in the context of extremely
-     * advanced performance tuning.
-     *
-     * Zstd currently supports the use of a CDict in three ways:
-     *
-     * - The contents of the CDict can be copied into the working context. This
-     *   means that the compression can search both the dictionary and input
-     *   while operating on a single set of internal tables. This makes
-     *   the compression faster per-byte of input. However, the initial copy of
-     *   the CDict's tables incurs a fixed cost at the beginning of the
-     *   compression. For small compressions (< 8 KB), that copy can dominate
-     *   the cost of the compression.
-     *
-     * - The CDict's tables can be used in-place. In this model, compression is
-     *   slower per input byte, because the compressor has to search two sets of
-     *   tables. However, this model incurs no start-up cost (as long as the
-     *   working context's tables can be reused). For small inputs, this can be
-     *   faster than copying the CDict's tables.
-     *
-     * - The CDict's tables are not used at all, and instead we use the working
-     *   context alone to reload the dictionary and use params based on the source
-     *   size. See ZSTD_compress_insertDictionary() and ZSTD_compress_usingDict().
-     *   This method is effective when the dictionary sizes are very small relative
-     *   to the input size, and the input size is fairly large to begin with.
-     *
-     * Zstd has a simple internal heuristic that selects which strategy to use
-     * at the beginning of a compression. However, if experimentation shows that
-     * Zstd is making poor choices, it is possible to override that choice with
-     * this enum.
-     */
-    ZSTD_dictDefaultAttach = 0, /* Use the default heuristic. */
-    ZSTD_dictForceAttach   = 1, /* Never copy the dictionary. */
-    ZSTD_dictForceCopy     = 2, /* Always copy the dictionary. */
-    ZSTD_dictForceLoad     = 3  /* Always reload the dictionary */
-} ZSTD_dictAttachPref_e;
-

-
typedef enum {
-  ZSTD_lcm_auto = 0,          /**< Automatically determine the compression mode based on the compression level.
-                               *   Negative compression levels will be uncompressed, and positive compression
-                               *   levels will be compressed. */
-  ZSTD_lcm_huffman = 1,       /**< Always attempt Huffman compression. Uncompressed literals will still be
-                               *   emitted if Huffman compression is not profitable. */
-  ZSTD_lcm_uncompressed = 2   /**< Always emit uncompressed literals. */
-} ZSTD_literalCompressionMode_e;
-

-
typedef enum {
-  /* Note: This enum controls features which are conditionally beneficial. Zstd typically will make a final
-   * decision on whether or not to enable the feature (ZSTD_ps_auto), but setting the switch to ZSTD_ps_enable
-   * or ZSTD_ps_disable allow for a force enable/disable the feature.
-   */
-  ZSTD_ps_auto = 0,         /* Let the library automatically determine whether the feature shall be enabled */
-  ZSTD_ps_enable = 1,       /* Force-enable the feature */
-  ZSTD_ps_disable = 2       /* Do not use the feature */
-} ZSTD_paramSwitch_e;
-

-

Frame header and size functions


-
-
ZSTDLIB_STATIC_API unsigned long long ZSTD_findDecompressedSize(const void* src, size_t srcSize);
-

`src` should point to the start of a series of ZSTD encoded and/or skippable frames - `srcSize` must be the _exact_ size of this series - (i.e. there should be a frame boundary at `src + srcSize`) - @return : - decompressed size of all data in all successive frames - - if the decompressed size cannot be determined: ZSTD_CONTENTSIZE_UNKNOWN - - if an error occurred: ZSTD_CONTENTSIZE_ERROR - - note 1 : decompressed size is an optional field, that may not be present, especially in streaming mode. - When `return==ZSTD_CONTENTSIZE_UNKNOWN`, data to decompress could be any size. - In which case, it's necessary to use streaming mode to decompress data. - note 2 : decompressed size is always present when compression is done with ZSTD_compress() - note 3 : decompressed size can be very large (64-bits value), - potentially larger than what local system can handle as a single memory segment. - In which case, it's necessary to use streaming mode to decompress data. - note 4 : If source is untrusted, decompressed size could be wrong or intentionally modified. - Always ensure result fits within application's authorized limits. - Each application can set its own limits. - note 5 : ZSTD_findDecompressedSize handles multiple frames, and so it must traverse the input to - read each contained frame header. This is fast as most of the data is skipped, - however it does mean that all frame data must be present and valid. -


- -
ZSTDLIB_STATIC_API unsigned long long ZSTD_decompressBound(const void* src, size_t srcSize);
-

`src` should point to the start of a series of ZSTD encoded and/or skippable frames - `srcSize` must be the _exact_ size of this series - (i.e. there should be a frame boundary at `src + srcSize`) - @return : - upper-bound for the decompressed size of all data in all successive frames - - if an error occurred: ZSTD_CONTENTSIZE_ERROR - - note 1 : an error can occur if `src` contains an invalid or incorrectly formatted frame. - note 2 : the upper-bound is exact when the decompressed size field is available in every ZSTD encoded frame of `src`. - in this case, `ZSTD_findDecompressedSize` and `ZSTD_decompressBound` return the same value. - note 3 : when the decompressed size field isn't available, the upper-bound for that frame is calculated by: - upper-bound = # blocks * min(128 KB, Window_Size) - -


- -
ZSTDLIB_STATIC_API size_t ZSTD_frameHeaderSize(const void* src, size_t srcSize);
-

srcSize must be >= ZSTD_FRAMEHEADERSIZE_PREFIX. - @return : size of the Frame Header, - or an error code (if srcSize is too small) -


- -
typedef enum { ZSTD_frame, ZSTD_skippableFrame } ZSTD_frameType_e;
-

-
typedef struct {
-    unsigned long long frameContentSize; /* if == ZSTD_CONTENTSIZE_UNKNOWN, it means this field is not available. 0 means "empty" */
-    unsigned long long windowSize;       /* can be very large, up to <= frameContentSize */
-    unsigned blockSizeMax;
-    ZSTD_frameType_e frameType;          /* if == ZSTD_skippableFrame, frameContentSize is the size of skippable content */
-    unsigned headerSize;
-    unsigned dictID;
-    unsigned checksumFlag;
-    unsigned _reserved1;
-    unsigned _reserved2;
-} ZSTD_frameHeader;
-

-
ZSTDLIB_STATIC_API size_t ZSTD_getFrameHeader(ZSTD_frameHeader* zfhPtr, const void* src, size_t srcSize);   /**< doesn't consume input */
-/*! ZSTD_getFrameHeader_advanced() :
- *  same as ZSTD_getFrameHeader(),
- *  with added capability to select a format (like ZSTD_f_zstd1_magicless) */
-ZSTDLIB_STATIC_API size_t ZSTD_getFrameHeader_advanced(ZSTD_frameHeader* zfhPtr, const void* src, size_t srcSize, ZSTD_format_e format);
-

decode Frame Header, or requires larger `srcSize`. - @return : 0, `zfhPtr` is correctly filled, - >0, `srcSize` is too small, value is wanted `srcSize` amount, - or an error code, which can be tested using ZSTD_isError() -


- -
ZSTDLIB_STATIC_API size_t ZSTD_decompressionMargin(const void* src, size_t srcSize);
-

Zstd supports in-place decompression, where the input and output buffers overlap. - In this case, the output buffer must be at least (Margin + Output_Size) bytes large, - and the input buffer must be at the end of the output buffer. - - _______________________ Output Buffer ________________________ - | | - | ____ Input Buffer ____| - | | | - v v v - |---------------------------------------|-----------|----------| - ^ ^ ^ - |___________________ Output_Size ___________________|_ Margin _| - - NOTE: See also ZSTD_DECOMPRESSION_MARGIN(). - NOTE: This applies only to single-pass decompression through ZSTD_decompress() or - ZSTD_decompressDCtx(). - NOTE: This function supports multi-frame input. - - @param src The compressed frame(s) - @param srcSize The size of the compressed frame(s) - @returns The decompression margin or an error that can be checked with ZSTD_isError(). - -


- -
#define ZSTD_DECOMPRESSION_MARGIN(originalSize, blockSize) ((size_t)(                                              \
-        ZSTD_FRAMEHEADERSIZE_MAX                                                              /* Frame header */ + \
-        4                                                                                         /* checksum */ + \
-        ((originalSize) == 0 ? 0 : 3 * (((originalSize) + (blockSize) - 1) / blockSize)) /* 3 bytes per block */ + \
-        (blockSize)                                                                    /* One block of margin */   \
-    ))
-

Similar to ZSTD_decompressionMargin(), but instead of computing the margin from - the compressed frame, compute it from the original size and the blockSizeLog. - See ZSTD_decompressionMargin() for details. - - WARNING: This macro does not support multi-frame input, the input must be a single - zstd frame. If you need that support use the function, or implement it yourself. - - @param originalSize The original uncompressed size of the data. - @param blockSize The block size == MIN(windowSize, ZSTD_BLOCKSIZE_MAX). - Unless you explicitly set the windowLog smaller than - ZSTD_BLOCKSIZELOG_MAX you can just use ZSTD_BLOCKSIZE_MAX. - -


- -
typedef enum {
-  ZSTD_sf_noBlockDelimiters = 0,         /* Representation of ZSTD_Sequence has no block delimiters, sequences only */
-  ZSTD_sf_explicitBlockDelimiters = 1    /* Representation of ZSTD_Sequence contains explicit block delimiters */
-} ZSTD_sequenceFormat_e;
-

-
ZSTDLIB_STATIC_API size_t ZSTD_sequenceBound(size_t srcSize);
-

`srcSize` : size of the input buffer - @return : upper-bound for the number of sequences that can be generated - from a buffer of srcSize bytes - - note : returns number of sequences - to get bytes, multiply by sizeof(ZSTD_Sequence). - -


- -

Generate sequences using ZSTD_compress2(), given a source buffer. - - Each block will end with a dummy sequence - with offset == 0, matchLength == 0, and litLength == length of last literals. - litLength may be == 0, and if so, then the sequence of (of: 0 ml: 0 ll: 0) - simply acts as a block delimiter. - - @zc can be used to insert custom compression params. - This function invokes ZSTD_compress2(). - - The output of this function can be fed into ZSTD_compressSequences() with CCtx - setting of ZSTD_c_blockDelimiters as ZSTD_sf_explicitBlockDelimiters - @return : number of sequences generated - -


- -
ZSTDLIB_STATIC_API size_t ZSTD_mergeBlockDelimiters(ZSTD_Sequence* sequences, size_t seqsSize);
-

Given an array of ZSTD_Sequence, remove all sequences that represent block delimiters/last literals - by merging them into the literals of the next sequence. - - As such, the final generated result has no explicit representation of block boundaries, - and the final last literals segment is not represented in the sequences. - - The output of this function can be fed into ZSTD_compressSequences() with CCtx - setting of ZSTD_c_blockDelimiters as ZSTD_sf_noBlockDelimiters - @return : number of sequences left after merging - -


- -
ZSTDLIB_STATIC_API size_t
-ZSTD_compressSequences( ZSTD_CCtx* cctx, void* dst, size_t dstSize,
-            const ZSTD_Sequence* inSeqs, size_t inSeqsSize,
-            const void* src, size_t srcSize);
-

Compress an array of ZSTD_Sequence, associated with @src buffer, into dst. - @src contains the entire input (not just the literals). - If @srcSize > sum(sequence.length), the remaining bytes are considered all literals - If a dictionary is included, then the cctx should reference the dict. (see: ZSTD_CCtx_refCDict(), ZSTD_CCtx_loadDictionary(), etc.) - The entire source is compressed into a single frame. - - The compression behavior changes based on cctx params. In particular: - If ZSTD_c_blockDelimiters == ZSTD_sf_noBlockDelimiters, the array of ZSTD_Sequence is expected to contain - no block delimiters (defined in ZSTD_Sequence). Block boundaries are roughly determined based on - the block size derived from the cctx, and sequences may be split. This is the default setting. - - If ZSTD_c_blockDelimiters == ZSTD_sf_explicitBlockDelimiters, the array of ZSTD_Sequence is expected to contain - block delimiters (defined in ZSTD_Sequence). Behavior is undefined if no block delimiters are provided. - - If ZSTD_c_validateSequences == 0, this function will blindly accept the sequences provided. Invalid sequences cause undefined - behavior. If ZSTD_c_validateSequences == 1, then if sequence is invalid (see doc/zstd_compression_format.md for - specifics regarding offset/matchlength requirements) then the function will bail out and return an error. - - In addition to the two adjustable experimental params, there are other important cctx params. - - ZSTD_c_minMatch MUST be set as less than or equal to the smallest match generated by the match finder. It has a minimum value of ZSTD_MINMATCH_MIN. - - ZSTD_c_compressionLevel accordingly adjusts the strength of the entropy coder, as it would in typical compression. - - ZSTD_c_windowLog affects offset validation: this function will return an error at higher debug levels if a provided offset - is larger than what the spec allows for a given window log and dictionary (if present). See: doc/zstd_compression_format.md - - Note: Repcodes are, as of now, always re-calculated within this function, so ZSTD_Sequence::rep is unused. - Note 2: Once we integrate ability to ingest repcodes, the explicit block delims mode must respect those repcodes exactly, - and cannot emit an RLE block that disagrees with the repcode history - @return : final compressed size, or a ZSTD error code. - -


- -
ZSTDLIB_STATIC_API size_t ZSTD_writeSkippableFrame(void* dst, size_t dstCapacity,
-                                const void* src, size_t srcSize, unsigned magicVariant);
-

Generates a zstd skippable frame containing data given by src, and writes it to dst buffer. - - Skippable frames begin with a 4-byte magic number. There are 16 possible choices of magic number, - ranging from ZSTD_MAGIC_SKIPPABLE_START to ZSTD_MAGIC_SKIPPABLE_START+15. - As such, the parameter magicVariant controls the exact skippable frame magic number variant used, so - the magic number used will be ZSTD_MAGIC_SKIPPABLE_START + magicVariant. - - Returns an error if destination buffer is not large enough, if the source size is not representable - with a 4-byte unsigned int, or if the parameter magicVariant is greater than 15 (and therefore invalid). - - @return : number of bytes written or a ZSTD error. - -


- -
size_t ZSTD_readSkippableFrame(void* dst, size_t dstCapacity, unsigned* magicVariant,
-                                const void* src, size_t srcSize);
-

Retrieves a zstd skippable frame containing data given by src, and writes it to dst buffer. - - The parameter magicVariant will receive the magicVariant that was supplied when the frame was written, - i.e. magicNumber - ZSTD_MAGIC_SKIPPABLE_START. This can be NULL if the caller is not interested - in the magicVariant. - - Returns an error if destination buffer is not large enough, or if the frame is not skippable. - - @return : number of bytes written or a ZSTD error. - -


- -
unsigned ZSTD_isSkippableFrame(const void* buffer, size_t size);
-

Tells if the content of `buffer` starts with a valid Frame Identifier for a skippable frame. - -


- -

Memory management


-
-
ZSTDLIB_STATIC_API size_t ZSTD_estimateCCtxSize(int compressionLevel);
-ZSTDLIB_STATIC_API size_t ZSTD_estimateCCtxSize_usingCParams(ZSTD_compressionParameters cParams);
-ZSTDLIB_STATIC_API size_t ZSTD_estimateCCtxSize_usingCCtxParams(const ZSTD_CCtx_params* params);
-ZSTDLIB_STATIC_API size_t ZSTD_estimateDCtxSize(void);
-

These functions make it possible to estimate memory usage - of a future {D,C}Ctx, before its creation. - - ZSTD_estimateCCtxSize() will provide a memory budget large enough - for any compression level up to selected one. - Note : Unlike ZSTD_estimateCStreamSize*(), this estimate - does not include space for a window buffer. - Therefore, the estimation is only guaranteed for single-shot compressions, not streaming. - The estimate will assume the input may be arbitrarily large, - which is the worst case. - - When srcSize can be bound by a known and rather "small" value, - this fact can be used to provide a tighter estimation - because the CCtx compression context will need less memory. - This tighter estimation can be provided by more advanced functions - ZSTD_estimateCCtxSize_usingCParams(), which can be used in tandem with ZSTD_getCParams(), - and ZSTD_estimateCCtxSize_usingCCtxParams(), which can be used in tandem with ZSTD_CCtxParams_setParameter(). - Both can be used to estimate memory using custom compression parameters and arbitrary srcSize limits. - - Note : only single-threaded compression is supported. - ZSTD_estimateCCtxSize_usingCCtxParams() will return an error code if ZSTD_c_nbWorkers is >= 1. - - Note 2 : ZSTD_estimateCCtxSize* functions are not compatible with the Block-Level Sequence Producer API at this time. - Size estimates assume that no external sequence producer is registered. - -


- -
ZSTDLIB_STATIC_API size_t ZSTD_estimateCStreamSize(int compressionLevel);
-ZSTDLIB_STATIC_API size_t ZSTD_estimateCStreamSize_usingCParams(ZSTD_compressionParameters cParams);
-ZSTDLIB_STATIC_API size_t ZSTD_estimateCStreamSize_usingCCtxParams(const ZSTD_CCtx_params* params);
-ZSTDLIB_STATIC_API size_t ZSTD_estimateDStreamSize(size_t windowSize);
-ZSTDLIB_STATIC_API size_t ZSTD_estimateDStreamSize_fromFrame(const void* src, size_t srcSize);
-

ZSTD_estimateCStreamSize() will provide a budget large enough for any compression level up to selected one. - It will also consider src size to be arbitrarily "large", which is worst case. - If srcSize is known to always be small, ZSTD_estimateCStreamSize_usingCParams() can provide a tighter estimation. - ZSTD_estimateCStreamSize_usingCParams() can be used in tandem with ZSTD_getCParams() to create cParams from compressionLevel. - ZSTD_estimateCStreamSize_usingCCtxParams() can be used in tandem with ZSTD_CCtxParams_setParameter(). Only single-threaded compression is supported. This function will return an error code if ZSTD_c_nbWorkers is >= 1. - Note : CStream size estimation is only correct for single-threaded compression. - ZSTD_DStream memory budget depends on window Size. - This information can be passed manually, using ZSTD_estimateDStreamSize, - or deducted from a valid frame Header, using ZSTD_estimateDStreamSize_fromFrame(); - Note : if streaming is init with function ZSTD_init?Stream_usingDict(), - an internal ?Dict will be created, which additional size is not estimated here. - In this case, get total size by adding ZSTD_estimate?DictSize - Note 2 : only single-threaded compression is supported. - ZSTD_estimateCStreamSize_usingCCtxParams() will return an error code if ZSTD_c_nbWorkers is >= 1. - Note 3 : ZSTD_estimateCStreamSize* functions are not compatible with the Block-Level Sequence Producer API at this time. - Size estimates assume that no external sequence producer is registered. - -


- -
ZSTDLIB_STATIC_API size_t ZSTD_estimateCDictSize(size_t dictSize, int compressionLevel);
-ZSTDLIB_STATIC_API size_t ZSTD_estimateCDictSize_advanced(size_t dictSize, ZSTD_compressionParameters cParams, ZSTD_dictLoadMethod_e dictLoadMethod);
-ZSTDLIB_STATIC_API size_t ZSTD_estimateDDictSize(size_t dictSize, ZSTD_dictLoadMethod_e dictLoadMethod);
-

ZSTD_estimateCDictSize() will bet that src size is relatively "small", and content is copied, like ZSTD_createCDict(). - ZSTD_estimateCDictSize_advanced() makes it possible to control compression parameters precisely, like ZSTD_createCDict_advanced(). - Note : dictionaries created by reference (`ZSTD_dlm_byRef`) are logically smaller. - -


- -
ZSTDLIB_STATIC_API ZSTD_CCtx*    ZSTD_initStaticCCtx(void* workspace, size_t workspaceSize);
-ZSTDLIB_STATIC_API ZSTD_CStream* ZSTD_initStaticCStream(void* workspace, size_t workspaceSize);    /**< same as ZSTD_initStaticCCtx() */
-

Initialize an object using a pre-allocated fixed-size buffer. - workspace: The memory area to emplace the object into. - Provided pointer *must be 8-bytes aligned*. - Buffer must outlive object. - workspaceSize: Use ZSTD_estimate*Size() to determine - how large workspace must be to support target scenario. - @return : pointer to object (same address as workspace, just different type), - or NULL if error (size too small, incorrect alignment, etc.) - Note : zstd will never resize nor malloc() when using a static buffer. - If the object requires more memory than available, - zstd will just error out (typically ZSTD_error_memory_allocation). - Note 2 : there is no corresponding "free" function. - Since workspace is allocated externally, it must be freed externally too. - Note 3 : cParams : use ZSTD_getCParams() to convert a compression level - into its associated cParams. - Limitation 1 : currently not compatible with internal dictionary creation, triggered by - ZSTD_CCtx_loadDictionary(), ZSTD_initCStream_usingDict() or ZSTD_initDStream_usingDict(). - Limitation 2 : static cctx currently not compatible with multi-threading. - Limitation 3 : static dctx is incompatible with legacy support. - -


- -
ZSTDLIB_STATIC_API ZSTD_DStream* ZSTD_initStaticDStream(void* workspace, size_t workspaceSize);    /**< same as ZSTD_initStaticDCtx() */
-

-
typedef void* (*ZSTD_allocFunction) (void* opaque, size_t size);
-typedef void  (*ZSTD_freeFunction) (void* opaque, void* address);
-typedef struct { ZSTD_allocFunction customAlloc; ZSTD_freeFunction customFree; void* opaque; } ZSTD_customMem;
-static
-#ifdef __GNUC__
-__attribute__((__unused__))
-#endif
-ZSTD_customMem const ZSTD_defaultCMem = { NULL, NULL, NULL };  /**< this constant defers to stdlib's functions */
-

These prototypes make it possible to pass your own allocation/free functions. - ZSTD_customMem is provided at creation time, using ZSTD_create*_advanced() variants listed below. - All allocation/free operations will be completed using these custom variants instead of regular ones. - -


- -
typedef struct POOL_ctx_s ZSTD_threadPool;
-ZSTDLIB_STATIC_API ZSTD_threadPool* ZSTD_createThreadPool(size_t numThreads);
-ZSTDLIB_STATIC_API void ZSTD_freeThreadPool (ZSTD_threadPool* pool);  /* accept NULL pointer */
-ZSTDLIB_STATIC_API size_t ZSTD_CCtx_refThreadPool(ZSTD_CCtx* cctx, ZSTD_threadPool* pool);
-

These prototypes make it possible to share a thread pool among multiple compression contexts. - This can limit resources for applications with multiple threads where each one uses - a threaded compression mode (via ZSTD_c_nbWorkers parameter). - ZSTD_createThreadPool creates a new thread pool with a given number of threads. - Note that the lifetime of such pool must exist while being used. - ZSTD_CCtx_refThreadPool assigns a thread pool to a context (use NULL argument value - to use an internal thread pool). - ZSTD_freeThreadPool frees a thread pool, accepts NULL pointer. - -


- -

Advanced compression functions


-
-
ZSTDLIB_STATIC_API ZSTD_CDict* ZSTD_createCDict_byReference(const void* dictBuffer, size_t dictSize, int compressionLevel);
-

Create a digested dictionary for compression - Dictionary content is just referenced, not duplicated. - As a consequence, `dictBuffer` **must** outlive CDict, - and its content must remain unmodified throughout the lifetime of CDict. - note: equivalent to ZSTD_createCDict_advanced(), with dictLoadMethod==ZSTD_dlm_byRef -


- -
ZSTDLIB_STATIC_API ZSTD_compressionParameters ZSTD_getCParams(int compressionLevel, unsigned long long estimatedSrcSize, size_t dictSize);
-

@return ZSTD_compressionParameters structure for a selected compression level and estimated srcSize. - `estimatedSrcSize` value is optional, select 0 if not known -


- -
ZSTDLIB_STATIC_API ZSTD_parameters ZSTD_getParams(int compressionLevel, unsigned long long estimatedSrcSize, size_t dictSize);
-

same as ZSTD_getCParams(), but @return a full `ZSTD_parameters` object instead of sub-component `ZSTD_compressionParameters`. - All fields of `ZSTD_frameParameters` are set to default : contentSize=1, checksum=0, noDictID=0 -


- -
ZSTDLIB_STATIC_API size_t ZSTD_checkCParams(ZSTD_compressionParameters params);
-

Ensure param values remain within authorized range. - @return 0 on success, or an error code (can be checked with ZSTD_isError()) -


- -
ZSTDLIB_STATIC_API ZSTD_compressionParameters ZSTD_adjustCParams(ZSTD_compressionParameters cPar, unsigned long long srcSize, size_t dictSize);
-

optimize params for a given `srcSize` and `dictSize`. - `srcSize` can be unknown, in which case use ZSTD_CONTENTSIZE_UNKNOWN. - `dictSize` must be `0` when there is no dictionary. - cPar can be invalid : all parameters will be clamped within valid range in the @return struct. - This function never fails (wide contract) -


- -
ZSTDLIB_STATIC_API size_t ZSTD_CCtx_setCParams(ZSTD_CCtx* cctx, ZSTD_compressionParameters cparams);
-

Set all parameters provided within @p cparams into the working @p cctx. - Note : if modifying parameters during compression (MT mode only), - note that changes to the .windowLog parameter will be ignored. - @return 0 on success, or an error code (can be checked with ZSTD_isError()). - On failure, no parameters are updated. - -


- -
ZSTDLIB_STATIC_API size_t ZSTD_CCtx_setFParams(ZSTD_CCtx* cctx, ZSTD_frameParameters fparams);
-

Set all parameters provided within @p fparams into the working @p cctx. - @return 0 on success, or an error code (can be checked with ZSTD_isError()). - -


- -
ZSTDLIB_STATIC_API size_t ZSTD_CCtx_setParams(ZSTD_CCtx* cctx, ZSTD_parameters params);
-

Set all parameters provided within @p params into the working @p cctx. - @return 0 on success, or an error code (can be checked with ZSTD_isError()). - -


- -
ZSTD_DEPRECATED("use ZSTD_compress2")
-ZSTDLIB_STATIC_API
-size_t ZSTD_compress_advanced(ZSTD_CCtx* cctx,
-                  void* dst, size_t dstCapacity,
-            const void* src, size_t srcSize,
-            const void* dict,size_t dictSize,
-                  ZSTD_parameters params);
-

Note : this function is now DEPRECATED. - It can be replaced by ZSTD_compress2(), in combination with ZSTD_CCtx_setParameter() and other parameter setters. - This prototype will generate compilation warnings. -


- -
ZSTD_DEPRECATED("use ZSTD_compress2 with ZSTD_CCtx_loadDictionary")
-ZSTDLIB_STATIC_API
-size_t ZSTD_compress_usingCDict_advanced(ZSTD_CCtx* cctx,
-                                  void* dst, size_t dstCapacity,
-                            const void* src, size_t srcSize,
-                            const ZSTD_CDict* cdict,
-                                  ZSTD_frameParameters fParams);
-

Note : this function is now DEPRECATED. - It can be replaced by ZSTD_compress2(), in combination with ZSTD_CCtx_loadDictionary() and other parameter setters. - This prototype will generate compilation warnings. -


- -
ZSTDLIB_STATIC_API size_t ZSTD_CCtx_loadDictionary_byReference(ZSTD_CCtx* cctx, const void* dict, size_t dictSize);
-

Same as ZSTD_CCtx_loadDictionary(), but dictionary content is referenced, instead of being copied into CCtx. - It saves some memory, but also requires that `dict` outlives its usage within `cctx` -


- -
ZSTDLIB_STATIC_API size_t ZSTD_CCtx_loadDictionary_advanced(ZSTD_CCtx* cctx, const void* dict, size_t dictSize, ZSTD_dictLoadMethod_e dictLoadMethod, ZSTD_dictContentType_e dictContentType);
-

Same as ZSTD_CCtx_loadDictionary(), but gives finer control over - how to load the dictionary (by copy ? by reference ?) - and how to interpret it (automatic ? force raw mode ? full mode only ?) -


- -
ZSTDLIB_STATIC_API size_t ZSTD_CCtx_refPrefix_advanced(ZSTD_CCtx* cctx, const void* prefix, size_t prefixSize, ZSTD_dictContentType_e dictContentType);
-

Same as ZSTD_CCtx_refPrefix(), but gives finer control over - how to interpret prefix content (automatic ? force raw mode (default) ? full mode only ?) -


- -
ZSTDLIB_STATIC_API size_t ZSTD_CCtx_getParameter(const ZSTD_CCtx* cctx, ZSTD_cParameter param, int* value);
-

Get the requested compression parameter value, selected by enum ZSTD_cParameter, - and store it into int* value. - @return : 0, or an error code (which can be tested with ZSTD_isError()). - -


- -
ZSTDLIB_STATIC_API ZSTD_CCtx_params* ZSTD_createCCtxParams(void);
-ZSTDLIB_STATIC_API size_t ZSTD_freeCCtxParams(ZSTD_CCtx_params* params);  /* accept NULL pointer */
-

Quick howto : - - ZSTD_createCCtxParams() : Create a ZSTD_CCtx_params structure - - ZSTD_CCtxParams_setParameter() : Push parameters one by one into - an existing ZSTD_CCtx_params structure. - This is similar to - ZSTD_CCtx_setParameter(). - - ZSTD_CCtx_setParametersUsingCCtxParams() : Apply parameters to - an existing CCtx. - These parameters will be applied to - all subsequent frames. - - ZSTD_compressStream2() : Do compression using the CCtx. - - ZSTD_freeCCtxParams() : Free the memory, accept NULL pointer. - - This can be used with ZSTD_estimateCCtxSize_advanced_usingCCtxParams() - for static allocation of CCtx for single-threaded compression. - -


- -
ZSTDLIB_STATIC_API size_t ZSTD_CCtxParams_reset(ZSTD_CCtx_params* params);
-

Reset params to default values. - -


- -
ZSTDLIB_STATIC_API size_t ZSTD_CCtxParams_init(ZSTD_CCtx_params* cctxParams, int compressionLevel);
-

Initializes the compression parameters of cctxParams according to - compression level. All other parameters are reset to their default values. - -


- -
ZSTDLIB_STATIC_API size_t ZSTD_CCtxParams_init_advanced(ZSTD_CCtx_params* cctxParams, ZSTD_parameters params);
-

Initializes the compression and frame parameters of cctxParams according to - params. All other parameters are reset to their default values. - -


- -
ZSTDLIB_STATIC_API size_t ZSTD_CCtxParams_setParameter(ZSTD_CCtx_params* params, ZSTD_cParameter param, int value);
-

Similar to ZSTD_CCtx_setParameter. - Set one compression parameter, selected by enum ZSTD_cParameter. - Parameters must be applied to a ZSTD_CCtx using - ZSTD_CCtx_setParametersUsingCCtxParams(). - @result : a code representing success or failure (which can be tested with - ZSTD_isError()). - -


- -
ZSTDLIB_STATIC_API size_t ZSTD_CCtxParams_getParameter(const ZSTD_CCtx_params* params, ZSTD_cParameter param, int* value);
-

Similar to ZSTD_CCtx_getParameter. - Get the requested value of one compression parameter, selected by enum ZSTD_cParameter. - @result : 0, or an error code (which can be tested with ZSTD_isError()). - -


- -
ZSTDLIB_STATIC_API size_t ZSTD_CCtx_setParametersUsingCCtxParams(
-        ZSTD_CCtx* cctx, const ZSTD_CCtx_params* params);
-

Apply a set of ZSTD_CCtx_params to the compression context. - This can be done even after compression is started, - if nbWorkers==0, this will have no impact until a new compression is started. - if nbWorkers>=1, new parameters will be picked up at next job, - with a few restrictions (windowLog, pledgedSrcSize, nbWorkers, jobSize, and overlapLog are not updated). - -


- -
ZSTDLIB_STATIC_API size_t ZSTD_compressStream2_simpleArgs (
-                ZSTD_CCtx* cctx,
-                void* dst, size_t dstCapacity, size_t* dstPos,
-          const void* src, size_t srcSize, size_t* srcPos,
-                ZSTD_EndDirective endOp);
-

Same as ZSTD_compressStream2(), - but using only integral types as arguments. - This variant might be helpful for binders from dynamic languages - which have troubles handling structures containing memory pointers. - -


- -

Advanced decompression functions


-
-
ZSTDLIB_STATIC_API unsigned ZSTD_isFrame(const void* buffer, size_t size);
-

Tells if the content of `buffer` starts with a valid Frame Identifier. - Note : Frame Identifier is 4 bytes. If `size < 4`, @return will always be 0. - Note 2 : Legacy Frame Identifiers are considered valid only if Legacy Support is enabled. - Note 3 : Skippable Frame Identifiers are considered valid. -


- -
ZSTDLIB_STATIC_API ZSTD_DDict* ZSTD_createDDict_byReference(const void* dictBuffer, size_t dictSize);
-

Create a digested dictionary, ready to start decompression operation without startup delay. - Dictionary content is referenced, and therefore stays in dictBuffer. - It is important that dictBuffer outlives DDict, - it must remain read accessible throughout the lifetime of DDict -


- -
ZSTDLIB_STATIC_API size_t ZSTD_DCtx_loadDictionary_byReference(ZSTD_DCtx* dctx, const void* dict, size_t dictSize);
-

Same as ZSTD_DCtx_loadDictionary(), - but references `dict` content instead of copying it into `dctx`. - This saves memory if `dict` remains around., - However, it's imperative that `dict` remains accessible (and unmodified) while being used, so it must outlive decompression. -


- -
ZSTDLIB_STATIC_API size_t ZSTD_DCtx_loadDictionary_advanced(ZSTD_DCtx* dctx, const void* dict, size_t dictSize, ZSTD_dictLoadMethod_e dictLoadMethod, ZSTD_dictContentType_e dictContentType);
-

Same as ZSTD_DCtx_loadDictionary(), - but gives direct control over - how to load the dictionary (by copy ? by reference ?) - and how to interpret it (automatic ? force raw mode ? full mode only ?). -


- -
ZSTDLIB_STATIC_API size_t ZSTD_DCtx_refPrefix_advanced(ZSTD_DCtx* dctx, const void* prefix, size_t prefixSize, ZSTD_dictContentType_e dictContentType);
-

Same as ZSTD_DCtx_refPrefix(), but gives finer control over - how to interpret prefix content (automatic ? force raw mode (default) ? full mode only ?) -


- -
ZSTDLIB_STATIC_API size_t ZSTD_DCtx_setMaxWindowSize(ZSTD_DCtx* dctx, size_t maxWindowSize);
-

Refuses allocating internal buffers for frames requiring a window size larger than provided limit. - This protects a decoder context from reserving too much memory for itself (potential attack scenario). - This parameter is only useful in streaming mode, since no internal buffer is allocated in single-pass mode. - By default, a decompression context accepts all window sizes <= (1 << ZSTD_WINDOWLOG_LIMIT_DEFAULT) - @return : 0, or an error code (which can be tested using ZSTD_isError()). - -


- -
ZSTDLIB_STATIC_API size_t ZSTD_DCtx_getParameter(ZSTD_DCtx* dctx, ZSTD_dParameter param, int* value);
-

Get the requested decompression parameter value, selected by enum ZSTD_dParameter, - and store it into int* value. - @return : 0, or an error code (which can be tested with ZSTD_isError()). - -


- -
ZSTD_DEPRECATED("use ZSTD_DCtx_setParameter() instead")
-ZSTDLIB_STATIC_API
-size_t ZSTD_DCtx_setFormat(ZSTD_DCtx* dctx, ZSTD_format_e format);
-

This function is REDUNDANT. Prefer ZSTD_DCtx_setParameter(). - Instruct the decoder context about what kind of data to decode next. - This instruction is mandatory to decode data without a fully-formed header, - such ZSTD_f_zstd1_magicless for example. - @return : 0, or an error code (which can be tested using ZSTD_isError()). -


- -
ZSTDLIB_STATIC_API size_t ZSTD_decompressStream_simpleArgs (
-                ZSTD_DCtx* dctx,
-                void* dst, size_t dstCapacity, size_t* dstPos,
-          const void* src, size_t srcSize, size_t* srcPos);
-

Same as ZSTD_decompressStream(), - but using only integral types as arguments. - This can be helpful for binders from dynamic languages - which have troubles handling structures containing memory pointers. - -


- -

Advanced streaming functions

  Warning : most of these functions are now redundant with the Advanced API.
-  Once Advanced API reaches "stable" status,
-  redundant functions will be deprecated, and then at some point removed.
-
- -

Advanced Streaming compression functions


-
ZSTD_DEPRECATED("use ZSTD_CCtx_reset, see zstd.h for detailed instructions")
-ZSTDLIB_STATIC_API
-size_t ZSTD_initCStream_srcSize(ZSTD_CStream* zcs,
-             int compressionLevel,
-             unsigned long long pledgedSrcSize);
-

This function is DEPRECATED, and equivalent to: - ZSTD_CCtx_reset(zcs, ZSTD_reset_session_only); - ZSTD_CCtx_refCDict(zcs, NULL); // clear the dictionary (if any) - ZSTD_CCtx_setParameter(zcs, ZSTD_c_compressionLevel, compressionLevel); - ZSTD_CCtx_setPledgedSrcSize(zcs, pledgedSrcSize); - - pledgedSrcSize must be correct. If it is not known at init time, use - ZSTD_CONTENTSIZE_UNKNOWN. Note that, for compatibility with older programs, - "0" also disables frame content size field. It may be enabled in the future. - This prototype will generate compilation warnings. - -


- -
ZSTD_DEPRECATED("use ZSTD_CCtx_reset, see zstd.h for detailed instructions")
-ZSTDLIB_STATIC_API
-size_t ZSTD_initCStream_usingDict(ZSTD_CStream* zcs,
-         const void* dict, size_t dictSize,
-               int compressionLevel);
-

This function is DEPRECATED, and is equivalent to: - ZSTD_CCtx_reset(zcs, ZSTD_reset_session_only); - ZSTD_CCtx_setParameter(zcs, ZSTD_c_compressionLevel, compressionLevel); - ZSTD_CCtx_loadDictionary(zcs, dict, dictSize); - - Creates of an internal CDict (incompatible with static CCtx), except if - dict == NULL or dictSize < 8, in which case no dict is used. - Note: dict is loaded with ZSTD_dct_auto (treated as a full zstd dictionary if - it begins with ZSTD_MAGIC_DICTIONARY, else as raw content) and ZSTD_dlm_byCopy. - This prototype will generate compilation warnings. - -


- -
ZSTD_DEPRECATED("use ZSTD_CCtx_reset, see zstd.h for detailed instructions")
-ZSTDLIB_STATIC_API
-size_t ZSTD_initCStream_advanced(ZSTD_CStream* zcs,
-        const void* dict, size_t dictSize,
-              ZSTD_parameters params,
-              unsigned long long pledgedSrcSize);
-

This function is DEPRECATED, and is equivalent to: - ZSTD_CCtx_reset(zcs, ZSTD_reset_session_only); - ZSTD_CCtx_setParams(zcs, params); - ZSTD_CCtx_setPledgedSrcSize(zcs, pledgedSrcSize); - ZSTD_CCtx_loadDictionary(zcs, dict, dictSize); - - dict is loaded with ZSTD_dct_auto and ZSTD_dlm_byCopy. - pledgedSrcSize must be correct. - If srcSize is not known at init time, use value ZSTD_CONTENTSIZE_UNKNOWN. - This prototype will generate compilation warnings. - -


- -
ZSTD_DEPRECATED("use ZSTD_CCtx_reset and ZSTD_CCtx_refCDict, see zstd.h for detailed instructions")
-ZSTDLIB_STATIC_API
-size_t ZSTD_initCStream_usingCDict(ZSTD_CStream* zcs, const ZSTD_CDict* cdict);
-

This function is DEPRECATED, and equivalent to: - ZSTD_CCtx_reset(zcs, ZSTD_reset_session_only); - ZSTD_CCtx_refCDict(zcs, cdict); - - note : cdict will just be referenced, and must outlive compression session - This prototype will generate compilation warnings. - -


- -
ZSTD_DEPRECATED("use ZSTD_CCtx_reset and ZSTD_CCtx_refCDict, see zstd.h for detailed instructions")
-ZSTDLIB_STATIC_API
-size_t ZSTD_initCStream_usingCDict_advanced(ZSTD_CStream* zcs,
-                   const ZSTD_CDict* cdict,
-                         ZSTD_frameParameters fParams,
-                         unsigned long long pledgedSrcSize);
-

This function is DEPRECATED, and is equivalent to: - ZSTD_CCtx_reset(zcs, ZSTD_reset_session_only); - ZSTD_CCtx_setFParams(zcs, fParams); - ZSTD_CCtx_setPledgedSrcSize(zcs, pledgedSrcSize); - ZSTD_CCtx_refCDict(zcs, cdict); - - same as ZSTD_initCStream_usingCDict(), with control over frame parameters. - pledgedSrcSize must be correct. If srcSize is not known at init time, use - value ZSTD_CONTENTSIZE_UNKNOWN. - This prototype will generate compilation warnings. - -


- -
ZSTD_DEPRECATED("use ZSTD_CCtx_reset, see zstd.h for detailed instructions")
-ZSTDLIB_STATIC_API
-size_t ZSTD_resetCStream(ZSTD_CStream* zcs, unsigned long long pledgedSrcSize);
-

This function is DEPRECATED, and is equivalent to: - ZSTD_CCtx_reset(zcs, ZSTD_reset_session_only); - ZSTD_CCtx_setPledgedSrcSize(zcs, pledgedSrcSize); - Note: ZSTD_resetCStream() interprets pledgedSrcSize == 0 as ZSTD_CONTENTSIZE_UNKNOWN, but - ZSTD_CCtx_setPledgedSrcSize() does not do the same, so ZSTD_CONTENTSIZE_UNKNOWN must be - explicitly specified. - - start a new frame, using same parameters from previous frame. - This is typically useful to skip dictionary loading stage, since it will re-use it in-place. - Note that zcs must be init at least once before using ZSTD_resetCStream(). - If pledgedSrcSize is not known at reset time, use macro ZSTD_CONTENTSIZE_UNKNOWN. - If pledgedSrcSize > 0, its value must be correct, as it will be written in header, and controlled at the end. - For the time being, pledgedSrcSize==0 is interpreted as "srcSize unknown" for compatibility with older programs, - but it will change to mean "empty" in future version, so use macro ZSTD_CONTENTSIZE_UNKNOWN instead. - @return : 0, or an error code (which can be tested using ZSTD_isError()) - This prototype will generate compilation warnings. - -


- -
typedef struct {
-    unsigned long long ingested;   /* nb input bytes read and buffered */
-    unsigned long long consumed;   /* nb input bytes actually compressed */
-    unsigned long long produced;   /* nb of compressed bytes generated and buffered */
-    unsigned long long flushed;    /* nb of compressed bytes flushed : not provided; can be tracked from caller side */
-    unsigned currentJobID;         /* MT only : latest started job nb */
-    unsigned nbActiveWorkers;      /* MT only : nb of workers actively compressing at probe time */
-} ZSTD_frameProgression;
-

-
ZSTDLIB_STATIC_API size_t ZSTD_toFlushNow(ZSTD_CCtx* cctx);
-

Tell how many bytes are ready to be flushed immediately. - Useful for multithreading scenarios (nbWorkers >= 1). - Probe the oldest active job, defined as oldest job not yet entirely flushed, - and check its output buffer. - @return : amount of data stored in oldest job and ready to be flushed immediately. - if @return == 0, it means either : - + there is no active job (could be checked with ZSTD_frameProgression()), or - + oldest job is still actively compressing data, - but everything it has produced has also been flushed so far, - therefore flush speed is limited by production speed of oldest job - irrespective of the speed of concurrent (and newer) jobs. - -


- -

Advanced Streaming decompression functions


-
ZSTD_DEPRECATED("use ZSTD_DCtx_reset + ZSTD_DCtx_loadDictionary, see zstd.h for detailed instructions")
-ZSTDLIB_STATIC_API size_t ZSTD_initDStream_usingDict(ZSTD_DStream* zds, const void* dict, size_t dictSize);
-

- ZSTD_DCtx_reset(zds, ZSTD_reset_session_only); - ZSTD_DCtx_loadDictionary(zds, dict, dictSize); - - note: no dictionary will be used if dict == NULL or dictSize < 8 - -


- -
ZSTD_DEPRECATED("use ZSTD_DCtx_reset + ZSTD_DCtx_refDDict, see zstd.h for detailed instructions")
-ZSTDLIB_STATIC_API size_t ZSTD_initDStream_usingDDict(ZSTD_DStream* zds, const ZSTD_DDict* ddict);
-

- ZSTD_DCtx_reset(zds, ZSTD_reset_session_only); - ZSTD_DCtx_refDDict(zds, ddict); - - note : ddict is referenced, it must outlive decompression session - -


- -
ZSTD_DEPRECATED("use ZSTD_DCtx_reset, see zstd.h for detailed instructions")
-ZSTDLIB_STATIC_API size_t ZSTD_resetDStream(ZSTD_DStream* zds);
-

- ZSTD_DCtx_reset(zds, ZSTD_reset_session_only); - - re-use decompression parameters from previous init; saves dictionary loading - -


- -
ZSTDLIB_STATIC_API void
-ZSTD_registerSequenceProducer(
-  ZSTD_CCtx* cctx,
-  void* sequenceProducerState,
-  ZSTD_sequenceProducer_F* sequenceProducer
-);
-

Instruct zstd to use a block-level external sequence producer function. - - The sequenceProducerState must be initialized by the caller, and the caller is - responsible for managing its lifetime. This parameter is sticky across - compressions. It will remain set until the user explicitly resets compression - parameters. - - Sequence producer registration is considered to be an "advanced parameter", - part of the "advanced API". This means it will only have an effect on compression - APIs which respect advanced parameters, such as compress2() and compressStream2(). - Older compression APIs such as compressCCtx(), which predate the introduction of - "advanced parameters", will ignore any external sequence producer setting. - - The sequence producer can be "cleared" by registering a NULL function pointer. This - removes all limitations described above in the "LIMITATIONS" section of the API docs. - - The user is strongly encouraged to read the full API documentation (above) before - calling this function. -


- -

Buffer-less and synchronous inner streaming functions (DEPRECATED)

-  This API is deprecated, and will be removed in a future version.
-  It allows streaming (de)compression with user allocated buffers.
-  However, it is hard to use, and not as well tested as the rest of
-  our API.
-
-  Please use the normal streaming API instead: ZSTD_compressStream2,
-  and ZSTD_decompressStream.
-  If there is functionality that you need, but it doesn't provide,
-  please open an issue on our GitHub.
- 
-
- -

Buffer-less streaming compression (synchronous mode)

-  A ZSTD_CCtx object is required to track streaming operations.
-  Use ZSTD_createCCtx() / ZSTD_freeCCtx() to manage resource.
-  ZSTD_CCtx object can be re-used multiple times within successive compression operations.
-
-  Start by initializing a context.
-  Use ZSTD_compressBegin(), or ZSTD_compressBegin_usingDict() for dictionary compression.
-
-  Then, consume your input using ZSTD_compressContinue().
-  There are some important considerations to keep in mind when using this advanced function :
-  - ZSTD_compressContinue() has no internal buffer. It uses externally provided buffers only.
-  - Interface is synchronous : input is consumed entirely and produces 1+ compressed blocks.
-  - Caller must ensure there is enough space in `dst` to store compressed data under worst case scenario.
-    Worst case evaluation is provided by ZSTD_compressBound().
-    ZSTD_compressContinue() doesn't guarantee recover after a failed compression.
-  - ZSTD_compressContinue() presumes prior input ***is still accessible and unmodified*** (up to maximum distance size, see WindowLog).
-    It remembers all previous contiguous blocks, plus one separated memory segment (which can itself consists of multiple contiguous blocks)
-  - ZSTD_compressContinue() detects that prior input has been overwritten when `src` buffer overlaps.
-    In which case, it will "discard" the relevant memory section from its history.
-
-  Finish a frame with ZSTD_compressEnd(), which will write the last block(s) and optional checksum.
-  It's possible to use srcSize==0, in which case, it will write a final empty block to end the frame.
-  Without last block mark, frames are considered unfinished (hence corrupted) by compliant decoders.
-
-  `ZSTD_CCtx` object can be re-used (ZSTD_compressBegin()) to compress again.
-
- -

Buffer-less streaming compression functions

ZSTD_DEPRECATED("The buffer-less API is deprecated in favor of the normal streaming API. See docs.")
-ZSTDLIB_STATIC_API size_t ZSTD_compressBegin(ZSTD_CCtx* cctx, int compressionLevel);
-ZSTD_DEPRECATED("The buffer-less API is deprecated in favor of the normal streaming API. See docs.")
-ZSTDLIB_STATIC_API size_t ZSTD_compressBegin_usingDict(ZSTD_CCtx* cctx, const void* dict, size_t dictSize, int compressionLevel);
-ZSTD_DEPRECATED("The buffer-less API is deprecated in favor of the normal streaming API. See docs.")
-ZSTDLIB_STATIC_API size_t ZSTD_compressBegin_usingCDict(ZSTD_CCtx* cctx, const ZSTD_CDict* cdict); /**< note: fails if cdict==NULL */
-

-
size_t ZSTD_copyCCtx(ZSTD_CCtx* cctx, const ZSTD_CCtx* preparedCCtx, unsigned long long pledgedSrcSize); /**<  note: if pledgedSrcSize is not known, use ZSTD_CONTENTSIZE_UNKNOWN */
-

-
size_t ZSTD_compressBegin_advanced(ZSTD_CCtx* cctx, const void* dict, size_t dictSize, ZSTD_parameters params, unsigned long long pledgedSrcSize); /**< pledgedSrcSize : If srcSize is not known at init time, use ZSTD_CONTENTSIZE_UNKNOWN */
-

-

Buffer-less streaming decompression (synchronous mode)

-  A ZSTD_DCtx object is required to track streaming operations.
-  Use ZSTD_createDCtx() / ZSTD_freeDCtx() to manage it.
-  A ZSTD_DCtx object can be re-used multiple times.
-
-  First typical operation is to retrieve frame parameters, using ZSTD_getFrameHeader().
-  Frame header is extracted from the beginning of compressed frame, so providing only the frame's beginning is enough.
-  Data fragment must be large enough to ensure successful decoding.
- `ZSTD_frameHeaderSize_max` bytes is guaranteed to always be large enough.
-  result  : 0 : successful decoding, the `ZSTD_frameHeader` structure is correctly filled.
-           >0 : `srcSize` is too small, please provide at least result bytes on next attempt.
-           errorCode, which can be tested using ZSTD_isError().
-
-  It fills a ZSTD_frameHeader structure with important information to correctly decode the frame,
-  such as the dictionary ID, content size, or maximum back-reference distance (`windowSize`).
-  Note that these values could be wrong, either because of data corruption, or because a 3rd party deliberately spoofs false information.
-  As a consequence, check that values remain within valid application range.
-  For example, do not allocate memory blindly, check that `windowSize` is within expectation.
-  Each application can set its own limits, depending on local restrictions.
-  For extended interoperability, it is recommended to support `windowSize` of at least 8 MB.
-
-  ZSTD_decompressContinue() needs previous data blocks during decompression, up to `windowSize` bytes.
-  ZSTD_decompressContinue() is very sensitive to contiguity,
-  if 2 blocks don't follow each other, make sure that either the compressor breaks contiguity at the same place,
-  or that previous contiguous segment is large enough to properly handle maximum back-reference distance.
-  There are multiple ways to guarantee this condition.
-
-  The most memory efficient way is to use a round buffer of sufficient size.
-  Sufficient size is determined by invoking ZSTD_decodingBufferSize_min(),
-  which can return an error code if required value is too large for current system (in 32-bits mode).
-  In a round buffer methodology, ZSTD_decompressContinue() decompresses each block next to previous one,
-  up to the moment there is not enough room left in the buffer to guarantee decoding another full block,
-  which maximum size is provided in `ZSTD_frameHeader` structure, field `blockSizeMax`.
-  At which point, decoding can resume from the beginning of the buffer.
-  Note that already decoded data stored in the buffer should be flushed before being overwritten.
-
-  There are alternatives possible, for example using two or more buffers of size `windowSize` each, though they consume more memory.
-
-  Finally, if you control the compression process, you can also ignore all buffer size rules,
-  as long as the encoder and decoder progress in "lock-step",
-  aka use exactly the same buffer sizes, break contiguity at the same place, etc.
-
-  Once buffers are setup, start decompression, with ZSTD_decompressBegin().
-  If decompression requires a dictionary, use ZSTD_decompressBegin_usingDict() or ZSTD_decompressBegin_usingDDict().
-
-  Then use ZSTD_nextSrcSizeToDecompress() and ZSTD_decompressContinue() alternatively.
-  ZSTD_nextSrcSizeToDecompress() tells how many bytes to provide as 'srcSize' to ZSTD_decompressContinue().
-  ZSTD_decompressContinue() requires this _exact_ amount of bytes, or it will fail.
-
-  result of ZSTD_decompressContinue() is the number of bytes regenerated within 'dst' (necessarily <= dstCapacity).
-  It can be zero : it just means ZSTD_decompressContinue() has decoded some metadata item.
-  It can also be an error code, which can be tested with ZSTD_isError().
-
-  A frame is fully decoded when ZSTD_nextSrcSizeToDecompress() returns zero.
-  Context can then be reset to start a new decompression.
-
-  Note : it's possible to know if next input to present is a header or a block, using ZSTD_nextInputType().
-  This information is not required to properly decode a frame.
-
-  == Special case : skippable frames 
-
-  Skippable frames allow integration of user-defined data into a flow of concatenated frames.
-  Skippable frames will be ignored (skipped) by decompressor.
-  The format of skippable frames is as follows :
-  a) Skippable frame ID - 4 Bytes, Little endian format, any value from 0x184D2A50 to 0x184D2A5F
-  b) Frame Size - 4 Bytes, Little endian format, unsigned 32-bits
-  c) Frame Content - any content (User Data) of length equal to Frame Size
-  For skippable frames ZSTD_getFrameHeader() returns zfhPtr->frameType==ZSTD_skippableFrame.
-  For skippable frames ZSTD_decompressContinue() always returns 0 : it only skips the content.
-
- -

Buffer-less streaming decompression functions


-
ZSTDLIB_STATIC_API size_t ZSTD_decodingBufferSize_min(unsigned long long windowSize, unsigned long long frameContentSize);  /**< when frame content size is not known, pass in frameContentSize == ZSTD_CONTENTSIZE_UNKNOWN */
-

-
typedef enum { ZSTDnit_frameHeader, ZSTDnit_blockHeader, ZSTDnit_block, ZSTDnit_lastBlock, ZSTDnit_checksum, ZSTDnit_skippableFrame } ZSTD_nextInputType_e;
-

-

Block level API (DEPRECATED)


-
-

You can get the frame header down to 2 bytes by setting: - - ZSTD_c_format = ZSTD_f_zstd1_magicless - - ZSTD_c_contentSizeFlag = 0 - - ZSTD_c_checksumFlag = 0 - - ZSTD_c_dictIDFlag = 0 - - This API is not as well tested as our normal API, so we recommend not using it. - We will be removing it in a future version. If the normal API doesn't provide - the functionality you need, please open a GitHub issue. - - Block functions produce and decode raw zstd blocks, without frame metadata. - Frame metadata cost is typically ~12 bytes, which can be non-negligible for very small blocks (< 100 bytes). - But users will have to take in charge needed metadata to regenerate data, such as compressed and content sizes. - - A few rules to respect : - - Compressing and decompressing require a context structure - + Use ZSTD_createCCtx() and ZSTD_createDCtx() - - It is necessary to init context before starting - + compression : any ZSTD_compressBegin*() variant, including with dictionary - + decompression : any ZSTD_decompressBegin*() variant, including with dictionary - - Block size is limited, it must be <= ZSTD_getBlockSize() <= ZSTD_BLOCKSIZE_MAX == 128 KB - + If input is larger than a block size, it's necessary to split input data into multiple blocks - + For inputs larger than a single block, consider using regular ZSTD_compress() instead. - Frame metadata is not that costly, and quickly becomes negligible as source size grows larger than a block. - - When a block is considered not compressible enough, ZSTD_compressBlock() result will be 0 (zero) ! - ===> In which case, nothing is produced into `dst` ! - + User __must__ test for such outcome and deal directly with uncompressed data - + A block cannot be declared incompressible if ZSTD_compressBlock() return value was != 0. - Doing so would mess up with statistics history, leading to potential data corruption. - + ZSTD_decompressBlock() _doesn't accept uncompressed data as input_ !! - + In case of multiple successive blocks, should some of them be uncompressed, - decoder must be informed of their existence in order to follow proper history. - Use ZSTD_insertBlock() for such a case. -


- -

Raw zstd block functions

ZSTD_DEPRECATED("The block API is deprecated in favor of the normal compression API. See docs.")
-ZSTDLIB_STATIC_API size_t ZSTD_getBlockSize   (const ZSTD_CCtx* cctx);
-ZSTD_DEPRECATED("The block API is deprecated in favor of the normal compression API. See docs.")
-ZSTDLIB_STATIC_API size_t ZSTD_compressBlock  (ZSTD_CCtx* cctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
-ZSTD_DEPRECATED("The block API is deprecated in favor of the normal compression API. See docs.")
-ZSTDLIB_STATIC_API size_t ZSTD_decompressBlock(ZSTD_DCtx* dctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
-ZSTD_DEPRECATED("The block API is deprecated in favor of the normal compression API. See docs.")
-ZSTDLIB_STATIC_API size_t ZSTD_insertBlock    (ZSTD_DCtx* dctx, const void* blockStart, size_t blockSize);  /**< insert uncompressed block into `dctx` history. Useful for multi-blocks decompression. */
-

- - diff --git a/third_party/zstd/examples/.gitignore b/third_party/zstd/examples/.gitignore index d682cae38..034682d4e 100644 --- a/third_party/zstd/examples/.gitignore +++ b/third_party/zstd/examples/.gitignore @@ -1,3 +1,4 @@ +// clang-format off #build simple_compression simple_decompression diff --git a/third_party/zstd/examples/Makefile b/third_party/zstd/examples/Makefile index 31f52d357..b23819626 100644 --- a/third_party/zstd/examples/Makefile +++ b/third_party/zstd/examples/Makefile @@ -1,3 +1,4 @@ +// clang-format off # ################################################################ # Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. diff --git a/third_party/zstd/examples/README.md b/third_party/zstd/examples/README.md index 0bff7ac19..86efe8668 100644 --- a/third_party/zstd/examples/README.md +++ b/third_party/zstd/examples/README.md @@ -1,3 +1,4 @@ +// clang-format off Zstandard library : usage examples ================================== diff --git a/third_party/zstd/examples/common.h b/third_party/zstd/examples/common.h index 4873e877a..7ad28551f 100644 --- a/third_party/zstd/examples/common.h +++ b/third_party/zstd/examples/common.h @@ -1,3 +1,4 @@ +// clang-format off /* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. @@ -14,12 +15,42 @@ #ifndef COMMON_H #define COMMON_H -#include // malloc, free, exit -#include // fprintf, perror, fopen, etc. -#include // strerror -#include // errno -#include // stat -#include +#include "libc/calls/calls.h" +#include "libc/calls/termios.h" +#include "libc/fmt/conv.h" +#include "libc/limits.h" +#include "libc/mem/alg.h" +#include "libc/mem/alloca.h" +#include "libc/mem/mem.h" +#include "libc/runtime/runtime.h" +#include "libc/stdio/dprintf.h" +#include "libc/stdio/rand.h" +#include "libc/stdio/temp.h" +#include "libc/str/str.h" +#include "libc/sysv/consts/exit.h" +#include "third_party/getopt/getopt.h" +#include "third_party/musl/crypt.h" +#include "third_party/musl/rand48.h" // malloc, free, exit +#include "libc/calls/calls.h" +#include "libc/calls/weirdtypes.h" +#include "libc/fmt/fmt.h" +#include "libc/stdio/dprintf.h" +#include "libc/stdio/stdio.h" +#include "libc/stdio/temp.h" +#include "third_party/musl/tempnam.h" // fprintf, perror, fopen, etc. +#include "libc/mem/alg.h" +#include "libc/mem/mem.h" +#include "libc/str/str.h" // strerror +#include "libc/errno.h" // errno +#include "libc/calls/calls.h" +#include "libc/calls/struct/stat.h" +#include "libc/calls/struct/stat.macros.h" +#include "libc/calls/struct/timespec.h" +#include "libc/calls/weirdtypes.h" +#include "libc/sysv/consts/s.h" +#include "libc/sysv/consts/utime.h" +#include "libc/time/time.h" // stat +// MISSING #include /* UNUSED_ATTR tells the compiler it is okay if the function is unused. */ diff --git a/third_party/zstd/examples/dictionary_compression.c b/third_party/zstd/examples/dictionary_compression.c index 83edc1cad..672d3a357 100644 --- a/third_party/zstd/examples/dictionary_compression.c +++ b/third_party/zstd/examples/dictionary_compression.c @@ -1,3 +1,4 @@ +// clang-format off /* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. @@ -17,11 +18,34 @@ * published in `lib/zdict.h` . **/ -#include // printf -#include // free -#include // memset, strcat -#include // presumes zstd library is installed -#include "common.h" // Helper functions, CHECK(), and CHECK_ZSTD() +#include "libc/calls/calls.h" +#include "libc/calls/weirdtypes.h" +#include "libc/fmt/fmt.h" +#include "libc/stdio/dprintf.h" +#include "libc/stdio/stdio.h" +#include "libc/stdio/temp.h" +#include "third_party/musl/tempnam.h" // printf +#include "libc/calls/calls.h" +#include "libc/calls/termios.h" +#include "libc/fmt/conv.h" +#include "libc/limits.h" +#include "libc/mem/alg.h" +#include "libc/mem/alloca.h" +#include "libc/mem/mem.h" +#include "libc/runtime/runtime.h" +#include "libc/stdio/dprintf.h" +#include "libc/stdio/rand.h" +#include "libc/stdio/temp.h" +#include "libc/str/str.h" +#include "libc/sysv/consts/exit.h" +#include "third_party/getopt/getopt.h" +#include "third_party/musl/crypt.h" +#include "third_party/musl/rand48.h" // free +#include "libc/mem/alg.h" +#include "libc/mem/mem.h" +#include "libc/str/str.h" // memset, strcat +// MISSING #include // presumes zstd library is installed +#include "third_party/zstd/examples/common.h" // Helper functions, CHECK(), and CHECK_ZSTD() /* createDict() : ** `dictFileName` is supposed already created using `zstd --train` */ diff --git a/third_party/zstd/examples/dictionary_decompression.c b/third_party/zstd/examples/dictionary_decompression.c index e6c999964..12e6da1c7 100644 --- a/third_party/zstd/examples/dictionary_decompression.c +++ b/third_party/zstd/examples/dictionary_decompression.c @@ -1,3 +1,4 @@ +// clang-format off /* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. @@ -9,10 +10,31 @@ */ -#include // printf -#include // free -#include // presumes zstd library is installed -#include "common.h" // Helper functions, CHECK(), and CHECK_ZSTD() +#include "libc/calls/calls.h" +#include "libc/calls/weirdtypes.h" +#include "libc/fmt/fmt.h" +#include "libc/stdio/dprintf.h" +#include "libc/stdio/stdio.h" +#include "libc/stdio/temp.h" +#include "third_party/musl/tempnam.h" // printf +#include "libc/calls/calls.h" +#include "libc/calls/termios.h" +#include "libc/fmt/conv.h" +#include "libc/limits.h" +#include "libc/mem/alg.h" +#include "libc/mem/alloca.h" +#include "libc/mem/mem.h" +#include "libc/runtime/runtime.h" +#include "libc/stdio/dprintf.h" +#include "libc/stdio/rand.h" +#include "libc/stdio/temp.h" +#include "libc/str/str.h" +#include "libc/sysv/consts/exit.h" +#include "third_party/getopt/getopt.h" +#include "third_party/musl/crypt.h" +#include "third_party/musl/rand48.h" // free +// MISSING #include // presumes zstd library is installed +#include "third_party/zstd/examples/common.h" // Helper functions, CHECK(), and CHECK_ZSTD() /* createDict() : `dictFileName` is supposed to have been created using `zstd --train` */ diff --git a/third_party/zstd/examples/multiple_simple_compression.c b/third_party/zstd/examples/multiple_simple_compression.c index bf77ca133..25e6901a1 100644 --- a/third_party/zstd/examples/multiple_simple_compression.c +++ b/third_party/zstd/examples/multiple_simple_compression.c @@ -1,3 +1,4 @@ +// clang-format off /* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. @@ -8,11 +9,34 @@ * You may select, at your option, one of the above-listed licenses. */ -#include // printf -#include // free -#include // memcpy, strlen -#include // presumes zstd library is installed -#include "common.h" // Helper functions, CHECK(), and CHECK_ZSTD() +#include "libc/calls/calls.h" +#include "libc/calls/weirdtypes.h" +#include "libc/fmt/fmt.h" +#include "libc/stdio/dprintf.h" +#include "libc/stdio/stdio.h" +#include "libc/stdio/temp.h" +#include "third_party/musl/tempnam.h" // printf +#include "libc/calls/calls.h" +#include "libc/calls/termios.h" +#include "libc/fmt/conv.h" +#include "libc/limits.h" +#include "libc/mem/alg.h" +#include "libc/mem/alloca.h" +#include "libc/mem/mem.h" +#include "libc/runtime/runtime.h" +#include "libc/stdio/dprintf.h" +#include "libc/stdio/rand.h" +#include "libc/stdio/temp.h" +#include "libc/str/str.h" +#include "libc/sysv/consts/exit.h" +#include "third_party/getopt/getopt.h" +#include "third_party/musl/crypt.h" +#include "third_party/musl/rand48.h" // free +#include "libc/mem/alg.h" +#include "libc/mem/mem.h" +#include "libc/str/str.h" // memcpy, strlen +// MISSING #include // presumes zstd library is installed +#include "third_party/zstd/examples/common.h" // Helper functions, CHECK(), and CHECK_ZSTD() typedef struct { void* fBuffer; diff --git a/third_party/zstd/examples/multiple_streaming_compression.c b/third_party/zstd/examples/multiple_streaming_compression.c index b12ad03dc..e18c6b38f 100644 --- a/third_party/zstd/examples/multiple_streaming_compression.c +++ b/third_party/zstd/examples/multiple_streaming_compression.c @@ -1,3 +1,4 @@ +// clang-format off /* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. @@ -14,11 +15,34 @@ * All structures and buffers will be created only once, * and shared across all compression operations */ -#include // printf -#include // free -#include // memset, strcat -#include // presumes zstd library is installed -#include "common.h" // Helper functions, CHECK(), and CHECK_ZSTD() +#include "libc/calls/calls.h" +#include "libc/calls/weirdtypes.h" +#include "libc/fmt/fmt.h" +#include "libc/stdio/dprintf.h" +#include "libc/stdio/stdio.h" +#include "libc/stdio/temp.h" +#include "third_party/musl/tempnam.h" // printf +#include "libc/calls/calls.h" +#include "libc/calls/termios.h" +#include "libc/fmt/conv.h" +#include "libc/limits.h" +#include "libc/mem/alg.h" +#include "libc/mem/alloca.h" +#include "libc/mem/mem.h" +#include "libc/runtime/runtime.h" +#include "libc/stdio/dprintf.h" +#include "libc/stdio/rand.h" +#include "libc/stdio/temp.h" +#include "libc/str/str.h" +#include "libc/sysv/consts/exit.h" +#include "third_party/getopt/getopt.h" +#include "third_party/musl/crypt.h" +#include "third_party/musl/rand48.h" // free +#include "libc/mem/alg.h" +#include "libc/mem/mem.h" +#include "libc/str/str.h" // memset, strcat +// MISSING #include // presumes zstd library is installed +#include "third_party/zstd/examples/common.h" // Helper functions, CHECK(), and CHECK_ZSTD() typedef struct { void* buffIn; diff --git a/third_party/zstd/examples/simple_compression.c b/third_party/zstd/examples/simple_compression.c index 7c880725f..e1a0c4f50 100644 --- a/third_party/zstd/examples/simple_compression.c +++ b/third_party/zstd/examples/simple_compression.c @@ -1,3 +1,4 @@ +// clang-format off /* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. @@ -8,11 +9,34 @@ * You may select, at your option, one of the above-listed licenses. */ -#include // printf -#include // free -#include // strlen, strcat, memset -#include // presumes zstd library is installed -#include "common.h" // Helper functions, CHECK(), and CHECK_ZSTD() +#include "libc/calls/calls.h" +#include "libc/calls/weirdtypes.h" +#include "libc/fmt/fmt.h" +#include "libc/stdio/dprintf.h" +#include "libc/stdio/stdio.h" +#include "libc/stdio/temp.h" +#include "third_party/musl/tempnam.h" // printf +#include "libc/calls/calls.h" +#include "libc/calls/termios.h" +#include "libc/fmt/conv.h" +#include "libc/limits.h" +#include "libc/mem/alg.h" +#include "libc/mem/alloca.h" +#include "libc/mem/mem.h" +#include "libc/runtime/runtime.h" +#include "libc/stdio/dprintf.h" +#include "libc/stdio/rand.h" +#include "libc/stdio/temp.h" +#include "libc/str/str.h" +#include "libc/sysv/consts/exit.h" +#include "third_party/getopt/getopt.h" +#include "third_party/musl/crypt.h" +#include "third_party/musl/rand48.h" // free +#include "libc/mem/alg.h" +#include "libc/mem/mem.h" +#include "libc/str/str.h" // strlen, strcat, memset +// MISSING #include // presumes zstd library is installed +#include "third_party/zstd/examples/common.h" // Helper functions, CHECK(), and CHECK_ZSTD() static void compress_orDie(const char* fname, const char* oname) { diff --git a/third_party/zstd/examples/simple_decompression.c b/third_party/zstd/examples/simple_decompression.c index f499156f6..7bb1603a3 100644 --- a/third_party/zstd/examples/simple_decompression.c +++ b/third_party/zstd/examples/simple_decompression.c @@ -1,3 +1,4 @@ +// clang-format off /* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. @@ -8,10 +9,31 @@ * You may select, at your option, one of the above-listed licenses. */ -#include // printf -#include // free -#include // presumes zstd library is installed -#include "common.h" // Helper functions, CHECK(), and CHECK_ZSTD() +#include "libc/calls/calls.h" +#include "libc/calls/weirdtypes.h" +#include "libc/fmt/fmt.h" +#include "libc/stdio/dprintf.h" +#include "libc/stdio/stdio.h" +#include "libc/stdio/temp.h" +#include "third_party/musl/tempnam.h" // printf +#include "libc/calls/calls.h" +#include "libc/calls/termios.h" +#include "libc/fmt/conv.h" +#include "libc/limits.h" +#include "libc/mem/alg.h" +#include "libc/mem/alloca.h" +#include "libc/mem/mem.h" +#include "libc/runtime/runtime.h" +#include "libc/stdio/dprintf.h" +#include "libc/stdio/rand.h" +#include "libc/stdio/temp.h" +#include "libc/str/str.h" +#include "libc/sysv/consts/exit.h" +#include "third_party/getopt/getopt.h" +#include "third_party/musl/crypt.h" +#include "third_party/musl/rand48.h" // free +// MISSING #include // presumes zstd library is installed +#include "third_party/zstd/examples/common.h" // Helper functions, CHECK(), and CHECK_ZSTD() static void decompress(const char* fname) { diff --git a/third_party/zstd/examples/streaming_compression.c b/third_party/zstd/examples/streaming_compression.c index 063aa82a2..dacfead29 100644 --- a/third_party/zstd/examples/streaming_compression.c +++ b/third_party/zstd/examples/streaming_compression.c @@ -1,3 +1,4 @@ +// clang-format off /* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. @@ -9,11 +10,34 @@ */ -#include // printf -#include // free -#include // memset, strcat, strlen -#include // presumes zstd library is installed -#include "common.h" // Helper functions, CHECK(), and CHECK_ZSTD() +#include "libc/calls/calls.h" +#include "libc/calls/weirdtypes.h" +#include "libc/fmt/fmt.h" +#include "libc/stdio/dprintf.h" +#include "libc/stdio/stdio.h" +#include "libc/stdio/temp.h" +#include "third_party/musl/tempnam.h" // printf +#include "libc/calls/calls.h" +#include "libc/calls/termios.h" +#include "libc/fmt/conv.h" +#include "libc/limits.h" +#include "libc/mem/alg.h" +#include "libc/mem/alloca.h" +#include "libc/mem/mem.h" +#include "libc/runtime/runtime.h" +#include "libc/stdio/dprintf.h" +#include "libc/stdio/rand.h" +#include "libc/stdio/temp.h" +#include "libc/str/str.h" +#include "libc/sysv/consts/exit.h" +#include "third_party/getopt/getopt.h" +#include "third_party/musl/crypt.h" +#include "third_party/musl/rand48.h" // free +#include "libc/mem/alg.h" +#include "libc/mem/mem.h" +#include "libc/str/str.h" // memset, strcat, strlen +// MISSING #include // presumes zstd library is installed +#include "third_party/zstd/examples/common.h" // Helper functions, CHECK(), and CHECK_ZSTD() static void compressFile_orDie(const char* fname, const char* outName, int cLevel, int nbThreads) diff --git a/third_party/zstd/examples/streaming_compression_thread_pool.c b/third_party/zstd/examples/streaming_compression_thread_pool.c index a1a024129..2cc845aea 100644 --- a/third_party/zstd/examples/streaming_compression_thread_pool.c +++ b/third_party/zstd/examples/streaming_compression_thread_pool.c @@ -1,3 +1,4 @@ +// clang-format off /* * Copyright (c) Martin Liska, SUSE, Meta Platforms, Inc. and affiliates. * All rights reserved. @@ -9,12 +10,38 @@ */ -#include // printf -#include // free -#include // memset, strcat, strlen -#include // presumes zstd library is installed -#include "common.h" // Helper functions, CHECK(), and CHECK_ZSTD() -#include +#include "libc/calls/calls.h" +#include "libc/calls/weirdtypes.h" +#include "libc/fmt/fmt.h" +#include "libc/stdio/dprintf.h" +#include "libc/stdio/stdio.h" +#include "libc/stdio/temp.h" +#include "third_party/musl/tempnam.h" // printf +#include "libc/calls/calls.h" +#include "libc/calls/termios.h" +#include "libc/fmt/conv.h" +#include "libc/limits.h" +#include "libc/mem/alg.h" +#include "libc/mem/alloca.h" +#include "libc/mem/mem.h" +#include "libc/runtime/runtime.h" +#include "libc/stdio/dprintf.h" +#include "libc/stdio/rand.h" +#include "libc/stdio/temp.h" +#include "libc/str/str.h" +#include "libc/sysv/consts/exit.h" +#include "third_party/getopt/getopt.h" +#include "third_party/musl/crypt.h" +#include "third_party/musl/rand48.h" // free +#include "libc/mem/alg.h" +#include "libc/mem/mem.h" +#include "libc/str/str.h" // memset, strcat, strlen +// MISSING #include // presumes zstd library is installed +#include "third_party/zstd/examples/common.h" // Helper functions, CHECK(), and CHECK_ZSTD() +#include "libc/calls/weirdtypes.h" +#include "libc/sysv/consts/clock.h" +#include "libc/thread/thread.h" +#include "libc/thread/thread2.h" typedef struct compress_args { diff --git a/third_party/zstd/examples/streaming_decompression.c b/third_party/zstd/examples/streaming_decompression.c index 95fa11227..6e591e532 100644 --- a/third_party/zstd/examples/streaming_decompression.c +++ b/third_party/zstd/examples/streaming_decompression.c @@ -1,3 +1,4 @@ +// clang-format off /* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. @@ -9,10 +10,31 @@ */ -#include // fprintf -#include // free -#include // presumes zstd library is installed -#include "common.h" // Helper functions, CHECK(), and CHECK_ZSTD() +#include "libc/calls/calls.h" +#include "libc/calls/weirdtypes.h" +#include "libc/fmt/fmt.h" +#include "libc/stdio/dprintf.h" +#include "libc/stdio/stdio.h" +#include "libc/stdio/temp.h" +#include "third_party/musl/tempnam.h" // fprintf +#include "libc/calls/calls.h" +#include "libc/calls/termios.h" +#include "libc/fmt/conv.h" +#include "libc/limits.h" +#include "libc/mem/alg.h" +#include "libc/mem/alloca.h" +#include "libc/mem/mem.h" +#include "libc/runtime/runtime.h" +#include "libc/stdio/dprintf.h" +#include "libc/stdio/rand.h" +#include "libc/stdio/temp.h" +#include "libc/str/str.h" +#include "libc/sysv/consts/exit.h" +#include "third_party/getopt/getopt.h" +#include "third_party/musl/crypt.h" +#include "third_party/musl/rand48.h" // free +// MISSING #include // presumes zstd library is installed +#include "third_party/zstd/examples/common.h" // Helper functions, CHECK(), and CHECK_ZSTD() static void decompressFile_orDie(const char* fname) { diff --git a/third_party/zstd/examples/streaming_memory_usage.c b/third_party/zstd/examples/streaming_memory_usage.c index 957acb61a..098d7cc06 100644 --- a/third_party/zstd/examples/streaming_memory_usage.c +++ b/third_party/zstd/examples/streaming_memory_usage.c @@ -1,3 +1,4 @@ +// clang-format off /* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. @@ -16,10 +17,16 @@ /*=== Dependencies ===*/ -#include // printf +#include "libc/calls/calls.h" +#include "libc/calls/weirdtypes.h" +#include "libc/fmt/fmt.h" +#include "libc/stdio/dprintf.h" +#include "libc/stdio/stdio.h" +#include "libc/stdio/temp.h" +#include "third_party/musl/tempnam.h" // printf #define ZSTD_STATIC_LINKING_ONLY -#include // presumes zstd library is installed -#include "common.h" // Helper functions, CHECK(), and CHECK_ZSTD() +// MISSING #include // presumes zstd library is installed +#include "third_party/zstd/examples/common.h" // Helper functions, CHECK(), and CHECK_ZSTD() /*=== functions ===*/ diff --git a/third_party/zstd/lib/.gitignore b/third_party/zstd/lib/.gitignore deleted file mode 100644 index 4cd50ac61..000000000 --- a/third_party/zstd/lib/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -# make install artefact -libzstd.pc -libzstd-nomt diff --git a/third_party/zstd/lib/BUCK b/third_party/zstd/lib/BUCK deleted file mode 100644 index 60c6bbb54..000000000 --- a/third_party/zstd/lib/BUCK +++ /dev/null @@ -1,232 +0,0 @@ -cxx_library( - name='zstd', - header_namespace='', - exported_headers=['zstd.h'], - visibility=['PUBLIC'], - deps=[ - ':common', - ':compress', - ':decompress', - ':deprecated', - ], -) - -cxx_library( - name='compress', - header_namespace='', - visibility=['PUBLIC'], - exported_headers=subdir_glob([ - ('compress', 'zstd*.h'), - ]), - srcs=glob(['compress/zstd*.c', 'compress/hist.c']), - deps=[':common'], -) - -cxx_library( - name='decompress', - header_namespace='', - visibility=['PUBLIC'], - headers=subdir_glob([ - ('decompress', '*_impl.h'), - ]), - srcs=glob(['decompress/zstd*.c']), - deps=[ - ':common', - ':legacy', - ], -) - -cxx_library( - name='deprecated', - header_namespace='', - visibility=['PUBLIC'], - exported_headers=subdir_glob([ - ('deprecated', '*.h'), - ]), - srcs=glob(['deprecated/*.c']), - deps=[':common'], -) - -cxx_library( - name='legacy', - header_namespace='', - visibility=['PUBLIC'], - exported_headers=subdir_glob([ - ('legacy', '*.h'), - ]), - srcs=glob(['legacy/*.c']), - deps=[':common'], - exported_preprocessor_flags=[ - '-DZSTD_LEGACY_SUPPORT=4', - ], -) - -cxx_library( - name='zdict', - header_namespace='', - visibility=['PUBLIC'], - exported_headers=['zdict.h'], - headers=subdir_glob([ - ('dictBuilder', 'divsufsort.h'), - ('dictBuilder', 'cover.h'), - ]), - srcs=glob(['dictBuilder/*.c']), - deps=[':common'], -) - -cxx_library( - name='compiler', - header_namespace='', - visibility=['PUBLIC'], - exported_headers=subdir_glob([ - ('common', 'compiler.h'), - ]), -) - -cxx_library( - name='cpu', - header_namespace='', - visibility=['PUBLIC'], - exported_headers=subdir_glob([ - ('common', 'cpu.h'), - ]), -) - -cxx_library( - name='bitstream', - header_namespace='', - visibility=['PUBLIC'], - exported_headers=subdir_glob([ - ('common', 'bitstream.h'), - ]), -) - -cxx_library( - name='entropy', - header_namespace='', - visibility=['PUBLIC'], - exported_headers=subdir_glob([ - ('common', 'fse.h'), - ('common', 'huf.h'), - ]), - srcs=[ - 'common/entropy_common.c', - 'common/fse_decompress.c', - 'compress/fse_compress.c', - 'compress/huf_compress.c', - 'decompress/huf_decompress.c', - ], - deps=[ - ':debug', - ':bitstream', - ':compiler', - ':errors', - ':mem', - ], -) - -cxx_library( - name='errors', - header_namespace='', - visibility=['PUBLIC'], - exported_headers=[ - 'zstd_errors.h', - 'common/error_private.h', - ] - srcs=['common/error_private.c'], -) - -cxx_library( - name='mem', - header_namespace='', - visibility=['PUBLIC'], - exported_headers=subdir_glob([ - ('common', 'mem.h'), - ]), -) - -cxx_library( - name='pool', - header_namespace='', - visibility=['PUBLIC'], - exported_headers=subdir_glob([ - ('common', 'pool.h'), - ]), - srcs=['common/pool.c'], - deps=[ - ':threading', - ':zstd_common', - ], -) - -cxx_library( - name='threading', - header_namespace='', - visibility=['PUBLIC'], - exported_headers=subdir_glob([ - ('common', 'threading.h'), - ]), - srcs=['common/threading.c'], - exported_preprocessor_flags=[ - '-DZSTD_MULTITHREAD', - ], - exported_linker_flags=[ - '-pthread', - ], -) - -cxx_library( - name='xxhash', - header_namespace='', - visibility=['PUBLIC'], - exported_headers=subdir_glob([ - ('common', 'xxhash.h'), - ]), - srcs=['common/xxhash.c'], - exported_preprocessor_flags=[ - '-DXXH_NAMESPACE=ZSTD_', - ], -) - -cxx_library( - name='zstd_common', - header_namespace='', - visibility=['PUBLIC'], - exported_headers=subdir_glob([ - ('', 'zstd.h'), - ('common', 'zstd_internal.h'), - ]), - srcs=['common/zstd_common.c'], - deps=[ - ':compiler', - ':errors', - ':mem', - ], -) - -cxx_library( - name='debug', - header_namespace='', - visibility=['PUBLIC'], - exported_headers=subdir_glob([ - ('common', 'debug.h'), - ]), - srcs=['common/debug.c'], -) - -cxx_library( - name='common', - deps=[ - ':debug', - ':bitstream', - ':compiler', - ':cpu', - ':entropy', - ':errors', - ':mem', - ':pool', - ':threading', - ':xxhash', - ':zstd_common', - ] -) diff --git a/third_party/zstd/lib/Makefile b/third_party/zstd/lib/Makefile deleted file mode 100644 index a4cf61ab1..000000000 --- a/third_party/zstd/lib/Makefile +++ /dev/null @@ -1,357 +0,0 @@ -# ################################################################ -# Copyright (c) Meta Platforms, Inc. and affiliates. -# All rights reserved. -# -# This source code is licensed under both the BSD-style license (found in the -# LICENSE file in the root directory of this source tree) and the GPLv2 (found -# in the COPYING file in the root directory of this source tree). -# You may select, at your option, one of the above-listed licenses. -# ################################################################ - -# Modules -ZSTD_LIB_COMPRESSION ?= 1 -ZSTD_LIB_DECOMPRESSION ?= 1 -ZSTD_LIB_DICTBUILDER ?= 1 -ZSTD_LIB_DEPRECATED ?= 0 - -# Input variables for libzstd.mk -ifeq ($(ZSTD_LIB_COMPRESSION), 0) - ZSTD_LIB_DICTBUILDER = 0 - ZSTD_LIB_DEPRECATED = 0 -endif - -ifeq ($(ZSTD_LIB_DECOMPRESSION), 0) - ZSTD_LEGACY_SUPPORT = 0 - ZSTD_LIB_DEPRECATED = 0 -endif - -include libzstd.mk - -ZSTD_FILES := $(ZSTD_COMMON_FILES) $(ZSTD_LEGACY_FILES) - -ifneq ($(ZSTD_LIB_COMPRESSION), 0) - ZSTD_FILES += $(ZSTD_COMPRESS_FILES) -endif - -ifneq ($(ZSTD_LIB_DECOMPRESSION), 0) - ZSTD_FILES += $(ZSTD_DECOMPRESS_FILES) -endif - -ifneq ($(ZSTD_LIB_DEPRECATED), 0) - ZSTD_FILES += $(ZSTD_DEPRECATED_FILES) -endif - -ifneq ($(ZSTD_LIB_DICTBUILDER), 0) - ZSTD_FILES += $(ZSTD_DICTBUILDER_FILES) -endif - -ZSTD_LOCAL_SRC := $(notdir $(ZSTD_FILES)) -ZSTD_LOCAL_OBJ0 := $(ZSTD_LOCAL_SRC:.c=.o) -ZSTD_LOCAL_OBJ := $(ZSTD_LOCAL_OBJ0:.S=.o) - -VERSION := $(ZSTD_VERSION) - -# Note: by default, the static library is built single-threaded and dynamic library is built -# multi-threaded. It is possible to force multi or single threaded builds by appending -# -mt or -nomt to the build target (like lib-mt for multi-threaded, lib-nomt for single-threaded). -.PHONY: default -default: lib-release - -CPPFLAGS_DYNLIB += -DZSTD_MULTITHREAD # dynamic library build defaults to multi-threaded -LDFLAGS_DYNLIB += -pthread -CPPFLAGS_STATLIB += # static library build defaults to single-threaded - - -ifeq ($(findstring GCC,$(CCVER)),GCC) -decompress/zstd_decompress_block.o : CFLAGS+=-fno-tree-vectorize -endif - - -# macOS linker doesn't support -soname, and use different extension -# see : https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/DynamicLibraryDesignGuidelines.html -ifeq ($(UNAME), Darwin) - SHARED_EXT = dylib - SHARED_EXT_MAJOR = $(LIBVER_MAJOR).$(SHARED_EXT) - SHARED_EXT_VER = $(LIBVER).$(SHARED_EXT) - SONAME_FLAGS = -install_name $(LIBDIR)/libzstd.$(SHARED_EXT_MAJOR) -compatibility_version $(LIBVER_MAJOR) -current_version $(LIBVER) -else - ifeq ($(UNAME), AIX) - SONAME_FLAGS = - else - SONAME_FLAGS = -Wl,-soname=libzstd.$(SHARED_EXT).$(LIBVER_MAJOR) - endif - SHARED_EXT = so - SHARED_EXT_MAJOR = $(SHARED_EXT).$(LIBVER_MAJOR) - SHARED_EXT_VER = $(SHARED_EXT).$(LIBVER) -endif - - -.PHONY: all -all: lib - - -.PHONY: libzstd.a # must be run every time -libzstd.a: CPPFLAGS += $(CPPFLAGS_STATLIB) - -SET_CACHE_DIRECTORY = \ - +$(MAKE) --no-print-directory $@ \ - BUILD_DIR=obj/$(HASH_DIR) \ - CPPFLAGS="$(CPPFLAGS)" \ - CFLAGS="$(CFLAGS)" \ - LDFLAGS="$(LDFLAGS)" - -ifndef BUILD_DIR -# determine BUILD_DIR from compilation flags - -libzstd.a: - $(SET_CACHE_DIRECTORY) - -else -# BUILD_DIR is defined - -ZSTD_STATLIB_DIR := $(BUILD_DIR)/static -ZSTD_STATLIB := $(ZSTD_STATLIB_DIR)/libzstd.a -ZSTD_STATLIB_OBJ := $(addprefix $(ZSTD_STATLIB_DIR)/,$(ZSTD_LOCAL_OBJ)) -$(ZSTD_STATLIB): ARFLAGS = rcs -$(ZSTD_STATLIB): | $(ZSTD_STATLIB_DIR) -$(ZSTD_STATLIB): $(ZSTD_STATLIB_OBJ) - # Check for multithread flag at target execution time - $(if $(filter -DZSTD_MULTITHREAD,$(CPPFLAGS)),\ - @echo compiling multi-threaded static library $(LIBVER),\ - @echo compiling single-threaded static library $(LIBVER)) - $(AR) $(ARFLAGS) $@ $^ - -libzstd.a: $(ZSTD_STATLIB) - cp -f $< $@ - -endif - -ifneq (,$(filter Windows%,$(TARGET_SYSTEM))) - -LIBZSTD = dll/libzstd.dll -$(LIBZSTD): $(ZSTD_FILES) - @echo compiling dynamic library $(LIBVER) - $(CC) $(FLAGS) -DZSTD_DLL_EXPORT=1 -Wl,--out-implib,dll/libzstd.dll.a -shared $^ -o $@ - -else # not Windows - -LIBZSTD = libzstd.$(SHARED_EXT_VER) -.PHONY: $(LIBZSTD) # must be run every time -$(LIBZSTD): CPPFLAGS += $(CPPFLAGS_DYNLIB) -$(LIBZSTD): CFLAGS += -fPIC -fvisibility=hidden -$(LIBZSTD): LDFLAGS += -shared $(LDFLAGS_DYNLIB) - -ifndef BUILD_DIR -# determine BUILD_DIR from compilation flags - -$(LIBZSTD): - $(SET_CACHE_DIRECTORY) - -else -# BUILD_DIR is defined - -ZSTD_DYNLIB_DIR := $(BUILD_DIR)/dynamic -ZSTD_DYNLIB := $(ZSTD_DYNLIB_DIR)/$(LIBZSTD) -ZSTD_DYNLIB_OBJ := $(addprefix $(ZSTD_DYNLIB_DIR)/,$(ZSTD_LOCAL_OBJ)) - -$(ZSTD_DYNLIB): | $(ZSTD_DYNLIB_DIR) -$(ZSTD_DYNLIB): $(ZSTD_DYNLIB_OBJ) -# Check for multithread flag at target execution time - $(if $(filter -DZSTD_MULTITHREAD,$(CPPFLAGS)),\ - @echo compiling multi-threaded dynamic library $(LIBVER),\ - @echo compiling single-threaded dynamic library $(LIBVER)) - $(CC) $(FLAGS) $^ $(LDFLAGS) $(SONAME_FLAGS) -o $@ - @echo creating versioned links - ln -sf $@ libzstd.$(SHARED_EXT_MAJOR) - ln -sf $@ libzstd.$(SHARED_EXT) - -$(LIBZSTD): $(ZSTD_DYNLIB) - cp -f $< $@ - -endif # ifndef BUILD_DIR -endif # if windows - -.PHONY: libzstd -libzstd : $(LIBZSTD) - -.PHONY: lib -lib : libzstd.a libzstd - - -# note : do not define lib-mt or lib-release as .PHONY -# make does not consider implicit pattern rule for .PHONY target - -%-mt : CPPFLAGS_DYNLIB := -DZSTD_MULTITHREAD -%-mt : CPPFLAGS_STATLIB := -DZSTD_MULTITHREAD -%-mt : LDFLAGS_DYNLIB := -pthread -%-mt : % - @echo multi-threaded build completed - -%-nomt : CPPFLAGS_DYNLIB := -%-nomt : LDFLAGS_DYNLIB := -%-nomt : CPPFLAGS_STATLIB := -%-nomt : % - @echo single-threaded build completed - -%-release : DEBUGFLAGS := -%-release : % - @echo release build completed - - -# Generate .h dependencies automatically - -DEPFLAGS = -MT $@ -MMD -MP -MF - -$(ZSTD_DYNLIB_DIR)/%.o : %.c $(ZSTD_DYNLIB_DIR)/%.d | $(ZSTD_DYNLIB_DIR) - @echo CC $@ - $(COMPILE.c) $(DEPFLAGS) $(ZSTD_DYNLIB_DIR)/$*.d $(OUTPUT_OPTION) $< - -$(ZSTD_STATLIB_DIR)/%.o : %.c $(ZSTD_STATLIB_DIR)/%.d | $(ZSTD_STATLIB_DIR) - @echo CC $@ - $(COMPILE.c) $(DEPFLAGS) $(ZSTD_STATLIB_DIR)/$*.d $(OUTPUT_OPTION) $< - -$(ZSTD_DYNLIB_DIR)/%.o : %.S | $(ZSTD_DYNLIB_DIR) - @echo AS $@ - $(COMPILE.S) $(OUTPUT_OPTION) $< - -$(ZSTD_STATLIB_DIR)/%.o : %.S | $(ZSTD_STATLIB_DIR) - @echo AS $@ - $(COMPILE.S) $(OUTPUT_OPTION) $< - -MKDIR ?= mkdir -$(BUILD_DIR) $(ZSTD_DYNLIB_DIR) $(ZSTD_STATLIB_DIR): - $(MKDIR) -p $@ - -DEPFILES := $(ZSTD_DYNLIB_OBJ:.o=.d) $(ZSTD_STATLIB_OBJ:.o=.d) -$(DEPFILES): - -include $(wildcard $(DEPFILES)) - - -# Special case : building library in single-thread mode _and_ without zstdmt_compress.c -ZSTDMT_FILES = compress/zstdmt_compress.c -ZSTD_NOMT_FILES = $(filter-out $(ZSTDMT_FILES),$(ZSTD_FILES)) -libzstd-nomt: CFLAGS += -fPIC -fvisibility=hidden -libzstd-nomt: LDFLAGS += -shared -libzstd-nomt: $(ZSTD_NOMT_FILES) - @echo compiling single-thread dynamic library $(LIBVER) - @echo files : $(ZSTD_NOMT_FILES) - $(CC) $(FLAGS) $^ $(LDFLAGS) $(SONAME_FLAGS) -o $@ - -.PHONY: clean -clean: - $(RM) -r *.dSYM # macOS-specific - $(RM) core *.o *.a *.gcda *.$(SHARED_EXT) *.$(SHARED_EXT).* libzstd.pc - $(RM) dll/libzstd.dll dll/libzstd.lib libzstd-nomt* - $(RM) -r obj/* - @echo Cleaning library completed - -#----------------------------------------------------------------------------- -# make install is validated only for below listed environments -#----------------------------------------------------------------------------- -ifneq (,$(filter $(UNAME),Linux Darwin GNU/kFreeBSD GNU OpenBSD FreeBSD NetBSD DragonFly SunOS Haiku AIX)) - -lib: libzstd.pc - -HAS_EXPLICIT_EXEC_PREFIX := $(if $(or $(EXEC_PREFIX),$(exec_prefix)),1,) - -DESTDIR ?= -# directory variables : GNU conventions prefer lowercase -# see https://www.gnu.org/prep/standards/html_node/Makefile-Conventions.html -# support both lower and uppercase (BSD), use uppercase in script -prefix ?= /usr/local -PREFIX ?= $(prefix) -exec_prefix ?= $(PREFIX) -EXEC_PREFIX ?= $(exec_prefix) -libdir ?= $(EXEC_PREFIX)/lib -LIBDIR ?= $(libdir) -includedir ?= $(PREFIX)/include -INCLUDEDIR ?= $(includedir) - -PCINCDIR := $(patsubst $(PREFIX)%,%,$(INCLUDEDIR)) -PCLIBDIR := $(patsubst $(EXEC_PREFIX)%,%,$(LIBDIR)) - -# If we successfully stripped off a prefix, we'll add a reference to the -# relevant pc variable. -PCINCPREFIX := $(if $(findstring $(INCLUDEDIR),$(PCINCDIR)),,$${prefix}) -PCLIBPREFIX := $(if $(findstring $(LIBDIR),$(PCLIBDIR)),,$${exec_prefix}) - -# If no explicit EXEC_PREFIX was set by the caller, write it out as a reference -# to PREFIX, rather than as a resolved value. -PCEXEC_PREFIX := $(if $(HAS_EXPLICIT_EXEC_PREFIX),$(EXEC_PREFIX),$${prefix}) - -ifneq (,$(filter $(UNAME),FreeBSD NetBSD DragonFly)) - PKGCONFIGDIR ?= $(PREFIX)/libdata/pkgconfig -else - PKGCONFIGDIR ?= $(LIBDIR)/pkgconfig -endif - -ifneq (,$(filter $(UNAME),SunOS)) - INSTALL ?= ginstall -else - INSTALL ?= install -endif - -INSTALL_PROGRAM ?= $(INSTALL) -INSTALL_DATA ?= $(INSTALL) -m 644 - - -libzstd.pc: libzstd.pc.in - @echo creating pkgconfig - @sed \ - -e 's|@PREFIX@|$(PREFIX)|' \ - -e 's|@EXEC_PREFIX@|$(PCEXEC_PREFIX)|' \ - -e 's|@INCLUDEDIR@|$(PCINCPREFIX)$(PCINCDIR)|' \ - -e 's|@LIBDIR@|$(PCLIBPREFIX)$(PCLIBDIR)|' \ - -e 's|@VERSION@|$(VERSION)|' \ - -e 's|@LIBS_PRIVATE@|$(LDFLAGS_DYNLIB)|' \ - $< >$@ - -.PHONY: install -install: install-pc install-static install-shared install-includes - @echo zstd static and shared library installed - -.PHONY: install-pc -install-pc: libzstd.pc - [ -e $(DESTDIR)$(PKGCONFIGDIR) ] || $(INSTALL) -d -m 755 $(DESTDIR)$(PKGCONFIGDIR)/ - $(INSTALL_DATA) libzstd.pc $(DESTDIR)$(PKGCONFIGDIR)/ - -.PHONY: install-static -install-static: - # only generate libzstd.a if it's not already present - [ -e libzstd.a ] || $(MAKE) libzstd.a-release - [ -e $(DESTDIR)$(LIBDIR) ] || $(INSTALL) -d -m 755 $(DESTDIR)$(LIBDIR)/ - @echo Installing static library - $(INSTALL_DATA) libzstd.a $(DESTDIR)$(LIBDIR) - -.PHONY: install-shared -install-shared: - # only generate libzstd.so if it's not already present - [ -e $(LIBZSTD) ] || $(MAKE) libzstd-release - [ -e $(DESTDIR)$(LIBDIR) ] || $(INSTALL) -d -m 755 $(DESTDIR)$(LIBDIR)/ - @echo Installing shared library - $(INSTALL_PROGRAM) $(LIBZSTD) $(DESTDIR)$(LIBDIR) - ln -sf $(LIBZSTD) $(DESTDIR)$(LIBDIR)/libzstd.$(SHARED_EXT_MAJOR) - ln -sf $(LIBZSTD) $(DESTDIR)$(LIBDIR)/libzstd.$(SHARED_EXT) - -.PHONY: install-includes -install-includes: - [ -e $(DESTDIR)$(INCLUDEDIR) ] || $(INSTALL) -d -m 755 $(DESTDIR)$(INCLUDEDIR)/ - @echo Installing includes - $(INSTALL_DATA) zstd.h $(DESTDIR)$(INCLUDEDIR) - $(INSTALL_DATA) zstd_errors.h $(DESTDIR)$(INCLUDEDIR) - $(INSTALL_DATA) zdict.h $(DESTDIR)$(INCLUDEDIR) - -.PHONY: uninstall -uninstall: - $(RM) $(DESTDIR)$(LIBDIR)/libzstd.a - $(RM) $(DESTDIR)$(LIBDIR)/libzstd.$(SHARED_EXT) - $(RM) $(DESTDIR)$(LIBDIR)/libzstd.$(SHARED_EXT_MAJOR) - $(RM) $(DESTDIR)$(LIBDIR)/$(LIBZSTD) - $(RM) $(DESTDIR)$(PKGCONFIGDIR)/libzstd.pc - $(RM) $(DESTDIR)$(INCLUDEDIR)/zstd.h - $(RM) $(DESTDIR)$(INCLUDEDIR)/zstd_errors.h - $(RM) $(DESTDIR)$(INCLUDEDIR)/zdict.h - @echo zstd libraries successfully uninstalled - -endif diff --git a/third_party/zstd/lib/README.md b/third_party/zstd/lib/README.md index 479820933..92d365ed0 100644 --- a/third_party/zstd/lib/README.md +++ b/third_party/zstd/lib/README.md @@ -1,3 +1,4 @@ +// clang-format off Zstandard library files ================================ diff --git a/third_party/zstd/lib/common/allocations.h b/third_party/zstd/lib/common/allocations.h index 5e8995501..6e432c26d 100644 --- a/third_party/zstd/lib/common/allocations.h +++ b/third_party/zstd/lib/common/allocations.h @@ -1,3 +1,4 @@ +// clang-format off /* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. @@ -12,11 +13,11 @@ */ #define ZSTD_DEPS_NEED_MALLOC -#include "zstd_deps.h" /* ZSTD_malloc, ZSTD_calloc, ZSTD_free, ZSTD_memset */ +#include "third_party/zstd/lib/common/zstd_deps.h" /* ZSTD_malloc, ZSTD_calloc, ZSTD_free, ZSTD_memset */ -#include "compiler.h" /* MEM_STATIC */ +#include "third_party/zstd/lib/common/compiler.h" /* MEM_STATIC */ #define ZSTD_STATIC_LINKING_ONLY -#include "../zstd.h" /* ZSTD_customMem */ +#include "third_party/zstd/lib/zstd.h" /* ZSTD_customMem */ #ifndef ZSTD_ALLOCATIONS_H #define ZSTD_ALLOCATIONS_H diff --git a/third_party/zstd/lib/common/bits.h b/third_party/zstd/lib/common/bits.h index def56c474..18b1af37a 100644 --- a/third_party/zstd/lib/common/bits.h +++ b/third_party/zstd/lib/common/bits.h @@ -1,3 +1,4 @@ +// clang-format off /* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. @@ -11,7 +12,8 @@ #ifndef ZSTD_BITS_H #define ZSTD_BITS_H -#include "mem.h" +#include "third_party/zstd/lib/common/mem.h" +#include "libc/assert.h" MEM_STATIC unsigned ZSTD_countTrailingZeros32_fallback(U32 val) { diff --git a/third_party/zstd/lib/common/bitstream.h b/third_party/zstd/lib/common/bitstream.h index a737f011c..6e085fc4b 100644 --- a/third_party/zstd/lib/common/bitstream.h +++ b/third_party/zstd/lib/common/bitstream.h @@ -1,3 +1,4 @@ +// clang-format off /* ****************************************************************** * bitstream * Part of FSE library @@ -26,11 +27,11 @@ extern "C" { /*-**************************************** * Dependencies ******************************************/ -#include "mem.h" /* unaligned access routines */ -#include "compiler.h" /* UNLIKELY() */ -#include "debug.h" /* assert(), DEBUGLOG(), RAWLOG() */ -#include "error_private.h" /* error codes and messages */ -#include "bits.h" /* ZSTD_highbit32 */ +#include "third_party/zstd/lib/common/mem.h" /* unaligned access routines */ +#include "third_party/zstd/lib/common/compiler.h" /* UNLIKELY() */ +#include "third_party/zstd/lib/common/debug.h" /* assert(), DEBUGLOG(), RAWLOG() */ +#include "third_party/zstd/lib/common/error_private.h" /* error codes and messages */ +#include "third_party/zstd/lib/common/bits.h" /* ZSTD_highbit32 */ /*========================================= @@ -38,9 +39,9 @@ extern "C" { =========================================*/ #ifndef ZSTD_NO_INTRINSICS # if (defined(__BMI__) || defined(__BMI2__)) && defined(__GNUC__) -# include /* support for bextr (experimental)/bzhi */ +#include "third_party/intel/immintrin.internal.h" /* support for bextr (experimental)/bzhi */ # elif defined(__ICCARM__) -# include +// MISSING #include # endif #endif diff --git a/third_party/zstd/lib/common/compiler.h b/third_party/zstd/lib/common/compiler.h index bcaa575dd..cbc046010 100644 --- a/third_party/zstd/lib/common/compiler.h +++ b/third_party/zstd/lib/common/compiler.h @@ -1,3 +1,4 @@ +// clang-format off /* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. @@ -11,7 +12,7 @@ #ifndef ZSTD_COMPILER_H #define ZSTD_COMPILER_H -#include "portability_macros.h" +#include "third_party/zstd/lib/common/portability_macros.h" /*-******************************************************* * Compiler specifics @@ -134,7 +135,7 @@ # define PREFETCH_L2(ptr) (void)(ptr) /* disabled */ #else # if defined(_MSC_VER) && (defined(_M_X64) || defined(_M_I86)) && !defined(_M_ARM64EC) /* _mm_prefetch() is not defined outside of x86/x64 */ -# include /* https://msdn.microsoft.com/fr-fr/library/84szxsww(v=vs.90).aspx */ +#include "third_party/intel/mmintrin.internal.h" /* https://msdn.microsoft.com/fr-fr/library/84szxsww(v=vs.90).aspx */ # define PREFETCH_L1(ptr) _mm_prefetch((const char*)(ptr), _MM_HINT_T0) # define PREFETCH_L2(ptr) _mm_prefetch((const char*)(ptr), _MM_HINT_T1) # elif defined(__GNUC__) && ( (__GNUC__ >= 4) || ( (__GNUC__ == 3) && (__GNUC_MINOR__ >= 1) ) ) @@ -194,7 +195,7 @@ /* disable warnings */ #ifdef _MSC_VER /* Visual Studio */ -# include /* For Visual 2005 */ +// MISSING #include /* For Visual 2005 */ # pragma warning(disable : 4100) /* disable: C4100: unreferenced formal parameter */ # pragma warning(disable : 4127) /* disable: C4127: conditional expression is constant */ # pragma warning(disable : 4204) /* disable: C4204: non-constant aggregate initializer */ @@ -227,9 +228,9 @@ # endif # # if defined(ZSTD_ARCH_X86_SSE2) -# include +#include "third_party/intel/emmintrin.internal.h" # elif defined(ZSTD_ARCH_ARM_NEON) -# include +// MISSING #include # endif #endif @@ -288,7 +289,7 @@ # elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) /* C11 support */ -# include +#include "libc/stdalign.internal.h" # define ZSTD_ALIGNOF(T) alignof(T) # else @@ -317,9 +318,9 @@ /* Not all platforms that support msan provide sanitizers/msan_interface.h. * We therefore declare the functions we need ourselves, rather than trying to * include the header file... */ -#include /* size_t */ + /* size_t */ #define ZSTD_DEPS_NEED_STDINT -#include "zstd_deps.h" /* intptr_t */ +#include "third_party/zstd/lib/common/zstd_deps.h" /* intptr_t */ /* Make memory region fully initialized (without changing its contents). */ void __msan_unpoison(const volatile void *a, size_t size); @@ -342,7 +343,7 @@ void __msan_print_shadow(const volatile void *x, size_t size); /* Not all platforms that support asan provide sanitizers/asan_interface.h. * We therefore declare the functions we need ourselves, rather than trying to * include the header file... */ -#include /* size_t */ + /* size_t */ /** * Marks a memory region ([addr, addr+size)) as unaddressable. diff --git a/third_party/zstd/lib/common/cpu.h b/third_party/zstd/lib/common/cpu.h index 8bc34a36d..7a1b008c7 100644 --- a/third_party/zstd/lib/common/cpu.h +++ b/third_party/zstd/lib/common/cpu.h @@ -1,3 +1,4 @@ +// clang-format off /* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. @@ -16,10 +17,10 @@ * https://github.com/facebook/folly/blob/master/folly/CpuId.h */ -#include "mem.h" +#include "third_party/zstd/lib/common/mem.h" #ifdef _MSC_VER -#include +// MISSING #include #endif typedef struct { diff --git a/third_party/zstd/lib/common/debug.c b/third_party/zstd/lib/common/debug.c index ebf7bfccf..ee5a4de72 100644 --- a/third_party/zstd/lib/common/debug.c +++ b/third_party/zstd/lib/common/debug.c @@ -1,3 +1,4 @@ +// clang-format off /* ****************************************************************** * debug * Part of FSE library @@ -19,6 +20,6 @@ * such as DEBUGLOG and RAWLOG */ -#include "debug.h" +#include "third_party/zstd/lib/common/debug.h" int g_debuglevel = DEBUGLEVEL; diff --git a/third_party/zstd/lib/common/debug.h b/third_party/zstd/lib/common/debug.h index 0e9817ea6..ce8653f41 100644 --- a/third_party/zstd/lib/common/debug.h +++ b/third_party/zstd/lib/common/debug.h @@ -1,3 +1,4 @@ +// clang-format off /* ****************************************************************** * debug * Part of FSE library @@ -68,16 +69,16 @@ extern "C" { #if (DEBUGLEVEL>=1) # define ZSTD_DEPS_NEED_ASSERT -# include "zstd_deps.h" +#include "third_party/zstd/lib/common/zstd_deps.h" #else -# ifndef assert /* assert may be already defined, due to prior #include */ +# ifndef assert /* assert may be already defined, due to prior #include "libc/assert.h" # define assert(condition) ((void)0) /* disable assert (default) */ # endif #endif #if (DEBUGLEVEL>=2) # define ZSTD_DEPS_NEED_IO -# include "zstd_deps.h" +#include "third_party/zstd/lib/common/zstd_deps.h" extern int g_debuglevel; /* the variable is only declared, it actually lives in debug.c, and is shared by the whole process. diff --git a/third_party/zstd/lib/common/entropy_common.c b/third_party/zstd/lib/common/entropy_common.c index e2173afb0..276c2474b 100644 --- a/third_party/zstd/lib/common/entropy_common.c +++ b/third_party/zstd/lib/common/entropy_common.c @@ -1,3 +1,4 @@ +// clang-format off /* ****************************************************************** * Common functions of New Generation Entropy library * Copyright (c) Meta Platforms, Inc. and affiliates. @@ -15,12 +16,12 @@ /* ************************************* * Dependencies ***************************************/ -#include "mem.h" -#include "error_private.h" /* ERR_*, ERROR */ +#include "third_party/zstd/lib/common/mem.h" +#include "third_party/zstd/lib/common/error_private.h" /* ERR_*, ERROR */ #define FSE_STATIC_LINKING_ONLY /* FSE_MIN_TABLELOG */ -#include "fse.h" -#include "huf.h" -#include "bits.h" /* ZSDT_highbit32, ZSTD_countTrailingZeros32 */ +#include "third_party/zstd/lib/common/fse.h" +#include "third_party/zstd/lib/common/huf.h" +#include "third_party/zstd/lib/common/bits.h" /* ZSDT_highbit32, ZSTD_countTrailingZeros32 */ /*=== Version ===*/ diff --git a/third_party/zstd/lib/common/error_private.c b/third_party/zstd/lib/common/error_private.c index 075fc5ef4..1de279027 100644 --- a/third_party/zstd/lib/common/error_private.c +++ b/third_party/zstd/lib/common/error_private.c @@ -1,3 +1,4 @@ +// clang-format off /* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. @@ -10,7 +11,7 @@ /* The purpose of this file is to have a single list of error strings embedded in binary */ -#include "error_private.h" +#include "third_party/zstd/lib/common/error_private.h" const char* ERR_getErrorString(ERR_enum code) { diff --git a/third_party/zstd/lib/common/error_private.h b/third_party/zstd/lib/common/error_private.h index 325daad40..9c9a10bfe 100644 --- a/third_party/zstd/lib/common/error_private.h +++ b/third_party/zstd/lib/common/error_private.h @@ -1,3 +1,4 @@ +// clang-format off /* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. @@ -21,10 +22,10 @@ extern "C" { /* **************************************** * Dependencies ******************************************/ -#include "../zstd_errors.h" /* enum list */ -#include "compiler.h" -#include "debug.h" -#include "zstd_deps.h" /* size_t */ +#include "third_party/zstd/lib/zstd_errors.h" /* enum list */ +#include "third_party/zstd/lib/common/compiler.h" +#include "third_party/zstd/lib/common/debug.h" +#include "third_party/zstd/lib/common/zstd_deps.h" /* size_t */ /* **************************************** diff --git a/third_party/zstd/lib/common/fse.h b/third_party/zstd/lib/common/fse.h index 02a1f0bc5..0b2c2c304 100644 --- a/third_party/zstd/lib/common/fse.h +++ b/third_party/zstd/lib/common/fse.h @@ -1,3 +1,4 @@ +// clang-format off /* ****************************************************************** * FSE : Finite State Entropy codec * Public Prototypes declaration @@ -23,7 +24,7 @@ extern "C" { /*-***************************************** * Dependencies ******************************************/ -#include "zstd_deps.h" /* size_t, ptrdiff_t */ +#include "third_party/zstd/lib/common/zstd_deps.h" /* size_t, ptrdiff_t */ /*-***************************************** @@ -233,7 +234,7 @@ If there is an error, the function will return an error code, which can be teste #define FSE_H_FSE_STATIC_LINKING_ONLY /* *** Dependency *** */ -#include "bitstream.h" +#include "third_party/zstd/lib/common/bitstream.h" /* ***************************************** diff --git a/third_party/zstd/lib/common/fse_decompress.c b/third_party/zstd/lib/common/fse_decompress.c index 1e1c9f92d..f61a3b602 100644 --- a/third_party/zstd/lib/common/fse_decompress.c +++ b/third_party/zstd/lib/common/fse_decompress.c @@ -1,3 +1,4 @@ +// clang-format off /* ****************************************************************** * FSE : Finite State Entropy decoder * Copyright (c) Meta Platforms, Inc. and affiliates. @@ -16,15 +17,15 @@ /* ************************************************************** * Includes ****************************************************************/ -#include "debug.h" /* assert */ -#include "bitstream.h" -#include "compiler.h" +#include "third_party/zstd/lib/common/debug.h" /* assert */ +#include "third_party/zstd/lib/common/bitstream.h" +#include "third_party/zstd/lib/common/compiler.h" #define FSE_STATIC_LINKING_ONLY -#include "fse.h" -#include "error_private.h" +#include "third_party/zstd/lib/common/fse.h" +#include "third_party/zstd/lib/common/error_private.h" #define ZSTD_DEPS_NEED_MALLOC -#include "zstd_deps.h" -#include "bits.h" /* ZSTD_highbit32 */ +#include "third_party/zstd/lib/common/zstd_deps.h" +#include "third_party/zstd/lib/common/bits.h" /* ZSTD_highbit32 */ /* ************************************************************** diff --git a/third_party/zstd/lib/common/huf.h b/third_party/zstd/lib/common/huf.h index 73d1ee565..abe7d18e4 100644 --- a/third_party/zstd/lib/common/huf.h +++ b/third_party/zstd/lib/common/huf.h @@ -1,3 +1,4 @@ +// clang-format off /* ****************************************************************** * huff0 huffman codec, * part of Finite State Entropy library @@ -20,10 +21,10 @@ extern "C" { #define HUF_H_298734234 /* *** Dependencies *** */ -#include "zstd_deps.h" /* size_t */ -#include "mem.h" /* U32 */ +#include "third_party/zstd/lib/common/zstd_deps.h" /* size_t */ +#include "third_party/zstd/lib/common/mem.h" /* U32 */ #define FSE_STATIC_LINKING_ONLY -#include "fse.h" +#include "third_party/zstd/lib/common/fse.h" /* *** Tool functions *** */ diff --git a/third_party/zstd/lib/common/mem.h b/third_party/zstd/lib/common/mem.h index 096f4be51..8217f8270 100644 --- a/third_party/zstd/lib/common/mem.h +++ b/third_party/zstd/lib/common/mem.h @@ -1,3 +1,4 @@ +// clang-format off /* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. @@ -18,18 +19,33 @@ extern "C" { /*-**************************************** * Dependencies ******************************************/ -#include /* size_t, ptrdiff_t */ -#include "compiler.h" /* __has_builtin */ -#include "debug.h" /* DEBUG_STATIC_ASSERT */ -#include "zstd_deps.h" /* ZSTD_memcpy */ + /* size_t, ptrdiff_t */ +#include "third_party/zstd/lib/common/compiler.h" /* __has_builtin */ +#include "third_party/zstd/lib/common/debug.h" /* DEBUG_STATIC_ASSERT */ +#include "third_party/zstd/lib/common/zstd_deps.h" /* ZSTD_memcpy */ /*-**************************************** * Compiler specifics ******************************************/ #if defined(_MSC_VER) /* Visual Studio */ -# include /* _byteswap_ulong */ -# include /* _byteswap_* */ +#include "libc/calls/calls.h" +#include "libc/calls/termios.h" +#include "libc/fmt/conv.h" +#include "libc/limits.h" +#include "libc/mem/alg.h" +#include "libc/mem/alloca.h" +#include "libc/mem/mem.h" +#include "libc/runtime/runtime.h" +#include "libc/stdio/dprintf.h" +#include "libc/stdio/rand.h" +#include "libc/stdio/temp.h" +#include "libc/str/str.h" +#include "libc/sysv/consts/exit.h" +#include "third_party/getopt/getopt.h" +#include "third_party/musl/crypt.h" +#include "third_party/musl/rand48.h" /* _byteswap_ulong */ +// MISSING #include /* _byteswap_* */ #endif /*-************************************************************** @@ -37,9 +53,14 @@ extern "C" { *****************************************************************/ #if !defined (__VMS) && (defined (__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */) ) # if defined(_AIX) -# include +#include "libc/fmt/conv.h" +#include "libc/inttypes.h" +#include "libc/limits.h" +#include "libc/literal.h" # else -# include /* intptr_t */ +#include "libc/inttypes.h" +#include "libc/limits.h" +#include "libc/literal.h" /* intptr_t */ # endif typedef uint8_t BYTE; typedef uint8_t U8; @@ -51,7 +72,12 @@ extern "C" { typedef uint64_t U64; typedef int64_t S64; #else -# include +#include "libc/limits.h" +#include "libc/sysv/consts/_posix.h" +#include "libc/sysv/consts/iov.h" +#include "libc/sysv/consts/limits.h" +#include "libc/sysv/consts/xopen.h" +#include "libc/thread/thread.h" #if CHAR_BIT != 8 # error "this implementation requires char to be exactly 8-bit type" #endif diff --git a/third_party/zstd/lib/common/pool.c b/third_party/zstd/lib/common/pool.c index d5ca5a780..59d9370a3 100644 --- a/third_party/zstd/lib/common/pool.c +++ b/third_party/zstd/lib/common/pool.c @@ -1,3 +1,4 @@ +// clang-format off /* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. @@ -10,10 +11,10 @@ /* ====== Dependencies ======= */ -#include "../common/allocations.h" /* ZSTD_customCalloc, ZSTD_customFree */ -#include "zstd_deps.h" /* size_t */ -#include "debug.h" /* assert */ -#include "pool.h" +#include "third_party/zstd/lib/common/allocations.h" /* ZSTD_customCalloc, ZSTD_customFree */ +#include "third_party/zstd/lib/common/zstd_deps.h" /* size_t */ +#include "third_party/zstd/lib/common/debug.h" /* assert */ +#include "third_party/zstd/lib/common/pool.h" /* ====== Compiler specifics ====== */ #if defined(_MSC_VER) @@ -23,7 +24,7 @@ #ifdef ZSTD_MULTITHREAD -#include "threading.h" /* pthread adaptation */ +#include "third_party/zstd/lib/common/threading.h" /* pthread adaptation */ /* A job is a function and an opaque argument */ typedef struct POOL_job_s { diff --git a/third_party/zstd/lib/common/pool.h b/third_party/zstd/lib/common/pool.h index eb22ff509..c83d5c414 100644 --- a/third_party/zstd/lib/common/pool.h +++ b/third_party/zstd/lib/common/pool.h @@ -1,3 +1,4 @@ +// clang-format off /* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. @@ -16,9 +17,10 @@ extern "C" { #endif -#include "zstd_deps.h" +#include "third_party/zstd/lib/common/zstd_deps.h" #define ZSTD_STATIC_LINKING_ONLY /* ZSTD_customMem */ -#include "../zstd.h" +#include "third_party/zstd/lib/zstd.h" +#include "libc/assert.h" typedef struct POOL_ctx_s POOL_ctx; diff --git a/third_party/zstd/lib/common/portability_macros.h b/third_party/zstd/lib/common/portability_macros.h index 8fd6ea82d..cf419d471 100644 --- a/third_party/zstd/lib/common/portability_macros.h +++ b/third_party/zstd/lib/common/portability_macros.h @@ -1,3 +1,4 @@ +// clang-format off /* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. @@ -144,7 +145,7 @@ #if defined(__ELF__) && (defined(__x86_64__) || defined(__i386__)) \ && defined(__has_include) # if __has_include() -# include +// MISSING #include # define ZSTD_CET_ENDBRANCH _CET_ENDBR # endif #endif diff --git a/third_party/zstd/lib/common/threading.c b/third_party/zstd/lib/common/threading.c index 25bb8b981..bb956e1e5 100644 --- a/third_party/zstd/lib/common/threading.c +++ b/third_party/zstd/lib/common/threading.c @@ -1,3 +1,4 @@ +// clang-format off /** * Copyright (c) 2016 Tino Reichardt * All rights reserved. @@ -15,7 +16,7 @@ * This file will hold wrapper for systems, which do not support pthreads */ -#include "threading.h" +#include "third_party/zstd/lib/common/threading.h" /* create fake symbol to avoid empty translation unit warning */ int g_ZSTD_threading_useless_symbol; @@ -28,8 +29,8 @@ int g_ZSTD_threading_useless_symbol; /* === Dependencies === */ -#include -#include +// MISSING #include +#include "libc/errno.h" /* === Implementation === */ @@ -135,7 +136,7 @@ int ZSTD_pthread_join(ZSTD_pthread_t thread) #if defined(ZSTD_MULTITHREAD) && DEBUGLEVEL >= 1 && !defined(_WIN32) #define ZSTD_DEPS_NEED_MALLOC -#include "zstd_deps.h" +#include "third_party/zstd/lib/common/zstd_deps.h" int ZSTD_pthread_mutex_init(ZSTD_pthread_mutex_t* mutex, pthread_mutexattr_t const* attr) { diff --git a/third_party/zstd/lib/common/threading.h b/third_party/zstd/lib/common/threading.h index fb5c1c878..c339a5254 100644 --- a/third_party/zstd/lib/common/threading.h +++ b/third_party/zstd/lib/common/threading.h @@ -1,3 +1,4 @@ +// clang-format off /** * Copyright (c) 2016 Tino Reichardt * All rights reserved. @@ -14,7 +15,7 @@ #ifndef THREADING_H_938743 #define THREADING_H_938743 -#include "debug.h" +#include "third_party/zstd/lib/common/debug.h" #if defined (__cplusplus) extern "C" { @@ -40,7 +41,25 @@ extern "C" { #endif #undef ERROR /* reported already defined on VS 2015 (Rich Geldreich) */ -#include +#include "libc/nt/accounting.h" +#include "libc/nt/automation.h" +#include "libc/nt/console.h" +#include "libc/nt/debug.h" +#include "libc/nt/dll.h" +#include "libc/nt/enum/keyaccess.h" +#include "libc/nt/enum/regtype.h" +#include "libc/nt/errors.h" +#include "libc/nt/events.h" +#include "libc/nt/files.h" +#include "libc/nt/ipc.h" +#include "libc/nt/memory.h" +#include "libc/nt/paint.h" +#include "libc/nt/process.h" +#include "libc/nt/registry.h" +#include "libc/nt/synchronization.h" +#include "libc/nt/thread.h" +#include "libc/nt/windows.h" +#include "libc/nt/winsock.h" #undef ERROR #define ERROR(name) ZSTD_ERROR(name) @@ -75,7 +94,10 @@ int ZSTD_pthread_join(ZSTD_pthread_t thread); #elif defined(ZSTD_MULTITHREAD) /* posix assumed ; need a better detection method */ /* === POSIX Systems === */ -# include +#include "libc/calls/weirdtypes.h" +#include "libc/sysv/consts/clock.h" +#include "libc/thread/thread.h" +#include "libc/thread/thread2.h" #if DEBUGLEVEL < 1 diff --git a/third_party/zstd/lib/common/xxhash.c b/third_party/zstd/lib/common/xxhash.c index fd237c906..cd6c7c998 100644 --- a/third_party/zstd/lib/common/xxhash.c +++ b/third_party/zstd/lib/common/xxhash.c @@ -1,3 +1,4 @@ +// clang-format off /* * xxHash - Fast Hash algorithm * Copyright (c) Meta Platforms, Inc. and affiliates. @@ -21,4 +22,4 @@ #define XXH_STATIC_LINKING_ONLY /* access advanced declarations */ #define XXH_IMPLEMENTATION /* access definitions */ -#include "xxhash.h" +#include "third_party/zstd/lib/common/xxhash.h" diff --git a/third_party/zstd/lib/common/xxhash.h b/third_party/zstd/lib/common/xxhash.h index 69572117a..a57805804 100644 --- a/third_party/zstd/lib/common/xxhash.h +++ b/third_party/zstd/lib/common/xxhash.h @@ -1,3 +1,4 @@ +// clang-format off /* * xxHash - Fast Hash algorithm * Copyright (c) Meta Platforms, Inc. and affiliates. @@ -84,7 +85,7 @@ extern "C" { * * Usage: * #define XXH_INLINE_ALL - * #include "xxhash.h" + * #include "third_party/zstd/lib/common/xxhash.h" * * Do not compile and link xxhash.o as a separate object, as it is not useful. */ @@ -328,7 +329,7 @@ XXH_PUBLIC_API unsigned XXH_versionNumber (void); /* **************************** * Common basic types ******************************/ -#include /* size_t */ + /* size_t */ typedef enum { XXH_OK=0, XXH_ERROR } XXH_errorcode; @@ -346,11 +347,18 @@ typedef uint32_t XXH32_hash_t; #elif !defined (__VMS) \ && (defined (__cplusplus) \ || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */) ) -# include +#include "libc/inttypes.h" +#include "libc/limits.h" +#include "libc/literal.h" typedef uint32_t XXH32_hash_t; #else -# include +#include "libc/limits.h" +#include "libc/sysv/consts/_posix.h" +#include "libc/sysv/consts/iov.h" +#include "libc/sysv/consts/limits.h" +#include "libc/sysv/consts/xopen.h" +#include "libc/thread/thread.h" # if UINT_MAX == 0xFFFFFFFFUL typedef unsigned int XXH32_hash_t; # else @@ -427,8 +435,14 @@ XXH_PUBLIC_API XXH32_hash_t XXH32 (const void* input, size_t length, XXH32_hash_ * * Example code for incrementally hashing a file: * @code{.c} - * #include - * #include + * #include "libc/calls/calls.h" +#include "libc/calls/weirdtypes.h" +#include "libc/fmt/fmt.h" +#include "libc/stdio/dprintf.h" +#include "libc/stdio/stdio.h" +#include "libc/stdio/temp.h" +#include "third_party/musl/tempnam.h" + * // MISSING #include * #define BUFFER_SIZE 256 * * // Note: XXH64 and XXH3 use the same interface. @@ -644,10 +658,17 @@ typedef uint64_t XXH64_hash_t; #elif !defined (__VMS) \ && (defined (__cplusplus) \ || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */) ) -# include +#include "libc/inttypes.h" +#include "libc/limits.h" +#include "libc/literal.h" typedef uint64_t XXH64_hash_t; #else -# include +#include "libc/limits.h" +#include "libc/sysv/consts/_posix.h" +#include "libc/sysv/consts/iov.h" +#include "libc/sysv/consts/limits.h" +#include "libc/sysv/consts/xopen.h" +#include "libc/thread/thread.h" # if defined(__LP64__) && ULONG_MAX == 0xFFFFFFFFFFFFFFFFULL /* LP64 ABI says uint64_t is unsigned long */ typedef unsigned long XXH64_hash_t; @@ -1000,7 +1021,7 @@ struct XXH64_state_s { #ifndef XXH_NO_XXH3 #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) /* >= C11 */ -# include +#include "libc/stdalign.internal.h" # define XXH_ALIGN(n) alignas(n) #elif defined(__cplusplus) && (__cplusplus >= 201103L) /* >= C++11 */ /* In C++ alignas() is a keyword */ @@ -1451,7 +1472,7 @@ XXH3_128bits_reset_withSecretandSeed(XXH3_state_t* statePtr, /* Modify the local functions below should you wish to use some other memory routines */ /* for ZSTD_malloc(), ZSTD_free() */ #define ZSTD_DEPS_NEED_MALLOC -#include "zstd_deps.h" /* size_t, ZSTD_malloc, ZSTD_free, ZSTD_memcpy */ +#include "third_party/zstd/lib/common/zstd_deps.h" /* size_t, ZSTD_malloc, ZSTD_free, ZSTD_memcpy */ static void* XXH_malloc(size_t s) { return ZSTD_malloc(s); } static void XXH_free (void* p) { ZSTD_free(p); } static void* XXH_memcpy(void* dest, const void* src, size_t size) { return ZSTD_memcpy(dest,src,size); } @@ -1509,7 +1530,7 @@ static void* XXH_memcpy(void* dest, const void* src, size_t size) { return ZSTD_ #endif #if (XXH_DEBUGLEVEL>=1) -# include /* note: can still be disabled with NDEBUG */ +#include "libc/assert.h" /* note: can still be disabled with NDEBUG */ # define XXH_ASSERT(c) assert(c) #else # define XXH_ASSERT(c) ((void)0) @@ -1518,7 +1539,7 @@ static void* XXH_memcpy(void* dest, const void* src, size_t size) { return ZSTD_ /* note: use after variable declarations */ #ifndef XXH_STATIC_ASSERT # if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) /* C11 */ -# include +#include "libc/assert.h" # define XXH_STATIC_ASSERT_WITH_MESSAGE(c,m) do { static_assert((c),m); } while(0) # elif defined(__cplusplus) && (__cplusplus >= 201103L) /* C++11 */ # define XXH_STATIC_ASSERT_WITH_MESSAGE(c,m) do { static_assert((c),m); } while(0) @@ -1556,7 +1577,9 @@ static void* XXH_memcpy(void* dest, const void* src, size_t size) { return ZSTD_ #if !defined (__VMS) \ && (defined (__cplusplus) \ || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */) ) -# include +#include "libc/inttypes.h" +#include "libc/limits.h" +#include "libc/literal.h" typedef uint8_t xxh_u8; #else typedef unsigned char xxh_u8; @@ -2681,17 +2704,17 @@ XXH_PUBLIC_API XXH64_hash_t XXH64_hashFromCanonical(const XXH64_canonical_t* src || defined(__aarch64__) || defined(_M_ARM) \ || defined(_M_ARM64) || defined(_M_ARM64EC) # define inline __inline__ /* circumvent a clang bug */ -# include +// MISSING #include # undef inline # elif defined(__AVX2__) -# include +#include "third_party/intel/immintrin.internal.h" # elif defined(__SSE2__) -# include +#include "third_party/intel/emmintrin.internal.h" # endif #endif #if defined(_MSC_VER) -# include +// MISSING #include #endif /* @@ -3067,7 +3090,7 @@ enum XXH_VECTOR_TYPE /* fake enum */ { */ #if XXH_VECTOR == XXH_VSX # if defined(__s390x__) -# include +// MISSING #include # else /* gcc's altivec.h can have the unwanted consequence to unconditionally * #define bool, vector, and pixel keywords, @@ -3080,7 +3103,7 @@ enum XXH_VECTOR_TYPE /* fake enum */ { # if defined(__GNUC__) && !defined(__APPLE_ALTIVEC__) # define __APPLE_ALTIVEC__ # endif -# include +// MISSING #include # endif typedef __vector unsigned long long xxh_u64x2; @@ -3167,7 +3190,7 @@ XXH_FORCE_INLINE xxh_u64x2 XXH_vec_mule(xxh_u32x4 a, xxh_u32x4 b) # define XXH_PREFETCH(ptr) (void)(ptr) /* disabled */ #else # if defined(_MSC_VER) && (defined(_M_X64) || defined(_M_IX86)) && !defined(_M_ARM64EC) /* _mm_prefetch() not defined outside of x86/x64 */ -# include /* https://msdn.microsoft.com/fr-fr/library/84szxsww(v=vs.90).aspx */ +#include "third_party/intel/mmintrin.internal.h" /* https://msdn.microsoft.com/fr-fr/library/84szxsww(v=vs.90).aspx */ # define XXH_PREFETCH(ptr) _mm_prefetch((const char*)(ptr), _MM_HINT_T0) # elif defined(__GNUC__) && ( (__GNUC__ >= 4) || ( (__GNUC__ == 3) && (__GNUC_MINOR__ >= 1) ) ) # define XXH_PREFETCH(ptr) __builtin_prefetch((ptr), 0 /* rw==read */, 3 /* locality */) @@ -5543,7 +5566,9 @@ XXH_PUBLIC_API XXH128_hash_t XXH3_128bits_digest (const XXH3_state_t* state) /* 128-bit utility functions */ -#include /* memcmp, memcpy */ +#include "libc/mem/alg.h" +#include "libc/mem/mem.h" +#include "libc/str/str.h" /* memcmp, memcpy */ /* return : 1 is equal, 0 if different */ /*! @ingroup xxh3_family */ diff --git a/third_party/zstd/lib/common/zstd_common.c b/third_party/zstd/lib/common/zstd_common.c index 3f04c22ab..ac1dad872 100644 --- a/third_party/zstd/lib/common/zstd_common.c +++ b/third_party/zstd/lib/common/zstd_common.c @@ -1,3 +1,4 @@ +// clang-format off /* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. @@ -14,8 +15,8 @@ * Dependencies ***************************************/ #define ZSTD_DEPS_NEED_MALLOC -#include "error_private.h" -#include "zstd_internal.h" +#include "third_party/zstd/lib/common/error_private.h" +#include "third_party/zstd/lib/common/zstd_internal.h" /*-**************************************** diff --git a/third_party/zstd/lib/common/zstd_deps.h b/third_party/zstd/lib/common/zstd_deps.h index 4d767ae9b..a0b065090 100644 --- a/third_party/zstd/lib/common/zstd_deps.h +++ b/third_party/zstd/lib/common/zstd_deps.h @@ -1,3 +1,4 @@ +// clang-format off /* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. @@ -24,9 +25,16 @@ #ifndef ZSTD_DEPS_COMMON #define ZSTD_DEPS_COMMON -#include -#include -#include +#include "libc/limits.h" +#include "libc/sysv/consts/_posix.h" +#include "libc/sysv/consts/iov.h" +#include "libc/sysv/consts/limits.h" +#include "libc/sysv/consts/xopen.h" +#include "libc/thread/thread.h" + +#include "libc/mem/alg.h" +#include "libc/mem/mem.h" +#include "libc/str/str.h" #if defined(__GNUC__) && __GNUC__ >= 4 # define ZSTD_memcpy(d,s,l) __builtin_memcpy((d),(s),(l)) @@ -49,7 +57,22 @@ #ifndef ZSTD_DEPS_MALLOC #define ZSTD_DEPS_MALLOC -#include +#include "libc/calls/calls.h" +#include "libc/calls/termios.h" +#include "libc/fmt/conv.h" +#include "libc/limits.h" +#include "libc/mem/alg.h" +#include "libc/mem/alloca.h" +#include "libc/mem/mem.h" +#include "libc/runtime/runtime.h" +#include "libc/stdio/dprintf.h" +#include "libc/stdio/rand.h" +#include "libc/stdio/temp.h" +#include "libc/str/str.h" +#include "libc/sysv/consts/exit.h" +#include "third_party/getopt/getopt.h" +#include "third_party/musl/crypt.h" +#include "third_party/musl/rand48.h" #define ZSTD_malloc(s) malloc(s) #define ZSTD_calloc(n,s) calloc((n), (s)) @@ -79,7 +102,7 @@ #ifndef ZSTD_DEPS_ASSERT #define ZSTD_DEPS_ASSERT -#include +#include "libc/assert.h" #endif /* ZSTD_DEPS_ASSERT */ #endif /* ZSTD_DEPS_NEED_ASSERT */ @@ -91,7 +114,13 @@ #ifndef ZSTD_DEPS_IO #define ZSTD_DEPS_IO -#include +#include "libc/calls/calls.h" +#include "libc/calls/weirdtypes.h" +#include "libc/fmt/fmt.h" +#include "libc/stdio/dprintf.h" +#include "libc/stdio/stdio.h" +#include "libc/stdio/temp.h" +#include "third_party/musl/tempnam.h" #define ZSTD_DEBUG_PRINT(...) fprintf(stderr, __VA_ARGS__) #endif /* ZSTD_DEPS_IO */ @@ -105,7 +134,9 @@ #ifndef ZSTD_DEPS_STDINT #define ZSTD_DEPS_STDINT -#include +#include "libc/inttypes.h" +#include "libc/limits.h" +#include "libc/literal.h" #endif /* ZSTD_DEPS_STDINT */ #endif /* ZSTD_DEPS_NEED_STDINT */ diff --git a/third_party/zstd/lib/common/zstd_internal.h b/third_party/zstd/lib/common/zstd_internal.h index f7c57a028..b1d19b44f 100644 --- a/third_party/zstd/lib/common/zstd_internal.h +++ b/third_party/zstd/lib/common/zstd_internal.h @@ -1,3 +1,4 @@ +// clang-format off /* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. @@ -19,22 +20,22 @@ /*-************************************* * Dependencies ***************************************/ -#include "compiler.h" -#include "cpu.h" -#include "mem.h" -#include "debug.h" /* assert, DEBUGLOG, RAWLOG, g_debuglevel */ -#include "error_private.h" +#include "third_party/zstd/lib/common/compiler.h" +#include "third_party/zstd/lib/common/cpu.h" +#include "third_party/zstd/lib/common/mem.h" +#include "third_party/zstd/lib/common/debug.h" /* assert, DEBUGLOG, RAWLOG, g_debuglevel */ +#include "third_party/zstd/lib/common/error_private.h" #define ZSTD_STATIC_LINKING_ONLY -#include "../zstd.h" +#include "third_party/zstd/lib/zstd.h" #define FSE_STATIC_LINKING_ONLY -#include "fse.h" -#include "huf.h" +#include "third_party/zstd/lib/common/fse.h" +#include "third_party/zstd/lib/common/huf.h" #ifndef XXH_STATIC_LINKING_ONLY # define XXH_STATIC_LINKING_ONLY /* XXH64_state_t */ #endif -#include "xxhash.h" /* XXH_reset, update, digest */ +#include "third_party/zstd/lib/common/xxhash.h" /* XXH_reset, update, digest */ #ifndef ZSTD_NO_TRACE -# include "zstd_trace.h" +#include "third_party/zstd/lib/common/zstd_trace.h" #else # define ZSTD_TRACE 0 #endif diff --git a/third_party/zstd/lib/common/zstd_trace.h b/third_party/zstd/lib/common/zstd_trace.h index da20534eb..04b7ac68c 100644 --- a/third_party/zstd/lib/common/zstd_trace.h +++ b/third_party/zstd/lib/common/zstd_trace.h @@ -1,3 +1,4 @@ +// clang-format off /* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. @@ -15,7 +16,7 @@ extern "C" { #endif -#include + /* weak symbol support * For now, enable conservatively: diff --git a/third_party/zstd/lib/compress/clevels.h b/third_party/zstd/lib/compress/clevels.h index c18da465f..470076f02 100644 --- a/third_party/zstd/lib/compress/clevels.h +++ b/third_party/zstd/lib/compress/clevels.h @@ -1,3 +1,4 @@ +// clang-format off /* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. @@ -12,7 +13,7 @@ #define ZSTD_CLEVELS_H #define ZSTD_STATIC_LINKING_ONLY /* ZSTD_compressionParameters */ -#include "../zstd.h" +#include "third_party/zstd/lib/zstd.h" /*-===== Pre-defined compression levels =====-*/ diff --git a/third_party/zstd/lib/compress/fse_compress.c b/third_party/zstd/lib/compress/fse_compress.c index 5d3770808..285ac6885 100644 --- a/third_party/zstd/lib/compress/fse_compress.c +++ b/third_party/zstd/lib/compress/fse_compress.c @@ -1,3 +1,4 @@ +// clang-format off /* ****************************************************************** * FSE : Finite State Entropy encoder * Copyright (c) Meta Platforms, Inc. and affiliates. @@ -15,18 +16,18 @@ /* ************************************************************** * Includes ****************************************************************/ -#include "../common/compiler.h" -#include "../common/mem.h" /* U32, U16, etc. */ -#include "../common/debug.h" /* assert, DEBUGLOG */ -#include "hist.h" /* HIST_count_wksp */ -#include "../common/bitstream.h" +#include "third_party/zstd/lib/common/compiler.h" +#include "third_party/zstd/lib/common/mem.h" /* U32, U16, etc. */ +#include "third_party/zstd/lib/common/debug.h" /* assert, DEBUGLOG */ +#include "third_party/zstd/lib/compress/hist.h" /* HIST_count_wksp */ +#include "third_party/zstd/lib/common/bitstream.h" #define FSE_STATIC_LINKING_ONLY -#include "../common/fse.h" -#include "../common/error_private.h" +#include "third_party/zstd/lib/common/fse.h" +#include "third_party/zstd/lib/common/error_private.h" #define ZSTD_DEPS_NEED_MALLOC #define ZSTD_DEPS_NEED_MATH64 -#include "../common/zstd_deps.h" /* ZSTD_malloc, ZSTD_free, ZSTD_memcpy, ZSTD_memset */ -#include "../common/bits.h" /* ZSTD_highbit32 */ +#include "third_party/zstd/lib/common/zstd_deps.h" /* ZSTD_malloc, ZSTD_free, ZSTD_memcpy, ZSTD_memset */ +#include "third_party/zstd/lib/common/bits.h" /* ZSTD_highbit32 */ /* ************************************************************** diff --git a/third_party/zstd/lib/compress/hist.c b/third_party/zstd/lib/compress/hist.c index e2fb431f0..6440f2be3 100644 --- a/third_party/zstd/lib/compress/hist.c +++ b/third_party/zstd/lib/compress/hist.c @@ -1,3 +1,4 @@ +// clang-format off /* ****************************************************************** * hist : Histogram functions * part of Finite State Entropy project @@ -14,10 +15,10 @@ ****************************************************************** */ /* --- dependencies --- */ -#include "../common/mem.h" /* U32, BYTE, etc. */ -#include "../common/debug.h" /* assert, DEBUGLOG */ -#include "../common/error_private.h" /* ERROR */ -#include "hist.h" +#include "third_party/zstd/lib/common/mem.h" /* U32, BYTE, etc. */ +#include "third_party/zstd/lib/common/debug.h" /* assert, DEBUGLOG */ +#include "third_party/zstd/lib/common/error_private.h" /* ERROR */ +#include "third_party/zstd/lib/compress/hist.h" /* --- Error management --- */ diff --git a/third_party/zstd/lib/compress/hist.h b/third_party/zstd/lib/compress/hist.h index 887896b81..ef25cb270 100644 --- a/third_party/zstd/lib/compress/hist.h +++ b/third_party/zstd/lib/compress/hist.h @@ -1,3 +1,4 @@ +// clang-format off /* ****************************************************************** * hist : Histogram functions * part of Finite State Entropy project @@ -14,7 +15,8 @@ ****************************************************************** */ /* --- dependencies --- */ -#include "../common/zstd_deps.h" /* size_t */ +#include "third_party/zstd/lib/common/zstd_deps.h" /* size_t */ +#include "libc/assert.h" /* --- simple histogram functions --- */ diff --git a/third_party/zstd/lib/compress/huf_compress.c b/third_party/zstd/lib/compress/huf_compress.c index 29871877a..b370fe18e 100644 --- a/third_party/zstd/lib/compress/huf_compress.c +++ b/third_party/zstd/lib/compress/huf_compress.c @@ -1,3 +1,4 @@ +// clang-format off /* ****************************************************************** * Huffman encoder, part of New Generation Entropy library * Copyright (c) Meta Platforms, Inc. and affiliates. @@ -23,15 +24,15 @@ /* ************************************************************** * Includes ****************************************************************/ -#include "../common/zstd_deps.h" /* ZSTD_memcpy, ZSTD_memset */ -#include "../common/compiler.h" -#include "../common/bitstream.h" -#include "hist.h" +#include "third_party/zstd/lib/common/zstd_deps.h" /* ZSTD_memcpy, ZSTD_memset */ +#include "third_party/zstd/lib/common/compiler.h" +#include "third_party/zstd/lib/common/bitstream.h" +#include "third_party/zstd/lib/compress/hist.h" #define FSE_STATIC_LINKING_ONLY /* FSE_optimalTableLog_internal */ -#include "../common/fse.h" /* header compression */ -#include "../common/huf.h" -#include "../common/error_private.h" -#include "../common/bits.h" /* ZSTD_highbit32 */ +#include "third_party/zstd/lib/common/fse.h" /* header compression */ +#include "third_party/zstd/lib/common/huf.h" +#include "third_party/zstd/lib/common/error_private.h" +#include "third_party/zstd/lib/common/bits.h" /* ZSTD_highbit32 */ /* ************************************************************** diff --git a/third_party/zstd/lib/compress/zstd_compress.c b/third_party/zstd/lib/compress/zstd_compress.c index 19446b63f..d9360d8b0 100644 --- a/third_party/zstd/lib/compress/zstd_compress.c +++ b/third_party/zstd/lib/compress/zstd_compress.c @@ -1,3 +1,4 @@ +// clang-format off /* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. @@ -11,23 +12,23 @@ /*-************************************* * Dependencies ***************************************/ -#include "../common/allocations.h" /* ZSTD_customMalloc, ZSTD_customCalloc, ZSTD_customFree */ -#include "../common/zstd_deps.h" /* INT_MAX, ZSTD_memset, ZSTD_memcpy */ -#include "../common/mem.h" -#include "hist.h" /* HIST_countFast_wksp */ +#include "third_party/zstd/lib/common/allocations.h" /* ZSTD_customMalloc, ZSTD_customCalloc, ZSTD_customFree */ +#include "third_party/zstd/lib/common/zstd_deps.h" /* INT_MAX, ZSTD_memset, ZSTD_memcpy */ +#include "third_party/zstd/lib/common/mem.h" +#include "third_party/zstd/lib/compress/hist.h" /* HIST_countFast_wksp */ #define FSE_STATIC_LINKING_ONLY /* FSE_encodeSymbol */ -#include "../common/fse.h" -#include "../common/huf.h" -#include "zstd_compress_internal.h" -#include "zstd_compress_sequences.h" -#include "zstd_compress_literals.h" -#include "zstd_fast.h" -#include "zstd_double_fast.h" -#include "zstd_lazy.h" -#include "zstd_opt.h" -#include "zstd_ldm.h" -#include "zstd_compress_superblock.h" -#include "../common/bits.h" /* ZSTD_highbit32, ZSTD_rotateRight_U64 */ +#include "third_party/zstd/lib/common/fse.h" +#include "third_party/zstd/lib/common/huf.h" +#include "third_party/zstd/lib/compress/zstd_compress_internal.h" +#include "third_party/zstd/lib/compress/zstd_compress_sequences.h" +#include "third_party/zstd/lib/compress/zstd_compress_literals.h" +#include "third_party/zstd/lib/compress/zstd_fast.h" +#include "third_party/zstd/lib/compress/zstd_double_fast.h" +#include "third_party/zstd/lib/compress/zstd_lazy.h" +#include "third_party/zstd/lib/compress/zstd_opt.h" +#include "third_party/zstd/lib/compress/zstd_ldm.h" +#include "third_party/zstd/lib/compress/zstd_compress_superblock.h" +#include "third_party/zstd/lib/common/bits.h" /* ZSTD_highbit32, ZSTD_rotateRight_U64 */ /* *************************************************************** * Tuning parameters @@ -6940,7 +6941,7 @@ size_t ZSTD_endStream(ZSTD_CStream* zcs, ZSTD_outBuffer* output) /*-===== Pre-defined compression levels =====-*/ -#include "clevels.h" +#include "third_party/zstd/lib/compress/clevels.h" int ZSTD_maxCLevel(void) { return ZSTD_MAX_CLEVEL; } int ZSTD_minCLevel(void) { return (int)-ZSTD_TARGETLENGTH_MAX; } diff --git a/third_party/zstd/lib/compress/zstd_compress_internal.h b/third_party/zstd/lib/compress/zstd_compress_internal.h index 10f68d010..b68694a3a 100644 --- a/third_party/zstd/lib/compress/zstd_compress_internal.h +++ b/third_party/zstd/lib/compress/zstd_compress_internal.h @@ -1,3 +1,4 @@ +// clang-format off /* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. @@ -18,12 +19,12 @@ /*-************************************* * Dependencies ***************************************/ -#include "../common/zstd_internal.h" -#include "zstd_cwksp.h" +#include "third_party/zstd/lib/common/zstd_internal.h" +#include "third_party/zstd/lib/compress/zstd_cwksp.h" #ifdef ZSTD_MULTITHREAD -# include "zstdmt_compress.h" +#include "third_party/zstd/lib/compress/zstdmt_compress.h" #endif -#include "../common/bits.h" /* ZSTD_highbit32, ZSTD_NbCommonBytes */ +#include "third_party/zstd/lib/common/bits.h" /* ZSTD_highbit32, ZSTD_NbCommonBytes */ #if defined (__cplusplus) extern "C" { diff --git a/third_party/zstd/lib/compress/zstd_compress_literals.c b/third_party/zstd/lib/compress/zstd_compress_literals.c index bfd4f11ab..f96fd297d 100644 --- a/third_party/zstd/lib/compress/zstd_compress_literals.c +++ b/third_party/zstd/lib/compress/zstd_compress_literals.c @@ -1,3 +1,4 @@ +// clang-format off /* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. @@ -11,7 +12,7 @@ /*-************************************* * Dependencies ***************************************/ -#include "zstd_compress_literals.h" +#include "third_party/zstd/lib/compress/zstd_compress_literals.h" /* ************************************************************** diff --git a/third_party/zstd/lib/compress/zstd_compress_literals.h b/third_party/zstd/lib/compress/zstd_compress_literals.h index b060c8ad2..96764c983 100644 --- a/third_party/zstd/lib/compress/zstd_compress_literals.h +++ b/third_party/zstd/lib/compress/zstd_compress_literals.h @@ -1,3 +1,4 @@ +// clang-format off /* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. @@ -11,7 +12,7 @@ #ifndef ZSTD_COMPRESS_LITERALS_H #define ZSTD_COMPRESS_LITERALS_H -#include "zstd_compress_internal.h" /* ZSTD_hufCTables_t, ZSTD_minGain() */ +#include "third_party/zstd/lib/compress/zstd_compress_internal.h" /* ZSTD_hufCTables_t, ZSTD_minGain() */ size_t ZSTD_noCompressLiterals (void* dst, size_t dstCapacity, const void* src, size_t srcSize); diff --git a/third_party/zstd/lib/compress/zstd_compress_sequences.c b/third_party/zstd/lib/compress/zstd_compress_sequences.c index 8872d4d35..695a00874 100644 --- a/third_party/zstd/lib/compress/zstd_compress_sequences.c +++ b/third_party/zstd/lib/compress/zstd_compress_sequences.c @@ -1,3 +1,4 @@ +// clang-format off /* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. @@ -11,7 +12,7 @@ /*-************************************* * Dependencies ***************************************/ -#include "zstd_compress_sequences.h" +#include "third_party/zstd/lib/compress/zstd_compress_sequences.h" /** * -log2(x / 256) lookup table for x in [0, 256). diff --git a/third_party/zstd/lib/compress/zstd_compress_sequences.h b/third_party/zstd/lib/compress/zstd_compress_sequences.h index 4a3a05da9..2707d2f71 100644 --- a/third_party/zstd/lib/compress/zstd_compress_sequences.h +++ b/third_party/zstd/lib/compress/zstd_compress_sequences.h @@ -1,3 +1,4 @@ +// clang-format off /* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. @@ -11,8 +12,8 @@ #ifndef ZSTD_COMPRESS_SEQUENCES_H #define ZSTD_COMPRESS_SEQUENCES_H -#include "../common/fse.h" /* FSE_repeat, FSE_CTable */ -#include "../common/zstd_internal.h" /* symbolEncodingType_e, ZSTD_strategy */ +#include "third_party/zstd/lib/common/fse.h" /* FSE_repeat, FSE_CTable */ +#include "third_party/zstd/lib/common/zstd_internal.h" /* symbolEncodingType_e, ZSTD_strategy */ typedef enum { ZSTD_defaultDisallowed = 0, diff --git a/third_party/zstd/lib/compress/zstd_compress_superblock.c b/third_party/zstd/lib/compress/zstd_compress_superblock.c index dacaf85db..785143b19 100644 --- a/third_party/zstd/lib/compress/zstd_compress_superblock.c +++ b/third_party/zstd/lib/compress/zstd_compress_superblock.c @@ -1,3 +1,4 @@ +// clang-format off /* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. @@ -11,13 +12,13 @@ /*-************************************* * Dependencies ***************************************/ -#include "zstd_compress_superblock.h" +#include "third_party/zstd/lib/compress/zstd_compress_superblock.h" -#include "../common/zstd_internal.h" /* ZSTD_getSequenceLength */ -#include "hist.h" /* HIST_countFast_wksp */ -#include "zstd_compress_internal.h" /* ZSTD_[huf|fse|entropy]CTablesMetadata_t */ -#include "zstd_compress_sequences.h" -#include "zstd_compress_literals.h" +#include "third_party/zstd/lib/common/zstd_internal.h" /* ZSTD_getSequenceLength */ +#include "third_party/zstd/lib/compress/hist.h" /* HIST_countFast_wksp */ +#include "third_party/zstd/lib/compress/zstd_compress_internal.h" /* ZSTD_[huf|fse|entropy]CTablesMetadata_t */ +#include "third_party/zstd/lib/compress/zstd_compress_sequences.h" +#include "third_party/zstd/lib/compress/zstd_compress_literals.h" /** ZSTD_compressSubBlock_literal() : * Compresses literals section for a sub-block. diff --git a/third_party/zstd/lib/compress/zstd_compress_superblock.h b/third_party/zstd/lib/compress/zstd_compress_superblock.h index 8e494f0d5..b9ba29b90 100644 --- a/third_party/zstd/lib/compress/zstd_compress_superblock.h +++ b/third_party/zstd/lib/compress/zstd_compress_superblock.h @@ -1,3 +1,4 @@ +// clang-format off /* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. @@ -15,7 +16,7 @@ * Dependencies ***************************************/ -#include "../zstd.h" /* ZSTD_CCtx */ +#include "third_party/zstd/lib/zstd.h" /* ZSTD_CCtx */ /*-************************************* * Target Compressed Block Size diff --git a/third_party/zstd/lib/compress/zstd_cwksp.h b/third_party/zstd/lib/compress/zstd_cwksp.h index cfe808f15..e2a542b87 100644 --- a/third_party/zstd/lib/compress/zstd_cwksp.h +++ b/third_party/zstd/lib/compress/zstd_cwksp.h @@ -1,3 +1,4 @@ +// clang-format off /* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. @@ -14,9 +15,9 @@ /*-************************************* * Dependencies ***************************************/ -#include "../common/allocations.h" /* ZSTD_customMalloc, ZSTD_customFree */ -#include "../common/zstd_internal.h" -#include "../common/portability_macros.h" +#include "third_party/zstd/lib/common/allocations.h" /* ZSTD_customMalloc, ZSTD_customFree */ +#include "third_party/zstd/lib/common/zstd_internal.h" +#include "third_party/zstd/lib/common/portability_macros.h" #if defined (__cplusplus) extern "C" { diff --git a/third_party/zstd/lib/compress/zstd_double_fast.c b/third_party/zstd/lib/compress/zstd_double_fast.c index d4544b390..b18048faa 100644 --- a/third_party/zstd/lib/compress/zstd_double_fast.c +++ b/third_party/zstd/lib/compress/zstd_double_fast.c @@ -1,3 +1,4 @@ +// clang-format off /* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. @@ -8,8 +9,8 @@ * You may select, at your option, one of the above-listed licenses. */ -#include "zstd_compress_internal.h" -#include "zstd_double_fast.h" +#include "third_party/zstd/lib/compress/zstd_compress_internal.h" +#include "third_party/zstd/lib/compress/zstd_double_fast.h" #ifndef ZSTD_EXCLUDE_DFAST_BLOCK_COMPRESSOR diff --git a/third_party/zstd/lib/compress/zstd_double_fast.h b/third_party/zstd/lib/compress/zstd_double_fast.h index ce6ed8c97..44ce99ff2 100644 --- a/third_party/zstd/lib/compress/zstd_double_fast.h +++ b/third_party/zstd/lib/compress/zstd_double_fast.h @@ -1,3 +1,4 @@ +// clang-format off /* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. @@ -15,8 +16,8 @@ extern "C" { #endif -#include "../common/mem.h" /* U32 */ -#include "zstd_compress_internal.h" /* ZSTD_CCtx, size_t */ +#include "third_party/zstd/lib/common/mem.h" /* U32 */ +#include "third_party/zstd/lib/compress/zstd_compress_internal.h" /* ZSTD_CCtx, size_t */ #ifndef ZSTD_EXCLUDE_DFAST_BLOCK_COMPRESSOR diff --git a/third_party/zstd/lib/compress/zstd_fast.c b/third_party/zstd/lib/compress/zstd_fast.c index 5f2c6a2ed..9af32be82 100644 --- a/third_party/zstd/lib/compress/zstd_fast.c +++ b/third_party/zstd/lib/compress/zstd_fast.c @@ -1,3 +1,4 @@ +// clang-format off /* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. @@ -8,8 +9,8 @@ * You may select, at your option, one of the above-listed licenses. */ -#include "zstd_compress_internal.h" /* ZSTD_hashPtr, ZSTD_count, ZSTD_storeSeq */ -#include "zstd_fast.h" +#include "third_party/zstd/lib/compress/zstd_compress_internal.h" /* ZSTD_hashPtr, ZSTD_count, ZSTD_storeSeq */ +#include "third_party/zstd/lib/compress/zstd_fast.h" static void ZSTD_fillHashTableForCDict(ZSTD_matchState_t* ms, const void* const end, diff --git a/third_party/zstd/lib/compress/zstd_fast.h b/third_party/zstd/lib/compress/zstd_fast.h index 9e4236b47..9ab65629f 100644 --- a/third_party/zstd/lib/compress/zstd_fast.h +++ b/third_party/zstd/lib/compress/zstd_fast.h @@ -1,3 +1,4 @@ +// clang-format off /* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. @@ -15,8 +16,8 @@ extern "C" { #endif -#include "../common/mem.h" /* U32 */ -#include "zstd_compress_internal.h" +#include "third_party/zstd/lib/common/mem.h" /* U32 */ +#include "third_party/zstd/lib/compress/zstd_compress_internal.h" void ZSTD_fillHashTable(ZSTD_matchState_t* ms, void const* end, ZSTD_dictTableLoadMethod_e dtlm, diff --git a/third_party/zstd/lib/compress/zstd_lazy.c b/third_party/zstd/lib/compress/zstd_lazy.c index 834520fd7..a9dabd41f 100644 --- a/third_party/zstd/lib/compress/zstd_lazy.c +++ b/third_party/zstd/lib/compress/zstd_lazy.c @@ -1,3 +1,4 @@ +// clang-format off /* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. @@ -8,9 +9,9 @@ * You may select, at your option, one of the above-listed licenses. */ -#include "zstd_compress_internal.h" -#include "zstd_lazy.h" -#include "../common/bits.h" /* ZSTD_countTrailingZeros64 */ +#include "third_party/zstd/lib/compress/zstd_compress_internal.h" +#include "third_party/zstd/lib/compress/zstd_lazy.h" +#include "third_party/zstd/lib/common/bits.h" /* ZSTD_countTrailingZeros64 */ #if !defined(ZSTD_EXCLUDE_GREEDY_BLOCK_COMPRESSOR) \ || !defined(ZSTD_EXCLUDE_LAZY_BLOCK_COMPRESSOR) \ diff --git a/third_party/zstd/lib/compress/zstd_lazy.h b/third_party/zstd/lib/compress/zstd_lazy.h index 3635813bd..505ac04c1 100644 --- a/third_party/zstd/lib/compress/zstd_lazy.h +++ b/third_party/zstd/lib/compress/zstd_lazy.h @@ -1,3 +1,4 @@ +// clang-format off /* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. @@ -15,7 +16,7 @@ extern "C" { #endif -#include "zstd_compress_internal.h" +#include "third_party/zstd/lib/compress/zstd_compress_internal.h" /** * Dedicated Dictionary Search Structure bucket log. In the diff --git a/third_party/zstd/lib/compress/zstd_ldm.c b/third_party/zstd/lib/compress/zstd_ldm.c index 01c1f75aa..2e1df4242 100644 --- a/third_party/zstd/lib/compress/zstd_ldm.c +++ b/third_party/zstd/lib/compress/zstd_ldm.c @@ -1,3 +1,4 @@ +// clang-format off /* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. @@ -8,13 +9,13 @@ * You may select, at your option, one of the above-listed licenses. */ -#include "zstd_ldm.h" +#include "third_party/zstd/lib/compress/zstd_ldm.h" -#include "../common/debug.h" -#include "../common/xxhash.h" -#include "zstd_fast.h" /* ZSTD_fillHashTable() */ -#include "zstd_double_fast.h" /* ZSTD_fillDoubleHashTable() */ -#include "zstd_ldm_geartab.h" +#include "third_party/zstd/lib/common/debug.h" +#include "third_party/zstd/lib/common/xxhash.h" +#include "third_party/zstd/lib/compress/zstd_fast.h" /* ZSTD_fillHashTable() */ +#include "third_party/zstd/lib/compress/zstd_double_fast.h" /* ZSTD_fillDoubleHashTable() */ +#include "third_party/zstd/lib/compress/zstd_ldm_geartab.h" #define LDM_BUCKET_SIZE_LOG 3 #define LDM_MIN_MATCH_LENGTH 64 diff --git a/third_party/zstd/lib/compress/zstd_ldm.h b/third_party/zstd/lib/compress/zstd_ldm.h index f147021d2..4d5f27d39 100644 --- a/third_party/zstd/lib/compress/zstd_ldm.h +++ b/third_party/zstd/lib/compress/zstd_ldm.h @@ -1,3 +1,4 @@ +// clang-format off /* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. @@ -15,8 +16,8 @@ extern "C" { #endif -#include "zstd_compress_internal.h" /* ldmParams_t, U32 */ -#include "../zstd.h" /* ZSTD_CCtx, size_t */ +#include "third_party/zstd/lib/compress/zstd_compress_internal.h" /* ldmParams_t, U32 */ +#include "third_party/zstd/lib/zstd.h" /* ZSTD_CCtx, size_t */ /*-************************************* * Long distance matching diff --git a/third_party/zstd/lib/compress/zstd_ldm_geartab.h b/third_party/zstd/lib/compress/zstd_ldm_geartab.h index ef34bc5c9..c3a0a90fc 100644 --- a/third_party/zstd/lib/compress/zstd_ldm_geartab.h +++ b/third_party/zstd/lib/compress/zstd_ldm_geartab.h @@ -1,3 +1,4 @@ +// clang-format off /* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. @@ -11,8 +12,8 @@ #ifndef ZSTD_LDM_GEARTAB_H #define ZSTD_LDM_GEARTAB_H -#include "../common/compiler.h" /* UNUSED_ATTR */ -#include "../common/mem.h" /* U64 */ +#include "third_party/zstd/lib/common/compiler.h" /* UNUSED_ATTR */ +#include "third_party/zstd/lib/common/mem.h" /* U64 */ static UNUSED_ATTR const U64 ZSTD_ldm_gearTab[256] = { 0xf5b8f72c5f77775c, 0x84935f266b7ac412, 0xb647ada9ca730ccc, diff --git a/third_party/zstd/lib/compress/zstd_opt.c b/third_party/zstd/lib/compress/zstd_opt.c index 3d54e21ae..da8ef8818 100644 --- a/third_party/zstd/lib/compress/zstd_opt.c +++ b/third_party/zstd/lib/compress/zstd_opt.c @@ -1,3 +1,4 @@ +// clang-format off /* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. @@ -8,9 +9,9 @@ * You may select, at your option, one of the above-listed licenses. */ -#include "zstd_compress_internal.h" -#include "hist.h" -#include "zstd_opt.h" +#include "third_party/zstd/lib/compress/zstd_compress_internal.h" +#include "third_party/zstd/lib/compress/hist.h" +#include "third_party/zstd/lib/compress/zstd_opt.h" #if !defined(ZSTD_EXCLUDE_BTLAZY2_BLOCK_COMPRESSOR) \ || !defined(ZSTD_EXCLUDE_BTOPT_BLOCK_COMPRESSOR) \ diff --git a/third_party/zstd/lib/compress/zstd_opt.h b/third_party/zstd/lib/compress/zstd_opt.h index d4e711315..91621b911 100644 --- a/third_party/zstd/lib/compress/zstd_opt.h +++ b/third_party/zstd/lib/compress/zstd_opt.h @@ -1,3 +1,4 @@ +// clang-format off /* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. @@ -15,7 +16,7 @@ extern "C" { #endif -#include "zstd_compress_internal.h" +#include "third_party/zstd/lib/compress/zstd_compress_internal.h" #if !defined(ZSTD_EXCLUDE_BTLAZY2_BLOCK_COMPRESSOR) \ || !defined(ZSTD_EXCLUDE_BTOPT_BLOCK_COMPRESSOR) \ diff --git a/third_party/zstd/lib/compress/zstdmt_compress.c b/third_party/zstd/lib/compress/zstdmt_compress.c index 678607556..89ea3a099 100644 --- a/third_party/zstd/lib/compress/zstdmt_compress.c +++ b/third_party/zstd/lib/compress/zstdmt_compress.c @@ -1,3 +1,4 @@ +// clang-format off /* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. @@ -20,14 +21,14 @@ /* ====== Dependencies ====== */ -#include "../common/allocations.h" /* ZSTD_customMalloc, ZSTD_customCalloc, ZSTD_customFree */ -#include "../common/zstd_deps.h" /* ZSTD_memcpy, ZSTD_memset, INT_MAX, UINT_MAX */ -#include "../common/mem.h" /* MEM_STATIC */ -#include "../common/pool.h" /* threadpool */ -#include "../common/threading.h" /* mutex */ -#include "zstd_compress_internal.h" /* MIN, ERROR, ZSTD_*, ZSTD_highbit32 */ -#include "zstd_ldm.h" -#include "zstdmt_compress.h" +#include "third_party/zstd/lib/common/allocations.h" /* ZSTD_customMalloc, ZSTD_customCalloc, ZSTD_customFree */ +#include "third_party/zstd/lib/common/zstd_deps.h" /* ZSTD_memcpy, ZSTD_memset, INT_MAX, UINT_MAX */ +#include "third_party/zstd/lib/common/mem.h" /* MEM_STATIC */ +#include "third_party/zstd/lib/common/pool.h" /* threadpool */ +#include "third_party/zstd/lib/common/threading.h" /* mutex */ +#include "third_party/zstd/lib/compress/zstd_compress_internal.h" /* MIN, ERROR, ZSTD_*, ZSTD_highbit32 */ +#include "third_party/zstd/lib/compress/zstd_ldm.h" +#include "third_party/zstd/lib/compress/zstdmt_compress.h" /* Guards code to support resizing the SeqPool. * We will want to resize the SeqPool to save memory in the future. @@ -40,9 +41,29 @@ && !defined(_MSC_VER) \ && !defined(__MINGW32__) -# include -# include -# include +#include "libc/calls/calls.h" +#include "libc/calls/weirdtypes.h" +#include "libc/fmt/fmt.h" +#include "libc/stdio/dprintf.h" +#include "libc/stdio/stdio.h" +#include "libc/stdio/temp.h" +#include "third_party/musl/tempnam.h" +#include "libc/calls/calls.h" +#include "libc/calls/weirdtypes.h" +#include "libc/runtime/pathconf.h" +#include "libc/runtime/runtime.h" +#include "libc/runtime/sysconf.h" +#include "libc/sysv/consts/f.h" +#include "libc/sysv/consts/fileno.h" +#include "libc/sysv/consts/o.h" +#include "libc/sysv/consts/ok.h" +#include "libc/time/time.h" +#include "third_party/getopt/getopt.h" +#include "third_party/musl/crypt.h" +#include "third_party/musl/lockf.h" +#include "libc/calls/calls.h" +#include "libc/calls/struct/tms.h" +#include "libc/calls/weirdtypes.h" # define DEBUG_PRINTHEX(l,p,n) { \ unsigned debug_u; \ diff --git a/third_party/zstd/lib/compress/zstdmt_compress.h b/third_party/zstd/lib/compress/zstdmt_compress.h index ed4dc0e99..2aa689ef8 100644 --- a/third_party/zstd/lib/compress/zstdmt_compress.h +++ b/third_party/zstd/lib/compress/zstdmt_compress.h @@ -1,3 +1,4 @@ +// clang-format off /* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. @@ -26,9 +27,9 @@ */ /* === Dependencies === */ -#include "../common/zstd_deps.h" /* size_t */ +#include "third_party/zstd/lib/common/zstd_deps.h" /* size_t */ #define ZSTD_STATIC_LINKING_ONLY /* ZSTD_parameters */ -#include "../zstd.h" /* ZSTD_inBuffer, ZSTD_outBuffer, ZSTDLIB_API */ +#include "third_party/zstd/lib/zstd.h" /* ZSTD_inBuffer, ZSTD_outBuffer, ZSTDLIB_API */ /* === Constants === */ diff --git a/third_party/zstd/lib/decompress/huf_decompress.c b/third_party/zstd/lib/decompress/huf_decompress.c index 5b217ac58..7571442d9 100644 --- a/third_party/zstd/lib/decompress/huf_decompress.c +++ b/third_party/zstd/lib/decompress/huf_decompress.c @@ -1,3 +1,4 @@ +// clang-format off /* ****************************************************************** * huff0 huffman decoder, * part of Finite State Entropy library @@ -15,14 +16,14 @@ /* ************************************************************** * Dependencies ****************************************************************/ -#include "../common/zstd_deps.h" /* ZSTD_memcpy, ZSTD_memset */ -#include "../common/compiler.h" -#include "../common/bitstream.h" /* BIT_* */ -#include "../common/fse.h" /* to compress headers */ -#include "../common/huf.h" -#include "../common/error_private.h" -#include "../common/zstd_internal.h" -#include "../common/bits.h" /* ZSTD_highbit32, ZSTD_countTrailingZeros64 */ +#include "third_party/zstd/lib/common/zstd_deps.h" /* ZSTD_memcpy, ZSTD_memset */ +#include "third_party/zstd/lib/common/compiler.h" +#include "third_party/zstd/lib/common/bitstream.h" /* BIT_* */ +#include "third_party/zstd/lib/common/fse.h" /* to compress headers */ +#include "third_party/zstd/lib/common/huf.h" +#include "third_party/zstd/lib/common/error_private.h" +#include "third_party/zstd/lib/common/zstd_internal.h" +#include "third_party/zstd/lib/common/bits.h" /* ZSTD_highbit32, ZSTD_countTrailingZeros64 */ /* ************************************************************** * Constants diff --git a/third_party/zstd/lib/decompress/huf_decompress_amd64.S b/third_party/zstd/lib/decompress/huf_decompress_amd64.S index 671624fe3..6befbe5a9 100644 --- a/third_party/zstd/lib/decompress/huf_decompress_amd64.S +++ b/third_party/zstd/lib/decompress/huf_decompress_amd64.S @@ -1,3 +1,4 @@ +// clang-format off /* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. @@ -8,7 +9,7 @@ * You may select, at your option, one of the above-listed licenses. */ -#include "../common/portability_macros.h" +#include "third_party/zstd/lib/common/portability_macros.h" /* Stack marking * ref: https://wiki.gentoo.org/wiki/Hardened/GNU_stack_quickstart diff --git a/third_party/zstd/lib/decompress/zstd_ddict.c b/third_party/zstd/lib/decompress/zstd_ddict.c index 309ec0d03..a288291d0 100644 --- a/third_party/zstd/lib/decompress/zstd_ddict.c +++ b/third_party/zstd/lib/decompress/zstd_ddict.c @@ -1,3 +1,4 @@ +// clang-format off /* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. @@ -14,18 +15,18 @@ /*-******************************************************* * Dependencies *********************************************************/ -#include "../common/allocations.h" /* ZSTD_customMalloc, ZSTD_customFree */ -#include "../common/zstd_deps.h" /* ZSTD_memcpy, ZSTD_memmove, ZSTD_memset */ -#include "../common/cpu.h" /* bmi2 */ -#include "../common/mem.h" /* low level memory routines */ +#include "third_party/zstd/lib/common/allocations.h" /* ZSTD_customMalloc, ZSTD_customFree */ +#include "third_party/zstd/lib/common/zstd_deps.h" /* ZSTD_memcpy, ZSTD_memmove, ZSTD_memset */ +#include "third_party/zstd/lib/common/cpu.h" /* bmi2 */ +#include "third_party/zstd/lib/common/mem.h" /* low level memory routines */ #define FSE_STATIC_LINKING_ONLY -#include "../common/fse.h" -#include "../common/huf.h" -#include "zstd_decompress_internal.h" -#include "zstd_ddict.h" +#include "third_party/zstd/lib/common/fse.h" +#include "third_party/zstd/lib/common/huf.h" +#include "third_party/zstd/lib/decompress/zstd_decompress_internal.h" +#include "third_party/zstd/lib/decompress/zstd_ddict.h" #if defined(ZSTD_LEGACY_SUPPORT) && (ZSTD_LEGACY_SUPPORT>=1) -# include "../legacy/zstd_legacy.h" +#include "third_party/zstd/lib/legacy/zstd_legacy.h" #endif diff --git a/third_party/zstd/lib/decompress/zstd_ddict.h b/third_party/zstd/lib/decompress/zstd_ddict.h index c4ca8877a..9116bde3b 100644 --- a/third_party/zstd/lib/decompress/zstd_ddict.h +++ b/third_party/zstd/lib/decompress/zstd_ddict.h @@ -1,3 +1,4 @@ +// clang-format off /* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. @@ -15,8 +16,8 @@ /*-******************************************************* * Dependencies *********************************************************/ -#include "../common/zstd_deps.h" /* size_t */ -#include "../zstd.h" /* ZSTD_DDict, and several public functions */ +#include "third_party/zstd/lib/common/zstd_deps.h" /* size_t */ +#include "third_party/zstd/lib/zstd.h" /* ZSTD_DDict, and several public functions */ /*-******************************************************* diff --git a/third_party/zstd/lib/decompress/zstd_decompress.c b/third_party/zstd/lib/decompress/zstd_decompress.c index 94eb95151..0c84e33df 100644 --- a/third_party/zstd/lib/decompress/zstd_decompress.c +++ b/third_party/zstd/lib/decompress/zstd_decompress.c @@ -1,3 +1,4 @@ +// clang-format off /* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. @@ -55,21 +56,21 @@ /*-******************************************************* * Dependencies *********************************************************/ -#include "../common/allocations.h" /* ZSTD_customMalloc, ZSTD_customCalloc, ZSTD_customFree */ -#include "../common/zstd_deps.h" /* ZSTD_memcpy, ZSTD_memmove, ZSTD_memset */ -#include "../common/mem.h" /* low level memory routines */ +#include "third_party/zstd/lib/common/allocations.h" /* ZSTD_customMalloc, ZSTD_customCalloc, ZSTD_customFree */ +#include "third_party/zstd/lib/common/zstd_deps.h" /* ZSTD_memcpy, ZSTD_memmove, ZSTD_memset */ +#include "third_party/zstd/lib/common/mem.h" /* low level memory routines */ #define FSE_STATIC_LINKING_ONLY -#include "../common/fse.h" -#include "../common/huf.h" -#include "../common/xxhash.h" /* XXH64_reset, XXH64_update, XXH64_digest, XXH64 */ -#include "../common/zstd_internal.h" /* blockProperties_t */ -#include "zstd_decompress_internal.h" /* ZSTD_DCtx */ -#include "zstd_ddict.h" /* ZSTD_DDictDictContent */ -#include "zstd_decompress_block.h" /* ZSTD_decompressBlock_internal */ -#include "../common/bits.h" /* ZSTD_highbit32 */ +#include "third_party/zstd/lib/common/fse.h" +#include "third_party/zstd/lib/common/huf.h" +#include "third_party/zstd/lib/common/xxhash.h" /* XXH64_reset, XXH64_update, XXH64_digest, XXH64 */ +#include "third_party/zstd/lib/common/zstd_internal.h" /* blockProperties_t */ +#include "third_party/zstd/lib/decompress/zstd_decompress_internal.h" /* ZSTD_DCtx */ +#include "third_party/zstd/lib/decompress/zstd_ddict.h" /* ZSTD_DDictDictContent */ +#include "third_party/zstd/lib/decompress/zstd_decompress_block.h" /* ZSTD_decompressBlock_internal */ +#include "third_party/zstd/lib/common/bits.h" /* ZSTD_highbit32 */ #if defined(ZSTD_LEGACY_SUPPORT) && (ZSTD_LEGACY_SUPPORT>=1) -# include "../legacy/zstd_legacy.h" +#include "third_party/zstd/lib/legacy/zstd_legacy.h" #endif diff --git a/third_party/zstd/lib/decompress/zstd_decompress_block.c b/third_party/zstd/lib/decompress/zstd_decompress_block.c index 93947ba58..ac7bca566 100644 --- a/third_party/zstd/lib/decompress/zstd_decompress_block.c +++ b/third_party/zstd/lib/decompress/zstd_decompress_block.c @@ -1,3 +1,4 @@ +// clang-format off /* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. @@ -14,18 +15,18 @@ /*-******************************************************* * Dependencies *********************************************************/ -#include "../common/zstd_deps.h" /* ZSTD_memcpy, ZSTD_memmove, ZSTD_memset */ -#include "../common/compiler.h" /* prefetch */ -#include "../common/cpu.h" /* bmi2 */ -#include "../common/mem.h" /* low level memory routines */ +#include "third_party/zstd/lib/common/zstd_deps.h" /* ZSTD_memcpy, ZSTD_memmove, ZSTD_memset */ +#include "third_party/zstd/lib/common/compiler.h" /* prefetch */ +#include "third_party/zstd/lib/common/cpu.h" /* bmi2 */ +#include "third_party/zstd/lib/common/mem.h" /* low level memory routines */ #define FSE_STATIC_LINKING_ONLY -#include "../common/fse.h" -#include "../common/huf.h" -#include "../common/zstd_internal.h" -#include "zstd_decompress_internal.h" /* ZSTD_DCtx */ -#include "zstd_ddict.h" /* ZSTD_DDictDictContent */ -#include "zstd_decompress_block.h" -#include "../common/bits.h" /* ZSTD_highbit32 */ +#include "third_party/zstd/lib/common/fse.h" +#include "third_party/zstd/lib/common/huf.h" +#include "third_party/zstd/lib/common/zstd_internal.h" +#include "third_party/zstd/lib/decompress/zstd_decompress_internal.h" /* ZSTD_DCtx */ +#include "third_party/zstd/lib/decompress/zstd_ddict.h" /* ZSTD_DDictDictContent */ +#include "third_party/zstd/lib/decompress/zstd_decompress_block.h" +#include "third_party/zstd/lib/common/bits.h" /* ZSTD_highbit32 */ /*_******************************************************* * Macros diff --git a/third_party/zstd/lib/decompress/zstd_decompress_block.h b/third_party/zstd/lib/decompress/zstd_decompress_block.h index ab152404b..634b702ab 100644 --- a/third_party/zstd/lib/decompress/zstd_decompress_block.h +++ b/third_party/zstd/lib/decompress/zstd_decompress_block.h @@ -1,3 +1,4 @@ +// clang-format off /* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. @@ -15,10 +16,10 @@ /*-******************************************************* * Dependencies *********************************************************/ -#include "../common/zstd_deps.h" /* size_t */ -#include "../zstd.h" /* DCtx, and some public functions */ -#include "../common/zstd_internal.h" /* blockProperties_t, and some public functions */ -#include "zstd_decompress_internal.h" /* ZSTD_seqSymbol */ +#include "third_party/zstd/lib/common/zstd_deps.h" /* size_t */ +#include "third_party/zstd/lib/zstd.h" /* DCtx, and some public functions */ +#include "third_party/zstd/lib/common/zstd_internal.h" /* blockProperties_t, and some public functions */ +#include "third_party/zstd/lib/decompress/zstd_decompress_internal.h" /* ZSTD_seqSymbol */ /* === Prototypes === */ diff --git a/third_party/zstd/lib/decompress/zstd_decompress_internal.h b/third_party/zstd/lib/decompress/zstd_decompress_internal.h index 83a7a0115..c2372926a 100644 --- a/third_party/zstd/lib/decompress/zstd_decompress_internal.h +++ b/third_party/zstd/lib/decompress/zstd_decompress_internal.h @@ -1,3 +1,4 @@ +// clang-format off /* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. @@ -19,8 +20,8 @@ /*-******************************************************* * Dependencies *********************************************************/ -#include "../common/mem.h" /* BYTE, U16, U32 */ -#include "../common/zstd_internal.h" /* constants : MaxLL, MaxML, MaxOff, LLFSELog, etc. */ +#include "third_party/zstd/lib/common/mem.h" /* BYTE, U16, U32 */ +#include "third_party/zstd/lib/common/zstd_internal.h" /* constants : MaxLL, MaxML, MaxOff, LLFSELog, etc. */ diff --git a/third_party/zstd/lib/deprecated/zbuff.h b/third_party/zstd/lib/deprecated/zbuff.h index a968245b3..66a26c679 100644 --- a/third_party/zstd/lib/deprecated/zbuff.h +++ b/third_party/zstd/lib/deprecated/zbuff.h @@ -1,3 +1,4 @@ +// clang-format off /* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. @@ -27,8 +28,8 @@ extern "C" { /* ************************************* * Dependencies ***************************************/ -#include /* size_t */ -#include "../zstd.h" /* ZSTD_CStream, ZSTD_DStream, ZSTDLIB_API */ + /* size_t */ +#include "third_party/zstd/lib/zstd.h" /* ZSTD_CStream, ZSTD_DStream, ZSTDLIB_API */ /* *************************************************************** @@ -186,7 +187,7 @@ ZBUFF_DEPRECATED("use ZSTD_DStreamOutSize") size_t ZBUFF_recommendedDOutSize(voi /*--- Dependency ---*/ #define ZSTD_STATIC_LINKING_ONLY /* ZSTD_parameters, ZSTD_customMem */ -#include "../zstd.h" +#include "third_party/zstd/lib/zstd.h" /*--- Custom memory allocator ---*/ diff --git a/third_party/zstd/lib/deprecated/zbuff_common.c b/third_party/zstd/lib/deprecated/zbuff_common.c index 5a2f2db35..6ac62991c 100644 --- a/third_party/zstd/lib/deprecated/zbuff_common.c +++ b/third_party/zstd/lib/deprecated/zbuff_common.c @@ -1,3 +1,4 @@ +// clang-format off /* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. @@ -11,8 +12,8 @@ /*-************************************* * Dependencies ***************************************/ -#include "../common/error_private.h" -#include "zbuff.h" +#include "third_party/zstd/lib/common/error_private.h" +#include "third_party/zstd/lib/deprecated/zbuff.h" /*-**************************************** * ZBUFF Error Management (deprecated) diff --git a/third_party/zstd/lib/deprecated/zbuff_compress.c b/third_party/zstd/lib/deprecated/zbuff_compress.c index 1d8682150..4a7fea984 100644 --- a/third_party/zstd/lib/deprecated/zbuff_compress.c +++ b/third_party/zstd/lib/deprecated/zbuff_compress.c @@ -1,3 +1,4 @@ +// clang-format off /* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. @@ -14,8 +15,8 @@ * Dependencies ***************************************/ #define ZBUFF_STATIC_LINKING_ONLY -#include "zbuff.h" -#include "../common/error_private.h" +#include "third_party/zstd/lib/deprecated/zbuff.h" +#include "third_party/zstd/lib/common/error_private.h" /*-*********************************************************** diff --git a/third_party/zstd/lib/deprecated/zbuff_decompress.c b/third_party/zstd/lib/deprecated/zbuff_decompress.c index 12a66af74..daa22cb35 100644 --- a/third_party/zstd/lib/deprecated/zbuff_decompress.c +++ b/third_party/zstd/lib/deprecated/zbuff_decompress.c @@ -1,3 +1,4 @@ +// clang-format off /* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. @@ -14,9 +15,9 @@ * Dependencies ***************************************/ #define ZSTD_DISABLE_DEPRECATE_WARNINGS /* suppress warning on ZSTD_initDStream_usingDict */ -#include "../zstd.h" /* ZSTD_CStream, ZSTD_DStream, ZSTDLIB_API */ +#include "third_party/zstd/lib/zstd.h" /* ZSTD_CStream, ZSTD_DStream, ZSTDLIB_API */ #define ZBUFF_STATIC_LINKING_ONLY -#include "zbuff.h" +#include "third_party/zstd/lib/deprecated/zbuff.h" ZBUFF_DCtx* ZBUFF_createDCtx(void) diff --git a/third_party/zstd/lib/dictBuilder/cover.c b/third_party/zstd/lib/dictBuilder/cover.c index 9e5e7d5b5..956ed32c0 100644 --- a/third_party/zstd/lib/dictBuilder/cover.c +++ b/third_party/zstd/lib/dictBuilder/cover.c @@ -1,3 +1,4 @@ +// clang-format off /* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. @@ -21,22 +22,53 @@ /*-************************************* * Dependencies ***************************************/ -#include /* fprintf */ -#include /* malloc, free, qsort */ -#include /* memset */ -#include /* clock */ +#include "libc/calls/calls.h" +#include "libc/calls/weirdtypes.h" +#include "libc/fmt/fmt.h" +#include "libc/stdio/dprintf.h" +#include "libc/stdio/stdio.h" +#include "libc/stdio/temp.h" +#include "third_party/musl/tempnam.h" /* fprintf */ +#include "libc/calls/calls.h" +#include "libc/calls/termios.h" +#include "libc/fmt/conv.h" +#include "libc/limits.h" +#include "libc/mem/alg.h" +#include "libc/mem/alloca.h" +#include "libc/mem/mem.h" +#include "libc/runtime/runtime.h" +#include "libc/stdio/dprintf.h" +#include "libc/stdio/rand.h" +#include "libc/stdio/temp.h" +#include "libc/str/str.h" +#include "libc/sysv/consts/exit.h" +#include "third_party/getopt/getopt.h" +#include "third_party/musl/crypt.h" +#include "third_party/musl/rand48.h" /* malloc, free, qsort */ +#include "libc/mem/alg.h" +#include "libc/mem/mem.h" +#include "libc/str/str.h" /* memset */ +#include "libc/calls/calls.h" +#include "libc/calls/struct/timespec.h" +#include "libc/calls/struct/timeval.h" +#include "libc/calls/weirdtypes.h" +#include "libc/sysv/consts/clock.h" +#include "libc/sysv/consts/sched.h" +#include "libc/sysv/consts/timer.h" +#include "libc/time/struct/tm.h" +#include "libc/time/time.h" /* clock */ #ifndef ZDICT_STATIC_LINKING_ONLY # define ZDICT_STATIC_LINKING_ONLY #endif -#include "../common/mem.h" /* read */ -#include "../common/pool.h" -#include "../common/threading.h" -#include "../common/zstd_internal.h" /* includes zstd.h */ -#include "../common/bits.h" /* ZSTD_highbit32 */ -#include "../zdict.h" -#include "cover.h" +#include "third_party/zstd/lib/common/mem.h" /* read */ +#include "third_party/zstd/lib/common/pool.h" +#include "third_party/zstd/lib/common/threading.h" +#include "third_party/zstd/lib/common/zstd_internal.h" /* includes zstd.h */ +#include "third_party/zstd/lib/common/bits.h" /* ZSTD_highbit32 */ +#include "third_party/zstd/lib/zdict.h" +#include "third_party/zstd/lib/dictBuilder/cover.h" /*-************************************* * Constants diff --git a/third_party/zstd/lib/dictBuilder/cover.h b/third_party/zstd/lib/dictBuilder/cover.h index 252624bde..e6b97ed55 100644 --- a/third_party/zstd/lib/dictBuilder/cover.h +++ b/third_party/zstd/lib/dictBuilder/cover.h @@ -1,3 +1,4 @@ +// clang-format off /* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. @@ -12,15 +13,46 @@ # define ZDICT_STATIC_LINKING_ONLY #endif -#include /* fprintf */ -#include /* malloc, free, qsort */ -#include /* memset */ -#include /* clock */ -#include "../common/mem.h" /* read */ -#include "../common/pool.h" -#include "../common/threading.h" -#include "../common/zstd_internal.h" /* includes zstd.h */ -#include "../zdict.h" +#include "libc/calls/calls.h" +#include "libc/calls/weirdtypes.h" +#include "libc/fmt/fmt.h" +#include "libc/stdio/dprintf.h" +#include "libc/stdio/stdio.h" +#include "libc/stdio/temp.h" +#include "third_party/musl/tempnam.h" /* fprintf */ +#include "libc/calls/calls.h" +#include "libc/calls/termios.h" +#include "libc/fmt/conv.h" +#include "libc/limits.h" +#include "libc/mem/alg.h" +#include "libc/mem/alloca.h" +#include "libc/mem/mem.h" +#include "libc/runtime/runtime.h" +#include "libc/stdio/dprintf.h" +#include "libc/stdio/rand.h" +#include "libc/stdio/temp.h" +#include "libc/str/str.h" +#include "libc/sysv/consts/exit.h" +#include "third_party/getopt/getopt.h" +#include "third_party/musl/crypt.h" +#include "third_party/musl/rand48.h" /* malloc, free, qsort */ +#include "libc/mem/alg.h" +#include "libc/mem/mem.h" +#include "libc/str/str.h" /* memset */ +#include "libc/calls/calls.h" +#include "libc/calls/struct/timespec.h" +#include "libc/calls/struct/timeval.h" +#include "libc/calls/weirdtypes.h" +#include "libc/sysv/consts/clock.h" +#include "libc/sysv/consts/sched.h" +#include "libc/sysv/consts/timer.h" +#include "libc/time/struct/tm.h" +#include "libc/time/time.h" /* clock */ +#include "third_party/zstd/lib/common/mem.h" /* read */ +#include "third_party/zstd/lib/common/pool.h" +#include "third_party/zstd/lib/common/threading.h" +#include "third_party/zstd/lib/common/zstd_internal.h" /* includes zstd.h */ +#include "third_party/zstd/lib/zdict.h" /** * COVER_best_t is used for two purposes: diff --git a/third_party/zstd/lib/dictBuilder/divsufsort.c b/third_party/zstd/lib/dictBuilder/divsufsort.c index a2870fb3b..3613a6f89 100644 --- a/third_party/zstd/lib/dictBuilder/divsufsort.c +++ b/third_party/zstd/lib/dictBuilder/divsufsort.c @@ -1,3 +1,4 @@ +// clang-format off /* * divsufsort.c for libdivsufsort-lite * Copyright (c) 2003-2008 Yuta Mori All Rights Reserved. @@ -36,11 +37,32 @@ /*- Dependencies -*/ -#include -#include -#include +#include "libc/assert.h" +#include "libc/calls/calls.h" +#include "libc/calls/weirdtypes.h" +#include "libc/fmt/fmt.h" +#include "libc/stdio/dprintf.h" +#include "libc/stdio/stdio.h" +#include "libc/stdio/temp.h" +#include "third_party/musl/tempnam.h" +#include "libc/calls/calls.h" +#include "libc/calls/termios.h" +#include "libc/fmt/conv.h" +#include "libc/limits.h" +#include "libc/mem/alg.h" +#include "libc/mem/alloca.h" +#include "libc/mem/mem.h" +#include "libc/runtime/runtime.h" +#include "libc/stdio/dprintf.h" +#include "libc/stdio/rand.h" +#include "libc/stdio/temp.h" +#include "libc/str/str.h" +#include "libc/sysv/consts/exit.h" +#include "third_party/getopt/getopt.h" +#include "third_party/musl/crypt.h" +#include "third_party/musl/rand48.h" -#include "divsufsort.h" +#include "third_party/zstd/lib/dictBuilder/divsufsort.h" /*- Constants -*/ #if defined(INLINE) diff --git a/third_party/zstd/lib/dictBuilder/divsufsort.h b/third_party/zstd/lib/dictBuilder/divsufsort.h index 5440994af..bf40083c3 100644 --- a/third_party/zstd/lib/dictBuilder/divsufsort.h +++ b/third_party/zstd/lib/dictBuilder/divsufsort.h @@ -1,3 +1,4 @@ +// clang-format off /* * divsufsort.h for libdivsufsort-lite * Copyright (c) 2003-2008 Yuta Mori All Rights Reserved. diff --git a/third_party/zstd/lib/dictBuilder/fastcover.c b/third_party/zstd/lib/dictBuilder/fastcover.c index 46bba0120..b12c8461c 100644 --- a/third_party/zstd/lib/dictBuilder/fastcover.c +++ b/third_party/zstd/lib/dictBuilder/fastcover.c @@ -1,3 +1,4 @@ +// clang-format off /* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. @@ -11,22 +12,53 @@ /*-************************************* * Dependencies ***************************************/ -#include /* fprintf */ -#include /* malloc, free, qsort */ -#include /* memset */ -#include /* clock */ +#include "libc/calls/calls.h" +#include "libc/calls/weirdtypes.h" +#include "libc/fmt/fmt.h" +#include "libc/stdio/dprintf.h" +#include "libc/stdio/stdio.h" +#include "libc/stdio/temp.h" +#include "third_party/musl/tempnam.h" /* fprintf */ +#include "libc/calls/calls.h" +#include "libc/calls/termios.h" +#include "libc/fmt/conv.h" +#include "libc/limits.h" +#include "libc/mem/alg.h" +#include "libc/mem/alloca.h" +#include "libc/mem/mem.h" +#include "libc/runtime/runtime.h" +#include "libc/stdio/dprintf.h" +#include "libc/stdio/rand.h" +#include "libc/stdio/temp.h" +#include "libc/str/str.h" +#include "libc/sysv/consts/exit.h" +#include "third_party/getopt/getopt.h" +#include "third_party/musl/crypt.h" +#include "third_party/musl/rand48.h" /* malloc, free, qsort */ +#include "libc/mem/alg.h" +#include "libc/mem/mem.h" +#include "libc/str/str.h" /* memset */ +#include "libc/calls/calls.h" +#include "libc/calls/struct/timespec.h" +#include "libc/calls/struct/timeval.h" +#include "libc/calls/weirdtypes.h" +#include "libc/sysv/consts/clock.h" +#include "libc/sysv/consts/sched.h" +#include "libc/sysv/consts/timer.h" +#include "libc/time/struct/tm.h" +#include "libc/time/time.h" /* clock */ #ifndef ZDICT_STATIC_LINKING_ONLY # define ZDICT_STATIC_LINKING_ONLY #endif -#include "../common/mem.h" /* read */ -#include "../common/pool.h" -#include "../common/threading.h" -#include "../common/zstd_internal.h" /* includes zstd.h */ -#include "../compress/zstd_compress_internal.h" /* ZSTD_hash*() */ -#include "../zdict.h" -#include "cover.h" +#include "third_party/zstd/lib/common/mem.h" /* read */ +#include "third_party/zstd/lib/common/pool.h" +#include "third_party/zstd/lib/common/threading.h" +#include "third_party/zstd/lib/common/zstd_internal.h" /* includes zstd.h */ +#include "third_party/zstd/lib/compress/zstd_compress_internal.h" /* ZSTD_hash*() */ +#include "third_party/zstd/lib/zdict.h" +#include "third_party/zstd/lib/dictBuilder/cover.h" /*-************************************* diff --git a/third_party/zstd/lib/dictBuilder/zdict.c b/third_party/zstd/lib/dictBuilder/zdict.c index 58290f450..9caf439ad 100644 --- a/third_party/zstd/lib/dictBuilder/zdict.c +++ b/third_party/zstd/lib/dictBuilder/zdict.c @@ -1,3 +1,4 @@ +// clang-format off /* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. @@ -36,24 +37,55 @@ /*-************************************* * Dependencies ***************************************/ -#include /* malloc, free */ -#include /* memset */ -#include /* fprintf, fopen, ftello64 */ -#include /* clock */ +#include "libc/calls/calls.h" +#include "libc/calls/termios.h" +#include "libc/fmt/conv.h" +#include "libc/limits.h" +#include "libc/mem/alg.h" +#include "libc/mem/alloca.h" +#include "libc/mem/mem.h" +#include "libc/runtime/runtime.h" +#include "libc/stdio/dprintf.h" +#include "libc/stdio/rand.h" +#include "libc/stdio/temp.h" +#include "libc/str/str.h" +#include "libc/sysv/consts/exit.h" +#include "third_party/getopt/getopt.h" +#include "third_party/musl/crypt.h" +#include "third_party/musl/rand48.h" /* malloc, free */ +#include "libc/mem/alg.h" +#include "libc/mem/mem.h" +#include "libc/str/str.h" /* memset */ +#include "libc/calls/calls.h" +#include "libc/calls/weirdtypes.h" +#include "libc/fmt/fmt.h" +#include "libc/stdio/dprintf.h" +#include "libc/stdio/stdio.h" +#include "libc/stdio/temp.h" +#include "third_party/musl/tempnam.h" /* fprintf, fopen, ftello64 */ +#include "libc/calls/calls.h" +#include "libc/calls/struct/timespec.h" +#include "libc/calls/struct/timeval.h" +#include "libc/calls/weirdtypes.h" +#include "libc/sysv/consts/clock.h" +#include "libc/sysv/consts/sched.h" +#include "libc/sysv/consts/timer.h" +#include "libc/time/struct/tm.h" +#include "libc/time/time.h" /* clock */ #ifndef ZDICT_STATIC_LINKING_ONLY # define ZDICT_STATIC_LINKING_ONLY #endif -#include "../common/mem.h" /* read */ -#include "../common/fse.h" /* FSE_normalizeCount, FSE_writeNCount */ -#include "../common/huf.h" /* HUF_buildCTable, HUF_writeCTable */ -#include "../common/zstd_internal.h" /* includes zstd.h */ -#include "../common/xxhash.h" /* XXH64 */ -#include "../compress/zstd_compress_internal.h" /* ZSTD_loadCEntropy() */ -#include "../zdict.h" -#include "divsufsort.h" -#include "../common/bits.h" /* ZSTD_NbCommonBytes */ +#include "third_party/zstd/lib/common/mem.h" /* read */ +#include "third_party/zstd/lib/common/fse.h" /* FSE_normalizeCount, FSE_writeNCount */ +#include "third_party/zstd/lib/common/huf.h" /* HUF_buildCTable, HUF_writeCTable */ +#include "third_party/zstd/lib/common/zstd_internal.h" /* includes zstd.h */ +#include "third_party/zstd/lib/common/xxhash.h" /* XXH64 */ +#include "third_party/zstd/lib/compress/zstd_compress_internal.h" /* ZSTD_loadCEntropy() */ +#include "third_party/zstd/lib/zdict.h" +#include "third_party/zstd/lib/dictBuilder/divsufsort.h" +#include "third_party/zstd/lib/common/bits.h" /* ZSTD_NbCommonBytes */ /*-************************************* diff --git a/third_party/zstd/lib/dll/example/Makefile b/third_party/zstd/lib/dll/example/Makefile index 86cf6906e..94d8c0f43 100644 --- a/third_party/zstd/lib/dll/example/Makefile +++ b/third_party/zstd/lib/dll/example/Makefile @@ -1,3 +1,4 @@ +// clang-format off # ################################################################ # Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. diff --git a/third_party/zstd/lib/dll/example/README.md b/third_party/zstd/lib/dll/example/README.md index 46aec7980..e49bada59 100644 --- a/third_party/zstd/lib/dll/example/README.md +++ b/third_party/zstd/lib/dll/example/README.md @@ -1,3 +1,4 @@ +// clang-format off # ZSTD Windows binary package ## The package contents diff --git a/third_party/zstd/lib/dll/example/build_package.bat b/third_party/zstd/lib/dll/example/build_package.bat index e410c63b2..68940adaf 100644 --- a/third_party/zstd/lib/dll/example/build_package.bat +++ b/third_party/zstd/lib/dll/example/build_package.bat @@ -1,20 +1,21 @@ -@ECHO OFF -MKDIR bin\dll bin\static bin\example bin\include -COPY tests\fullbench.c bin\example\ -COPY programs\datagen.c bin\example\ -COPY programs\datagen.h bin\example\ -COPY programs\util.h bin\example\ -COPY programs\platform.h bin\example\ -COPY lib\common\mem.h bin\example\ -COPY lib\common\zstd_internal.h bin\example\ -COPY lib\common\error_private.h bin\example\ -COPY lib\common\xxhash.h bin\example\ -COPY lib\libzstd.a bin\static\libzstd_static.lib -COPY lib\dll\libzstd.* bin\dll\ -COPY lib\dll\example\Makefile bin\example\ -COPY lib\dll\example\fullbench-dll.* bin\example\ -COPY lib\dll\example\README.md bin\ -COPY lib\zstd.h bin\include\ -COPY lib\common\zstd_errors.h bin\include\ -COPY lib\dictBuilder\zdict.h bin\include\ -COPY programs\zstd.exe bin\zstd.exe +// clang-format off +@ECHO OFF +MKDIR bin\dll bin\static bin\example bin\include +COPY tests\fullbench.c bin\example\ +COPY programs\datagen.c bin\example\ +COPY programs\datagen.h bin\example\ +COPY programs\util.h bin\example\ +COPY programs\platform.h bin\example\ +COPY lib\common\mem.h bin\example\ +COPY lib\common\zstd_internal.h bin\example\ +COPY lib\common\error_private.h bin\example\ +COPY lib\common\xxhash.h bin\example\ +COPY lib\libzstd.a bin\static\libzstd_static.lib +COPY lib\dll\libzstd.* bin\dll\ +COPY lib\dll\example\Makefile bin\example\ +COPY lib\dll\example\fullbench-dll.* bin\example\ +COPY lib\dll\example\README.md bin\ +COPY lib\zstd.h bin\include\ +COPY lib\common\zstd_errors.h bin\include\ +COPY lib\dictBuilder\zdict.h bin\include\ +COPY programs\zstd.exe bin\zstd.exe diff --git a/third_party/zstd/lib/dll/example/fullbench-dll.sln b/third_party/zstd/lib/dll/example/fullbench-dll.sln index ef8d4c024..357a74204 100644 --- a/third_party/zstd/lib/dll/example/fullbench-dll.sln +++ b/third_party/zstd/lib/dll/example/fullbench-dll.sln @@ -1,25 +1,26 @@ -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Express 2012 for Windows Desktop -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fullbench-dll", "fullbench-dll.vcxproj", "{13992FD2-077E-4954-B065-A428198201A9}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {13992FD2-077E-4954-B065-A428198201A9}.Debug|Win32.ActiveCfg = Debug|Win32 - {13992FD2-077E-4954-B065-A428198201A9}.Debug|Win32.Build.0 = Debug|Win32 - {13992FD2-077E-4954-B065-A428198201A9}.Debug|x64.ActiveCfg = Debug|x64 - {13992FD2-077E-4954-B065-A428198201A9}.Debug|x64.Build.0 = Debug|x64 - {13992FD2-077E-4954-B065-A428198201A9}.Release|Win32.ActiveCfg = Release|Win32 - {13992FD2-077E-4954-B065-A428198201A9}.Release|Win32.Build.0 = Release|Win32 - {13992FD2-077E-4954-B065-A428198201A9}.Release|x64.ActiveCfg = Release|x64 - {13992FD2-077E-4954-B065-A428198201A9}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal +// clang-format off +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Express 2012 for Windows Desktop +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fullbench-dll", "fullbench-dll.vcxproj", "{13992FD2-077E-4954-B065-A428198201A9}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {13992FD2-077E-4954-B065-A428198201A9}.Debug|Win32.ActiveCfg = Debug|Win32 + {13992FD2-077E-4954-B065-A428198201A9}.Debug|Win32.Build.0 = Debug|Win32 + {13992FD2-077E-4954-B065-A428198201A9}.Debug|x64.ActiveCfg = Debug|x64 + {13992FD2-077E-4954-B065-A428198201A9}.Debug|x64.Build.0 = Debug|x64 + {13992FD2-077E-4954-B065-A428198201A9}.Release|Win32.ActiveCfg = Release|Win32 + {13992FD2-077E-4954-B065-A428198201A9}.Release|Win32.Build.0 = Release|Win32 + {13992FD2-077E-4954-B065-A428198201A9}.Release|x64.ActiveCfg = Release|x64 + {13992FD2-077E-4954-B065-A428198201A9}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/third_party/zstd/lib/dll/example/fullbench-dll.vcxproj b/third_party/zstd/lib/dll/example/fullbench-dll.vcxproj index fbea7832c..9b42ac7ea 100644 --- a/third_party/zstd/lib/dll/example/fullbench-dll.vcxproj +++ b/third_party/zstd/lib/dll/example/fullbench-dll.vcxproj @@ -1,181 +1,182 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {00000000-1CC8-4FD7-9281-6B8DBB9D3DF8} - Win32Proj - fullbench-dll - $(SolutionDir)bin\$(Platform)_$(Configuration)\ - $(SolutionDir)bin\obj\$(RootNamespace)_$(Platform)_$(Configuration)\ - - - - Application - true - MultiByte - - - Application - true - MultiByte - - - Application - false - true - MultiByte - - - Application - false - true - MultiByte - - - - - - - - - - - - - - - - - - - true - $(IncludePath);$(SolutionDir)..\..\lib;$(SolutionDir)..\..\programs;$(SolutionDir)..\..\lib\legacy;$(SolutionDir)..\..\lib\common;$(UniversalCRT_IncludePath); - false - - - true - $(IncludePath);$(SolutionDir)..\..\lib;$(SolutionDir)..\..\programs;$(SolutionDir)..\..\lib\legacy;$(SolutionDir)..\..\lib\common;$(UniversalCRT_IncludePath); - false - - - false - $(IncludePath);$(SolutionDir)..\..\lib;$(SolutionDir)..\..\programs;$(SolutionDir)..\..\lib\legacy;$(SolutionDir)..\..\lib\common;$(UniversalCRT_IncludePath); - false - - - false - $(IncludePath);$(SolutionDir)..\..\lib;$(SolutionDir)..\..\programs;$(SolutionDir)..\..\lib\legacy;$(SolutionDir)..\..\lib\common;$(UniversalCRT_IncludePath); - false - - - - - - Level4 - Disabled - WIN32;_DEBUG;_CONSOLE;ZSTD_DLL_IMPORT=1;%(PreprocessorDefinitions) - true - false - ..\include - - - Console - true - $(SolutionDir)..\dll;%(AdditionalLibraryDirectories) - libzstd.lib;%(AdditionalDependencies) - false - - - - - - - Level4 - Disabled - WIN32;_DEBUG;_CONSOLE;ZSTD_DLL_IMPORT=1;%(PreprocessorDefinitions) - true - false - ..\include - - - Console - true - $(SolutionDir)..\dll;%(AdditionalLibraryDirectories) - libzstd.lib;%(AdditionalDependencies) - - - - - Level4 - - - MaxSpeed - true - true - WIN32;_DEBUG;_CONSOLE;ZSTD_DLL_IMPORT=1;%(PreprocessorDefinitions) - false - ..\include - false - MultiThreaded - - - Console - true - true - true - $(SolutionDir)..\dll;%(AdditionalLibraryDirectories) - libzstd.lib;%(AdditionalDependencies) - false - - - - - Level4 - - - MaxSpeed - true - true - WIN32;_DEBUG;_CONSOLE;ZSTD_DLL_IMPORT=1;%(PreprocessorDefinitions) - false - false - ..\include - MultiThreaded - - - Console - true - true - true - $(SolutionDir)..\dll;%(AdditionalLibraryDirectories) - libzstd.lib;%(AdditionalDependencies) - - - - - - - - - - - - +// clang-format off + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {00000000-1CC8-4FD7-9281-6B8DBB9D3DF8} + Win32Proj + fullbench-dll + $(SolutionDir)bin\$(Platform)_$(Configuration)\ + $(SolutionDir)bin\obj\$(RootNamespace)_$(Platform)_$(Configuration)\ + + + + Application + true + MultiByte + + + Application + true + MultiByte + + + Application + false + true + MultiByte + + + Application + false + true + MultiByte + + + + + + + + + + + + + + + + + + + true + $(IncludePath);$(SolutionDir)..\..\lib;$(SolutionDir)..\..\programs;$(SolutionDir)..\..\lib\legacy;$(SolutionDir)..\..\lib\common;$(UniversalCRT_IncludePath); + false + + + true + $(IncludePath);$(SolutionDir)..\..\lib;$(SolutionDir)..\..\programs;$(SolutionDir)..\..\lib\legacy;$(SolutionDir)..\..\lib\common;$(UniversalCRT_IncludePath); + false + + + false + $(IncludePath);$(SolutionDir)..\..\lib;$(SolutionDir)..\..\programs;$(SolutionDir)..\..\lib\legacy;$(SolutionDir)..\..\lib\common;$(UniversalCRT_IncludePath); + false + + + false + $(IncludePath);$(SolutionDir)..\..\lib;$(SolutionDir)..\..\programs;$(SolutionDir)..\..\lib\legacy;$(SolutionDir)..\..\lib\common;$(UniversalCRT_IncludePath); + false + + + + + + Level4 + Disabled + WIN32;_DEBUG;_CONSOLE;ZSTD_DLL_IMPORT=1;%(PreprocessorDefinitions) + true + false + ..\include + + + Console + true + $(SolutionDir)..\dll;%(AdditionalLibraryDirectories) + libzstd.lib;%(AdditionalDependencies) + false + + + + + + + Level4 + Disabled + WIN32;_DEBUG;_CONSOLE;ZSTD_DLL_IMPORT=1;%(PreprocessorDefinitions) + true + false + ..\include + + + Console + true + $(SolutionDir)..\dll;%(AdditionalLibraryDirectories) + libzstd.lib;%(AdditionalDependencies) + + + + + Level4 + + + MaxSpeed + true + true + WIN32;_DEBUG;_CONSOLE;ZSTD_DLL_IMPORT=1;%(PreprocessorDefinitions) + false + ..\include + false + MultiThreaded + + + Console + true + true + true + $(SolutionDir)..\dll;%(AdditionalLibraryDirectories) + libzstd.lib;%(AdditionalDependencies) + false + + + + + Level4 + + + MaxSpeed + true + true + WIN32;_DEBUG;_CONSOLE;ZSTD_DLL_IMPORT=1;%(PreprocessorDefinitions) + false + false + ..\include + MultiThreaded + + + Console + true + true + true + $(SolutionDir)..\dll;%(AdditionalLibraryDirectories) + libzstd.lib;%(AdditionalDependencies) + + + + + + + + + + + + \ No newline at end of file diff --git a/third_party/zstd/lib/legacy/zstd_legacy.h b/third_party/zstd/lib/legacy/zstd_legacy.h deleted file mode 100644 index dd173251d..000000000 --- a/third_party/zstd/lib/legacy/zstd_legacy.h +++ /dev/null @@ -1,422 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under both the BSD-style license (found in the - * LICENSE file in the root directory of this source tree) and the GPLv2 (found - * in the COPYING file in the root directory of this source tree). - * You may select, at your option, one of the above-listed licenses. - */ - -#ifndef ZSTD_LEGACY_H -#define ZSTD_LEGACY_H - -#if defined (__cplusplus) -extern "C" { -#endif - -/* ************************************* -* Includes -***************************************/ -#include "../common/mem.h" /* MEM_STATIC */ -#include "../common/error_private.h" /* ERROR */ -#include "../common/zstd_internal.h" /* ZSTD_inBuffer, ZSTD_outBuffer, ZSTD_frameSizeInfo */ - -#if !defined (ZSTD_LEGACY_SUPPORT) || (ZSTD_LEGACY_SUPPORT == 0) -# undef ZSTD_LEGACY_SUPPORT -# define ZSTD_LEGACY_SUPPORT 8 -#endif - -#if (ZSTD_LEGACY_SUPPORT <= 1) -# include "zstd_v01.h" -#endif -#if (ZSTD_LEGACY_SUPPORT <= 2) -# include "zstd_v02.h" -#endif -#if (ZSTD_LEGACY_SUPPORT <= 3) -# include "zstd_v03.h" -#endif -#if (ZSTD_LEGACY_SUPPORT <= 4) -# include "zstd_v04.h" -#endif -#if (ZSTD_LEGACY_SUPPORT <= 5) -# include "zstd_v05.h" -#endif -#if (ZSTD_LEGACY_SUPPORT <= 6) -# include "zstd_v06.h" -#endif -#if (ZSTD_LEGACY_SUPPORT <= 7) -# include "zstd_v07.h" -#endif - -/** ZSTD_isLegacy() : - @return : > 0 if supported by legacy decoder. 0 otherwise. - return value is the version. -*/ -MEM_STATIC unsigned ZSTD_isLegacy(const void* src, size_t srcSize) -{ - U32 magicNumberLE; - if (srcSize<4) return 0; - magicNumberLE = MEM_readLE32(src); - switch(magicNumberLE) - { -#if (ZSTD_LEGACY_SUPPORT <= 1) - case ZSTDv01_magicNumberLE:return 1; -#endif -#if (ZSTD_LEGACY_SUPPORT <= 2) - case ZSTDv02_magicNumber : return 2; -#endif -#if (ZSTD_LEGACY_SUPPORT <= 3) - case ZSTDv03_magicNumber : return 3; -#endif -#if (ZSTD_LEGACY_SUPPORT <= 4) - case ZSTDv04_magicNumber : return 4; -#endif -#if (ZSTD_LEGACY_SUPPORT <= 5) - case ZSTDv05_MAGICNUMBER : return 5; -#endif -#if (ZSTD_LEGACY_SUPPORT <= 6) - case ZSTDv06_MAGICNUMBER : return 6; -#endif -#if (ZSTD_LEGACY_SUPPORT <= 7) - case ZSTDv07_MAGICNUMBER : return 7; -#endif - default : return 0; - } -} - - -MEM_STATIC unsigned long long ZSTD_getDecompressedSize_legacy(const void* src, size_t srcSize) -{ - U32 const version = ZSTD_isLegacy(src, srcSize); - if (version < 5) return 0; /* no decompressed size in frame header, or not a legacy format */ -#if (ZSTD_LEGACY_SUPPORT <= 5) - if (version==5) { - ZSTDv05_parameters fParams; - size_t const frResult = ZSTDv05_getFrameParams(&fParams, src, srcSize); - if (frResult != 0) return 0; - return fParams.srcSize; - } -#endif -#if (ZSTD_LEGACY_SUPPORT <= 6) - if (version==6) { - ZSTDv06_frameParams fParams; - size_t const frResult = ZSTDv06_getFrameParams(&fParams, src, srcSize); - if (frResult != 0) return 0; - return fParams.frameContentSize; - } -#endif -#if (ZSTD_LEGACY_SUPPORT <= 7) - if (version==7) { - ZSTDv07_frameParams fParams; - size_t const frResult = ZSTDv07_getFrameParams(&fParams, src, srcSize); - if (frResult != 0) return 0; - return fParams.frameContentSize; - } -#endif - return 0; /* should not be possible */ -} - - -MEM_STATIC size_t ZSTD_decompressLegacy( - void* dst, size_t dstCapacity, - const void* src, size_t compressedSize, - const void* dict,size_t dictSize) -{ - U32 const version = ZSTD_isLegacy(src, compressedSize); - (void)dst; (void)dstCapacity; (void)dict; (void)dictSize; /* unused when ZSTD_LEGACY_SUPPORT >= 8 */ - switch(version) - { -#if (ZSTD_LEGACY_SUPPORT <= 1) - case 1 : - return ZSTDv01_decompress(dst, dstCapacity, src, compressedSize); -#endif -#if (ZSTD_LEGACY_SUPPORT <= 2) - case 2 : - return ZSTDv02_decompress(dst, dstCapacity, src, compressedSize); -#endif -#if (ZSTD_LEGACY_SUPPORT <= 3) - case 3 : - return ZSTDv03_decompress(dst, dstCapacity, src, compressedSize); -#endif -#if (ZSTD_LEGACY_SUPPORT <= 4) - case 4 : - return ZSTDv04_decompress(dst, dstCapacity, src, compressedSize); -#endif -#if (ZSTD_LEGACY_SUPPORT <= 5) - case 5 : - { size_t result; - ZSTDv05_DCtx* const zd = ZSTDv05_createDCtx(); - if (zd==NULL) return ERROR(memory_allocation); - result = ZSTDv05_decompress_usingDict(zd, dst, dstCapacity, src, compressedSize, dict, dictSize); - ZSTDv05_freeDCtx(zd); - return result; - } -#endif -#if (ZSTD_LEGACY_SUPPORT <= 6) - case 6 : - { size_t result; - ZSTDv06_DCtx* const zd = ZSTDv06_createDCtx(); - if (zd==NULL) return ERROR(memory_allocation); - result = ZSTDv06_decompress_usingDict(zd, dst, dstCapacity, src, compressedSize, dict, dictSize); - ZSTDv06_freeDCtx(zd); - return result; - } -#endif -#if (ZSTD_LEGACY_SUPPORT <= 7) - case 7 : - { size_t result; - ZSTDv07_DCtx* const zd = ZSTDv07_createDCtx(); - if (zd==NULL) return ERROR(memory_allocation); - result = ZSTDv07_decompress_usingDict(zd, dst, dstCapacity, src, compressedSize, dict, dictSize); - ZSTDv07_freeDCtx(zd); - return result; - } -#endif - default : - return ERROR(prefix_unknown); - } -} - -MEM_STATIC ZSTD_frameSizeInfo ZSTD_findFrameSizeInfoLegacy(const void *src, size_t srcSize) -{ - ZSTD_frameSizeInfo frameSizeInfo; - U32 const version = ZSTD_isLegacy(src, srcSize); - switch(version) - { -#if (ZSTD_LEGACY_SUPPORT <= 1) - case 1 : - ZSTDv01_findFrameSizeInfoLegacy(src, srcSize, - &frameSizeInfo.compressedSize, - &frameSizeInfo.decompressedBound); - break; -#endif -#if (ZSTD_LEGACY_SUPPORT <= 2) - case 2 : - ZSTDv02_findFrameSizeInfoLegacy(src, srcSize, - &frameSizeInfo.compressedSize, - &frameSizeInfo.decompressedBound); - break; -#endif -#if (ZSTD_LEGACY_SUPPORT <= 3) - case 3 : - ZSTDv03_findFrameSizeInfoLegacy(src, srcSize, - &frameSizeInfo.compressedSize, - &frameSizeInfo.decompressedBound); - break; -#endif -#if (ZSTD_LEGACY_SUPPORT <= 4) - case 4 : - ZSTDv04_findFrameSizeInfoLegacy(src, srcSize, - &frameSizeInfo.compressedSize, - &frameSizeInfo.decompressedBound); - break; -#endif -#if (ZSTD_LEGACY_SUPPORT <= 5) - case 5 : - ZSTDv05_findFrameSizeInfoLegacy(src, srcSize, - &frameSizeInfo.compressedSize, - &frameSizeInfo.decompressedBound); - break; -#endif -#if (ZSTD_LEGACY_SUPPORT <= 6) - case 6 : - ZSTDv06_findFrameSizeInfoLegacy(src, srcSize, - &frameSizeInfo.compressedSize, - &frameSizeInfo.decompressedBound); - break; -#endif -#if (ZSTD_LEGACY_SUPPORT <= 7) - case 7 : - ZSTDv07_findFrameSizeInfoLegacy(src, srcSize, - &frameSizeInfo.compressedSize, - &frameSizeInfo.decompressedBound); - break; -#endif - default : - frameSizeInfo.compressedSize = ERROR(prefix_unknown); - frameSizeInfo.decompressedBound = ZSTD_CONTENTSIZE_ERROR; - break; - } - if (!ZSTD_isError(frameSizeInfo.compressedSize) && frameSizeInfo.compressedSize > srcSize) { - frameSizeInfo.compressedSize = ERROR(srcSize_wrong); - frameSizeInfo.decompressedBound = ZSTD_CONTENTSIZE_ERROR; - } - /* In all cases, decompressedBound == nbBlocks * ZSTD_BLOCKSIZE_MAX. - * So we can compute nbBlocks without having to change every function. - */ - if (frameSizeInfo.decompressedBound != ZSTD_CONTENTSIZE_ERROR) { - assert((frameSizeInfo.decompressedBound & (ZSTD_BLOCKSIZE_MAX - 1)) == 0); - frameSizeInfo.nbBlocks = (size_t)(frameSizeInfo.decompressedBound / ZSTD_BLOCKSIZE_MAX); - } - return frameSizeInfo; -} - -MEM_STATIC size_t ZSTD_findFrameCompressedSizeLegacy(const void *src, size_t srcSize) -{ - ZSTD_frameSizeInfo frameSizeInfo = ZSTD_findFrameSizeInfoLegacy(src, srcSize); - return frameSizeInfo.compressedSize; -} - -MEM_STATIC size_t ZSTD_freeLegacyStreamContext(void* legacyContext, U32 version) -{ - switch(version) - { - default : - case 1 : - case 2 : - case 3 : - (void)legacyContext; - return ERROR(version_unsupported); -#if (ZSTD_LEGACY_SUPPORT <= 4) - case 4 : return ZBUFFv04_freeDCtx((ZBUFFv04_DCtx*)legacyContext); -#endif -#if (ZSTD_LEGACY_SUPPORT <= 5) - case 5 : return ZBUFFv05_freeDCtx((ZBUFFv05_DCtx*)legacyContext); -#endif -#if (ZSTD_LEGACY_SUPPORT <= 6) - case 6 : return ZBUFFv06_freeDCtx((ZBUFFv06_DCtx*)legacyContext); -#endif -#if (ZSTD_LEGACY_SUPPORT <= 7) - case 7 : return ZBUFFv07_freeDCtx((ZBUFFv07_DCtx*)legacyContext); -#endif - } -} - - -MEM_STATIC size_t ZSTD_initLegacyStream(void** legacyContext, U32 prevVersion, U32 newVersion, - const void* dict, size_t dictSize) -{ - DEBUGLOG(5, "ZSTD_initLegacyStream for v0.%u", newVersion); - if (prevVersion != newVersion) ZSTD_freeLegacyStreamContext(*legacyContext, prevVersion); - switch(newVersion) - { - default : - case 1 : - case 2 : - case 3 : - (void)dict; (void)dictSize; - return 0; -#if (ZSTD_LEGACY_SUPPORT <= 4) - case 4 : - { - ZBUFFv04_DCtx* dctx = (prevVersion != newVersion) ? ZBUFFv04_createDCtx() : (ZBUFFv04_DCtx*)*legacyContext; - if (dctx==NULL) return ERROR(memory_allocation); - ZBUFFv04_decompressInit(dctx); - ZBUFFv04_decompressWithDictionary(dctx, dict, dictSize); - *legacyContext = dctx; - return 0; - } -#endif -#if (ZSTD_LEGACY_SUPPORT <= 5) - case 5 : - { - ZBUFFv05_DCtx* dctx = (prevVersion != newVersion) ? ZBUFFv05_createDCtx() : (ZBUFFv05_DCtx*)*legacyContext; - if (dctx==NULL) return ERROR(memory_allocation); - ZBUFFv05_decompressInitDictionary(dctx, dict, dictSize); - *legacyContext = dctx; - return 0; - } -#endif -#if (ZSTD_LEGACY_SUPPORT <= 6) - case 6 : - { - ZBUFFv06_DCtx* dctx = (prevVersion != newVersion) ? ZBUFFv06_createDCtx() : (ZBUFFv06_DCtx*)*legacyContext; - if (dctx==NULL) return ERROR(memory_allocation); - ZBUFFv06_decompressInitDictionary(dctx, dict, dictSize); - *legacyContext = dctx; - return 0; - } -#endif -#if (ZSTD_LEGACY_SUPPORT <= 7) - case 7 : - { - ZBUFFv07_DCtx* dctx = (prevVersion != newVersion) ? ZBUFFv07_createDCtx() : (ZBUFFv07_DCtx*)*legacyContext; - if (dctx==NULL) return ERROR(memory_allocation); - ZBUFFv07_decompressInitDictionary(dctx, dict, dictSize); - *legacyContext = dctx; - return 0; - } -#endif - } -} - - - -MEM_STATIC size_t ZSTD_decompressLegacyStream(void* legacyContext, U32 version, - ZSTD_outBuffer* output, ZSTD_inBuffer* input) -{ - DEBUGLOG(5, "ZSTD_decompressLegacyStream for v0.%u", version); - switch(version) - { - default : - case 1 : - case 2 : - case 3 : - (void)legacyContext; (void)output; (void)input; - return ERROR(version_unsupported); -#if (ZSTD_LEGACY_SUPPORT <= 4) - case 4 : - { - ZBUFFv04_DCtx* dctx = (ZBUFFv04_DCtx*) legacyContext; - const void* src = (const char*)input->src + input->pos; - size_t readSize = input->size - input->pos; - void* dst = (char*)output->dst + output->pos; - size_t decodedSize = output->size - output->pos; - size_t const hintSize = ZBUFFv04_decompressContinue(dctx, dst, &decodedSize, src, &readSize); - output->pos += decodedSize; - input->pos += readSize; - return hintSize; - } -#endif -#if (ZSTD_LEGACY_SUPPORT <= 5) - case 5 : - { - ZBUFFv05_DCtx* dctx = (ZBUFFv05_DCtx*) legacyContext; - const void* src = (const char*)input->src + input->pos; - size_t readSize = input->size - input->pos; - void* dst = (char*)output->dst + output->pos; - size_t decodedSize = output->size - output->pos; - size_t const hintSize = ZBUFFv05_decompressContinue(dctx, dst, &decodedSize, src, &readSize); - output->pos += decodedSize; - input->pos += readSize; - return hintSize; - } -#endif -#if (ZSTD_LEGACY_SUPPORT <= 6) - case 6 : - { - ZBUFFv06_DCtx* dctx = (ZBUFFv06_DCtx*) legacyContext; - const void* src = (const char*)input->src + input->pos; - size_t readSize = input->size - input->pos; - void* dst = (char*)output->dst + output->pos; - size_t decodedSize = output->size - output->pos; - size_t const hintSize = ZBUFFv06_decompressContinue(dctx, dst, &decodedSize, src, &readSize); - output->pos += decodedSize; - input->pos += readSize; - return hintSize; - } -#endif -#if (ZSTD_LEGACY_SUPPORT <= 7) - case 7 : - { - ZBUFFv07_DCtx* dctx = (ZBUFFv07_DCtx*) legacyContext; - const void* src = (const char*)input->src + input->pos; - size_t readSize = input->size - input->pos; - void* dst = (char*)output->dst + output->pos; - size_t decodedSize = output->size - output->pos; - size_t const hintSize = ZBUFFv07_decompressContinue(dctx, dst, &decodedSize, src, &readSize); - output->pos += decodedSize; - input->pos += readSize; - return hintSize; - } -#endif - } -} - - -#if defined (__cplusplus) -} -#endif - -#endif /* ZSTD_LEGACY_H */ diff --git a/third_party/zstd/lib/legacy/zstd_v01.c b/third_party/zstd/lib/legacy/zstd_v01.c deleted file mode 100644 index 1a3aad07e..000000000 --- a/third_party/zstd/lib/legacy/zstd_v01.c +++ /dev/null @@ -1,2125 +0,0 @@ -/* - * Copyright (c) Yann Collet, Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under both the BSD-style license (found in the - * LICENSE file in the root directory of this source tree) and the GPLv2 (found - * in the COPYING file in the root directory of this source tree). - * You may select, at your option, one of the above-listed licenses. - */ - - -/****************************************** -* Includes -******************************************/ -#include /* size_t, ptrdiff_t */ -#include "zstd_v01.h" -#include "../common/error_private.h" - - -/****************************************** -* Static allocation -******************************************/ -/* You can statically allocate FSE CTable/DTable as a table of unsigned using below macro */ -#define FSE_DTABLE_SIZE_U32(maxTableLog) (1 + (1<2^N Bytes (examples : 10 -> 1KB; 12 -> 4KB ; 16 -> 64KB; 20 -> 1MB; etc.) -* Increasing memory usage improves compression ratio -* Reduced memory usage can improve speed, due to cache effect -* Recommended max value is 14, for 16KB, which nicely fits into Intel x86 L1 cache */ -#define FSE_MAX_MEMORY_USAGE 14 -#define FSE_DEFAULT_MEMORY_USAGE 13 - -/* FSE_MAX_SYMBOL_VALUE : -* Maximum symbol value authorized. -* Required for proper stack allocation */ -#define FSE_MAX_SYMBOL_VALUE 255 - - -/**************************************************************** -* template functions type & suffix -****************************************************************/ -#define FSE_FUNCTION_TYPE BYTE -#define FSE_FUNCTION_EXTENSION - - -/**************************************************************** -* Byte symbol type -****************************************************************/ -typedef struct -{ - unsigned short newState; - unsigned char symbol; - unsigned char nbBits; -} FSE_decode_t; /* size == U32 */ - - - -/**************************************************************** -* Compiler specifics -****************************************************************/ -#ifdef _MSC_VER /* Visual Studio */ -# define FORCE_INLINE static __forceinline -# include /* For Visual 2005 */ -# pragma warning(disable : 4127) /* disable: C4127: conditional expression is constant */ -# pragma warning(disable : 4214) /* disable: C4214: non-int bitfields */ -#else -# define GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__) -# if defined (__cplusplus) || defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 */ -# ifdef __GNUC__ -# define FORCE_INLINE static inline __attribute__((always_inline)) -# else -# define FORCE_INLINE static inline -# endif -# else -# define FORCE_INLINE static -# endif /* __STDC_VERSION__ */ -#endif - - -/**************************************************************** -* Includes -****************************************************************/ -#include /* malloc, free, qsort */ -#include /* memcpy, memset */ -#include /* printf (debug) */ - - -#ifndef MEM_ACCESS_MODULE -#define MEM_ACCESS_MODULE -/**************************************************************** -* Basic Types -*****************************************************************/ -#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 */ -# include -typedef uint8_t BYTE; -typedef uint16_t U16; -typedef int16_t S16; -typedef uint32_t U32; -typedef int32_t S32; -typedef uint64_t U64; -typedef int64_t S64; -#else -typedef unsigned char BYTE; -typedef unsigned short U16; -typedef signed short S16; -typedef unsigned int U32; -typedef signed int S32; -typedef unsigned long long U64; -typedef signed long long S64; -#endif - -#endif /* MEM_ACCESS_MODULE */ - -/**************************************************************** -* Memory I/O -*****************************************************************/ - -static unsigned FSE_32bits(void) -{ - return sizeof(void*)==4; -} - -static unsigned FSE_isLittleEndian(void) -{ - const union { U32 i; BYTE c[4]; } one = { 1 }; /* don't use static : performance detrimental */ - return one.c[0]; -} - -static U16 FSE_read16(const void* memPtr) -{ - U16 val; memcpy(&val, memPtr, sizeof(val)); return val; -} - -static U32 FSE_read32(const void* memPtr) -{ - U32 val; memcpy(&val, memPtr, sizeof(val)); return val; -} - -static U64 FSE_read64(const void* memPtr) -{ - U64 val; memcpy(&val, memPtr, sizeof(val)); return val; -} - -static U16 FSE_readLE16(const void* memPtr) -{ - if (FSE_isLittleEndian()) - return FSE_read16(memPtr); - else - { - const BYTE* p = (const BYTE*)memPtr; - return (U16)(p[0] + (p[1]<<8)); - } -} - -static U32 FSE_readLE32(const void* memPtr) -{ - if (FSE_isLittleEndian()) - return FSE_read32(memPtr); - else - { - const BYTE* p = (const BYTE*)memPtr; - return (U32)((U32)p[0] + ((U32)p[1]<<8) + ((U32)p[2]<<16) + ((U32)p[3]<<24)); - } -} - - -static U64 FSE_readLE64(const void* memPtr) -{ - if (FSE_isLittleEndian()) - return FSE_read64(memPtr); - else - { - const BYTE* p = (const BYTE*)memPtr; - return (U64)((U64)p[0] + ((U64)p[1]<<8) + ((U64)p[2]<<16) + ((U64)p[3]<<24) - + ((U64)p[4]<<32) + ((U64)p[5]<<40) + ((U64)p[6]<<48) + ((U64)p[7]<<56)); - } -} - -static size_t FSE_readLEST(const void* memPtr) -{ - if (FSE_32bits()) - return (size_t)FSE_readLE32(memPtr); - else - return (size_t)FSE_readLE64(memPtr); -} - - - -/**************************************************************** -* Constants -*****************************************************************/ -#define FSE_MAX_TABLELOG (FSE_MAX_MEMORY_USAGE-2) -#define FSE_MAX_TABLESIZE (1U< FSE_TABLELOG_ABSOLUTE_MAX -#error "FSE_MAX_TABLELOG > FSE_TABLELOG_ABSOLUTE_MAX is not supported" -#endif - - -/**************************************************************** -* Error Management -****************************************************************/ -#define FSE_STATIC_ASSERT(c) { enum { FSE_static_assert = 1/(int)(!!(c)) }; } /* use only *after* variable declarations */ - - -/**************************************************************** -* Complex types -****************************************************************/ -typedef struct -{ - int deltaFindState; - U32 deltaNbBits; -} FSE_symbolCompressionTransform; /* total 8 bytes */ - -typedef U32 DTable_max_t[FSE_DTABLE_SIZE_U32(FSE_MAX_TABLELOG)]; - -/**************************************************************** -* Internal functions -****************************************************************/ -FORCE_INLINE unsigned FSE_highbit32 (U32 val) -{ -# if defined(_MSC_VER) /* Visual */ - unsigned long r; - return _BitScanReverse(&r, val) ? (unsigned)r : 0; -# elif defined(__GNUC__) && (GCC_VERSION >= 304) /* GCC Intrinsic */ - return __builtin_clz (val) ^ 31; -# else /* Software version */ - static const unsigned DeBruijnClz[32] = { 0, 9, 1, 10, 13, 21, 2, 29, 11, 14, 16, 18, 22, 25, 3, 30, 8, 12, 20, 28, 15, 17, 24, 7, 19, 27, 23, 6, 26, 5, 4, 31 }; - U32 v = val; - unsigned r; - v |= v >> 1; - v |= v >> 2; - v |= v >> 4; - v |= v >> 8; - v |= v >> 16; - r = DeBruijnClz[ (U32) (v * 0x07C4ACDDU) >> 27]; - return r; -# endif -} - - -/**************************************************************** -* Templates -****************************************************************/ -/* - designed to be included - for type-specific functions (template emulation in C) - Objective is to write these functions only once, for improved maintenance -*/ - -/* safety checks */ -#ifndef FSE_FUNCTION_EXTENSION -# error "FSE_FUNCTION_EXTENSION must be defined" -#endif -#ifndef FSE_FUNCTION_TYPE -# error "FSE_FUNCTION_TYPE must be defined" -#endif - -/* Function names */ -#define FSE_CAT(X,Y) X##Y -#define FSE_FUNCTION_NAME(X,Y) FSE_CAT(X,Y) -#define FSE_TYPE_NAME(X,Y) FSE_CAT(X,Y) - - - -static U32 FSE_tableStep(U32 tableSize) { return (tableSize>>1) + (tableSize>>3) + 3; } - -#define FSE_DECODE_TYPE FSE_decode_t - - -typedef struct { - U16 tableLog; - U16 fastMode; -} FSE_DTableHeader; /* sizeof U32 */ - -static size_t FSE_buildDTable -(FSE_DTable* dt, const short* normalizedCounter, unsigned maxSymbolValue, unsigned tableLog) -{ - void* ptr = dt; - FSE_DTableHeader* const DTableH = (FSE_DTableHeader*)ptr; - FSE_DECODE_TYPE* const tableDecode = (FSE_DECODE_TYPE*)(ptr) + 1; /* because dt is unsigned, 32-bits aligned on 32-bits */ - const U32 tableSize = 1 << tableLog; - const U32 tableMask = tableSize-1; - const U32 step = FSE_tableStep(tableSize); - U16 symbolNext[FSE_MAX_SYMBOL_VALUE+1]; - U32 position = 0; - U32 highThreshold = tableSize-1; - const S16 largeLimit= (S16)(1 << (tableLog-1)); - U32 noLarge = 1; - U32 s; - - /* Sanity Checks */ - if (maxSymbolValue > FSE_MAX_SYMBOL_VALUE) return (size_t)-FSE_ERROR_maxSymbolValue_tooLarge; - if (tableLog > FSE_MAX_TABLELOG) return (size_t)-FSE_ERROR_tableLog_tooLarge; - - /* Init, lay down lowprob symbols */ - DTableH[0].tableLog = (U16)tableLog; - for (s=0; s<=maxSymbolValue; s++) - { - if (normalizedCounter[s]==-1) - { - tableDecode[highThreshold--].symbol = (FSE_FUNCTION_TYPE)s; - symbolNext[s] = 1; - } - else - { - if (normalizedCounter[s] >= largeLimit) noLarge=0; - symbolNext[s] = normalizedCounter[s]; - } - } - - /* Spread symbols */ - for (s=0; s<=maxSymbolValue; s++) - { - int i; - for (i=0; i highThreshold) position = (position + step) & tableMask; /* lowprob area */ - } - } - - if (position!=0) return (size_t)-FSE_ERROR_GENERIC; /* position must reach all cells once, otherwise normalizedCounter is incorrect */ - - /* Build Decoding table */ - { - U32 i; - for (i=0; ifastMode = (U16)noLarge; - return 0; -} - - -/****************************************** -* FSE byte symbol -******************************************/ -#ifndef FSE_COMMONDEFS_ONLY - -static unsigned FSE_isError(size_t code) { return (code > (size_t)(-FSE_ERROR_maxCode)); } - -static short FSE_abs(short a) -{ - return a<0? -a : a; -} - - -/**************************************************************** -* Header bitstream management -****************************************************************/ -static size_t FSE_readNCount (short* normalizedCounter, unsigned* maxSVPtr, unsigned* tableLogPtr, - const void* headerBuffer, size_t hbSize) -{ - const BYTE* const istart = (const BYTE*) headerBuffer; - const BYTE* const iend = istart + hbSize; - const BYTE* ip = istart; - int nbBits; - int remaining; - int threshold; - U32 bitStream; - int bitCount; - unsigned charnum = 0; - int previous0 = 0; - - if (hbSize < 4) return (size_t)-FSE_ERROR_srcSize_wrong; - bitStream = FSE_readLE32(ip); - nbBits = (bitStream & 0xF) + FSE_MIN_TABLELOG; /* extract tableLog */ - if (nbBits > FSE_TABLELOG_ABSOLUTE_MAX) return (size_t)-FSE_ERROR_tableLog_tooLarge; - bitStream >>= 4; - bitCount = 4; - *tableLogPtr = nbBits; - remaining = (1<1) && (charnum<=*maxSVPtr)) - { - if (previous0) - { - unsigned n0 = charnum; - while ((bitStream & 0xFFFF) == 0xFFFF) - { - n0+=24; - if (ip < iend-5) - { - ip+=2; - bitStream = FSE_readLE32(ip) >> bitCount; - } - else - { - bitStream >>= 16; - bitCount+=16; - } - } - while ((bitStream & 3) == 3) - { - n0+=3; - bitStream>>=2; - bitCount+=2; - } - n0 += bitStream & 3; - bitCount += 2; - if (n0 > *maxSVPtr) return (size_t)-FSE_ERROR_maxSymbolValue_tooSmall; - while (charnum < n0) normalizedCounter[charnum++] = 0; - if ((ip <= iend-7) || (ip + (bitCount>>3) <= iend-4)) - { - ip += bitCount>>3; - bitCount &= 7; - bitStream = FSE_readLE32(ip) >> bitCount; - } - else - bitStream >>= 2; - } - { - const short max = (short)((2*threshold-1)-remaining); - short count; - - if ((bitStream & (threshold-1)) < (U32)max) - { - count = (short)(bitStream & (threshold-1)); - bitCount += nbBits-1; - } - else - { - count = (short)(bitStream & (2*threshold-1)); - if (count >= threshold) count -= max; - bitCount += nbBits; - } - - count--; /* extra accuracy */ - remaining -= FSE_abs(count); - normalizedCounter[charnum++] = count; - previous0 = !count; - while (remaining < threshold) - { - nbBits--; - threshold >>= 1; - } - - { - if ((ip <= iend-7) || (ip + (bitCount>>3) <= iend-4)) - { - ip += bitCount>>3; - bitCount &= 7; - } - else - { - bitCount -= (int)(8 * (iend - 4 - ip)); - ip = iend - 4; - } - bitStream = FSE_readLE32(ip) >> (bitCount & 31); - } - } - } - if (remaining != 1) return (size_t)-FSE_ERROR_GENERIC; - *maxSVPtr = charnum-1; - - ip += (bitCount+7)>>3; - if ((size_t)(ip-istart) > hbSize) return (size_t)-FSE_ERROR_srcSize_wrong; - return ip-istart; -} - - -/********************************************************* -* Decompression (Byte symbols) -*********************************************************/ -static size_t FSE_buildDTable_rle (FSE_DTable* dt, BYTE symbolValue) -{ - void* ptr = dt; - FSE_DTableHeader* const DTableH = (FSE_DTableHeader*)ptr; - FSE_decode_t* const cell = (FSE_decode_t*)(ptr) + 1; /* because dt is unsigned */ - - DTableH->tableLog = 0; - DTableH->fastMode = 0; - - cell->newState = 0; - cell->symbol = symbolValue; - cell->nbBits = 0; - - return 0; -} - - -static size_t FSE_buildDTable_raw (FSE_DTable* dt, unsigned nbBits) -{ - void* ptr = dt; - FSE_DTableHeader* const DTableH = (FSE_DTableHeader*)ptr; - FSE_decode_t* const dinfo = (FSE_decode_t*)(ptr) + 1; /* because dt is unsigned */ - const unsigned tableSize = 1 << nbBits; - const unsigned tableMask = tableSize - 1; - const unsigned maxSymbolValue = tableMask; - unsigned s; - - /* Sanity checks */ - if (nbBits < 1) return (size_t)-FSE_ERROR_GENERIC; /* min size */ - - /* Build Decoding Table */ - DTableH->tableLog = (U16)nbBits; - DTableH->fastMode = 1; - for (s=0; s<=maxSymbolValue; s++) - { - dinfo[s].newState = 0; - dinfo[s].symbol = (BYTE)s; - dinfo[s].nbBits = (BYTE)nbBits; - } - - return 0; -} - - -/* FSE_initDStream - * Initialize a FSE_DStream_t. - * srcBuffer must point at the beginning of an FSE block. - * The function result is the size of the FSE_block (== srcSize). - * If srcSize is too small, the function will return an errorCode; - */ -static size_t FSE_initDStream(FSE_DStream_t* bitD, const void* srcBuffer, size_t srcSize) -{ - if (srcSize < 1) return (size_t)-FSE_ERROR_srcSize_wrong; - - if (srcSize >= sizeof(size_t)) - { - U32 contain32; - bitD->start = (const char*)srcBuffer; - bitD->ptr = (const char*)srcBuffer + srcSize - sizeof(size_t); - bitD->bitContainer = FSE_readLEST(bitD->ptr); - contain32 = ((const BYTE*)srcBuffer)[srcSize-1]; - if (contain32 == 0) return (size_t)-FSE_ERROR_GENERIC; /* stop bit not present */ - bitD->bitsConsumed = 8 - FSE_highbit32(contain32); - } - else - { - U32 contain32; - bitD->start = (const char*)srcBuffer; - bitD->ptr = bitD->start; - bitD->bitContainer = *(const BYTE*)(bitD->start); - switch(srcSize) - { - case 7: bitD->bitContainer += (size_t)(((const BYTE*)(bitD->start))[6]) << (sizeof(size_t)*8 - 16); - /* fallthrough */ - case 6: bitD->bitContainer += (size_t)(((const BYTE*)(bitD->start))[5]) << (sizeof(size_t)*8 - 24); - /* fallthrough */ - case 5: bitD->bitContainer += (size_t)(((const BYTE*)(bitD->start))[4]) << (sizeof(size_t)*8 - 32); - /* fallthrough */ - case 4: bitD->bitContainer += (size_t)(((const BYTE*)(bitD->start))[3]) << 24; - /* fallthrough */ - case 3: bitD->bitContainer += (size_t)(((const BYTE*)(bitD->start))[2]) << 16; - /* fallthrough */ - case 2: bitD->bitContainer += (size_t)(((const BYTE*)(bitD->start))[1]) << 8; - /* fallthrough */ - default:; - } - contain32 = ((const BYTE*)srcBuffer)[srcSize-1]; - if (contain32 == 0) return (size_t)-FSE_ERROR_GENERIC; /* stop bit not present */ - bitD->bitsConsumed = 8 - FSE_highbit32(contain32); - bitD->bitsConsumed += (U32)(sizeof(size_t) - srcSize)*8; - } - - return srcSize; -} - - -/*!FSE_lookBits - * Provides next n bits from the bitContainer. - * bitContainer is not modified (bits are still present for next read/look) - * On 32-bits, maxNbBits==25 - * On 64-bits, maxNbBits==57 - * return : value extracted. - */ -static size_t FSE_lookBits(FSE_DStream_t* bitD, U32 nbBits) -{ - const U32 bitMask = sizeof(bitD->bitContainer)*8 - 1; - return ((bitD->bitContainer << (bitD->bitsConsumed & bitMask)) >> 1) >> ((bitMask-nbBits) & bitMask); -} - -static size_t FSE_lookBitsFast(FSE_DStream_t* bitD, U32 nbBits) /* only if nbBits >= 1 !! */ -{ - const U32 bitMask = sizeof(bitD->bitContainer)*8 - 1; - return (bitD->bitContainer << (bitD->bitsConsumed & bitMask)) >> (((bitMask+1)-nbBits) & bitMask); -} - -static void FSE_skipBits(FSE_DStream_t* bitD, U32 nbBits) -{ - bitD->bitsConsumed += nbBits; -} - - -/*!FSE_readBits - * Read next n bits from the bitContainer. - * On 32-bits, don't read more than maxNbBits==25 - * On 64-bits, don't read more than maxNbBits==57 - * Use the fast variant *only* if n >= 1. - * return : value extracted. - */ -static size_t FSE_readBits(FSE_DStream_t* bitD, U32 nbBits) -{ - size_t value = FSE_lookBits(bitD, nbBits); - FSE_skipBits(bitD, nbBits); - return value; -} - -static size_t FSE_readBitsFast(FSE_DStream_t* bitD, U32 nbBits) /* only if nbBits >= 1 !! */ -{ - size_t value = FSE_lookBitsFast(bitD, nbBits); - FSE_skipBits(bitD, nbBits); - return value; -} - -static unsigned FSE_reloadDStream(FSE_DStream_t* bitD) -{ - if (bitD->bitsConsumed > (sizeof(bitD->bitContainer)*8)) /* should never happen */ - return FSE_DStream_tooFar; - - if (bitD->ptr >= bitD->start + sizeof(bitD->bitContainer)) - { - bitD->ptr -= bitD->bitsConsumed >> 3; - bitD->bitsConsumed &= 7; - bitD->bitContainer = FSE_readLEST(bitD->ptr); - return FSE_DStream_unfinished; - } - if (bitD->ptr == bitD->start) - { - if (bitD->bitsConsumed < sizeof(bitD->bitContainer)*8) return FSE_DStream_endOfBuffer; - return FSE_DStream_completed; - } - { - U32 nbBytes = bitD->bitsConsumed >> 3; - U32 result = FSE_DStream_unfinished; - if (bitD->ptr - nbBytes < bitD->start) - { - nbBytes = (U32)(bitD->ptr - bitD->start); /* ptr > start */ - result = FSE_DStream_endOfBuffer; - } - bitD->ptr -= nbBytes; - bitD->bitsConsumed -= nbBytes*8; - bitD->bitContainer = FSE_readLEST(bitD->ptr); /* reminder : srcSize > sizeof(bitD) */ - return result; - } -} - - -static void FSE_initDState(FSE_DState_t* DStatePtr, FSE_DStream_t* bitD, const FSE_DTable* dt) -{ - const void* ptr = dt; - const FSE_DTableHeader* const DTableH = (const FSE_DTableHeader*)ptr; - DStatePtr->state = FSE_readBits(bitD, DTableH->tableLog); - FSE_reloadDStream(bitD); - DStatePtr->table = dt + 1; -} - -static BYTE FSE_decodeSymbol(FSE_DState_t* DStatePtr, FSE_DStream_t* bitD) -{ - const FSE_decode_t DInfo = ((const FSE_decode_t*)(DStatePtr->table))[DStatePtr->state]; - const U32 nbBits = DInfo.nbBits; - BYTE symbol = DInfo.symbol; - size_t lowBits = FSE_readBits(bitD, nbBits); - - DStatePtr->state = DInfo.newState + lowBits; - return symbol; -} - -static BYTE FSE_decodeSymbolFast(FSE_DState_t* DStatePtr, FSE_DStream_t* bitD) -{ - const FSE_decode_t DInfo = ((const FSE_decode_t*)(DStatePtr->table))[DStatePtr->state]; - const U32 nbBits = DInfo.nbBits; - BYTE symbol = DInfo.symbol; - size_t lowBits = FSE_readBitsFast(bitD, nbBits); - - DStatePtr->state = DInfo.newState + lowBits; - return symbol; -} - -/* FSE_endOfDStream - Tells if bitD has reached end of bitStream or not */ - -static unsigned FSE_endOfDStream(const FSE_DStream_t* bitD) -{ - return ((bitD->ptr == bitD->start) && (bitD->bitsConsumed == sizeof(bitD->bitContainer)*8)); -} - -static unsigned FSE_endOfDState(const FSE_DState_t* DStatePtr) -{ - return DStatePtr->state == 0; -} - - -FORCE_INLINE size_t FSE_decompress_usingDTable_generic( - void* dst, size_t maxDstSize, - const void* cSrc, size_t cSrcSize, - const FSE_DTable* dt, const unsigned fast) -{ - BYTE* const ostart = (BYTE*) dst; - BYTE* op = ostart; - BYTE* const omax = op + maxDstSize; - BYTE* const olimit = omax-3; - - FSE_DStream_t bitD; - FSE_DState_t state1; - FSE_DState_t state2; - size_t errorCode; - - /* Init */ - errorCode = FSE_initDStream(&bitD, cSrc, cSrcSize); /* replaced last arg by maxCompressed Size */ - if (FSE_isError(errorCode)) return errorCode; - - FSE_initDState(&state1, &bitD, dt); - FSE_initDState(&state2, &bitD, dt); - -#define FSE_GETSYMBOL(statePtr) fast ? FSE_decodeSymbolFast(statePtr, &bitD) : FSE_decodeSymbol(statePtr, &bitD) - - /* 4 symbols per loop */ - for ( ; (FSE_reloadDStream(&bitD)==FSE_DStream_unfinished) && (op sizeof(bitD.bitContainer)*8) /* This test must be static */ - FSE_reloadDStream(&bitD); - - op[1] = FSE_GETSYMBOL(&state2); - - if (FSE_MAX_TABLELOG*4+7 > sizeof(bitD.bitContainer)*8) /* This test must be static */ - { if (FSE_reloadDStream(&bitD) > FSE_DStream_unfinished) { op+=2; break; } } - - op[2] = FSE_GETSYMBOL(&state1); - - if (FSE_MAX_TABLELOG*2+7 > sizeof(bitD.bitContainer)*8) /* This test must be static */ - FSE_reloadDStream(&bitD); - - op[3] = FSE_GETSYMBOL(&state2); - } - - /* tail */ - /* note : FSE_reloadDStream(&bitD) >= FSE_DStream_partiallyFilled; Ends at exactly FSE_DStream_completed */ - while (1) - { - if ( (FSE_reloadDStream(&bitD)>FSE_DStream_completed) || (op==omax) || (FSE_endOfDStream(&bitD) && (fast || FSE_endOfDState(&state1))) ) - break; - - *op++ = FSE_GETSYMBOL(&state1); - - if ( (FSE_reloadDStream(&bitD)>FSE_DStream_completed) || (op==omax) || (FSE_endOfDStream(&bitD) && (fast || FSE_endOfDState(&state2))) ) - break; - - *op++ = FSE_GETSYMBOL(&state2); - } - - /* end ? */ - if (FSE_endOfDStream(&bitD) && FSE_endOfDState(&state1) && FSE_endOfDState(&state2)) - return op-ostart; - - if (op==omax) return (size_t)-FSE_ERROR_dstSize_tooSmall; /* dst buffer is full, but cSrc unfinished */ - - return (size_t)-FSE_ERROR_corruptionDetected; -} - - -static size_t FSE_decompress_usingDTable(void* dst, size_t originalSize, - const void* cSrc, size_t cSrcSize, - const FSE_DTable* dt) -{ - FSE_DTableHeader DTableH; - memcpy(&DTableH, dt, sizeof(DTableH)); /* memcpy() into local variable, to avoid strict aliasing warning */ - - /* select fast mode (static) */ - if (DTableH.fastMode) return FSE_decompress_usingDTable_generic(dst, originalSize, cSrc, cSrcSize, dt, 1); - return FSE_decompress_usingDTable_generic(dst, originalSize, cSrc, cSrcSize, dt, 0); -} - - -static size_t FSE_decompress(void* dst, size_t maxDstSize, const void* cSrc, size_t cSrcSize) -{ - const BYTE* const istart = (const BYTE*)cSrc; - const BYTE* ip = istart; - short counting[FSE_MAX_SYMBOL_VALUE+1]; - DTable_max_t dt; /* Static analyzer seems unable to understand this table will be properly initialized later */ - unsigned tableLog; - unsigned maxSymbolValue = FSE_MAX_SYMBOL_VALUE; - size_t errorCode; - - if (cSrcSize<2) return (size_t)-FSE_ERROR_srcSize_wrong; /* too small input size */ - - /* normal FSE decoding mode */ - errorCode = FSE_readNCount (counting, &maxSymbolValue, &tableLog, istart, cSrcSize); - if (FSE_isError(errorCode)) return errorCode; - if (errorCode >= cSrcSize) return (size_t)-FSE_ERROR_srcSize_wrong; /* too small input size */ - ip += errorCode; - cSrcSize -= errorCode; - - errorCode = FSE_buildDTable (dt, counting, maxSymbolValue, tableLog); - if (FSE_isError(errorCode)) return errorCode; - - /* always return, even if it is an error code */ - return FSE_decompress_usingDTable (dst, maxDstSize, ip, cSrcSize, dt); -} - - - -/* ******************************************************* -* Huff0 : Huffman block compression -*********************************************************/ -#define HUF_MAX_SYMBOL_VALUE 255 -#define HUF_DEFAULT_TABLELOG 12 /* used by default, when not specified */ -#define HUF_MAX_TABLELOG 12 /* max possible tableLog; for allocation purpose; can be modified */ -#define HUF_ABSOLUTEMAX_TABLELOG 16 /* absolute limit of HUF_MAX_TABLELOG. Beyond that value, code does not work */ -#if (HUF_MAX_TABLELOG > HUF_ABSOLUTEMAX_TABLELOG) -# error "HUF_MAX_TABLELOG is too large !" -#endif - -typedef struct HUF_CElt_s { - U16 val; - BYTE nbBits; -} HUF_CElt ; - -typedef struct nodeElt_s { - U32 count; - U16 parent; - BYTE byte; - BYTE nbBits; -} nodeElt; - - -/* ******************************************************* -* Huff0 : Huffman block decompression -*********************************************************/ -typedef struct { - BYTE byte; - BYTE nbBits; -} HUF_DElt; - -static size_t HUF_readDTable (U16* DTable, const void* src, size_t srcSize) -{ - BYTE huffWeight[HUF_MAX_SYMBOL_VALUE + 1]; - U32 rankVal[HUF_ABSOLUTEMAX_TABLELOG + 1]; /* large enough for values from 0 to 16 */ - U32 weightTotal; - U32 maxBits; - const BYTE* ip = (const BYTE*) src; - size_t iSize; - size_t oSize; - U32 n; - U32 nextRankStart; - void* ptr = DTable+1; - HUF_DElt* const dt = (HUF_DElt*)ptr; - - if (!srcSize) return (size_t)-FSE_ERROR_srcSize_wrong; - iSize = ip[0]; - - FSE_STATIC_ASSERT(sizeof(HUF_DElt) == sizeof(U16)); /* if compilation fails here, assertion is false */ - //memset(huffWeight, 0, sizeof(huffWeight)); /* should not be necessary, but some analyzer complain ... */ - if (iSize >= 128) /* special header */ - { - if (iSize >= (242)) /* RLE */ - { - static int l[14] = { 1, 2, 3, 4, 7, 8, 15, 16, 31, 32, 63, 64, 127, 128 }; - oSize = l[iSize-242]; - memset(huffWeight, 1, sizeof(huffWeight)); - iSize = 0; - } - else /* Incompressible */ - { - oSize = iSize - 127; - iSize = ((oSize+1)/2); - if (iSize+1 > srcSize) return (size_t)-FSE_ERROR_srcSize_wrong; - ip += 1; - for (n=0; n> 4; - huffWeight[n+1] = ip[n/2] & 15; - } - } - } - else /* header compressed with FSE (normal case) */ - { - if (iSize+1 > srcSize) return (size_t)-FSE_ERROR_srcSize_wrong; - oSize = FSE_decompress(huffWeight, HUF_MAX_SYMBOL_VALUE, ip+1, iSize); /* max 255 values decoded, last one is implied */ - if (FSE_isError(oSize)) return oSize; - } - - /* collect weight stats */ - memset(rankVal, 0, sizeof(rankVal)); - weightTotal = 0; - for (n=0; n= HUF_ABSOLUTEMAX_TABLELOG) return (size_t)-FSE_ERROR_corruptionDetected; - rankVal[huffWeight[n]]++; - weightTotal += (1 << huffWeight[n]) >> 1; - } - if (weightTotal == 0) return (size_t)-FSE_ERROR_corruptionDetected; - - /* get last non-null symbol weight (implied, total must be 2^n) */ - maxBits = FSE_highbit32(weightTotal) + 1; - if (maxBits > DTable[0]) return (size_t)-FSE_ERROR_tableLog_tooLarge; /* DTable is too small */ - DTable[0] = (U16)maxBits; - { - U32 total = 1 << maxBits; - U32 rest = total - weightTotal; - U32 verif = 1 << FSE_highbit32(rest); - U32 lastWeight = FSE_highbit32(rest) + 1; - if (verif != rest) return (size_t)-FSE_ERROR_corruptionDetected; /* last value must be a clean power of 2 */ - huffWeight[oSize] = (BYTE)lastWeight; - rankVal[lastWeight]++; - } - - /* check tree construction validity */ - if ((rankVal[1] < 2) || (rankVal[1] & 1)) return (size_t)-FSE_ERROR_corruptionDetected; /* by construction : at least 2 elts of rank 1, must be even */ - - /* Prepare ranks */ - nextRankStart = 0; - for (n=1; n<=maxBits; n++) - { - U32 current = nextRankStart; - nextRankStart += (rankVal[n] << (n-1)); - rankVal[n] = current; - } - - /* fill DTable */ - for (n=0; n<=oSize; n++) - { - const U32 w = huffWeight[n]; - const U32 length = (1 << w) >> 1; - U32 i; - HUF_DElt D; - D.byte = (BYTE)n; D.nbBits = (BYTE)(maxBits + 1 - w); - for (i = rankVal[w]; i < rankVal[w] + length; i++) - dt[i] = D; - rankVal[w] += length; - } - - return iSize+1; -} - - -static BYTE HUF_decodeSymbol(FSE_DStream_t* Dstream, const HUF_DElt* dt, const U32 dtLog) -{ - const size_t val = FSE_lookBitsFast(Dstream, dtLog); /* note : dtLog >= 1 */ - const BYTE c = dt[val].byte; - FSE_skipBits(Dstream, dt[val].nbBits); - return c; -} - -static size_t HUF_decompress_usingDTable( /* -3% slower when non static */ - void* dst, size_t maxDstSize, - const void* cSrc, size_t cSrcSize, - const U16* DTable) -{ - if (cSrcSize < 6) return (size_t)-FSE_ERROR_srcSize_wrong; - { - BYTE* const ostart = (BYTE*) dst; - BYTE* op = ostart; - BYTE* const omax = op + maxDstSize; - BYTE* const olimit = maxDstSize < 15 ? op : omax-15; - - const void* ptr = DTable; - const HUF_DElt* const dt = (const HUF_DElt*)(ptr)+1; - const U32 dtLog = DTable[0]; - size_t errorCode; - U32 reloadStatus; - - /* Init */ - - const U16* jumpTable = (const U16*)cSrc; - const size_t length1 = FSE_readLE16(jumpTable); - const size_t length2 = FSE_readLE16(jumpTable+1); - const size_t length3 = FSE_readLE16(jumpTable+2); - const size_t length4 = cSrcSize - 6 - length1 - length2 - length3; /* check coherency !! */ - const char* const start1 = (const char*)(cSrc) + 6; - const char* const start2 = start1 + length1; - const char* const start3 = start2 + length2; - const char* const start4 = start3 + length3; - FSE_DStream_t bitD1, bitD2, bitD3, bitD4; - - if (length1+length2+length3+6 >= cSrcSize) return (size_t)-FSE_ERROR_srcSize_wrong; - - errorCode = FSE_initDStream(&bitD1, start1, length1); - if (FSE_isError(errorCode)) return errorCode; - errorCode = FSE_initDStream(&bitD2, start2, length2); - if (FSE_isError(errorCode)) return errorCode; - errorCode = FSE_initDStream(&bitD3, start3, length3); - if (FSE_isError(errorCode)) return errorCode; - errorCode = FSE_initDStream(&bitD4, start4, length4); - if (FSE_isError(errorCode)) return errorCode; - - reloadStatus=FSE_reloadDStream(&bitD2); - - /* 16 symbols per loop */ - for ( ; (reloadStatus12)) FSE_reloadDStream(&Dstream) - - #define HUF_DECODE_SYMBOL_2(n, Dstream) \ - op[n] = HUF_decodeSymbol(&Dstream, dt, dtLog); \ - if (FSE_32bits()) FSE_reloadDStream(&Dstream) - - HUF_DECODE_SYMBOL_1( 0, bitD1); - HUF_DECODE_SYMBOL_1( 1, bitD2); - HUF_DECODE_SYMBOL_1( 2, bitD3); - HUF_DECODE_SYMBOL_1( 3, bitD4); - HUF_DECODE_SYMBOL_2( 4, bitD1); - HUF_DECODE_SYMBOL_2( 5, bitD2); - HUF_DECODE_SYMBOL_2( 6, bitD3); - HUF_DECODE_SYMBOL_2( 7, bitD4); - HUF_DECODE_SYMBOL_1( 8, bitD1); - HUF_DECODE_SYMBOL_1( 9, bitD2); - HUF_DECODE_SYMBOL_1(10, bitD3); - HUF_DECODE_SYMBOL_1(11, bitD4); - HUF_DECODE_SYMBOL_0(12, bitD1); - HUF_DECODE_SYMBOL_0(13, bitD2); - HUF_DECODE_SYMBOL_0(14, bitD3); - HUF_DECODE_SYMBOL_0(15, bitD4); - } - - if (reloadStatus!=FSE_DStream_completed) /* not complete : some bitStream might be FSE_DStream_unfinished */ - return (size_t)-FSE_ERROR_corruptionDetected; - - /* tail */ - { - /* bitTail = bitD1; */ /* *much* slower : -20% !??! */ - FSE_DStream_t bitTail; - bitTail.ptr = bitD1.ptr; - bitTail.bitsConsumed = bitD1.bitsConsumed; - bitTail.bitContainer = bitD1.bitContainer; /* required in case of FSE_DStream_endOfBuffer */ - bitTail.start = start1; - for ( ; (FSE_reloadDStream(&bitTail) < FSE_DStream_completed) && (op= cSrcSize) return (size_t)-FSE_ERROR_srcSize_wrong; - ip += errorCode; - cSrcSize -= errorCode; - - return HUF_decompress_usingDTable (dst, maxDstSize, ip, cSrcSize, DTable); -} - - -#endif /* FSE_COMMONDEFS_ONLY */ - -/* - zstd - standard compression library - Copyright (C) 2014-2015, Yann Collet. - - BSD 2-Clause License (https://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 : - - zstd source repository : https://github.com/Cyan4973/zstd - - ztsd public forum : https://groups.google.com/forum/#!forum/lz4c -*/ - -/**************************************************************** -* Tuning parameters -*****************************************************************/ -/* MEMORY_USAGE : -* Memory usage formula : N->2^N Bytes (examples : 10 -> 1KB; 12 -> 4KB ; 16 -> 64KB; 20 -> 1MB; etc.) -* Increasing memory usage improves compression ratio -* Reduced memory usage can improve speed, due to cache effect */ -#define ZSTD_MEMORY_USAGE 17 - - -/************************************** - CPU Feature Detection -**************************************/ -/* - * Automated efficient unaligned memory access detection - * Based on known hardware architectures - * This list will be updated thanks to feedbacks - */ -#if defined(CPU_HAS_EFFICIENT_UNALIGNED_MEMORY_ACCESS) \ - || defined(__ARM_FEATURE_UNALIGNED) \ - || defined(__i386__) || defined(__x86_64__) \ - || defined(_M_IX86) || defined(_M_X64) \ - || defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_8__) \ - || (defined(_M_ARM) && (_M_ARM >= 7)) -# define ZSTD_UNALIGNED_ACCESS 1 -#else -# define ZSTD_UNALIGNED_ACCESS 0 -#endif - - -/******************************************************** -* Includes -*********************************************************/ -#include /* calloc */ -#include /* memcpy, memmove */ -#include /* debug : printf */ - - -/******************************************************** -* Compiler specifics -*********************************************************/ -#ifdef __AVX2__ -# include /* AVX2 intrinsics */ -#endif - -#ifdef _MSC_VER /* Visual Studio */ -# include /* For Visual 2005 */ -# pragma warning(disable : 4127) /* disable: C4127: conditional expression is constant */ -# pragma warning(disable : 4324) /* disable: C4324: padded structure */ -#endif - - -#ifndef MEM_ACCESS_MODULE -#define MEM_ACCESS_MODULE -/******************************************************** -* Basic Types -*********************************************************/ -#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 */ -# if defined(_AIX) -# include -# else -# include /* intptr_t */ -# endif -typedef uint8_t BYTE; -typedef uint16_t U16; -typedef int16_t S16; -typedef uint32_t U32; -typedef int32_t S32; -typedef uint64_t U64; -#else -typedef unsigned char BYTE; -typedef unsigned short U16; -typedef signed short S16; -typedef unsigned int U32; -typedef signed int S32; -typedef unsigned long long U64; -#endif - -#endif /* MEM_ACCESS_MODULE */ - - -/******************************************************** -* Constants -*********************************************************/ -static const U32 ZSTD_magicNumber = 0xFD2FB51E; /* 3rd version : seqNb header */ - -#define HASH_LOG (ZSTD_MEMORY_USAGE - 2) -#define HASH_TABLESIZE (1 << HASH_LOG) -#define HASH_MASK (HASH_TABLESIZE - 1) - -#define KNUTH 2654435761 - -#define BIT7 128 -#define BIT6 64 -#define BIT5 32 -#define BIT4 16 - -#define KB *(1 <<10) -#define MB *(1 <<20) -#define GB *(1U<<30) - -#define BLOCKSIZE (128 KB) /* define, for static allocation */ - -#define WORKPLACESIZE (BLOCKSIZE*3) -#define MINMATCH 4 -#define MLbits 7 -#define LLbits 6 -#define Offbits 5 -#define MaxML ((1<>3]; -#else - U32 hashTable[HASH_TABLESIZE]; -#endif - BYTE buffer[WORKPLACESIZE]; -} cctxi_t; - - - - -/************************************** -* Error Management -**************************************/ -/* published entry point */ -unsigned ZSTDv01_isError(size_t code) { return ERR_isError(code); } - - -/************************************** -* Tool functions -**************************************/ -#define ZSTD_VERSION_MAJOR 0 /* for breaking interface changes */ -#define ZSTD_VERSION_MINOR 1 /* for new (non-breaking) interface capabilities */ -#define ZSTD_VERSION_RELEASE 3 /* for tweaks, bug-fixes, or development */ -#define ZSTD_VERSION_NUMBER (ZSTD_VERSION_MAJOR *100*100 + ZSTD_VERSION_MINOR *100 + ZSTD_VERSION_RELEASE) - -/************************************************************** -* Decompression code -**************************************************************/ - -static size_t ZSTDv01_getcBlockSize(const void* src, size_t srcSize, blockProperties_t* bpPtr) -{ - const BYTE* const in = (const BYTE* const)src; - BYTE headerFlags; - U32 cSize; - - if (srcSize < 3) return ERROR(srcSize_wrong); - - headerFlags = *in; - cSize = in[2] + (in[1]<<8) + ((in[0] & 7)<<16); - - bpPtr->blockType = (blockType_t)(headerFlags >> 6); - bpPtr->origSize = (bpPtr->blockType == bt_rle) ? cSize : 0; - - if (bpPtr->blockType == bt_end) return 0; - if (bpPtr->blockType == bt_rle) return 1; - return cSize; -} - - -static size_t ZSTD_copyUncompressedBlock(void* dst, size_t maxDstSize, const void* src, size_t srcSize) -{ - if (srcSize > maxDstSize) return ERROR(dstSize_tooSmall); - if (srcSize > 0) { - memcpy(dst, src, srcSize); - } - return srcSize; -} - - -static size_t ZSTD_decompressLiterals(void* ctx, - void* dst, size_t maxDstSize, - const void* src, size_t srcSize) -{ - BYTE* op = (BYTE*)dst; - BYTE* const oend = op + maxDstSize; - const BYTE* ip = (const BYTE*)src; - size_t errorCode; - size_t litSize; - - /* check : minimum 2, for litSize, +1, for content */ - if (srcSize <= 3) return ERROR(corruption_detected); - - litSize = ip[1] + (ip[0]<<8); - litSize += ((ip[-3] >> 3) & 7) << 16; /* mmmmh.... */ - op = oend - litSize; - - (void)ctx; - if (litSize > maxDstSize) return ERROR(dstSize_tooSmall); - errorCode = HUF_decompress(op, litSize, ip+2, srcSize-2); - if (FSE_isError(errorCode)) return ERROR(GENERIC); - return litSize; -} - - -static size_t ZSTDv01_decodeLiteralsBlock(void* ctx, - void* dst, size_t maxDstSize, - const BYTE** litStart, size_t* litSize, - const void* src, size_t srcSize) -{ - const BYTE* const istart = (const BYTE* const)src; - const BYTE* ip = istart; - BYTE* const ostart = (BYTE* const)dst; - BYTE* const oend = ostart + maxDstSize; - blockProperties_t litbp; - - size_t litcSize = ZSTDv01_getcBlockSize(src, srcSize, &litbp); - if (ZSTDv01_isError(litcSize)) return litcSize; - if (litcSize > srcSize - ZSTD_blockHeaderSize) return ERROR(srcSize_wrong); - ip += ZSTD_blockHeaderSize; - - switch(litbp.blockType) - { - case bt_raw: - *litStart = ip; - ip += litcSize; - *litSize = litcSize; - break; - case bt_rle: - { - size_t rleSize = litbp.origSize; - if (rleSize>maxDstSize) return ERROR(dstSize_tooSmall); - if (!srcSize) return ERROR(srcSize_wrong); - if (rleSize > 0) { - memset(oend - rleSize, *ip, rleSize); - } - *litStart = oend - rleSize; - *litSize = rleSize; - ip++; - break; - } - case bt_compressed: - { - size_t decodedLitSize = ZSTD_decompressLiterals(ctx, dst, maxDstSize, ip, litcSize); - if (ZSTDv01_isError(decodedLitSize)) return decodedLitSize; - *litStart = oend - decodedLitSize; - *litSize = decodedLitSize; - ip += litcSize; - break; - } - case bt_end: - default: - return ERROR(GENERIC); - } - - return ip-istart; -} - - -static size_t ZSTDv01_decodeSeqHeaders(int* nbSeq, const BYTE** dumpsPtr, size_t* dumpsLengthPtr, - FSE_DTable* DTableLL, FSE_DTable* DTableML, FSE_DTable* DTableOffb, - const void* src, size_t srcSize) -{ - const BYTE* const istart = (const BYTE* const)src; - const BYTE* ip = istart; - const BYTE* const iend = istart + srcSize; - U32 LLtype, Offtype, MLtype; - U32 LLlog, Offlog, MLlog; - size_t dumpsLength; - - /* check */ - if (srcSize < 5) return ERROR(srcSize_wrong); - - /* SeqHead */ - *nbSeq = ZSTD_readLE16(ip); ip+=2; - LLtype = *ip >> 6; - Offtype = (*ip >> 4) & 3; - MLtype = (*ip >> 2) & 3; - if (*ip & 2) - { - dumpsLength = ip[2]; - dumpsLength += ip[1] << 8; - ip += 3; - } - else - { - dumpsLength = ip[1]; - dumpsLength += (ip[0] & 1) << 8; - ip += 2; - } - *dumpsPtr = ip; - ip += dumpsLength; - *dumpsLengthPtr = dumpsLength; - - /* check */ - if (ip > iend-3) return ERROR(srcSize_wrong); /* min : all 3 are "raw", hence no header, but at least xxLog bits per type */ - - /* sequences */ - { - S16 norm[MaxML+1]; /* assumption : MaxML >= MaxLL and MaxOff */ - size_t headerSize; - - /* Build DTables */ - switch(LLtype) - { - case bt_rle : - LLlog = 0; - FSE_buildDTable_rle(DTableLL, *ip++); break; - case bt_raw : - LLlog = LLbits; - FSE_buildDTable_raw(DTableLL, LLbits); break; - default : - { U32 max = MaxLL; - headerSize = FSE_readNCount(norm, &max, &LLlog, ip, iend-ip); - if (FSE_isError(headerSize)) return ERROR(GENERIC); - if (LLlog > LLFSELog) return ERROR(corruption_detected); - ip += headerSize; - FSE_buildDTable(DTableLL, norm, max, LLlog); - } } - - switch(Offtype) - { - case bt_rle : - Offlog = 0; - if (ip > iend-2) return ERROR(srcSize_wrong); /* min : "raw", hence no header, but at least xxLog bits */ - FSE_buildDTable_rle(DTableOffb, *ip++); break; - case bt_raw : - Offlog = Offbits; - FSE_buildDTable_raw(DTableOffb, Offbits); break; - default : - { U32 max = MaxOff; - headerSize = FSE_readNCount(norm, &max, &Offlog, ip, iend-ip); - if (FSE_isError(headerSize)) return ERROR(GENERIC); - if (Offlog > OffFSELog) return ERROR(corruption_detected); - ip += headerSize; - FSE_buildDTable(DTableOffb, norm, max, Offlog); - } } - - switch(MLtype) - { - case bt_rle : - MLlog = 0; - if (ip > iend-2) return ERROR(srcSize_wrong); /* min : "raw", hence no header, but at least xxLog bits */ - FSE_buildDTable_rle(DTableML, *ip++); break; - case bt_raw : - MLlog = MLbits; - FSE_buildDTable_raw(DTableML, MLbits); break; - default : - { U32 max = MaxML; - headerSize = FSE_readNCount(norm, &max, &MLlog, ip, iend-ip); - if (FSE_isError(headerSize)) return ERROR(GENERIC); - if (MLlog > MLFSELog) return ERROR(corruption_detected); - ip += headerSize; - FSE_buildDTable(DTableML, norm, max, MLlog); - } } } - - return ip-istart; -} - - -typedef struct { - size_t litLength; - size_t offset; - size_t matchLength; -} seq_t; - -typedef struct { - FSE_DStream_t DStream; - FSE_DState_t stateLL; - FSE_DState_t stateOffb; - FSE_DState_t stateML; - size_t prevOffset; - const BYTE* dumps; - const BYTE* dumpsEnd; -} seqState_t; - - -static void ZSTD_decodeSequence(seq_t* seq, seqState_t* seqState) -{ - size_t litLength; - size_t prevOffset; - size_t offset; - size_t matchLength; - const BYTE* dumps = seqState->dumps; - const BYTE* const de = seqState->dumpsEnd; - - /* Literal length */ - litLength = FSE_decodeSymbol(&(seqState->stateLL), &(seqState->DStream)); - prevOffset = litLength ? seq->offset : seqState->prevOffset; - seqState->prevOffset = seq->offset; - if (litLength == MaxLL) - { - const U32 add = dumpsstateOffb), &(seqState->DStream)); - if (ZSTD_32bits()) FSE_reloadDStream(&(seqState->DStream)); - nbBits = offsetCode - 1; - if (offsetCode==0) nbBits = 0; /* cmove */ - offset = ((size_t)1 << (nbBits & ((sizeof(offset)*8)-1))) + FSE_readBits(&(seqState->DStream), nbBits); - if (ZSTD_32bits()) FSE_reloadDStream(&(seqState->DStream)); - if (offsetCode==0) offset = prevOffset; - } - - /* MatchLength */ - matchLength = FSE_decodeSymbol(&(seqState->stateML), &(seqState->DStream)); - if (matchLength == MaxML) - { - const U32 add = dumpslitLength = litLength; - seq->offset = offset; - seq->matchLength = matchLength; - seqState->dumps = dumps; -} - - -static size_t ZSTD_execSequence(BYTE* op, - seq_t sequence, - const BYTE** litPtr, const BYTE* const litLimit, - BYTE* const base, BYTE* const oend) -{ - static const int dec32table[] = {0, 1, 2, 1, 4, 4, 4, 4}; /* added */ - static const int dec64table[] = {8, 8, 8, 7, 8, 9,10,11}; /* subtracted */ - const BYTE* const ostart = op; - BYTE* const oLitEnd = op + sequence.litLength; - const size_t litLength = sequence.litLength; - BYTE* const endMatch = op + litLength + sequence.matchLength; /* risk : address space overflow (32-bits) */ - const BYTE* const litEnd = *litPtr + litLength; - - /* checks */ - size_t const seqLength = sequence.litLength + sequence.matchLength; - - if (seqLength > (size_t)(oend - op)) return ERROR(dstSize_tooSmall); - if (sequence.litLength > (size_t)(litLimit - *litPtr)) return ERROR(corruption_detected); - /* Now we know there are no overflow in literal nor match lengths, can use pointer checks */ - if (sequence.offset > (U32)(oLitEnd - base)) return ERROR(corruption_detected); - - if (endMatch > oend) return ERROR(dstSize_tooSmall); /* overwrite beyond dst buffer */ - if (litEnd > litLimit) return ERROR(corruption_detected); /* overRead beyond lit buffer */ - if (sequence.matchLength > (size_t)(*litPtr-op)) return ERROR(dstSize_tooSmall); /* overwrite literal segment */ - - /* copy Literals */ - ZSTD_memmove(op, *litPtr, sequence.litLength); /* note : v0.1 seems to allow scenarios where output or input are close to end of buffer */ - - op += litLength; - *litPtr = litEnd; /* update for next sequence */ - - /* check : last match must be at a minimum distance of 8 from end of dest buffer */ - if (oend-op < 8) return ERROR(dstSize_tooSmall); - - /* copy Match */ - { - const U32 overlapRisk = (((size_t)(litEnd - endMatch)) < 12); - const BYTE* match = op - sequence.offset; /* possible underflow at op - offset ? */ - size_t qutt = 12; - U64 saved[2]; - - /* check */ - if (match < base) return ERROR(corruption_detected); - if (sequence.offset > (size_t)base) return ERROR(corruption_detected); - - /* save beginning of literal sequence, in case of write overlap */ - if (overlapRisk) - { - if ((endMatch + qutt) > oend) qutt = oend-endMatch; - memcpy(saved, endMatch, qutt); - } - - if (sequence.offset < 8) - { - const int dec64 = dec64table[sequence.offset]; - op[0] = match[0]; - op[1] = match[1]; - op[2] = match[2]; - op[3] = match[3]; - match += dec32table[sequence.offset]; - ZSTD_copy4(op+4, match); - match -= dec64; - } else { ZSTD_copy8(op, match); } - op += 8; match += 8; - - if (endMatch > oend-(16-MINMATCH)) - { - if (op < oend-8) - { - ZSTD_wildcopy(op, match, (oend-8) - op); - match += (oend-8) - op; - op = oend-8; - } - while (opLLTable; - U32* DTableML = dctx->MLTable; - U32* DTableOffb = dctx->OffTable; - BYTE* const base = (BYTE*) (dctx->base); - - /* Build Decoding Tables */ - errorCode = ZSTDv01_decodeSeqHeaders(&nbSeq, &dumps, &dumpsLength, - DTableLL, DTableML, DTableOffb, - ip, iend-ip); - if (ZSTDv01_isError(errorCode)) return errorCode; - ip += errorCode; - - /* Regen sequences */ - { - seq_t sequence; - seqState_t seqState; - - memset(&sequence, 0, sizeof(sequence)); - seqState.dumps = dumps; - seqState.dumpsEnd = dumps + dumpsLength; - seqState.prevOffset = 1; - errorCode = FSE_initDStream(&(seqState.DStream), ip, iend-ip); - if (FSE_isError(errorCode)) return ERROR(corruption_detected); - FSE_initDState(&(seqState.stateLL), &(seqState.DStream), DTableLL); - FSE_initDState(&(seqState.stateOffb), &(seqState.DStream), DTableOffb); - FSE_initDState(&(seqState.stateML), &(seqState.DStream), DTableML); - - for ( ; (FSE_reloadDStream(&(seqState.DStream)) <= FSE_DStream_completed) && (nbSeq>0) ; ) - { - size_t oneSeqSize; - nbSeq--; - ZSTD_decodeSequence(&sequence, &seqState); - oneSeqSize = ZSTD_execSequence(op, sequence, &litPtr, litEnd, base, oend); - if (ZSTDv01_isError(oneSeqSize)) return oneSeqSize; - op += oneSeqSize; - } - - /* check if reached exact end */ - if ( !FSE_endOfDStream(&(seqState.DStream)) ) return ERROR(corruption_detected); /* requested too much : data is corrupted */ - if (nbSeq<0) return ERROR(corruption_detected); /* requested too many sequences : data is corrupted */ - - /* last literal segment */ - { - size_t lastLLSize = litEnd - litPtr; - if (op+lastLLSize > oend) return ERROR(dstSize_tooSmall); - if (lastLLSize > 0) { - if (op != litPtr) memmove(op, litPtr, lastLLSize); - op += lastLLSize; - } - } - } - - return op-ostart; -} - - -static size_t ZSTD_decompressBlock( - void* ctx, - void* dst, size_t maxDstSize, - const void* src, size_t srcSize) -{ - /* blockType == blockCompressed, srcSize is trusted */ - const BYTE* ip = (const BYTE*)src; - const BYTE* litPtr = NULL; - size_t litSize = 0; - size_t errorCode; - - /* Decode literals sub-block */ - errorCode = ZSTDv01_decodeLiteralsBlock(ctx, dst, maxDstSize, &litPtr, &litSize, src, srcSize); - if (ZSTDv01_isError(errorCode)) return errorCode; - ip += errorCode; - srcSize -= errorCode; - - return ZSTD_decompressSequences(ctx, dst, maxDstSize, ip, srcSize, litPtr, litSize); -} - - -size_t ZSTDv01_decompressDCtx(void* ctx, void* dst, size_t maxDstSize, const void* src, size_t srcSize) -{ - const BYTE* ip = (const BYTE*)src; - const BYTE* iend = ip + srcSize; - BYTE* const ostart = (BYTE* const)dst; - BYTE* op = ostart; - BYTE* const oend = ostart + maxDstSize; - size_t remainingSize = srcSize; - U32 magicNumber; - size_t errorCode=0; - blockProperties_t blockProperties; - - /* Frame Header */ - if (srcSize < ZSTD_frameHeaderSize+ZSTD_blockHeaderSize) return ERROR(srcSize_wrong); - magicNumber = ZSTD_readBE32(src); - if (magicNumber != ZSTD_magicNumber) return ERROR(prefix_unknown); - ip += ZSTD_frameHeaderSize; remainingSize -= ZSTD_frameHeaderSize; - - /* Loop on each block */ - while (1) - { - size_t blockSize = ZSTDv01_getcBlockSize(ip, iend-ip, &blockProperties); - if (ZSTDv01_isError(blockSize)) return blockSize; - - ip += ZSTD_blockHeaderSize; - remainingSize -= ZSTD_blockHeaderSize; - if (blockSize > remainingSize) return ERROR(srcSize_wrong); - - switch(blockProperties.blockType) - { - case bt_compressed: - errorCode = ZSTD_decompressBlock(ctx, op, oend-op, ip, blockSize); - break; - case bt_raw : - errorCode = ZSTD_copyUncompressedBlock(op, oend-op, ip, blockSize); - break; - case bt_rle : - return ERROR(GENERIC); /* not yet supported */ - break; - case bt_end : - /* end of frame */ - if (remainingSize) return ERROR(srcSize_wrong); - break; - default: - return ERROR(GENERIC); - } - if (blockSize == 0) break; /* bt_end */ - - if (ZSTDv01_isError(errorCode)) return errorCode; - op += errorCode; - ip += blockSize; - remainingSize -= blockSize; - } - - return op-ostart; -} - -size_t ZSTDv01_decompress(void* dst, size_t maxDstSize, const void* src, size_t srcSize) -{ - dctx_t ctx; - ctx.base = dst; - return ZSTDv01_decompressDCtx(&ctx, dst, maxDstSize, src, srcSize); -} - -/* ZSTD_errorFrameSizeInfoLegacy() : - assumes `cSize` and `dBound` are _not_ NULL */ -static void ZSTD_errorFrameSizeInfoLegacy(size_t* cSize, unsigned long long* dBound, size_t ret) -{ - *cSize = ret; - *dBound = ZSTD_CONTENTSIZE_ERROR; -} - -void ZSTDv01_findFrameSizeInfoLegacy(const void *src, size_t srcSize, size_t* cSize, unsigned long long* dBound) -{ - const BYTE* ip = (const BYTE*)src; - size_t remainingSize = srcSize; - size_t nbBlocks = 0; - U32 magicNumber; - blockProperties_t blockProperties; - - /* Frame Header */ - if (srcSize < ZSTD_frameHeaderSize+ZSTD_blockHeaderSize) { - ZSTD_errorFrameSizeInfoLegacy(cSize, dBound, ERROR(srcSize_wrong)); - return; - } - magicNumber = ZSTD_readBE32(src); - if (magicNumber != ZSTD_magicNumber) { - ZSTD_errorFrameSizeInfoLegacy(cSize, dBound, ERROR(prefix_unknown)); - return; - } - ip += ZSTD_frameHeaderSize; remainingSize -= ZSTD_frameHeaderSize; - - /* Loop on each block */ - while (1) - { - size_t blockSize = ZSTDv01_getcBlockSize(ip, remainingSize, &blockProperties); - if (ZSTDv01_isError(blockSize)) { - ZSTD_errorFrameSizeInfoLegacy(cSize, dBound, blockSize); - return; - } - - ip += ZSTD_blockHeaderSize; - remainingSize -= ZSTD_blockHeaderSize; - if (blockSize > remainingSize) { - ZSTD_errorFrameSizeInfoLegacy(cSize, dBound, ERROR(srcSize_wrong)); - return; - } - - if (blockSize == 0) break; /* bt_end */ - - ip += blockSize; - remainingSize -= blockSize; - nbBlocks++; - } - - *cSize = ip - (const BYTE*)src; - *dBound = nbBlocks * BLOCKSIZE; -} - -/******************************* -* Streaming Decompression API -*******************************/ - -size_t ZSTDv01_resetDCtx(ZSTDv01_Dctx* dctx) -{ - dctx->expected = ZSTD_frameHeaderSize; - dctx->phase = 0; - dctx->previousDstEnd = NULL; - dctx->base = NULL; - return 0; -} - -ZSTDv01_Dctx* ZSTDv01_createDCtx(void) -{ - ZSTDv01_Dctx* dctx = (ZSTDv01_Dctx*)malloc(sizeof(ZSTDv01_Dctx)); - if (dctx==NULL) return NULL; - ZSTDv01_resetDCtx(dctx); - return dctx; -} - -size_t ZSTDv01_freeDCtx(ZSTDv01_Dctx* dctx) -{ - free(dctx); - return 0; -} - -size_t ZSTDv01_nextSrcSizeToDecompress(ZSTDv01_Dctx* dctx) -{ - return ((dctx_t*)dctx)->expected; -} - -size_t ZSTDv01_decompressContinue(ZSTDv01_Dctx* dctx, void* dst, size_t maxDstSize, const void* src, size_t srcSize) -{ - dctx_t* ctx = (dctx_t*)dctx; - - /* Sanity check */ - if (srcSize != ctx->expected) return ERROR(srcSize_wrong); - if (dst != ctx->previousDstEnd) /* not contiguous */ - ctx->base = dst; - - /* Decompress : frame header */ - if (ctx->phase == 0) - { - /* Check frame magic header */ - U32 magicNumber = ZSTD_readBE32(src); - if (magicNumber != ZSTD_magicNumber) return ERROR(prefix_unknown); - ctx->phase = 1; - ctx->expected = ZSTD_blockHeaderSize; - return 0; - } - - /* Decompress : block header */ - if (ctx->phase == 1) - { - blockProperties_t bp; - size_t blockSize = ZSTDv01_getcBlockSize(src, ZSTD_blockHeaderSize, &bp); - if (ZSTDv01_isError(blockSize)) return blockSize; - if (bp.blockType == bt_end) - { - ctx->expected = 0; - ctx->phase = 0; - } - else - { - ctx->expected = blockSize; - ctx->bType = bp.blockType; - ctx->phase = 2; - } - - return 0; - } - - /* Decompress : block content */ - { - size_t rSize; - switch(ctx->bType) - { - case bt_compressed: - rSize = ZSTD_decompressBlock(ctx, dst, maxDstSize, src, srcSize); - break; - case bt_raw : - rSize = ZSTD_copyUncompressedBlock(dst, maxDstSize, src, srcSize); - break; - case bt_rle : - return ERROR(GENERIC); /* not yet handled */ - break; - case bt_end : /* should never happen (filtered at phase 1) */ - rSize = 0; - break; - default: - return ERROR(GENERIC); - } - ctx->phase = 1; - ctx->expected = ZSTD_blockHeaderSize; - ctx->previousDstEnd = (void*)( ((char*)dst) + rSize); - return rSize; - } - -} diff --git a/third_party/zstd/lib/legacy/zstd_v01.h b/third_party/zstd/lib/legacy/zstd_v01.h deleted file mode 100644 index 6ac876954..000000000 --- a/third_party/zstd/lib/legacy/zstd_v01.h +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (c) Yann Collet, Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under both the BSD-style license (found in the - * LICENSE file in the root directory of this source tree) and the GPLv2 (found - * in the COPYING file in the root directory of this source tree). - * You may select, at your option, one of the above-listed licenses. - */ - -#ifndef ZSTD_V01_H_28739879432 -#define ZSTD_V01_H_28739879432 - -#if defined (__cplusplus) -extern "C" { -#endif - -/* ************************************* -* Includes -***************************************/ -#include /* size_t */ - - -/* ************************************* -* Simple one-step function -***************************************/ -/** -ZSTDv01_decompress() : decompress ZSTD frames compliant with v0.1.x format - compressedSize : is the exact source size - maxOriginalSize : is the size of the 'dst' buffer, which must be already allocated. - It must be equal or larger than originalSize, otherwise decompression will fail. - return : the number of bytes decompressed into destination buffer (originalSize) - or an errorCode if it fails (which can be tested using ZSTDv01_isError()) -*/ -size_t ZSTDv01_decompress( void* dst, size_t maxOriginalSize, - const void* src, size_t compressedSize); - - /** - ZSTDv01_findFrameSizeInfoLegacy() : get the source length and decompressed bound of a ZSTD frame compliant with v0.1.x format - srcSize : The size of the 'src' buffer, at least as large as the frame pointed to by 'src' - cSize (output parameter) : the number of bytes that would be read to decompress this frame - or an error code if it fails (which can be tested using ZSTDv01_isError()) - dBound (output parameter) : an upper-bound for the decompressed size of the data in the frame - or ZSTD_CONTENTSIZE_ERROR if an error occurs - - note : assumes `cSize` and `dBound` are _not_ NULL. - */ -void ZSTDv01_findFrameSizeInfoLegacy(const void *src, size_t srcSize, - size_t* cSize, unsigned long long* dBound); - -/** -ZSTDv01_isError() : tells if the result of ZSTDv01_decompress() is an error -*/ -unsigned ZSTDv01_isError(size_t code); - - -/* ************************************* -* Advanced functions -***************************************/ -typedef struct ZSTDv01_Dctx_s ZSTDv01_Dctx; -ZSTDv01_Dctx* ZSTDv01_createDCtx(void); -size_t ZSTDv01_freeDCtx(ZSTDv01_Dctx* dctx); - -size_t ZSTDv01_decompressDCtx(void* ctx, - void* dst, size_t maxOriginalSize, - const void* src, size_t compressedSize); - -/* ************************************* -* Streaming functions -***************************************/ -size_t ZSTDv01_resetDCtx(ZSTDv01_Dctx* dctx); - -size_t ZSTDv01_nextSrcSizeToDecompress(ZSTDv01_Dctx* dctx); -size_t ZSTDv01_decompressContinue(ZSTDv01_Dctx* dctx, void* dst, size_t maxDstSize, const void* src, size_t srcSize); -/** - Use above functions alternatively. - ZSTD_nextSrcSizeToDecompress() tells how much bytes to provide as 'srcSize' to ZSTD_decompressContinue(). - ZSTD_decompressContinue() will use previous data blocks to improve compression if they are located prior to current block. - Result is the number of bytes regenerated within 'dst'. - It can be zero, which is not an error; it just means ZSTD_decompressContinue() has decoded some header. -*/ - -/* ************************************* -* Prefix - version detection -***************************************/ -#define ZSTDv01_magicNumber 0xFD2FB51E /* Big Endian version */ -#define ZSTDv01_magicNumberLE 0x1EB52FFD /* Little Endian version */ - - -#if defined (__cplusplus) -} -#endif - -#endif /* ZSTD_V01_H_28739879432 */ diff --git a/third_party/zstd/lib/legacy/zstd_v02.c b/third_party/zstd/lib/legacy/zstd_v02.c deleted file mode 100644 index e09bb4a24..000000000 --- a/third_party/zstd/lib/legacy/zstd_v02.c +++ /dev/null @@ -1,3477 +0,0 @@ -/* - * Copyright (c) Yann Collet, Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under both the BSD-style license (found in the - * LICENSE file in the root directory of this source tree) and the GPLv2 (found - * in the COPYING file in the root directory of this source tree). - * You may select, at your option, one of the above-listed licenses. - */ - - -#include /* size_t, ptrdiff_t */ -#include "zstd_v02.h" -#include "../common/error_private.h" - - -/****************************************** -* Compiler-specific -******************************************/ -#if defined(_MSC_VER) /* Visual Studio */ -# include /* _byteswap_ulong */ -# include /* _byteswap_* */ -#endif - - -/* ****************************************************************** - mem.h - low-level memory access routines - Copyright (C) 2013-2015, Yann Collet. - - BSD 2-Clause License (https://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 : - - FSE source repository : https://github.com/Cyan4973/FiniteStateEntropy - - Public forum : https://groups.google.com/forum/#!forum/lz4c -****************************************************************** */ -#ifndef MEM_H_MODULE -#define MEM_H_MODULE - -#if defined (__cplusplus) -extern "C" { -#endif - -/****************************************** -* Includes -******************************************/ -#include /* size_t, ptrdiff_t */ -#include /* memcpy */ - - -/****************************************** -* Compiler-specific -******************************************/ -#if defined(__GNUC__) -# define MEM_STATIC static __attribute__((unused)) -#elif defined (__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */) -# define MEM_STATIC static inline -#elif defined(_MSC_VER) -# define MEM_STATIC static __inline -#else -# define MEM_STATIC static /* this version may generate warnings for unused static functions; disable the relevant warning */ -#endif - - -/**************************************************************** -* Basic Types -*****************************************************************/ -#if defined (__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */) -# if defined(_AIX) -# include -# else -# include /* intptr_t */ -# endif - typedef uint8_t BYTE; - typedef uint16_t U16; - typedef int16_t S16; - typedef uint32_t U32; - typedef int32_t S32; - typedef uint64_t U64; - typedef int64_t S64; -#else - typedef unsigned char BYTE; - typedef unsigned short U16; - typedef signed short S16; - typedef unsigned int U32; - typedef signed int S32; - typedef unsigned long long U64; - typedef signed long long S64; -#endif - - -/**************************************************************** -* Memory I/O -*****************************************************************/ - -MEM_STATIC unsigned MEM_32bits(void) { return sizeof(void*)==4; } -MEM_STATIC unsigned MEM_64bits(void) { return sizeof(void*)==8; } - -MEM_STATIC unsigned MEM_isLittleEndian(void) -{ - const union { U32 u; BYTE c[4]; } one = { 1 }; /* don't use static : performance detrimental */ - return one.c[0]; -} - -MEM_STATIC U16 MEM_read16(const void* memPtr) -{ - U16 val; memcpy(&val, memPtr, sizeof(val)); return val; -} - -MEM_STATIC U32 MEM_read32(const void* memPtr) -{ - U32 val; memcpy(&val, memPtr, sizeof(val)); return val; -} - -MEM_STATIC U64 MEM_read64(const void* memPtr) -{ - U64 val; memcpy(&val, memPtr, sizeof(val)); return val; -} - -MEM_STATIC void MEM_write16(void* memPtr, U16 value) -{ - memcpy(memPtr, &value, sizeof(value)); -} - -MEM_STATIC U16 MEM_readLE16(const void* memPtr) -{ - if (MEM_isLittleEndian()) - return MEM_read16(memPtr); - else - { - const BYTE* p = (const BYTE*)memPtr; - return (U16)(p[0] + (p[1]<<8)); - } -} - -MEM_STATIC void MEM_writeLE16(void* memPtr, U16 val) -{ - if (MEM_isLittleEndian()) - { - MEM_write16(memPtr, val); - } - else - { - BYTE* p = (BYTE*)memPtr; - p[0] = (BYTE)val; - p[1] = (BYTE)(val>>8); - } -} - -MEM_STATIC U32 MEM_readLE24(const void* memPtr) -{ - return MEM_readLE16(memPtr) + (((const BYTE*)memPtr)[2] << 16); -} - -MEM_STATIC U32 MEM_readLE32(const void* memPtr) -{ - if (MEM_isLittleEndian()) - return MEM_read32(memPtr); - else - { - const BYTE* p = (const BYTE*)memPtr; - return (U32)((U32)p[0] + ((U32)p[1]<<8) + ((U32)p[2]<<16) + ((U32)p[3]<<24)); - } -} - - -MEM_STATIC U64 MEM_readLE64(const void* memPtr) -{ - if (MEM_isLittleEndian()) - return MEM_read64(memPtr); - else - { - const BYTE* p = (const BYTE*)memPtr; - return (U64)((U64)p[0] + ((U64)p[1]<<8) + ((U64)p[2]<<16) + ((U64)p[3]<<24) - + ((U64)p[4]<<32) + ((U64)p[5]<<40) + ((U64)p[6]<<48) + ((U64)p[7]<<56)); - } -} - - -MEM_STATIC size_t MEM_readLEST(const void* memPtr) -{ - if (MEM_32bits()) - return (size_t)MEM_readLE32(memPtr); - else - return (size_t)MEM_readLE64(memPtr); -} - -#if defined (__cplusplus) -} -#endif - -#endif /* MEM_H_MODULE */ - - -/* ****************************************************************** - bitstream - Part of NewGen Entropy library - header file (to include) - Copyright (C) 2013-2015, Yann Collet. - - BSD 2-Clause License (https://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 : - - Source repository : https://github.com/Cyan4973/FiniteStateEntropy - - Public forum : https://groups.google.com/forum/#!forum/lz4c -****************************************************************** */ -#ifndef BITSTREAM_H_MODULE -#define BITSTREAM_H_MODULE - -#if defined (__cplusplus) -extern "C" { -#endif - - -/* -* This API consists of small unitary functions, which highly benefit from being inlined. -* Since link-time-optimization is not available for all compilers, -* these functions are defined into a .h to be included. -*/ - - -/********************************************** -* bitStream decompression API (read backward) -**********************************************/ -typedef struct -{ - size_t bitContainer; - unsigned bitsConsumed; - const char* ptr; - const char* start; -} BIT_DStream_t; - -typedef enum { BIT_DStream_unfinished = 0, - BIT_DStream_endOfBuffer = 1, - BIT_DStream_completed = 2, - BIT_DStream_overflow = 3 } BIT_DStream_status; /* result of BIT_reloadDStream() */ - /* 1,2,4,8 would be better for bitmap combinations, but slows down performance a bit ... :( */ - -MEM_STATIC size_t BIT_initDStream(BIT_DStream_t* bitD, const void* srcBuffer, size_t srcSize); -MEM_STATIC size_t BIT_readBits(BIT_DStream_t* bitD, unsigned nbBits); -MEM_STATIC BIT_DStream_status BIT_reloadDStream(BIT_DStream_t* bitD); -MEM_STATIC unsigned BIT_endOfDStream(const BIT_DStream_t* bitD); - - -/****************************************** -* unsafe API -******************************************/ -MEM_STATIC size_t BIT_readBitsFast(BIT_DStream_t* bitD, unsigned nbBits); -/* faster, but works only if nbBits >= 1 */ - - - -/**************************************************************** -* Helper functions -****************************************************************/ -MEM_STATIC unsigned BIT_highbit32 (U32 val) -{ -# if defined(_MSC_VER) /* Visual */ - unsigned long r; - return _BitScanReverse(&r, val) ? (unsigned)r : 0; -# elif defined(__GNUC__) && (__GNUC__ >= 3) /* Use GCC Intrinsic */ - return __builtin_clz (val) ^ 31; -# else /* Software version */ - static const unsigned DeBruijnClz[32] = { 0, 9, 1, 10, 13, 21, 2, 29, 11, 14, 16, 18, 22, 25, 3, 30, 8, 12, 20, 28, 15, 17, 24, 7, 19, 27, 23, 6, 26, 5, 4, 31 }; - U32 v = val; - unsigned r; - v |= v >> 1; - v |= v >> 2; - v |= v >> 4; - v |= v >> 8; - v |= v >> 16; - r = DeBruijnClz[ (U32) (v * 0x07C4ACDDU) >> 27]; - return r; -# endif -} - - - -/********************************************************** -* bitStream decoding -**********************************************************/ - -/*!BIT_initDStream -* Initialize a BIT_DStream_t. -* @bitD : a pointer to an already allocated BIT_DStream_t structure -* @srcBuffer must point at the beginning of a bitStream -* @srcSize must be the exact size of the bitStream -* @result : size of stream (== srcSize) or an errorCode if a problem is detected -*/ -MEM_STATIC size_t BIT_initDStream(BIT_DStream_t* bitD, const void* srcBuffer, size_t srcSize) -{ - if (srcSize < 1) { memset(bitD, 0, sizeof(*bitD)); return ERROR(srcSize_wrong); } - - if (srcSize >= sizeof(size_t)) /* normal case */ - { - U32 contain32; - bitD->start = (const char*)srcBuffer; - bitD->ptr = (const char*)srcBuffer + srcSize - sizeof(size_t); - bitD->bitContainer = MEM_readLEST(bitD->ptr); - contain32 = ((const BYTE*)srcBuffer)[srcSize-1]; - if (contain32 == 0) return ERROR(GENERIC); /* endMark not present */ - bitD->bitsConsumed = 8 - BIT_highbit32(contain32); - } - else - { - U32 contain32; - bitD->start = (const char*)srcBuffer; - bitD->ptr = bitD->start; - bitD->bitContainer = *(const BYTE*)(bitD->start); - switch(srcSize) - { - case 7: bitD->bitContainer += (size_t)(((const BYTE*)(bitD->start))[6]) << (sizeof(size_t)*8 - 16); - /* fallthrough */ - case 6: bitD->bitContainer += (size_t)(((const BYTE*)(bitD->start))[5]) << (sizeof(size_t)*8 - 24); - /* fallthrough */ - case 5: bitD->bitContainer += (size_t)(((const BYTE*)(bitD->start))[4]) << (sizeof(size_t)*8 - 32); - /* fallthrough */ - case 4: bitD->bitContainer += (size_t)(((const BYTE*)(bitD->start))[3]) << 24; - /* fallthrough */ - case 3: bitD->bitContainer += (size_t)(((const BYTE*)(bitD->start))[2]) << 16; - /* fallthrough */ - case 2: bitD->bitContainer += (size_t)(((const BYTE*)(bitD->start))[1]) << 8; - /* fallthrough */ - default:; - } - contain32 = ((const BYTE*)srcBuffer)[srcSize-1]; - if (contain32 == 0) return ERROR(GENERIC); /* endMark not present */ - bitD->bitsConsumed = 8 - BIT_highbit32(contain32); - bitD->bitsConsumed += (U32)(sizeof(size_t) - srcSize)*8; - } - - return srcSize; -} - -MEM_STATIC size_t BIT_lookBits(BIT_DStream_t* bitD, U32 nbBits) -{ - const U32 bitMask = sizeof(bitD->bitContainer)*8 - 1; - return ((bitD->bitContainer << (bitD->bitsConsumed & bitMask)) >> 1) >> ((bitMask-nbBits) & bitMask); -} - -/*! BIT_lookBitsFast : -* unsafe version; only works if nbBits >= 1 */ -MEM_STATIC size_t BIT_lookBitsFast(BIT_DStream_t* bitD, U32 nbBits) -{ - const U32 bitMask = sizeof(bitD->bitContainer)*8 - 1; - return (bitD->bitContainer << (bitD->bitsConsumed & bitMask)) >> (((bitMask+1)-nbBits) & bitMask); -} - -MEM_STATIC void BIT_skipBits(BIT_DStream_t* bitD, U32 nbBits) -{ - bitD->bitsConsumed += nbBits; -} - -MEM_STATIC size_t BIT_readBits(BIT_DStream_t* bitD, U32 nbBits) -{ - size_t value = BIT_lookBits(bitD, nbBits); - BIT_skipBits(bitD, nbBits); - return value; -} - -/*!BIT_readBitsFast : -* unsafe version; only works if nbBits >= 1 */ -MEM_STATIC size_t BIT_readBitsFast(BIT_DStream_t* bitD, U32 nbBits) -{ - size_t value = BIT_lookBitsFast(bitD, nbBits); - BIT_skipBits(bitD, nbBits); - return value; -} - -MEM_STATIC BIT_DStream_status BIT_reloadDStream(BIT_DStream_t* bitD) -{ - if (bitD->bitsConsumed > (sizeof(bitD->bitContainer)*8)) /* should never happen */ - return BIT_DStream_overflow; - - if (bitD->ptr >= bitD->start + sizeof(bitD->bitContainer)) - { - bitD->ptr -= bitD->bitsConsumed >> 3; - bitD->bitsConsumed &= 7; - bitD->bitContainer = MEM_readLEST(bitD->ptr); - return BIT_DStream_unfinished; - } - if (bitD->ptr == bitD->start) - { - if (bitD->bitsConsumed < sizeof(bitD->bitContainer)*8) return BIT_DStream_endOfBuffer; - return BIT_DStream_completed; - } - { - U32 nbBytes = bitD->bitsConsumed >> 3; - BIT_DStream_status result = BIT_DStream_unfinished; - if (bitD->ptr - nbBytes < bitD->start) - { - nbBytes = (U32)(bitD->ptr - bitD->start); /* ptr > start */ - result = BIT_DStream_endOfBuffer; - } - bitD->ptr -= nbBytes; - bitD->bitsConsumed -= nbBytes*8; - bitD->bitContainer = MEM_readLEST(bitD->ptr); /* reminder : srcSize > sizeof(bitD) */ - return result; - } -} - -/*! BIT_endOfDStream -* @return Tells if DStream has reached its exact end -*/ -MEM_STATIC unsigned BIT_endOfDStream(const BIT_DStream_t* DStream) -{ - return ((DStream->ptr == DStream->start) && (DStream->bitsConsumed == sizeof(DStream->bitContainer)*8)); -} - -#if defined (__cplusplus) -} -#endif - -#endif /* BITSTREAM_H_MODULE */ -/* ****************************************************************** - Error codes and messages - Copyright (C) 2013-2015, Yann Collet - - BSD 2-Clause License (https://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 : - - Source repository : https://github.com/Cyan4973/FiniteStateEntropy - - Public forum : https://groups.google.com/forum/#!forum/lz4c -****************************************************************** */ -#ifndef ERROR_H_MODULE -#define ERROR_H_MODULE - -#if defined (__cplusplus) -extern "C" { -#endif - - -/****************************************** -* Compiler-specific -******************************************/ -#if defined (__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */) -# define ERR_STATIC static inline -#elif defined(_MSC_VER) -# define ERR_STATIC static __inline -#elif defined(__GNUC__) -# define ERR_STATIC static __attribute__((unused)) -#else -# define ERR_STATIC static /* this version may generate warnings for unused static functions; disable the relevant warning */ -#endif - - -/****************************************** -* Error Management -******************************************/ -#define PREFIX(name) ZSTD_error_##name - -#define ERROR(name) (size_t)-PREFIX(name) - -#define ERROR_LIST(ITEM) \ - ITEM(PREFIX(No_Error)) ITEM(PREFIX(GENERIC)) \ - ITEM(PREFIX(dstSize_tooSmall)) ITEM(PREFIX(srcSize_wrong)) \ - ITEM(PREFIX(prefix_unknown)) ITEM(PREFIX(corruption_detected)) \ - ITEM(PREFIX(tableLog_tooLarge)) ITEM(PREFIX(maxSymbolValue_tooLarge)) ITEM(PREFIX(maxSymbolValue_tooSmall)) \ - ITEM(PREFIX(maxCode)) - -#define ERROR_GENERATE_ENUM(ENUM) ENUM, -typedef enum { ERROR_LIST(ERROR_GENERATE_ENUM) } ERR_codes; /* enum is exposed, to detect & handle specific errors; compare function result to -enum value */ - -#define ERROR_CONVERTTOSTRING(STRING) #STRING, -#define ERROR_GENERATE_STRING(EXPR) ERROR_CONVERTTOSTRING(EXPR) -static const char* ERR_strings[] = { ERROR_LIST(ERROR_GENERATE_STRING) }; - -ERR_STATIC unsigned ERR_isError(size_t code) { return (code > ERROR(maxCode)); } - -ERR_STATIC const char* ERR_getErrorName(size_t code) -{ - static const char* codeError = "Unspecified error code"; - if (ERR_isError(code)) return ERR_strings[-(int)(code)]; - return codeError; -} - - -#if defined (__cplusplus) -} -#endif - -#endif /* ERROR_H_MODULE */ -/* -Constructor and Destructor of type FSE_CTable - Note that its size depends on 'tableLog' and 'maxSymbolValue' */ -typedef unsigned FSE_CTable; /* don't allocate that. It's just a way to be more restrictive than void* */ -typedef unsigned FSE_DTable; /* don't allocate that. It's just a way to be more restrictive than void* */ - - -/* ****************************************************************** - FSE : Finite State Entropy coder - header file for static linking (only) - Copyright (C) 2013-2015, Yann Collet - - BSD 2-Clause License (https://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 : - - Source repository : https://github.com/Cyan4973/FiniteStateEntropy - - Public forum : https://groups.google.com/forum/#!forum/lz4c -****************************************************************** */ -#if defined (__cplusplus) -extern "C" { -#endif - - -/****************************************** -* Static allocation -******************************************/ -/* FSE buffer bounds */ -#define FSE_NCOUNTBOUND 512 -#define FSE_BLOCKBOUND(size) (size + (size>>7)) -#define FSE_COMPRESSBOUND(size) (FSE_NCOUNTBOUND + FSE_BLOCKBOUND(size)) /* Macro version, useful for static allocation */ - -/* You can statically allocate FSE CTable/DTable as a table of unsigned using below macro */ -#define FSE_CTABLE_SIZE_U32(maxTableLog, maxSymbolValue) (1 + (1<<(maxTableLog-1)) + ((maxSymbolValue+1)*2)) -#define FSE_DTABLE_SIZE_U32(maxTableLog) (1 + (1<= 1 (otherwise, result will be corrupted) */ - - -/****************************************** -* Implementation of inline functions -******************************************/ - -/* decompression */ - -typedef struct { - U16 tableLog; - U16 fastMode; -} FSE_DTableHeader; /* sizeof U32 */ - -typedef struct -{ - unsigned short newState; - unsigned char symbol; - unsigned char nbBits; -} FSE_decode_t; /* size == U32 */ - -MEM_STATIC void FSE_initDState(FSE_DState_t* DStatePtr, BIT_DStream_t* bitD, const FSE_DTable* dt) -{ - FSE_DTableHeader DTableH; - memcpy(&DTableH, dt, sizeof(DTableH)); - DStatePtr->state = BIT_readBits(bitD, DTableH.tableLog); - BIT_reloadDStream(bitD); - DStatePtr->table = dt + 1; -} - -MEM_STATIC BYTE FSE_decodeSymbol(FSE_DState_t* DStatePtr, BIT_DStream_t* bitD) -{ - const FSE_decode_t DInfo = ((const FSE_decode_t*)(DStatePtr->table))[DStatePtr->state]; - const U32 nbBits = DInfo.nbBits; - BYTE symbol = DInfo.symbol; - size_t lowBits = BIT_readBits(bitD, nbBits); - - DStatePtr->state = DInfo.newState + lowBits; - return symbol; -} - -MEM_STATIC BYTE FSE_decodeSymbolFast(FSE_DState_t* DStatePtr, BIT_DStream_t* bitD) -{ - const FSE_decode_t DInfo = ((const FSE_decode_t*)(DStatePtr->table))[DStatePtr->state]; - const U32 nbBits = DInfo.nbBits; - BYTE symbol = DInfo.symbol; - size_t lowBits = BIT_readBitsFast(bitD, nbBits); - - DStatePtr->state = DInfo.newState + lowBits; - return symbol; -} - -MEM_STATIC unsigned FSE_endOfDState(const FSE_DState_t* DStatePtr) -{ - return DStatePtr->state == 0; -} - - -#if defined (__cplusplus) -} -#endif -/* ****************************************************************** - Huff0 : Huffman coder, part of New Generation Entropy library - header file for static linking (only) - Copyright (C) 2013-2015, Yann Collet - - BSD 2-Clause License (https://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 : - - Source repository : https://github.com/Cyan4973/FiniteStateEntropy - - Public forum : https://groups.google.com/forum/#!forum/lz4c -****************************************************************** */ - -#if defined (__cplusplus) -extern "C" { -#endif - -/****************************************** -* Static allocation macros -******************************************/ -/* Huff0 buffer bounds */ -#define HUF_CTABLEBOUND 129 -#define HUF_BLOCKBOUND(size) (size + (size>>8) + 8) /* only true if incompressible pre-filtered with fast heuristic */ -#define HUF_COMPRESSBOUND(size) (HUF_CTABLEBOUND + HUF_BLOCKBOUND(size)) /* Macro version, useful for static allocation */ - -/* static allocation of Huff0's DTable */ -#define HUF_DTABLE_SIZE(maxTableLog) (1 + (1< /* size_t */ - - -/* ************************************* -* Version -***************************************/ -#define ZSTD_VERSION_MAJOR 0 /* for breaking interface changes */ -#define ZSTD_VERSION_MINOR 2 /* for new (non-breaking) interface capabilities */ -#define ZSTD_VERSION_RELEASE 2 /* for tweaks, bug-fixes, or development */ -#define ZSTD_VERSION_NUMBER (ZSTD_VERSION_MAJOR *100*100 + ZSTD_VERSION_MINOR *100 + ZSTD_VERSION_RELEASE) - - -/* ************************************* -* Advanced functions -***************************************/ -typedef struct ZSTD_CCtx_s ZSTD_CCtx; /* incomplete type */ - -#if defined (__cplusplus) -} -#endif -/* - zstd - standard compression library - Header File for static linking only - Copyright (C) 2014-2015, Yann Collet. - - BSD 2-Clause License (https://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 : - - zstd source repository : https://github.com/Cyan4973/zstd - - ztsd public forum : https://groups.google.com/forum/#!forum/lz4c -*/ - -/* The objects defined into this file should be considered experimental. - * They are not labelled stable, as their prototype may change in the future. - * You can use them for tests, provide feedback, or if you can endure risk of future changes. - */ - -#if defined (__cplusplus) -extern "C" { -#endif - -/* ************************************* -* Streaming functions -***************************************/ - -typedef struct ZSTD_DCtx_s ZSTD_DCtx; - -/* - Use above functions alternatively. - ZSTD_nextSrcSizeToDecompress() tells how much bytes to provide as 'srcSize' to ZSTD_decompressContinue(). - ZSTD_decompressContinue() will use previous data blocks to improve compression if they are located prior to current block. - Result is the number of bytes regenerated within 'dst'. - It can be zero, which is not an error; it just means ZSTD_decompressContinue() has decoded some header. -*/ - -/* ************************************* -* Prefix - version detection -***************************************/ -#define ZSTD_magicNumber 0xFD2FB522 /* v0.2 (current)*/ - - -#if defined (__cplusplus) -} -#endif -/* ****************************************************************** - FSE : Finite State Entropy coder - Copyright (C) 2013-2015, Yann Collet. - - BSD 2-Clause License (https://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 : - - FSE source repository : https://github.com/Cyan4973/FiniteStateEntropy - - Public forum : https://groups.google.com/forum/#!forum/lz4c -****************************************************************** */ - -#ifndef FSE_COMMONDEFS_ONLY - -/**************************************************************** -* Tuning parameters -****************************************************************/ -/* MEMORY_USAGE : -* Memory usage formula : N->2^N Bytes (examples : 10 -> 1KB; 12 -> 4KB ; 16 -> 64KB; 20 -> 1MB; etc.) -* Increasing memory usage improves compression ratio -* Reduced memory usage can improve speed, due to cache effect -* Recommended max value is 14, for 16KB, which nicely fits into Intel x86 L1 cache */ -#define FSE_MAX_MEMORY_USAGE 14 -#define FSE_DEFAULT_MEMORY_USAGE 13 - -/* FSE_MAX_SYMBOL_VALUE : -* Maximum symbol value authorized. -* Required for proper stack allocation */ -#define FSE_MAX_SYMBOL_VALUE 255 - - -/**************************************************************** -* template functions type & suffix -****************************************************************/ -#define FSE_FUNCTION_TYPE BYTE -#define FSE_FUNCTION_EXTENSION - - -/**************************************************************** -* Byte symbol type -****************************************************************/ -#endif /* !FSE_COMMONDEFS_ONLY */ - - -/**************************************************************** -* Compiler specifics -****************************************************************/ -#ifdef _MSC_VER /* Visual Studio */ -# define FORCE_INLINE static __forceinline -# include /* For Visual 2005 */ -# pragma warning(disable : 4127) /* disable: C4127: conditional expression is constant */ -# pragma warning(disable : 4214) /* disable: C4214: non-int bitfields */ -#else -# if defined (__cplusplus) || defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 */ -# ifdef __GNUC__ -# define FORCE_INLINE static inline __attribute__((always_inline)) -# else -# define FORCE_INLINE static inline -# endif -# else -# define FORCE_INLINE static -# endif /* __STDC_VERSION__ */ -#endif - - -/**************************************************************** -* Includes -****************************************************************/ -#include /* malloc, free, qsort */ -#include /* memcpy, memset */ -#include /* printf (debug) */ - -/**************************************************************** -* Constants -*****************************************************************/ -#define FSE_MAX_TABLELOG (FSE_MAX_MEMORY_USAGE-2) -#define FSE_MAX_TABLESIZE (1U< FSE_TABLELOG_ABSOLUTE_MAX -#error "FSE_MAX_TABLELOG > FSE_TABLELOG_ABSOLUTE_MAX is not supported" -#endif - - -/**************************************************************** -* Error Management -****************************************************************/ -#define FSE_STATIC_ASSERT(c) { enum { FSE_static_assert = 1/(int)(!!(c)) }; } /* use only *after* variable declarations */ - - -/**************************************************************** -* Complex types -****************************************************************/ -typedef U32 DTable_max_t[FSE_DTABLE_SIZE_U32(FSE_MAX_TABLELOG)]; - - -/**************************************************************** -* Templates -****************************************************************/ -/* - designed to be included - for type-specific functions (template emulation in C) - Objective is to write these functions only once, for improved maintenance -*/ - -/* safety checks */ -#ifndef FSE_FUNCTION_EXTENSION -# error "FSE_FUNCTION_EXTENSION must be defined" -#endif -#ifndef FSE_FUNCTION_TYPE -# error "FSE_FUNCTION_TYPE must be defined" -#endif - -/* Function names */ -#define FSE_CAT(X,Y) X##Y -#define FSE_FUNCTION_NAME(X,Y) FSE_CAT(X,Y) -#define FSE_TYPE_NAME(X,Y) FSE_CAT(X,Y) - - -/* Function templates */ - -#define FSE_DECODE_TYPE FSE_decode_t - -static U32 FSE_tableStep(U32 tableSize) { return (tableSize>>1) + (tableSize>>3) + 3; } - -static size_t FSE_buildDTable -(FSE_DTable* dt, const short* normalizedCounter, unsigned maxSymbolValue, unsigned tableLog) -{ - void* ptr = dt+1; - FSE_DECODE_TYPE* const tableDecode = (FSE_DECODE_TYPE*)ptr; - FSE_DTableHeader DTableH; - const U32 tableSize = 1 << tableLog; - const U32 tableMask = tableSize-1; - const U32 step = FSE_tableStep(tableSize); - U16 symbolNext[FSE_MAX_SYMBOL_VALUE+1]; - U32 position = 0; - U32 highThreshold = tableSize-1; - const S16 largeLimit= (S16)(1 << (tableLog-1)); - U32 noLarge = 1; - U32 s; - - /* Sanity Checks */ - if (maxSymbolValue > FSE_MAX_SYMBOL_VALUE) return ERROR(maxSymbolValue_tooLarge); - if (tableLog > FSE_MAX_TABLELOG) return ERROR(tableLog_tooLarge); - - /* Init, lay down lowprob symbols */ - DTableH.tableLog = (U16)tableLog; - for (s=0; s<=maxSymbolValue; s++) - { - if (normalizedCounter[s]==-1) - { - tableDecode[highThreshold--].symbol = (FSE_FUNCTION_TYPE)s; - symbolNext[s] = 1; - } - else - { - if (normalizedCounter[s] >= largeLimit) noLarge=0; - symbolNext[s] = normalizedCounter[s]; - } - } - - /* Spread symbols */ - for (s=0; s<=maxSymbolValue; s++) - { - int i; - for (i=0; i highThreshold) position = (position + step) & tableMask; /* lowprob area */ - } - } - - if (position!=0) return ERROR(GENERIC); /* position must reach all cells once, otherwise normalizedCounter is incorrect */ - - /* Build Decoding table */ - { - U32 i; - for (i=0; i FSE_TABLELOG_ABSOLUTE_MAX) return ERROR(tableLog_tooLarge); - bitStream >>= 4; - bitCount = 4; - *tableLogPtr = nbBits; - remaining = (1<1) && (charnum<=*maxSVPtr)) - { - if (previous0) - { - unsigned n0 = charnum; - while ((bitStream & 0xFFFF) == 0xFFFF) - { - n0+=24; - if (ip < iend-5) - { - ip+=2; - bitStream = MEM_readLE32(ip) >> bitCount; - } - else - { - bitStream >>= 16; - bitCount+=16; - } - } - while ((bitStream & 3) == 3) - { - n0+=3; - bitStream>>=2; - bitCount+=2; - } - n0 += bitStream & 3; - bitCount += 2; - if (n0 > *maxSVPtr) return ERROR(maxSymbolValue_tooSmall); - while (charnum < n0) normalizedCounter[charnum++] = 0; - if ((ip <= iend-7) || (ip + (bitCount>>3) <= iend-4)) - { - ip += bitCount>>3; - bitCount &= 7; - bitStream = MEM_readLE32(ip) >> bitCount; - } - else - bitStream >>= 2; - } - { - const short max = (short)((2*threshold-1)-remaining); - short count; - - if ((bitStream & (threshold-1)) < (U32)max) - { - count = (short)(bitStream & (threshold-1)); - bitCount += nbBits-1; - } - else - { - count = (short)(bitStream & (2*threshold-1)); - if (count >= threshold) count -= max; - bitCount += nbBits; - } - - count--; /* extra accuracy */ - remaining -= FSE_abs(count); - normalizedCounter[charnum++] = count; - previous0 = !count; - while (remaining < threshold) - { - nbBits--; - threshold >>= 1; - } - - { - if ((ip <= iend-7) || (ip + (bitCount>>3) <= iend-4)) - { - ip += bitCount>>3; - bitCount &= 7; - } - else - { - bitCount -= (int)(8 * (iend - 4 - ip)); - ip = iend - 4; - } - bitStream = MEM_readLE32(ip) >> (bitCount & 31); - } - } - } - if (remaining != 1) return ERROR(GENERIC); - *maxSVPtr = charnum-1; - - ip += (bitCount+7)>>3; - if ((size_t)(ip-istart) > hbSize) return ERROR(srcSize_wrong); - return ip-istart; -} - - -/********************************************************* -* Decompression (Byte symbols) -*********************************************************/ -static size_t FSE_buildDTable_rle (FSE_DTable* dt, BYTE symbolValue) -{ - void* ptr = dt; - FSE_DTableHeader* const DTableH = (FSE_DTableHeader*)ptr; - FSE_decode_t* const cell = (FSE_decode_t*)(ptr) + 1; /* because dt is unsigned */ - - DTableH->tableLog = 0; - DTableH->fastMode = 0; - - cell->newState = 0; - cell->symbol = symbolValue; - cell->nbBits = 0; - - return 0; -} - - -static size_t FSE_buildDTable_raw (FSE_DTable* dt, unsigned nbBits) -{ - void* ptr = dt; - FSE_DTableHeader* const DTableH = (FSE_DTableHeader*)ptr; - FSE_decode_t* const dinfo = (FSE_decode_t*)(ptr) + 1; /* because dt is unsigned */ - const unsigned tableSize = 1 << nbBits; - const unsigned tableMask = tableSize - 1; - const unsigned maxSymbolValue = tableMask; - unsigned s; - - /* Sanity checks */ - if (nbBits < 1) return ERROR(GENERIC); /* min size */ - - /* Build Decoding Table */ - DTableH->tableLog = (U16)nbBits; - DTableH->fastMode = 1; - for (s=0; s<=maxSymbolValue; s++) - { - dinfo[s].newState = 0; - dinfo[s].symbol = (BYTE)s; - dinfo[s].nbBits = (BYTE)nbBits; - } - - return 0; -} - -FORCE_INLINE size_t FSE_decompress_usingDTable_generic( - void* dst, size_t maxDstSize, - const void* cSrc, size_t cSrcSize, - const FSE_DTable* dt, const unsigned fast) -{ - BYTE* const ostart = (BYTE*) dst; - BYTE* op = ostart; - BYTE* const omax = op + maxDstSize; - BYTE* const olimit = omax-3; - - BIT_DStream_t bitD; - FSE_DState_t state1; - FSE_DState_t state2; - size_t errorCode; - - /* Init */ - errorCode = BIT_initDStream(&bitD, cSrc, cSrcSize); /* replaced last arg by maxCompressed Size */ - if (FSE_isError(errorCode)) return errorCode; - - FSE_initDState(&state1, &bitD, dt); - FSE_initDState(&state2, &bitD, dt); - -#define FSE_GETSYMBOL(statePtr) fast ? FSE_decodeSymbolFast(statePtr, &bitD) : FSE_decodeSymbol(statePtr, &bitD) - - /* 4 symbols per loop */ - for ( ; (BIT_reloadDStream(&bitD)==BIT_DStream_unfinished) && (op sizeof(bitD.bitContainer)*8) /* This test must be static */ - BIT_reloadDStream(&bitD); - - op[1] = FSE_GETSYMBOL(&state2); - - if (FSE_MAX_TABLELOG*4+7 > sizeof(bitD.bitContainer)*8) /* This test must be static */ - { if (BIT_reloadDStream(&bitD) > BIT_DStream_unfinished) { op+=2; break; } } - - op[2] = FSE_GETSYMBOL(&state1); - - if (FSE_MAX_TABLELOG*2+7 > sizeof(bitD.bitContainer)*8) /* This test must be static */ - BIT_reloadDStream(&bitD); - - op[3] = FSE_GETSYMBOL(&state2); - } - - /* tail */ - /* note : BIT_reloadDStream(&bitD) >= FSE_DStream_partiallyFilled; Ends at exactly BIT_DStream_completed */ - while (1) - { - if ( (BIT_reloadDStream(&bitD)>BIT_DStream_completed) || (op==omax) || (BIT_endOfDStream(&bitD) && (fast || FSE_endOfDState(&state1))) ) - break; - - *op++ = FSE_GETSYMBOL(&state1); - - if ( (BIT_reloadDStream(&bitD)>BIT_DStream_completed) || (op==omax) || (BIT_endOfDStream(&bitD) && (fast || FSE_endOfDState(&state2))) ) - break; - - *op++ = FSE_GETSYMBOL(&state2); - } - - /* end ? */ - if (BIT_endOfDStream(&bitD) && FSE_endOfDState(&state1) && FSE_endOfDState(&state2)) - return op-ostart; - - if (op==omax) return ERROR(dstSize_tooSmall); /* dst buffer is full, but cSrc unfinished */ - - return ERROR(corruption_detected); -} - - -static size_t FSE_decompress_usingDTable(void* dst, size_t originalSize, - const void* cSrc, size_t cSrcSize, - const FSE_DTable* dt) -{ - FSE_DTableHeader DTableH; - memcpy(&DTableH, dt, sizeof(DTableH)); - - /* select fast mode (static) */ - if (DTableH.fastMode) return FSE_decompress_usingDTable_generic(dst, originalSize, cSrc, cSrcSize, dt, 1); - return FSE_decompress_usingDTable_generic(dst, originalSize, cSrc, cSrcSize, dt, 0); -} - - -static size_t FSE_decompress(void* dst, size_t maxDstSize, const void* cSrc, size_t cSrcSize) -{ - const BYTE* const istart = (const BYTE*)cSrc; - const BYTE* ip = istart; - short counting[FSE_MAX_SYMBOL_VALUE+1]; - DTable_max_t dt; /* Static analyzer seems unable to understand this table will be properly initialized later */ - unsigned tableLog; - unsigned maxSymbolValue = FSE_MAX_SYMBOL_VALUE; - size_t errorCode; - - if (cSrcSize<2) return ERROR(srcSize_wrong); /* too small input size */ - - /* normal FSE decoding mode */ - errorCode = FSE_readNCount (counting, &maxSymbolValue, &tableLog, istart, cSrcSize); - if (FSE_isError(errorCode)) return errorCode; - if (errorCode >= cSrcSize) return ERROR(srcSize_wrong); /* too small input size */ - ip += errorCode; - cSrcSize -= errorCode; - - errorCode = FSE_buildDTable (dt, counting, maxSymbolValue, tableLog); - if (FSE_isError(errorCode)) return errorCode; - - /* always return, even if it is an error code */ - return FSE_decompress_usingDTable (dst, maxDstSize, ip, cSrcSize, dt); -} - - - -#endif /* FSE_COMMONDEFS_ONLY */ -/* ****************************************************************** - Huff0 : Huffman coder, part of New Generation Entropy library - Copyright (C) 2013-2015, Yann Collet. - - BSD 2-Clause License (https://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 : - - FSE+Huff0 source repository : https://github.com/Cyan4973/FiniteStateEntropy - - Public forum : https://groups.google.com/forum/#!forum/lz4c -****************************************************************** */ - -/**************************************************************** -* Compiler specifics -****************************************************************/ -#if defined (__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */) -/* inline is defined */ -#elif defined(_MSC_VER) -# define inline __inline -#else -# define inline /* disable inline */ -#endif - - -#ifdef _MSC_VER /* Visual Studio */ -# pragma warning(disable : 4127) /* disable: C4127: conditional expression is constant */ -#endif - - -/**************************************************************** -* Includes -****************************************************************/ -#include /* malloc, free, qsort */ -#include /* memcpy, memset */ -#include /* printf (debug) */ - -/**************************************************************** -* Error Management -****************************************************************/ -#define HUF_STATIC_ASSERT(c) { enum { HUF_static_assert = 1/(int)(!!(c)) }; } /* use only *after* variable declarations */ - - -/****************************************** -* Helper functions -******************************************/ -static unsigned HUF_isError(size_t code) { return ERR_isError(code); } - -#define HUF_ABSOLUTEMAX_TABLELOG 16 /* absolute limit of HUF_MAX_TABLELOG. Beyond that value, code does not work */ -#define HUF_MAX_TABLELOG 12 /* max configured tableLog (for static allocation); can be modified up to HUF_ABSOLUTEMAX_TABLELOG */ -#define HUF_DEFAULT_TABLELOG HUF_MAX_TABLELOG /* tableLog by default, when not specified */ -#define HUF_MAX_SYMBOL_VALUE 255 -#if (HUF_MAX_TABLELOG > HUF_ABSOLUTEMAX_TABLELOG) -# error "HUF_MAX_TABLELOG is too large !" -#endif - - - -/********************************************************* -* Huff0 : Huffman block decompression -*********************************************************/ -typedef struct { BYTE byte; BYTE nbBits; } HUF_DEltX2; /* single-symbol decoding */ - -typedef struct { U16 sequence; BYTE nbBits; BYTE length; } HUF_DEltX4; /* double-symbols decoding */ - -typedef struct { BYTE symbol; BYTE weight; } sortedSymbol_t; - -/*! HUF_readStats - Read compact Huffman tree, saved by HUF_writeCTable - @huffWeight : destination buffer - @return : size read from `src` -*/ -static size_t HUF_readStats(BYTE* huffWeight, size_t hwSize, U32* rankStats, - U32* nbSymbolsPtr, U32* tableLogPtr, - const void* src, size_t srcSize) -{ - U32 weightTotal; - U32 tableLog; - const BYTE* ip = (const BYTE*) src; - size_t iSize; - size_t oSize; - U32 n; - - if (!srcSize) return ERROR(srcSize_wrong); - iSize = ip[0]; - //memset(huffWeight, 0, hwSize); /* is not necessary, even though some analyzer complain ... */ - - if (iSize >= 128) /* special header */ - { - if (iSize >= (242)) /* RLE */ - { - static int l[14] = { 1, 2, 3, 4, 7, 8, 15, 16, 31, 32, 63, 64, 127, 128 }; - oSize = l[iSize-242]; - memset(huffWeight, 1, hwSize); - iSize = 0; - } - else /* Incompressible */ - { - oSize = iSize - 127; - iSize = ((oSize+1)/2); - if (iSize+1 > srcSize) return ERROR(srcSize_wrong); - if (oSize >= hwSize) return ERROR(corruption_detected); - ip += 1; - for (n=0; n> 4; - huffWeight[n+1] = ip[n/2] & 15; - } - } - } - else /* header compressed with FSE (normal case) */ - { - if (iSize+1 > srcSize) return ERROR(srcSize_wrong); - oSize = FSE_decompress(huffWeight, hwSize-1, ip+1, iSize); /* max (hwSize-1) values decoded, as last one is implied */ - if (FSE_isError(oSize)) return oSize; - } - - /* collect weight stats */ - memset(rankStats, 0, (HUF_ABSOLUTEMAX_TABLELOG + 1) * sizeof(U32)); - weightTotal = 0; - for (n=0; n= HUF_ABSOLUTEMAX_TABLELOG) return ERROR(corruption_detected); - rankStats[huffWeight[n]]++; - weightTotal += (1 << huffWeight[n]) >> 1; - } - if (weightTotal == 0) return ERROR(corruption_detected); - - /* get last non-null symbol weight (implied, total must be 2^n) */ - tableLog = BIT_highbit32(weightTotal) + 1; - if (tableLog > HUF_ABSOLUTEMAX_TABLELOG) return ERROR(corruption_detected); - { - U32 total = 1 << tableLog; - U32 rest = total - weightTotal; - U32 verif = 1 << BIT_highbit32(rest); - U32 lastWeight = BIT_highbit32(rest) + 1; - if (verif != rest) return ERROR(corruption_detected); /* last value must be a clean power of 2 */ - huffWeight[oSize] = (BYTE)lastWeight; - rankStats[lastWeight]++; - } - - /* check tree construction validity */ - if ((rankStats[1] < 2) || (rankStats[1] & 1)) return ERROR(corruption_detected); /* by construction : at least 2 elts of rank 1, must be even */ - - /* results */ - *nbSymbolsPtr = (U32)(oSize+1); - *tableLogPtr = tableLog; - return iSize+1; -} - - -/**************************/ -/* single-symbol decoding */ -/**************************/ - -static size_t HUF_readDTableX2 (U16* DTable, const void* src, size_t srcSize) -{ - BYTE huffWeight[HUF_MAX_SYMBOL_VALUE + 1]; - U32 rankVal[HUF_ABSOLUTEMAX_TABLELOG + 1]; /* large enough for values from 0 to 16 */ - U32 tableLog = 0; - const BYTE* ip = (const BYTE*) src; - size_t iSize = ip[0]; - U32 nbSymbols = 0; - U32 n; - U32 nextRankStart; - void* ptr = DTable+1; - HUF_DEltX2* const dt = (HUF_DEltX2*)ptr; - - HUF_STATIC_ASSERT(sizeof(HUF_DEltX2) == sizeof(U16)); /* if compilation fails here, assertion is false */ - //memset(huffWeight, 0, sizeof(huffWeight)); /* is not necessary, even though some analyzer complain ... */ - - iSize = HUF_readStats(huffWeight, HUF_MAX_SYMBOL_VALUE + 1, rankVal, &nbSymbols, &tableLog, src, srcSize); - if (HUF_isError(iSize)) return iSize; - - /* check result */ - if (tableLog > DTable[0]) return ERROR(tableLog_tooLarge); /* DTable is too small */ - DTable[0] = (U16)tableLog; /* maybe should separate sizeof DTable, as allocated, from used size of DTable, in case of DTable re-use */ - - /* Prepare ranks */ - nextRankStart = 0; - for (n=1; n<=tableLog; n++) - { - U32 current = nextRankStart; - nextRankStart += (rankVal[n] << (n-1)); - rankVal[n] = current; - } - - /* fill DTable */ - for (n=0; n> 1; - U32 i; - HUF_DEltX2 D; - D.byte = (BYTE)n; D.nbBits = (BYTE)(tableLog + 1 - w); - for (i = rankVal[w]; i < rankVal[w] + length; i++) - dt[i] = D; - rankVal[w] += length; - } - - return iSize; -} - -static BYTE HUF_decodeSymbolX2(BIT_DStream_t* Dstream, const HUF_DEltX2* dt, const U32 dtLog) -{ - const size_t val = BIT_lookBitsFast(Dstream, dtLog); /* note : dtLog >= 1 */ - const BYTE c = dt[val].byte; - BIT_skipBits(Dstream, dt[val].nbBits); - return c; -} - -#define HUF_DECODE_SYMBOLX2_0(ptr, DStreamPtr) \ - *ptr++ = HUF_decodeSymbolX2(DStreamPtr, dt, dtLog) - -#define HUF_DECODE_SYMBOLX2_1(ptr, DStreamPtr) \ - if (MEM_64bits() || (HUF_MAX_TABLELOG<=12)) \ - HUF_DECODE_SYMBOLX2_0(ptr, DStreamPtr) - -#define HUF_DECODE_SYMBOLX2_2(ptr, DStreamPtr) \ - if (MEM_64bits()) \ - HUF_DECODE_SYMBOLX2_0(ptr, DStreamPtr) - -static inline size_t HUF_decodeStreamX2(BYTE* p, BIT_DStream_t* const bitDPtr, BYTE* const pEnd, const HUF_DEltX2* const dt, const U32 dtLog) -{ - BYTE* const pStart = p; - - /* up to 4 symbols at a time */ - while ((BIT_reloadDStream(bitDPtr) == BIT_DStream_unfinished) && (p <= pEnd-4)) - { - HUF_DECODE_SYMBOLX2_2(p, bitDPtr); - HUF_DECODE_SYMBOLX2_1(p, bitDPtr); - HUF_DECODE_SYMBOLX2_2(p, bitDPtr); - HUF_DECODE_SYMBOLX2_0(p, bitDPtr); - } - - /* closer to the end */ - while ((BIT_reloadDStream(bitDPtr) == BIT_DStream_unfinished) && (p < pEnd)) - HUF_DECODE_SYMBOLX2_0(p, bitDPtr); - - /* no more data to retrieve from bitstream, hence no need to reload */ - while (p < pEnd) - HUF_DECODE_SYMBOLX2_0(p, bitDPtr); - - return pEnd-pStart; -} - - -static size_t HUF_decompress4X2_usingDTable( - void* dst, size_t dstSize, - const void* cSrc, size_t cSrcSize, - const U16* DTable) -{ - if (cSrcSize < 10) return ERROR(corruption_detected); /* strict minimum : jump table + 1 byte per stream */ - - { - const BYTE* const istart = (const BYTE*) cSrc; - BYTE* const ostart = (BYTE*) dst; - BYTE* const oend = ostart + dstSize; - - const void* ptr = DTable; - const HUF_DEltX2* const dt = ((const HUF_DEltX2*)ptr) +1; - const U32 dtLog = DTable[0]; - size_t errorCode; - - /* Init */ - BIT_DStream_t bitD1; - BIT_DStream_t bitD2; - BIT_DStream_t bitD3; - BIT_DStream_t bitD4; - const size_t length1 = MEM_readLE16(istart); - const size_t length2 = MEM_readLE16(istart+2); - const size_t length3 = MEM_readLE16(istart+4); - size_t length4; - const BYTE* const istart1 = istart + 6; /* jumpTable */ - const BYTE* const istart2 = istart1 + length1; - const BYTE* const istart3 = istart2 + length2; - const BYTE* const istart4 = istart3 + length3; - const size_t segmentSize = (dstSize+3) / 4; - BYTE* const opStart2 = ostart + segmentSize; - BYTE* const opStart3 = opStart2 + segmentSize; - BYTE* const opStart4 = opStart3 + segmentSize; - BYTE* op1 = ostart; - BYTE* op2 = opStart2; - BYTE* op3 = opStart3; - BYTE* op4 = opStart4; - U32 endSignal; - - length4 = cSrcSize - (length1 + length2 + length3 + 6); - if (length4 > cSrcSize) return ERROR(corruption_detected); /* overflow */ - errorCode = BIT_initDStream(&bitD1, istart1, length1); - if (HUF_isError(errorCode)) return errorCode; - errorCode = BIT_initDStream(&bitD2, istart2, length2); - if (HUF_isError(errorCode)) return errorCode; - errorCode = BIT_initDStream(&bitD3, istart3, length3); - if (HUF_isError(errorCode)) return errorCode; - errorCode = BIT_initDStream(&bitD4, istart4, length4); - if (HUF_isError(errorCode)) return errorCode; - - /* 16-32 symbols per loop (4-8 symbols per stream) */ - endSignal = BIT_reloadDStream(&bitD1) | BIT_reloadDStream(&bitD2) | BIT_reloadDStream(&bitD3) | BIT_reloadDStream(&bitD4); - for ( ; (endSignal==BIT_DStream_unfinished) && (op4<(oend-7)) ; ) - { - HUF_DECODE_SYMBOLX2_2(op1, &bitD1); - HUF_DECODE_SYMBOLX2_2(op2, &bitD2); - HUF_DECODE_SYMBOLX2_2(op3, &bitD3); - HUF_DECODE_SYMBOLX2_2(op4, &bitD4); - HUF_DECODE_SYMBOLX2_1(op1, &bitD1); - HUF_DECODE_SYMBOLX2_1(op2, &bitD2); - HUF_DECODE_SYMBOLX2_1(op3, &bitD3); - HUF_DECODE_SYMBOLX2_1(op4, &bitD4); - HUF_DECODE_SYMBOLX2_2(op1, &bitD1); - HUF_DECODE_SYMBOLX2_2(op2, &bitD2); - HUF_DECODE_SYMBOLX2_2(op3, &bitD3); - HUF_DECODE_SYMBOLX2_2(op4, &bitD4); - HUF_DECODE_SYMBOLX2_0(op1, &bitD1); - HUF_DECODE_SYMBOLX2_0(op2, &bitD2); - HUF_DECODE_SYMBOLX2_0(op3, &bitD3); - HUF_DECODE_SYMBOLX2_0(op4, &bitD4); - - endSignal = BIT_reloadDStream(&bitD1) | BIT_reloadDStream(&bitD2) | BIT_reloadDStream(&bitD3) | BIT_reloadDStream(&bitD4); - } - - /* check corruption */ - if (op1 > opStart2) return ERROR(corruption_detected); - if (op2 > opStart3) return ERROR(corruption_detected); - if (op3 > opStart4) return ERROR(corruption_detected); - /* note : op4 supposed already verified within main loop */ - - /* finish bitStreams one by one */ - HUF_decodeStreamX2(op1, &bitD1, opStart2, dt, dtLog); - HUF_decodeStreamX2(op2, &bitD2, opStart3, dt, dtLog); - HUF_decodeStreamX2(op3, &bitD3, opStart4, dt, dtLog); - HUF_decodeStreamX2(op4, &bitD4, oend, dt, dtLog); - - /* check */ - endSignal = BIT_endOfDStream(&bitD1) & BIT_endOfDStream(&bitD2) & BIT_endOfDStream(&bitD3) & BIT_endOfDStream(&bitD4); - if (!endSignal) return ERROR(corruption_detected); - - /* decoded size */ - return dstSize; - } -} - - -static size_t HUF_decompress4X2 (void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize) -{ - HUF_CREATE_STATIC_DTABLEX2(DTable, HUF_MAX_TABLELOG); - const BYTE* ip = (const BYTE*) cSrc; - size_t errorCode; - - errorCode = HUF_readDTableX2 (DTable, cSrc, cSrcSize); - if (HUF_isError(errorCode)) return errorCode; - if (errorCode >= cSrcSize) return ERROR(srcSize_wrong); - ip += errorCode; - cSrcSize -= errorCode; - - return HUF_decompress4X2_usingDTable (dst, dstSize, ip, cSrcSize, DTable); -} - - -/***************************/ -/* double-symbols decoding */ -/***************************/ - -static void HUF_fillDTableX4Level2(HUF_DEltX4* DTable, U32 sizeLog, const U32 consumed, - const U32* rankValOrigin, const int minWeight, - const sortedSymbol_t* sortedSymbols, const U32 sortedListSize, - U32 nbBitsBaseline, U16 baseSeq) -{ - HUF_DEltX4 DElt; - U32 rankVal[HUF_ABSOLUTEMAX_TABLELOG + 1]; - U32 s; - - /* get pre-calculated rankVal */ - memcpy(rankVal, rankValOrigin, sizeof(rankVal)); - - /* fill skipped values */ - if (minWeight>1) - { - U32 i, skipSize = rankVal[minWeight]; - MEM_writeLE16(&(DElt.sequence), baseSeq); - DElt.nbBits = (BYTE)(consumed); - DElt.length = 1; - for (i = 0; i < skipSize; i++) - DTable[i] = DElt; - } - - /* fill DTable */ - for (s=0; s= 1 */ - - rankVal[weight] += length; - } -} - -typedef U32 rankVal_t[HUF_ABSOLUTEMAX_TABLELOG][HUF_ABSOLUTEMAX_TABLELOG + 1]; - -static void HUF_fillDTableX4(HUF_DEltX4* DTable, const U32 targetLog, - const sortedSymbol_t* sortedList, const U32 sortedListSize, - const U32* rankStart, rankVal_t rankValOrigin, const U32 maxWeight, - const U32 nbBitsBaseline) -{ - U32 rankVal[HUF_ABSOLUTEMAX_TABLELOG + 1]; - const int scaleLog = nbBitsBaseline - targetLog; /* note : targetLog >= srcLog, hence scaleLog <= 1 */ - const U32 minBits = nbBitsBaseline - maxWeight; - U32 s; - - memcpy(rankVal, rankValOrigin, sizeof(rankVal)); - - /* fill DTable */ - for (s=0; s= minBits) /* enough room for a second symbol */ - { - U32 sortedRank; - int minWeight = nbBits + scaleLog; - if (minWeight < 1) minWeight = 1; - sortedRank = rankStart[minWeight]; - HUF_fillDTableX4Level2(DTable+start, targetLog-nbBits, nbBits, - rankValOrigin[nbBits], minWeight, - sortedList+sortedRank, sortedListSize-sortedRank, - nbBitsBaseline, symbol); - } - else - { - U32 i; - const U32 end = start + length; - HUF_DEltX4 DElt; - - MEM_writeLE16(&(DElt.sequence), symbol); - DElt.nbBits = (BYTE)(nbBits); - DElt.length = 1; - for (i = start; i < end; i++) - DTable[i] = DElt; - } - rankVal[weight] += length; - } -} - -static size_t HUF_readDTableX4 (U32* DTable, const void* src, size_t srcSize) -{ - BYTE weightList[HUF_MAX_SYMBOL_VALUE + 1]; - sortedSymbol_t sortedSymbol[HUF_MAX_SYMBOL_VALUE + 1]; - U32 rankStats[HUF_ABSOLUTEMAX_TABLELOG + 1] = { 0 }; - U32 rankStart0[HUF_ABSOLUTEMAX_TABLELOG + 2] = { 0 }; - U32* const rankStart = rankStart0+1; - rankVal_t rankVal; - U32 tableLog, maxW, sizeOfSort, nbSymbols; - const U32 memLog = DTable[0]; - const BYTE* ip = (const BYTE*) src; - size_t iSize = ip[0]; - void* ptr = DTable; - HUF_DEltX4* const dt = ((HUF_DEltX4*)ptr) + 1; - - HUF_STATIC_ASSERT(sizeof(HUF_DEltX4) == sizeof(U32)); /* if compilation fails here, assertion is false */ - if (memLog > HUF_ABSOLUTEMAX_TABLELOG) return ERROR(tableLog_tooLarge); - //memset(weightList, 0, sizeof(weightList)); /* is not necessary, even though some analyzer complain ... */ - - iSize = HUF_readStats(weightList, HUF_MAX_SYMBOL_VALUE + 1, rankStats, &nbSymbols, &tableLog, src, srcSize); - if (HUF_isError(iSize)) return iSize; - - /* check result */ - if (tableLog > memLog) return ERROR(tableLog_tooLarge); /* DTable can't fit code depth */ - - /* find maxWeight */ - for (maxW = tableLog; rankStats[maxW]==0; maxW--) - {if (!maxW) return ERROR(GENERIC); } /* necessarily finds a solution before maxW==0 */ - - /* Get start index of each weight */ - { - U32 w, nextRankStart = 0; - for (w=1; w<=maxW; w++) - { - U32 current = nextRankStart; - nextRankStart += rankStats[w]; - rankStart[w] = current; - } - rankStart[0] = nextRankStart; /* put all 0w symbols at the end of sorted list*/ - sizeOfSort = nextRankStart; - } - - /* sort symbols by weight */ - { - U32 s; - for (s=0; s> consumed; - } - } - } - - HUF_fillDTableX4(dt, memLog, - sortedSymbol, sizeOfSort, - rankStart0, rankVal, maxW, - tableLog+1); - - return iSize; -} - - -static U32 HUF_decodeSymbolX4(void* op, BIT_DStream_t* DStream, const HUF_DEltX4* dt, const U32 dtLog) -{ - const size_t val = BIT_lookBitsFast(DStream, dtLog); /* note : dtLog >= 1 */ - memcpy(op, dt+val, 2); - BIT_skipBits(DStream, dt[val].nbBits); - return dt[val].length; -} - -static U32 HUF_decodeLastSymbolX4(void* op, BIT_DStream_t* DStream, const HUF_DEltX4* dt, const U32 dtLog) -{ - const size_t val = BIT_lookBitsFast(DStream, dtLog); /* note : dtLog >= 1 */ - memcpy(op, dt+val, 1); - if (dt[val].length==1) BIT_skipBits(DStream, dt[val].nbBits); - else - { - if (DStream->bitsConsumed < (sizeof(DStream->bitContainer)*8)) - { - BIT_skipBits(DStream, dt[val].nbBits); - if (DStream->bitsConsumed > (sizeof(DStream->bitContainer)*8)) - DStream->bitsConsumed = (sizeof(DStream->bitContainer)*8); /* ugly hack; works only because it's the last symbol. Note : can't easily extract nbBits from just this symbol */ - } - } - return 1; -} - - -#define HUF_DECODE_SYMBOLX4_0(ptr, DStreamPtr) \ - ptr += HUF_decodeSymbolX4(ptr, DStreamPtr, dt, dtLog) - -#define HUF_DECODE_SYMBOLX4_1(ptr, DStreamPtr) \ - if (MEM_64bits() || (HUF_MAX_TABLELOG<=12)) \ - ptr += HUF_decodeSymbolX4(ptr, DStreamPtr, dt, dtLog) - -#define HUF_DECODE_SYMBOLX4_2(ptr, DStreamPtr) \ - if (MEM_64bits()) \ - ptr += HUF_decodeSymbolX4(ptr, DStreamPtr, dt, dtLog) - -static inline size_t HUF_decodeStreamX4(BYTE* p, BIT_DStream_t* bitDPtr, BYTE* const pEnd, const HUF_DEltX4* const dt, const U32 dtLog) -{ - BYTE* const pStart = p; - - /* up to 8 symbols at a time */ - while ((BIT_reloadDStream(bitDPtr) == BIT_DStream_unfinished) && (p < pEnd-7)) - { - HUF_DECODE_SYMBOLX4_2(p, bitDPtr); - HUF_DECODE_SYMBOLX4_1(p, bitDPtr); - HUF_DECODE_SYMBOLX4_2(p, bitDPtr); - HUF_DECODE_SYMBOLX4_0(p, bitDPtr); - } - - /* closer to the end */ - while ((BIT_reloadDStream(bitDPtr) == BIT_DStream_unfinished) && (p <= pEnd-2)) - HUF_DECODE_SYMBOLX4_0(p, bitDPtr); - - while (p <= pEnd-2) - HUF_DECODE_SYMBOLX4_0(p, bitDPtr); /* no need to reload : reached the end of DStream */ - - if (p < pEnd) - p += HUF_decodeLastSymbolX4(p, bitDPtr, dt, dtLog); - - return p-pStart; -} - - - -static size_t HUF_decompress4X4_usingDTable( - void* dst, size_t dstSize, - const void* cSrc, size_t cSrcSize, - const U32* DTable) -{ - if (cSrcSize < 10) return ERROR(corruption_detected); /* strict minimum : jump table + 1 byte per stream */ - - { - const BYTE* const istart = (const BYTE*) cSrc; - BYTE* const ostart = (BYTE*) dst; - BYTE* const oend = ostart + dstSize; - - const void* ptr = DTable; - const HUF_DEltX4* const dt = ((const HUF_DEltX4*)ptr) +1; - const U32 dtLog = DTable[0]; - size_t errorCode; - - /* Init */ - BIT_DStream_t bitD1; - BIT_DStream_t bitD2; - BIT_DStream_t bitD3; - BIT_DStream_t bitD4; - const size_t length1 = MEM_readLE16(istart); - const size_t length2 = MEM_readLE16(istart+2); - const size_t length3 = MEM_readLE16(istart+4); - size_t length4; - const BYTE* const istart1 = istart + 6; /* jumpTable */ - const BYTE* const istart2 = istart1 + length1; - const BYTE* const istart3 = istart2 + length2; - const BYTE* const istart4 = istart3 + length3; - const size_t segmentSize = (dstSize+3) / 4; - BYTE* const opStart2 = ostart + segmentSize; - BYTE* const opStart3 = opStart2 + segmentSize; - BYTE* const opStart4 = opStart3 + segmentSize; - BYTE* op1 = ostart; - BYTE* op2 = opStart2; - BYTE* op3 = opStart3; - BYTE* op4 = opStart4; - U32 endSignal; - - length4 = cSrcSize - (length1 + length2 + length3 + 6); - if (length4 > cSrcSize) return ERROR(corruption_detected); /* overflow */ - errorCode = BIT_initDStream(&bitD1, istart1, length1); - if (HUF_isError(errorCode)) return errorCode; - errorCode = BIT_initDStream(&bitD2, istart2, length2); - if (HUF_isError(errorCode)) return errorCode; - errorCode = BIT_initDStream(&bitD3, istart3, length3); - if (HUF_isError(errorCode)) return errorCode; - errorCode = BIT_initDStream(&bitD4, istart4, length4); - if (HUF_isError(errorCode)) return errorCode; - - /* 16-32 symbols per loop (4-8 symbols per stream) */ - endSignal = BIT_reloadDStream(&bitD1) | BIT_reloadDStream(&bitD2) | BIT_reloadDStream(&bitD3) | BIT_reloadDStream(&bitD4); - for ( ; (endSignal==BIT_DStream_unfinished) && (op4<(oend-7)) ; ) - { - HUF_DECODE_SYMBOLX4_2(op1, &bitD1); - HUF_DECODE_SYMBOLX4_2(op2, &bitD2); - HUF_DECODE_SYMBOLX4_2(op3, &bitD3); - HUF_DECODE_SYMBOLX4_2(op4, &bitD4); - HUF_DECODE_SYMBOLX4_1(op1, &bitD1); - HUF_DECODE_SYMBOLX4_1(op2, &bitD2); - HUF_DECODE_SYMBOLX4_1(op3, &bitD3); - HUF_DECODE_SYMBOLX4_1(op4, &bitD4); - HUF_DECODE_SYMBOLX4_2(op1, &bitD1); - HUF_DECODE_SYMBOLX4_2(op2, &bitD2); - HUF_DECODE_SYMBOLX4_2(op3, &bitD3); - HUF_DECODE_SYMBOLX4_2(op4, &bitD4); - HUF_DECODE_SYMBOLX4_0(op1, &bitD1); - HUF_DECODE_SYMBOLX4_0(op2, &bitD2); - HUF_DECODE_SYMBOLX4_0(op3, &bitD3); - HUF_DECODE_SYMBOLX4_0(op4, &bitD4); - - endSignal = BIT_reloadDStream(&bitD1) | BIT_reloadDStream(&bitD2) | BIT_reloadDStream(&bitD3) | BIT_reloadDStream(&bitD4); - } - - /* check corruption */ - if (op1 > opStart2) return ERROR(corruption_detected); - if (op2 > opStart3) return ERROR(corruption_detected); - if (op3 > opStart4) return ERROR(corruption_detected); - /* note : op4 supposed already verified within main loop */ - - /* finish bitStreams one by one */ - HUF_decodeStreamX4(op1, &bitD1, opStart2, dt, dtLog); - HUF_decodeStreamX4(op2, &bitD2, opStart3, dt, dtLog); - HUF_decodeStreamX4(op3, &bitD3, opStart4, dt, dtLog); - HUF_decodeStreamX4(op4, &bitD4, oend, dt, dtLog); - - /* check */ - endSignal = BIT_endOfDStream(&bitD1) & BIT_endOfDStream(&bitD2) & BIT_endOfDStream(&bitD3) & BIT_endOfDStream(&bitD4); - if (!endSignal) return ERROR(corruption_detected); - - /* decoded size */ - return dstSize; - } -} - - -static size_t HUF_decompress4X4 (void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize) -{ - HUF_CREATE_STATIC_DTABLEX4(DTable, HUF_MAX_TABLELOG); - const BYTE* ip = (const BYTE*) cSrc; - - size_t hSize = HUF_readDTableX4 (DTable, cSrc, cSrcSize); - if (HUF_isError(hSize)) return hSize; - if (hSize >= cSrcSize) return ERROR(srcSize_wrong); - ip += hSize; - cSrcSize -= hSize; - - return HUF_decompress4X4_usingDTable (dst, dstSize, ip, cSrcSize, DTable); -} - - -/**********************************/ -/* quad-symbol decoding */ -/**********************************/ -typedef struct { BYTE nbBits; BYTE nbBytes; } HUF_DDescX6; -typedef union { BYTE byte[4]; U32 sequence; } HUF_DSeqX6; - -/* recursive, up to level 3; may benefit from