From 1847ce88064ddb395f3592b11d603ec250d8d33e Mon Sep 17 00:00:00 2001 From: Alexandre Bury Date: Wed, 26 Jan 2022 15:41:16 -0500 Subject: [PATCH] Split binding generation into zstd and zdict --- zstd-safe/zstd-sys/build.rs | 1 + zstd-safe/zstd-sys/src/bindings_zdict.rs | 136 ++++++++ .../src/bindings_zdict_experimental.rs | 308 +++++++++++++++++ zstd-safe/zstd-sys/src/bindings_zdict_std.rs | 138 ++++++++ .../src/bindings_zdict_std_experimental.rs | 310 ++++++++++++++++++ .../src/{bindings.rs => bindings_zstd.rs} | 99 ------ ...ental.rs => bindings_zstd_experimental.rs} | 271 --------------- .../{bindings_std.rs => bindings_zstd_std.rs} | 101 ------ ...l.rs => bindings_zstd_std_experimental.rs} | 273 --------------- zstd-safe/zstd-sys/src/lib.rs | 37 ++- zstd-safe/zstd-sys/update_bindings.sh | 22 +- zstd-safe/zstd-sys/zdict.h | 17 + zstd-safe/zstd-sys/zstd.h | 2 - 13 files changed, 957 insertions(+), 758 deletions(-) create mode 100644 zstd-safe/zstd-sys/src/bindings_zdict.rs create mode 100644 zstd-safe/zstd-sys/src/bindings_zdict_experimental.rs create mode 100644 zstd-safe/zstd-sys/src/bindings_zdict_std.rs create mode 100644 zstd-safe/zstd-sys/src/bindings_zdict_std_experimental.rs rename zstd-safe/zstd-sys/src/{bindings.rs => bindings_zstd.rs} (89%) rename zstd-safe/zstd-sys/src/{bindings_experimental.rs => bindings_zstd_experimental.rs} (88%) rename zstd-safe/zstd-sys/src/{bindings_std.rs => bindings_zstd_std.rs} (89%) rename zstd-safe/zstd-sys/src/{bindings_std_experimental.rs => bindings_zstd_std_experimental.rs} (87%) create mode 100644 zstd-safe/zstd-sys/zdict.h diff --git a/zstd-safe/zstd-sys/build.rs b/zstd-safe/zstd-sys/build.rs index 8710c30d..ce6e7c53 100644 --- a/zstd-safe/zstd-sys/build.rs +++ b/zstd-safe/zstd-sys/build.rs @@ -6,6 +6,7 @@ use std::{env, fs}; fn generate_bindings(defs: Vec<&str>, headerpaths: Vec) { let bindings = bindgen::Builder::default() .header("zstd.h") + .header("zdict.h") .blocklist_type("max_align_t") .size_t_is_usize(true) .use_core() diff --git a/zstd-safe/zstd-sys/src/bindings_zdict.rs b/zstd-safe/zstd-sys/src/bindings_zdict.rs new file mode 100644 index 00000000..2cb24424 --- /dev/null +++ b/zstd-safe/zstd-sys/src/bindings_zdict.rs @@ -0,0 +1,136 @@ +/* +This file is auto-generated from the public API of the zstd library. +It is released under the same BSD license. + +BSD License + +For Zstandard software + +Copyright (c) 2016-present, Facebook, Inc. All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + * Neither the name Facebook nor the names of its contributors may be used to + endorse or promote products derived from this software without specific + prior written permission. + +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. +*/ +/* automatically generated by rust-bindgen 0.59.2 */ + +extern "C" { + #[doc = " ZDICT_trainFromBuffer():"] + #[doc = " Train a dictionary from an array of samples."] + #[doc = " Redirect towards ZDICT_optimizeTrainFromBuffer_fastCover() single-threaded, with d=8, steps=4,"] + #[doc = " f=20, and accel=1."] + #[doc = " Samples must be stored concatenated in a single flat buffer `samplesBuffer`,"] + #[doc = " supplied with an array of sizes `samplesSizes`, providing the size of each sample, in order."] + #[doc = " The resulting dictionary will be saved into `dictBuffer`."] + #[doc = " @return: size of dictionary stored into `dictBuffer` (<= `dictBufferCapacity`)"] + #[doc = " or an error code, which can be tested with ZDICT_isError()."] + #[doc = " Note: Dictionary training will fail if there are not enough samples to construct a"] + #[doc = " dictionary, or if most of the samples are too small (< 8 bytes being the lower limit)."] + #[doc = " If dictionary training fails, you should use zstd without a dictionary, as the dictionary"] + #[doc = " would've been ineffective anyways. If you believe your samples would benefit from a dictionary"] + #[doc = " please open an issue with details, and we can look into it."] + #[doc = " Note: ZDICT_trainFromBuffer()'s memory usage is about 6 MB."] + #[doc = " Tips: In general, a reasonable dictionary has a size of ~ 100 KB."] + #[doc = " It's possible to select smaller or larger size, just by specifying `dictBufferCapacity`."] + #[doc = " In general, it's recommended to provide a few thousands samples, though this can vary a lot."] + #[doc = " It's recommended that total size of all samples be about ~x100 times the target size of dictionary."] + pub fn ZDICT_trainFromBuffer( + dictBuffer: *mut libc::c_void, + dictBufferCapacity: usize, + samplesBuffer: *const libc::c_void, + samplesSizes: *const usize, + nbSamples: libc::c_uint, + ) -> usize; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct ZDICT_params_t { + pub compressionLevel: libc::c_int, + pub notificationLevel: libc::c_uint, + pub dictID: libc::c_uint, +} +extern "C" { + #[doc = " ZDICT_finalizeDictionary():"] + #[doc = " Given a custom content as a basis for dictionary, and a set of samples,"] + #[doc = " finalize dictionary by adding headers and statistics according to the zstd"] + #[doc = " dictionary format."] + #[doc = ""] + #[doc = " Samples must be stored concatenated in a flat buffer `samplesBuffer`,"] + #[doc = " supplied with an array of sizes `samplesSizes`, providing the size of each"] + #[doc = " sample in order. The samples are used to construct the statistics, so they"] + #[doc = " should be representative of what you will compress with this dictionary."] + #[doc = ""] + #[doc = " The compression level can be set in `parameters`. You should pass the"] + #[doc = " compression level you expect to use in production. The statistics for each"] + #[doc = " compression level differ, so tuning the dictionary for the compression level"] + #[doc = " can help quite a bit."] + #[doc = ""] + #[doc = " You can set an explicit dictionary ID in `parameters`, or allow us to pick"] + #[doc = " a random dictionary ID for you, but we can't guarantee no collisions."] + #[doc = ""] + #[doc = " The dstDictBuffer and the dictContent may overlap, and the content will be"] + #[doc = " appended to the end of the header. If the header + the content doesn't fit in"] + #[doc = " maxDictSize the beginning of the content is truncated to make room, since it"] + #[doc = " is presumed that the most profitable content is at the end of the dictionary,"] + #[doc = " since that is the cheapest to reference."] + #[doc = ""] + #[doc = " `maxDictSize` must be >= max(dictContentSize, ZSTD_DICTSIZE_MIN)."] + #[doc = ""] + #[doc = " @return: size of dictionary stored into `dstDictBuffer` (<= `maxDictSize`),"] + #[doc = " or an error code, which can be tested by ZDICT_isError()."] + #[doc = " Note: ZDICT_finalizeDictionary() will push notifications into stderr if"] + #[doc = " instructed to, using notificationLevel>0."] + #[doc = " NOTE: This function currently may fail in several edge cases including:"] + #[doc = " * Not enough samples"] + #[doc = " * Samples are uncompressible"] + #[doc = " * Samples are all exactly the same"] + pub fn ZDICT_finalizeDictionary( + dstDictBuffer: *mut libc::c_void, + maxDictSize: usize, + dictContent: *const libc::c_void, + dictContentSize: usize, + samplesBuffer: *const libc::c_void, + samplesSizes: *const usize, + nbSamples: libc::c_uint, + parameters: ZDICT_params_t, + ) -> usize; +} +extern "C" { + pub fn ZDICT_getDictID( + dictBuffer: *const libc::c_void, + dictSize: usize, + ) -> libc::c_uint; +} +extern "C" { + pub fn ZDICT_getDictHeaderSize( + dictBuffer: *const libc::c_void, + dictSize: usize, + ) -> usize; +} +extern "C" { + pub fn ZDICT_isError(errorCode: usize) -> libc::c_uint; +} +extern "C" { + pub fn ZDICT_getErrorName(errorCode: usize) -> *const libc::c_char; +} diff --git a/zstd-safe/zstd-sys/src/bindings_zdict_experimental.rs b/zstd-safe/zstd-sys/src/bindings_zdict_experimental.rs new file mode 100644 index 00000000..3833c95a --- /dev/null +++ b/zstd-safe/zstd-sys/src/bindings_zdict_experimental.rs @@ -0,0 +1,308 @@ +/* +This file is auto-generated from the public API of the zstd library. +It is released under the same BSD license. + +BSD License + +For Zstandard software + +Copyright (c) 2016-present, Facebook, Inc. All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + * Neither the name Facebook nor the names of its contributors may be used to + endorse or promote products derived from this software without specific + prior written permission. + +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. +*/ +/* automatically generated by rust-bindgen 0.59.2 */ + +pub const ZDICT_DICTSIZE_MIN: u32 = 256; +pub const ZDICT_CONTENTSIZE_MIN: u32 = 128; +extern "C" { + #[doc = " ZDICT_trainFromBuffer():"] + #[doc = " Train a dictionary from an array of samples."] + #[doc = " Redirect towards ZDICT_optimizeTrainFromBuffer_fastCover() single-threaded, with d=8, steps=4,"] + #[doc = " f=20, and accel=1."] + #[doc = " Samples must be stored concatenated in a single flat buffer `samplesBuffer`,"] + #[doc = " supplied with an array of sizes `samplesSizes`, providing the size of each sample, in order."] + #[doc = " The resulting dictionary will be saved into `dictBuffer`."] + #[doc = " @return: size of dictionary stored into `dictBuffer` (<= `dictBufferCapacity`)"] + #[doc = " or an error code, which can be tested with ZDICT_isError()."] + #[doc = " Note: Dictionary training will fail if there are not enough samples to construct a"] + #[doc = " dictionary, or if most of the samples are too small (< 8 bytes being the lower limit)."] + #[doc = " If dictionary training fails, you should use zstd without a dictionary, as the dictionary"] + #[doc = " would've been ineffective anyways. If you believe your samples would benefit from a dictionary"] + #[doc = " please open an issue with details, and we can look into it."] + #[doc = " Note: ZDICT_trainFromBuffer()'s memory usage is about 6 MB."] + #[doc = " Tips: In general, a reasonable dictionary has a size of ~ 100 KB."] + #[doc = " It's possible to select smaller or larger size, just by specifying `dictBufferCapacity`."] + #[doc = " In general, it's recommended to provide a few thousands samples, though this can vary a lot."] + #[doc = " It's recommended that total size of all samples be about ~x100 times the target size of dictionary."] + pub fn ZDICT_trainFromBuffer( + dictBuffer: *mut libc::c_void, + dictBufferCapacity: usize, + samplesBuffer: *const libc::c_void, + samplesSizes: *const usize, + nbSamples: libc::c_uint, + ) -> usize; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct ZDICT_params_t { + pub compressionLevel: libc::c_int, + pub notificationLevel: libc::c_uint, + pub dictID: libc::c_uint, +} +extern "C" { + #[doc = " ZDICT_finalizeDictionary():"] + #[doc = " Given a custom content as a basis for dictionary, and a set of samples,"] + #[doc = " finalize dictionary by adding headers and statistics according to the zstd"] + #[doc = " dictionary format."] + #[doc = ""] + #[doc = " Samples must be stored concatenated in a flat buffer `samplesBuffer`,"] + #[doc = " supplied with an array of sizes `samplesSizes`, providing the size of each"] + #[doc = " sample in order. The samples are used to construct the statistics, so they"] + #[doc = " should be representative of what you will compress with this dictionary."] + #[doc = ""] + #[doc = " The compression level can be set in `parameters`. You should pass the"] + #[doc = " compression level you expect to use in production. The statistics for each"] + #[doc = " compression level differ, so tuning the dictionary for the compression level"] + #[doc = " can help quite a bit."] + #[doc = ""] + #[doc = " You can set an explicit dictionary ID in `parameters`, or allow us to pick"] + #[doc = " a random dictionary ID for you, but we can't guarantee no collisions."] + #[doc = ""] + #[doc = " The dstDictBuffer and the dictContent may overlap, and the content will be"] + #[doc = " appended to the end of the header. If the header + the content doesn't fit in"] + #[doc = " maxDictSize the beginning of the content is truncated to make room, since it"] + #[doc = " is presumed that the most profitable content is at the end of the dictionary,"] + #[doc = " since that is the cheapest to reference."] + #[doc = ""] + #[doc = " `maxDictSize` must be >= max(dictContentSize, ZSTD_DICTSIZE_MIN)."] + #[doc = ""] + #[doc = " @return: size of dictionary stored into `dstDictBuffer` (<= `maxDictSize`),"] + #[doc = " or an error code, which can be tested by ZDICT_isError()."] + #[doc = " Note: ZDICT_finalizeDictionary() will push notifications into stderr if"] + #[doc = " instructed to, using notificationLevel>0."] + #[doc = " NOTE: This function currently may fail in several edge cases including:"] + #[doc = " * Not enough samples"] + #[doc = " * Samples are uncompressible"] + #[doc = " * Samples are all exactly the same"] + pub fn ZDICT_finalizeDictionary( + dstDictBuffer: *mut libc::c_void, + maxDictSize: usize, + dictContent: *const libc::c_void, + dictContentSize: usize, + samplesBuffer: *const libc::c_void, + samplesSizes: *const usize, + nbSamples: libc::c_uint, + parameters: ZDICT_params_t, + ) -> usize; +} +extern "C" { + pub fn ZDICT_getDictID( + dictBuffer: *const libc::c_void, + dictSize: usize, + ) -> libc::c_uint; +} +extern "C" { + pub fn ZDICT_getDictHeaderSize( + dictBuffer: *const libc::c_void, + dictSize: usize, + ) -> usize; +} +extern "C" { + pub fn ZDICT_isError(errorCode: usize) -> libc::c_uint; +} +extern "C" { + pub fn ZDICT_getErrorName(errorCode: usize) -> *const libc::c_char; +} +#[doc = " ZDICT_cover_params_t:"] +#[doc = " k and d are the only required parameters."] +#[doc = " For others, value 0 means default."] +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct ZDICT_cover_params_t { + pub k: libc::c_uint, + pub d: libc::c_uint, + pub steps: libc::c_uint, + pub nbThreads: libc::c_uint, + pub splitPoint: f64, + pub shrinkDict: libc::c_uint, + pub shrinkDictMaxRegression: libc::c_uint, + pub zParams: ZDICT_params_t, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct ZDICT_fastCover_params_t { + pub k: libc::c_uint, + pub d: libc::c_uint, + pub f: libc::c_uint, + pub steps: libc::c_uint, + pub nbThreads: libc::c_uint, + pub splitPoint: f64, + pub accel: libc::c_uint, + pub shrinkDict: libc::c_uint, + pub shrinkDictMaxRegression: libc::c_uint, + pub zParams: ZDICT_params_t, +} +extern "C" { + #[doc = " ZDICT_trainFromBuffer_cover():"] + #[doc = " Train a dictionary from an array of samples using the COVER algorithm."] + #[doc = " Samples must be stored concatenated in a single flat buffer `samplesBuffer`,"] + #[doc = " supplied with an array of sizes `samplesSizes`, providing the size of each sample, in order."] + #[doc = " The resulting dictionary will be saved into `dictBuffer`."] + #[doc = " @return: size of dictionary stored into `dictBuffer` (<= `dictBufferCapacity`)"] + #[doc = " or an error code, which can be tested with ZDICT_isError()."] + #[doc = " See ZDICT_trainFromBuffer() for details on failure modes."] + #[doc = " Note: ZDICT_trainFromBuffer_cover() requires about 9 bytes of memory for each input byte."] + #[doc = " Tips: In general, a reasonable dictionary has a size of ~ 100 KB."] + #[doc = " It's possible to select smaller or larger size, just by specifying `dictBufferCapacity`."] + #[doc = " In general, it's recommended to provide a few thousands samples, though this can vary a lot."] + #[doc = " It's recommended that total size of all samples be about ~x100 times the target size of dictionary."] + pub fn ZDICT_trainFromBuffer_cover( + dictBuffer: *mut libc::c_void, + dictBufferCapacity: usize, + samplesBuffer: *const libc::c_void, + samplesSizes: *const usize, + nbSamples: libc::c_uint, + parameters: ZDICT_cover_params_t, + ) -> usize; +} +extern "C" { + #[doc = " ZDICT_optimizeTrainFromBuffer_cover():"] + #[doc = " The same requirements as above hold for all the parameters except `parameters`."] + #[doc = " This function tries many parameter combinations and picks the best parameters."] + #[doc = " `*parameters` is filled with the best parameters found,"] + #[doc = " dictionary constructed with those parameters is stored in `dictBuffer`."] + #[doc = ""] + #[doc = " All of the parameters d, k, steps are optional."] + #[doc = " If d is non-zero then we don't check multiple values of d, otherwise we check d = {6, 8}."] + #[doc = " if steps is zero it defaults to its default value."] + #[doc = " If k is non-zero then we don't check multiple values of k, otherwise we check steps values in [50, 2000]."] + #[doc = ""] + #[doc = " @return: size of dictionary stored into `dictBuffer` (<= `dictBufferCapacity`)"] + #[doc = " or an error code, which can be tested with ZDICT_isError()."] + #[doc = " On success `*parameters` contains the parameters selected."] + #[doc = " See ZDICT_trainFromBuffer() for details on failure modes."] + #[doc = " Note: ZDICT_optimizeTrainFromBuffer_cover() requires about 8 bytes of memory for each input byte and additionally another 5 bytes of memory for each byte of memory for each thread."] + pub fn ZDICT_optimizeTrainFromBuffer_cover( + dictBuffer: *mut libc::c_void, + dictBufferCapacity: usize, + samplesBuffer: *const libc::c_void, + samplesSizes: *const usize, + nbSamples: libc::c_uint, + parameters: *mut ZDICT_cover_params_t, + ) -> usize; +} +extern "C" { + #[doc = " ZDICT_trainFromBuffer_fastCover():"] + #[doc = " Train a dictionary from an array of samples using a modified version of COVER algorithm."] + #[doc = " Samples must be stored concatenated in a single flat buffer `samplesBuffer`,"] + #[doc = " supplied with an array of sizes `samplesSizes`, providing the size of each sample, in order."] + #[doc = " d and k are required."] + #[doc = " All other parameters are optional, will use default values if not provided"] + #[doc = " The resulting dictionary will be saved into `dictBuffer`."] + #[doc = " @return: size of dictionary stored into `dictBuffer` (<= `dictBufferCapacity`)"] + #[doc = " or an error code, which can be tested with ZDICT_isError()."] + #[doc = " See ZDICT_trainFromBuffer() for details on failure modes."] + #[doc = " Note: ZDICT_trainFromBuffer_fastCover() requires 6 * 2^f bytes of memory."] + #[doc = " Tips: In general, a reasonable dictionary has a size of ~ 100 KB."] + #[doc = " It's possible to select smaller or larger size, just by specifying `dictBufferCapacity`."] + #[doc = " In general, it's recommended to provide a few thousands samples, though this can vary a lot."] + #[doc = " It's recommended that total size of all samples be about ~x100 times the target size of dictionary."] + pub fn ZDICT_trainFromBuffer_fastCover( + dictBuffer: *mut libc::c_void, + dictBufferCapacity: usize, + samplesBuffer: *const libc::c_void, + samplesSizes: *const usize, + nbSamples: libc::c_uint, + parameters: ZDICT_fastCover_params_t, + ) -> usize; +} +extern "C" { + #[doc = " ZDICT_optimizeTrainFromBuffer_fastCover():"] + #[doc = " The same requirements as above hold for all the parameters except `parameters`."] + #[doc = " This function tries many parameter combinations (specifically, k and d combinations)"] + #[doc = " and picks the best parameters. `*parameters` is filled with the best parameters found,"] + #[doc = " dictionary constructed with those parameters is stored in `dictBuffer`."] + #[doc = " All of the parameters d, k, steps, f, and accel are optional."] + #[doc = " If d is non-zero then we don't check multiple values of d, otherwise we check d = {6, 8}."] + #[doc = " if steps is zero it defaults to its default value."] + #[doc = " If k is non-zero then we don't check multiple values of k, otherwise we check steps values in [50, 2000]."] + #[doc = " If f is zero, default value of 20 is used."] + #[doc = " If accel is zero, default value of 1 is used."] + #[doc = ""] + #[doc = " @return: size of dictionary stored into `dictBuffer` (<= `dictBufferCapacity`)"] + #[doc = " or an error code, which can be tested with ZDICT_isError()."] + #[doc = " On success `*parameters` contains the parameters selected."] + #[doc = " See ZDICT_trainFromBuffer() for details on failure modes."] + #[doc = " Note: ZDICT_optimizeTrainFromBuffer_fastCover() requires about 6 * 2^f bytes of memory for each thread."] + pub fn ZDICT_optimizeTrainFromBuffer_fastCover( + dictBuffer: *mut libc::c_void, + dictBufferCapacity: usize, + samplesBuffer: *const libc::c_void, + samplesSizes: *const usize, + nbSamples: libc::c_uint, + parameters: *mut ZDICT_fastCover_params_t, + ) -> usize; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct ZDICT_legacy_params_t { + pub selectivityLevel: libc::c_uint, + pub zParams: ZDICT_params_t, +} +extern "C" { + #[doc = " ZDICT_trainFromBuffer_legacy():"] + #[doc = " Train a dictionary from an array of samples."] + #[doc = " Samples must be stored concatenated in a single flat buffer `samplesBuffer`,"] + #[doc = " supplied with an array of sizes `samplesSizes`, providing the size of each sample, in order."] + #[doc = " The resulting dictionary will be saved into `dictBuffer`."] + #[doc = " `parameters` is optional and can be provided with values set to 0 to mean \"default\"."] + #[doc = " @return: size of dictionary stored into `dictBuffer` (<= `dictBufferCapacity`)"] + #[doc = " or an error code, which can be tested with ZDICT_isError()."] + #[doc = " See ZDICT_trainFromBuffer() for details on failure modes."] + #[doc = " Tips: In general, a reasonable dictionary has a size of ~ 100 KB."] + #[doc = " It's possible to select smaller or larger size, just by specifying `dictBufferCapacity`."] + #[doc = " In general, it's recommended to provide a few thousands samples, though this can vary a lot."] + #[doc = " It's recommended that total size of all samples be about ~x100 times the target size of dictionary."] + #[doc = " Note: ZDICT_trainFromBuffer_legacy() will send notifications into stderr if instructed to, using notificationLevel>0."] + pub fn ZDICT_trainFromBuffer_legacy( + dictBuffer: *mut libc::c_void, + dictBufferCapacity: usize, + samplesBuffer: *const libc::c_void, + samplesSizes: *const usize, + nbSamples: libc::c_uint, + parameters: ZDICT_legacy_params_t, + ) -> usize; +} +extern "C" { + pub fn ZDICT_addEntropyTablesFromBuffer( + dictBuffer: *mut libc::c_void, + dictContentSize: usize, + dictBufferCapacity: usize, + samplesBuffer: *const libc::c_void, + samplesSizes: *const usize, + nbSamples: libc::c_uint, + ) -> usize; +} diff --git a/zstd-safe/zstd-sys/src/bindings_zdict_std.rs b/zstd-safe/zstd-sys/src/bindings_zdict_std.rs new file mode 100644 index 00000000..e04f0a65 --- /dev/null +++ b/zstd-safe/zstd-sys/src/bindings_zdict_std.rs @@ -0,0 +1,138 @@ +/* +This file is auto-generated from the public API of the zstd library. +It is released under the same BSD license. + +BSD License + +For Zstandard software + +Copyright (c) 2016-present, Facebook, Inc. All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + * Neither the name Facebook nor the names of its contributors may be used to + endorse or promote products derived from this software without specific + prior written permission. + +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. +*/ +/* automatically generated by rust-bindgen 0.59.2 */ + +extern "C" { + #[doc = " ZDICT_trainFromBuffer():"] + #[doc = " Train a dictionary from an array of samples."] + #[doc = " Redirect towards ZDICT_optimizeTrainFromBuffer_fastCover() single-threaded, with d=8, steps=4,"] + #[doc = " f=20, and accel=1."] + #[doc = " Samples must be stored concatenated in a single flat buffer `samplesBuffer`,"] + #[doc = " supplied with an array of sizes `samplesSizes`, providing the size of each sample, in order."] + #[doc = " The resulting dictionary will be saved into `dictBuffer`."] + #[doc = " @return: size of dictionary stored into `dictBuffer` (<= `dictBufferCapacity`)"] + #[doc = " or an error code, which can be tested with ZDICT_isError()."] + #[doc = " Note: Dictionary training will fail if there are not enough samples to construct a"] + #[doc = " dictionary, or if most of the samples are too small (< 8 bytes being the lower limit)."] + #[doc = " If dictionary training fails, you should use zstd without a dictionary, as the dictionary"] + #[doc = " would've been ineffective anyways. If you believe your samples would benefit from a dictionary"] + #[doc = " please open an issue with details, and we can look into it."] + #[doc = " Note: ZDICT_trainFromBuffer()'s memory usage is about 6 MB."] + #[doc = " Tips: In general, a reasonable dictionary has a size of ~ 100 KB."] + #[doc = " It's possible to select smaller or larger size, just by specifying `dictBufferCapacity`."] + #[doc = " In general, it's recommended to provide a few thousands samples, though this can vary a lot."] + #[doc = " It's recommended that total size of all samples be about ~x100 times the target size of dictionary."] + pub fn ZDICT_trainFromBuffer( + dictBuffer: *mut ::core::ffi::c_void, + dictBufferCapacity: usize, + samplesBuffer: *const ::core::ffi::c_void, + samplesSizes: *const usize, + nbSamples: ::std::os::raw::c_uint, + ) -> usize; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct ZDICT_params_t { + pub compressionLevel: ::std::os::raw::c_int, + pub notificationLevel: ::std::os::raw::c_uint, + pub dictID: ::std::os::raw::c_uint, +} +extern "C" { + #[doc = " ZDICT_finalizeDictionary():"] + #[doc = " Given a custom content as a basis for dictionary, and a set of samples,"] + #[doc = " finalize dictionary by adding headers and statistics according to the zstd"] + #[doc = " dictionary format."] + #[doc = ""] + #[doc = " Samples must be stored concatenated in a flat buffer `samplesBuffer`,"] + #[doc = " supplied with an array of sizes `samplesSizes`, providing the size of each"] + #[doc = " sample in order. The samples are used to construct the statistics, so they"] + #[doc = " should be representative of what you will compress with this dictionary."] + #[doc = ""] + #[doc = " The compression level can be set in `parameters`. You should pass the"] + #[doc = " compression level you expect to use in production. The statistics for each"] + #[doc = " compression level differ, so tuning the dictionary for the compression level"] + #[doc = " can help quite a bit."] + #[doc = ""] + #[doc = " You can set an explicit dictionary ID in `parameters`, or allow us to pick"] + #[doc = " a random dictionary ID for you, but we can't guarantee no collisions."] + #[doc = ""] + #[doc = " The dstDictBuffer and the dictContent may overlap, and the content will be"] + #[doc = " appended to the end of the header. If the header + the content doesn't fit in"] + #[doc = " maxDictSize the beginning of the content is truncated to make room, since it"] + #[doc = " is presumed that the most profitable content is at the end of the dictionary,"] + #[doc = " since that is the cheapest to reference."] + #[doc = ""] + #[doc = " `maxDictSize` must be >= max(dictContentSize, ZSTD_DICTSIZE_MIN)."] + #[doc = ""] + #[doc = " @return: size of dictionary stored into `dstDictBuffer` (<= `maxDictSize`),"] + #[doc = " or an error code, which can be tested by ZDICT_isError()."] + #[doc = " Note: ZDICT_finalizeDictionary() will push notifications into stderr if"] + #[doc = " instructed to, using notificationLevel>0."] + #[doc = " NOTE: This function currently may fail in several edge cases including:"] + #[doc = " * Not enough samples"] + #[doc = " * Samples are uncompressible"] + #[doc = " * Samples are all exactly the same"] + pub fn ZDICT_finalizeDictionary( + dstDictBuffer: *mut ::core::ffi::c_void, + maxDictSize: usize, + dictContent: *const ::core::ffi::c_void, + dictContentSize: usize, + samplesBuffer: *const ::core::ffi::c_void, + samplesSizes: *const usize, + nbSamples: ::std::os::raw::c_uint, + parameters: ZDICT_params_t, + ) -> usize; +} +extern "C" { + pub fn ZDICT_getDictID( + dictBuffer: *const ::core::ffi::c_void, + dictSize: usize, + ) -> ::std::os::raw::c_uint; +} +extern "C" { + pub fn ZDICT_getDictHeaderSize( + dictBuffer: *const ::core::ffi::c_void, + dictSize: usize, + ) -> usize; +} +extern "C" { + pub fn ZDICT_isError(errorCode: usize) -> ::std::os::raw::c_uint; +} +extern "C" { + pub fn ZDICT_getErrorName( + errorCode: usize, + ) -> *const ::std::os::raw::c_char; +} diff --git a/zstd-safe/zstd-sys/src/bindings_zdict_std_experimental.rs b/zstd-safe/zstd-sys/src/bindings_zdict_std_experimental.rs new file mode 100644 index 00000000..bd25130f --- /dev/null +++ b/zstd-safe/zstd-sys/src/bindings_zdict_std_experimental.rs @@ -0,0 +1,310 @@ +/* +This file is auto-generated from the public API of the zstd library. +It is released under the same BSD license. + +BSD License + +For Zstandard software + +Copyright (c) 2016-present, Facebook, Inc. All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + * Neither the name Facebook nor the names of its contributors may be used to + endorse or promote products derived from this software without specific + prior written permission. + +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. +*/ +/* automatically generated by rust-bindgen 0.59.2 */ + +pub const ZDICT_DICTSIZE_MIN: u32 = 256; +pub const ZDICT_CONTENTSIZE_MIN: u32 = 128; +extern "C" { + #[doc = " ZDICT_trainFromBuffer():"] + #[doc = " Train a dictionary from an array of samples."] + #[doc = " Redirect towards ZDICT_optimizeTrainFromBuffer_fastCover() single-threaded, with d=8, steps=4,"] + #[doc = " f=20, and accel=1."] + #[doc = " Samples must be stored concatenated in a single flat buffer `samplesBuffer`,"] + #[doc = " supplied with an array of sizes `samplesSizes`, providing the size of each sample, in order."] + #[doc = " The resulting dictionary will be saved into `dictBuffer`."] + #[doc = " @return: size of dictionary stored into `dictBuffer` (<= `dictBufferCapacity`)"] + #[doc = " or an error code, which can be tested with ZDICT_isError()."] + #[doc = " Note: Dictionary training will fail if there are not enough samples to construct a"] + #[doc = " dictionary, or if most of the samples are too small (< 8 bytes being the lower limit)."] + #[doc = " If dictionary training fails, you should use zstd without a dictionary, as the dictionary"] + #[doc = " would've been ineffective anyways. If you believe your samples would benefit from a dictionary"] + #[doc = " please open an issue with details, and we can look into it."] + #[doc = " Note: ZDICT_trainFromBuffer()'s memory usage is about 6 MB."] + #[doc = " Tips: In general, a reasonable dictionary has a size of ~ 100 KB."] + #[doc = " It's possible to select smaller or larger size, just by specifying `dictBufferCapacity`."] + #[doc = " In general, it's recommended to provide a few thousands samples, though this can vary a lot."] + #[doc = " It's recommended that total size of all samples be about ~x100 times the target size of dictionary."] + pub fn ZDICT_trainFromBuffer( + dictBuffer: *mut ::core::ffi::c_void, + dictBufferCapacity: usize, + samplesBuffer: *const ::core::ffi::c_void, + samplesSizes: *const usize, + nbSamples: ::std::os::raw::c_uint, + ) -> usize; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct ZDICT_params_t { + pub compressionLevel: ::std::os::raw::c_int, + pub notificationLevel: ::std::os::raw::c_uint, + pub dictID: ::std::os::raw::c_uint, +} +extern "C" { + #[doc = " ZDICT_finalizeDictionary():"] + #[doc = " Given a custom content as a basis for dictionary, and a set of samples,"] + #[doc = " finalize dictionary by adding headers and statistics according to the zstd"] + #[doc = " dictionary format."] + #[doc = ""] + #[doc = " Samples must be stored concatenated in a flat buffer `samplesBuffer`,"] + #[doc = " supplied with an array of sizes `samplesSizes`, providing the size of each"] + #[doc = " sample in order. The samples are used to construct the statistics, so they"] + #[doc = " should be representative of what you will compress with this dictionary."] + #[doc = ""] + #[doc = " The compression level can be set in `parameters`. You should pass the"] + #[doc = " compression level you expect to use in production. The statistics for each"] + #[doc = " compression level differ, so tuning the dictionary for the compression level"] + #[doc = " can help quite a bit."] + #[doc = ""] + #[doc = " You can set an explicit dictionary ID in `parameters`, or allow us to pick"] + #[doc = " a random dictionary ID for you, but we can't guarantee no collisions."] + #[doc = ""] + #[doc = " The dstDictBuffer and the dictContent may overlap, and the content will be"] + #[doc = " appended to the end of the header. If the header + the content doesn't fit in"] + #[doc = " maxDictSize the beginning of the content is truncated to make room, since it"] + #[doc = " is presumed that the most profitable content is at the end of the dictionary,"] + #[doc = " since that is the cheapest to reference."] + #[doc = ""] + #[doc = " `maxDictSize` must be >= max(dictContentSize, ZSTD_DICTSIZE_MIN)."] + #[doc = ""] + #[doc = " @return: size of dictionary stored into `dstDictBuffer` (<= `maxDictSize`),"] + #[doc = " or an error code, which can be tested by ZDICT_isError()."] + #[doc = " Note: ZDICT_finalizeDictionary() will push notifications into stderr if"] + #[doc = " instructed to, using notificationLevel>0."] + #[doc = " NOTE: This function currently may fail in several edge cases including:"] + #[doc = " * Not enough samples"] + #[doc = " * Samples are uncompressible"] + #[doc = " * Samples are all exactly the same"] + pub fn ZDICT_finalizeDictionary( + dstDictBuffer: *mut ::core::ffi::c_void, + maxDictSize: usize, + dictContent: *const ::core::ffi::c_void, + dictContentSize: usize, + samplesBuffer: *const ::core::ffi::c_void, + samplesSizes: *const usize, + nbSamples: ::std::os::raw::c_uint, + parameters: ZDICT_params_t, + ) -> usize; +} +extern "C" { + pub fn ZDICT_getDictID( + dictBuffer: *const ::core::ffi::c_void, + dictSize: usize, + ) -> ::std::os::raw::c_uint; +} +extern "C" { + pub fn ZDICT_getDictHeaderSize( + dictBuffer: *const ::core::ffi::c_void, + dictSize: usize, + ) -> usize; +} +extern "C" { + pub fn ZDICT_isError(errorCode: usize) -> ::std::os::raw::c_uint; +} +extern "C" { + pub fn ZDICT_getErrorName( + errorCode: usize, + ) -> *const ::std::os::raw::c_char; +} +#[doc = " ZDICT_cover_params_t:"] +#[doc = " k and d are the only required parameters."] +#[doc = " For others, value 0 means default."] +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct ZDICT_cover_params_t { + pub k: ::std::os::raw::c_uint, + pub d: ::std::os::raw::c_uint, + pub steps: ::std::os::raw::c_uint, + pub nbThreads: ::std::os::raw::c_uint, + pub splitPoint: f64, + pub shrinkDict: ::std::os::raw::c_uint, + pub shrinkDictMaxRegression: ::std::os::raw::c_uint, + pub zParams: ZDICT_params_t, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct ZDICT_fastCover_params_t { + pub k: ::std::os::raw::c_uint, + pub d: ::std::os::raw::c_uint, + pub f: ::std::os::raw::c_uint, + pub steps: ::std::os::raw::c_uint, + pub nbThreads: ::std::os::raw::c_uint, + pub splitPoint: f64, + pub accel: ::std::os::raw::c_uint, + pub shrinkDict: ::std::os::raw::c_uint, + pub shrinkDictMaxRegression: ::std::os::raw::c_uint, + pub zParams: ZDICT_params_t, +} +extern "C" { + #[doc = " ZDICT_trainFromBuffer_cover():"] + #[doc = " Train a dictionary from an array of samples using the COVER algorithm."] + #[doc = " Samples must be stored concatenated in a single flat buffer `samplesBuffer`,"] + #[doc = " supplied with an array of sizes `samplesSizes`, providing the size of each sample, in order."] + #[doc = " The resulting dictionary will be saved into `dictBuffer`."] + #[doc = " @return: size of dictionary stored into `dictBuffer` (<= `dictBufferCapacity`)"] + #[doc = " or an error code, which can be tested with ZDICT_isError()."] + #[doc = " See ZDICT_trainFromBuffer() for details on failure modes."] + #[doc = " Note: ZDICT_trainFromBuffer_cover() requires about 9 bytes of memory for each input byte."] + #[doc = " Tips: In general, a reasonable dictionary has a size of ~ 100 KB."] + #[doc = " It's possible to select smaller or larger size, just by specifying `dictBufferCapacity`."] + #[doc = " In general, it's recommended to provide a few thousands samples, though this can vary a lot."] + #[doc = " It's recommended that total size of all samples be about ~x100 times the target size of dictionary."] + pub fn ZDICT_trainFromBuffer_cover( + dictBuffer: *mut ::core::ffi::c_void, + dictBufferCapacity: usize, + samplesBuffer: *const ::core::ffi::c_void, + samplesSizes: *const usize, + nbSamples: ::std::os::raw::c_uint, + parameters: ZDICT_cover_params_t, + ) -> usize; +} +extern "C" { + #[doc = " ZDICT_optimizeTrainFromBuffer_cover():"] + #[doc = " The same requirements as above hold for all the parameters except `parameters`."] + #[doc = " This function tries many parameter combinations and picks the best parameters."] + #[doc = " `*parameters` is filled with the best parameters found,"] + #[doc = " dictionary constructed with those parameters is stored in `dictBuffer`."] + #[doc = ""] + #[doc = " All of the parameters d, k, steps are optional."] + #[doc = " If d is non-zero then we don't check multiple values of d, otherwise we check d = {6, 8}."] + #[doc = " if steps is zero it defaults to its default value."] + #[doc = " If k is non-zero then we don't check multiple values of k, otherwise we check steps values in [50, 2000]."] + #[doc = ""] + #[doc = " @return: size of dictionary stored into `dictBuffer` (<= `dictBufferCapacity`)"] + #[doc = " or an error code, which can be tested with ZDICT_isError()."] + #[doc = " On success `*parameters` contains the parameters selected."] + #[doc = " See ZDICT_trainFromBuffer() for details on failure modes."] + #[doc = " Note: ZDICT_optimizeTrainFromBuffer_cover() requires about 8 bytes of memory for each input byte and additionally another 5 bytes of memory for each byte of memory for each thread."] + pub fn ZDICT_optimizeTrainFromBuffer_cover( + dictBuffer: *mut ::core::ffi::c_void, + dictBufferCapacity: usize, + samplesBuffer: *const ::core::ffi::c_void, + samplesSizes: *const usize, + nbSamples: ::std::os::raw::c_uint, + parameters: *mut ZDICT_cover_params_t, + ) -> usize; +} +extern "C" { + #[doc = " ZDICT_trainFromBuffer_fastCover():"] + #[doc = " Train a dictionary from an array of samples using a modified version of COVER algorithm."] + #[doc = " Samples must be stored concatenated in a single flat buffer `samplesBuffer`,"] + #[doc = " supplied with an array of sizes `samplesSizes`, providing the size of each sample, in order."] + #[doc = " d and k are required."] + #[doc = " All other parameters are optional, will use default values if not provided"] + #[doc = " The resulting dictionary will be saved into `dictBuffer`."] + #[doc = " @return: size of dictionary stored into `dictBuffer` (<= `dictBufferCapacity`)"] + #[doc = " or an error code, which can be tested with ZDICT_isError()."] + #[doc = " See ZDICT_trainFromBuffer() for details on failure modes."] + #[doc = " Note: ZDICT_trainFromBuffer_fastCover() requires 6 * 2^f bytes of memory."] + #[doc = " Tips: In general, a reasonable dictionary has a size of ~ 100 KB."] + #[doc = " It's possible to select smaller or larger size, just by specifying `dictBufferCapacity`."] + #[doc = " In general, it's recommended to provide a few thousands samples, though this can vary a lot."] + #[doc = " It's recommended that total size of all samples be about ~x100 times the target size of dictionary."] + pub fn ZDICT_trainFromBuffer_fastCover( + dictBuffer: *mut ::core::ffi::c_void, + dictBufferCapacity: usize, + samplesBuffer: *const ::core::ffi::c_void, + samplesSizes: *const usize, + nbSamples: ::std::os::raw::c_uint, + parameters: ZDICT_fastCover_params_t, + ) -> usize; +} +extern "C" { + #[doc = " ZDICT_optimizeTrainFromBuffer_fastCover():"] + #[doc = " The same requirements as above hold for all the parameters except `parameters`."] + #[doc = " This function tries many parameter combinations (specifically, k and d combinations)"] + #[doc = " and picks the best parameters. `*parameters` is filled with the best parameters found,"] + #[doc = " dictionary constructed with those parameters is stored in `dictBuffer`."] + #[doc = " All of the parameters d, k, steps, f, and accel are optional."] + #[doc = " If d is non-zero then we don't check multiple values of d, otherwise we check d = {6, 8}."] + #[doc = " if steps is zero it defaults to its default value."] + #[doc = " If k is non-zero then we don't check multiple values of k, otherwise we check steps values in [50, 2000]."] + #[doc = " If f is zero, default value of 20 is used."] + #[doc = " If accel is zero, default value of 1 is used."] + #[doc = ""] + #[doc = " @return: size of dictionary stored into `dictBuffer` (<= `dictBufferCapacity`)"] + #[doc = " or an error code, which can be tested with ZDICT_isError()."] + #[doc = " On success `*parameters` contains the parameters selected."] + #[doc = " See ZDICT_trainFromBuffer() for details on failure modes."] + #[doc = " Note: ZDICT_optimizeTrainFromBuffer_fastCover() requires about 6 * 2^f bytes of memory for each thread."] + pub fn ZDICT_optimizeTrainFromBuffer_fastCover( + dictBuffer: *mut ::core::ffi::c_void, + dictBufferCapacity: usize, + samplesBuffer: *const ::core::ffi::c_void, + samplesSizes: *const usize, + nbSamples: ::std::os::raw::c_uint, + parameters: *mut ZDICT_fastCover_params_t, + ) -> usize; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct ZDICT_legacy_params_t { + pub selectivityLevel: ::std::os::raw::c_uint, + pub zParams: ZDICT_params_t, +} +extern "C" { + #[doc = " ZDICT_trainFromBuffer_legacy():"] + #[doc = " Train a dictionary from an array of samples."] + #[doc = " Samples must be stored concatenated in a single flat buffer `samplesBuffer`,"] + #[doc = " supplied with an array of sizes `samplesSizes`, providing the size of each sample, in order."] + #[doc = " The resulting dictionary will be saved into `dictBuffer`."] + #[doc = " `parameters` is optional and can be provided with values set to 0 to mean \"default\"."] + #[doc = " @return: size of dictionary stored into `dictBuffer` (<= `dictBufferCapacity`)"] + #[doc = " or an error code, which can be tested with ZDICT_isError()."] + #[doc = " See ZDICT_trainFromBuffer() for details on failure modes."] + #[doc = " Tips: In general, a reasonable dictionary has a size of ~ 100 KB."] + #[doc = " It's possible to select smaller or larger size, just by specifying `dictBufferCapacity`."] + #[doc = " In general, it's recommended to provide a few thousands samples, though this can vary a lot."] + #[doc = " It's recommended that total size of all samples be about ~x100 times the target size of dictionary."] + #[doc = " Note: ZDICT_trainFromBuffer_legacy() will send notifications into stderr if instructed to, using notificationLevel>0."] + pub fn ZDICT_trainFromBuffer_legacy( + dictBuffer: *mut ::core::ffi::c_void, + dictBufferCapacity: usize, + samplesBuffer: *const ::core::ffi::c_void, + samplesSizes: *const usize, + nbSamples: ::std::os::raw::c_uint, + parameters: ZDICT_legacy_params_t, + ) -> usize; +} +extern "C" { + pub fn ZDICT_addEntropyTablesFromBuffer( + dictBuffer: *mut ::core::ffi::c_void, + dictContentSize: usize, + dictBufferCapacity: usize, + samplesBuffer: *const ::core::ffi::c_void, + samplesSizes: *const usize, + nbSamples: ::std::os::raw::c_uint, + ) -> usize; +} diff --git a/zstd-safe/zstd-sys/src/bindings.rs b/zstd-safe/zstd-sys/src/bindings_zstd.rs similarity index 89% rename from zstd-safe/zstd-sys/src/bindings.rs rename to zstd-safe/zstd-sys/src/bindings_zstd.rs index efcaf58c..db905316 100644 --- a/zstd-safe/zstd-sys/src/bindings.rs +++ b/zstd-safe/zstd-sys/src/bindings_zstd.rs @@ -942,102 +942,3 @@ extern "C" { extern "C" { pub fn ZSTD_sizeof_DDict(ddict: *const ZSTD_DDict) -> usize; } -extern "C" { - #[doc = " ZDICT_trainFromBuffer():"] - #[doc = " Train a dictionary from an array of samples."] - #[doc = " Redirect towards ZDICT_optimizeTrainFromBuffer_fastCover() single-threaded, with d=8, steps=4,"] - #[doc = " f=20, and accel=1."] - #[doc = " Samples must be stored concatenated in a single flat buffer `samplesBuffer`,"] - #[doc = " supplied with an array of sizes `samplesSizes`, providing the size of each sample, in order."] - #[doc = " The resulting dictionary will be saved into `dictBuffer`."] - #[doc = " @return: size of dictionary stored into `dictBuffer` (<= `dictBufferCapacity`)"] - #[doc = " or an error code, which can be tested with ZDICT_isError()."] - #[doc = " Note: Dictionary training will fail if there are not enough samples to construct a"] - #[doc = " dictionary, or if most of the samples are too small (< 8 bytes being the lower limit)."] - #[doc = " If dictionary training fails, you should use zstd without a dictionary, as the dictionary"] - #[doc = " would've been ineffective anyways. If you believe your samples would benefit from a dictionary"] - #[doc = " please open an issue with details, and we can look into it."] - #[doc = " Note: ZDICT_trainFromBuffer()'s memory usage is about 6 MB."] - #[doc = " Tips: In general, a reasonable dictionary has a size of ~ 100 KB."] - #[doc = " It's possible to select smaller or larger size, just by specifying `dictBufferCapacity`."] - #[doc = " In general, it's recommended to provide a few thousands samples, though this can vary a lot."] - #[doc = " It's recommended that total size of all samples be about ~x100 times the target size of dictionary."] - pub fn ZDICT_trainFromBuffer( - dictBuffer: *mut libc::c_void, - dictBufferCapacity: usize, - samplesBuffer: *const libc::c_void, - samplesSizes: *const usize, - nbSamples: libc::c_uint, - ) -> usize; -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct ZDICT_params_t { - pub compressionLevel: libc::c_int, - pub notificationLevel: libc::c_uint, - pub dictID: libc::c_uint, -} -extern "C" { - #[doc = " ZDICT_finalizeDictionary():"] - #[doc = " Given a custom content as a basis for dictionary, and a set of samples,"] - #[doc = " finalize dictionary by adding headers and statistics according to the zstd"] - #[doc = " dictionary format."] - #[doc = ""] - #[doc = " Samples must be stored concatenated in a flat buffer `samplesBuffer`,"] - #[doc = " supplied with an array of sizes `samplesSizes`, providing the size of each"] - #[doc = " sample in order. The samples are used to construct the statistics, so they"] - #[doc = " should be representative of what you will compress with this dictionary."] - #[doc = ""] - #[doc = " The compression level can be set in `parameters`. You should pass the"] - #[doc = " compression level you expect to use in production. The statistics for each"] - #[doc = " compression level differ, so tuning the dictionary for the compression level"] - #[doc = " can help quite a bit."] - #[doc = ""] - #[doc = " You can set an explicit dictionary ID in `parameters`, or allow us to pick"] - #[doc = " a random dictionary ID for you, but we can't guarantee no collisions."] - #[doc = ""] - #[doc = " The dstDictBuffer and the dictContent may overlap, and the content will be"] - #[doc = " appended to the end of the header. If the header + the content doesn't fit in"] - #[doc = " maxDictSize the beginning of the content is truncated to make room, since it"] - #[doc = " is presumed that the most profitable content is at the end of the dictionary,"] - #[doc = " since that is the cheapest to reference."] - #[doc = ""] - #[doc = " `maxDictSize` must be >= max(dictContentSize, ZSTD_DICTSIZE_MIN)."] - #[doc = ""] - #[doc = " @return: size of dictionary stored into `dstDictBuffer` (<= `maxDictSize`),"] - #[doc = " or an error code, which can be tested by ZDICT_isError()."] - #[doc = " Note: ZDICT_finalizeDictionary() will push notifications into stderr if"] - #[doc = " instructed to, using notificationLevel>0."] - #[doc = " NOTE: This function currently may fail in several edge cases including:"] - #[doc = " * Not enough samples"] - #[doc = " * Samples are uncompressible"] - #[doc = " * Samples are all exactly the same"] - pub fn ZDICT_finalizeDictionary( - dstDictBuffer: *mut libc::c_void, - maxDictSize: usize, - dictContent: *const libc::c_void, - dictContentSize: usize, - samplesBuffer: *const libc::c_void, - samplesSizes: *const usize, - nbSamples: libc::c_uint, - parameters: ZDICT_params_t, - ) -> usize; -} -extern "C" { - pub fn ZDICT_getDictID( - dictBuffer: *const libc::c_void, - dictSize: usize, - ) -> libc::c_uint; -} -extern "C" { - pub fn ZDICT_getDictHeaderSize( - dictBuffer: *const libc::c_void, - dictSize: usize, - ) -> usize; -} -extern "C" { - pub fn ZDICT_isError(errorCode: usize) -> libc::c_uint; -} -extern "C" { - pub fn ZDICT_getErrorName(errorCode: usize) -> *const libc::c_char; -} diff --git a/zstd-safe/zstd-sys/src/bindings_experimental.rs b/zstd-safe/zstd-sys/src/bindings_zstd_experimental.rs similarity index 88% rename from zstd-safe/zstd-sys/src/bindings_experimental.rs rename to zstd-safe/zstd-sys/src/bindings_zstd_experimental.rs index bdf2863a..ed07595c 100644 --- a/zstd-safe/zstd-sys/src/bindings_experimental.rs +++ b/zstd-safe/zstd-sys/src/bindings_zstd_experimental.rs @@ -193,8 +193,6 @@ pub const ZSTD_LDM_HASHRATELOG_MIN: u32 = 0; pub const ZSTD_TARGETCBLOCKSIZE_MIN: u32 = 64; pub const ZSTD_TARGETCBLOCKSIZE_MAX: u32 = 131072; pub const ZSTD_SRCSIZEHINT_MIN: u32 = 0; -pub const ZDICT_DICTSIZE_MIN: u32 = 256; -pub const ZDICT_CONTENTSIZE_MIN: u32 = 128; pub type wchar_t = libc::c_int; extern "C" { #[doc = " ZSTD_versionNumber() :"] @@ -2351,272 +2349,3 @@ extern "C" { blockSize: usize, ) -> usize; } -extern "C" { - #[doc = " ZDICT_trainFromBuffer():"] - #[doc = " Train a dictionary from an array of samples."] - #[doc = " Redirect towards ZDICT_optimizeTrainFromBuffer_fastCover() single-threaded, with d=8, steps=4,"] - #[doc = " f=20, and accel=1."] - #[doc = " Samples must be stored concatenated in a single flat buffer `samplesBuffer`,"] - #[doc = " supplied with an array of sizes `samplesSizes`, providing the size of each sample, in order."] - #[doc = " The resulting dictionary will be saved into `dictBuffer`."] - #[doc = " @return: size of dictionary stored into `dictBuffer` (<= `dictBufferCapacity`)"] - #[doc = " or an error code, which can be tested with ZDICT_isError()."] - #[doc = " Note: Dictionary training will fail if there are not enough samples to construct a"] - #[doc = " dictionary, or if most of the samples are too small (< 8 bytes being the lower limit)."] - #[doc = " If dictionary training fails, you should use zstd without a dictionary, as the dictionary"] - #[doc = " would've been ineffective anyways. If you believe your samples would benefit from a dictionary"] - #[doc = " please open an issue with details, and we can look into it."] - #[doc = " Note: ZDICT_trainFromBuffer()'s memory usage is about 6 MB."] - #[doc = " Tips: In general, a reasonable dictionary has a size of ~ 100 KB."] - #[doc = " It's possible to select smaller or larger size, just by specifying `dictBufferCapacity`."] - #[doc = " In general, it's recommended to provide a few thousands samples, though this can vary a lot."] - #[doc = " It's recommended that total size of all samples be about ~x100 times the target size of dictionary."] - pub fn ZDICT_trainFromBuffer( - dictBuffer: *mut libc::c_void, - dictBufferCapacity: usize, - samplesBuffer: *const libc::c_void, - samplesSizes: *const usize, - nbSamples: libc::c_uint, - ) -> usize; -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct ZDICT_params_t { - pub compressionLevel: libc::c_int, - pub notificationLevel: libc::c_uint, - pub dictID: libc::c_uint, -} -extern "C" { - #[doc = " ZDICT_finalizeDictionary():"] - #[doc = " Given a custom content as a basis for dictionary, and a set of samples,"] - #[doc = " finalize dictionary by adding headers and statistics according to the zstd"] - #[doc = " dictionary format."] - #[doc = ""] - #[doc = " Samples must be stored concatenated in a flat buffer `samplesBuffer`,"] - #[doc = " supplied with an array of sizes `samplesSizes`, providing the size of each"] - #[doc = " sample in order. The samples are used to construct the statistics, so they"] - #[doc = " should be representative of what you will compress with this dictionary."] - #[doc = ""] - #[doc = " The compression level can be set in `parameters`. You should pass the"] - #[doc = " compression level you expect to use in production. The statistics for each"] - #[doc = " compression level differ, so tuning the dictionary for the compression level"] - #[doc = " can help quite a bit."] - #[doc = ""] - #[doc = " You can set an explicit dictionary ID in `parameters`, or allow us to pick"] - #[doc = " a random dictionary ID for you, but we can't guarantee no collisions."] - #[doc = ""] - #[doc = " The dstDictBuffer and the dictContent may overlap, and the content will be"] - #[doc = " appended to the end of the header. If the header + the content doesn't fit in"] - #[doc = " maxDictSize the beginning of the content is truncated to make room, since it"] - #[doc = " is presumed that the most profitable content is at the end of the dictionary,"] - #[doc = " since that is the cheapest to reference."] - #[doc = ""] - #[doc = " `maxDictSize` must be >= max(dictContentSize, ZSTD_DICTSIZE_MIN)."] - #[doc = ""] - #[doc = " @return: size of dictionary stored into `dstDictBuffer` (<= `maxDictSize`),"] - #[doc = " or an error code, which can be tested by ZDICT_isError()."] - #[doc = " Note: ZDICT_finalizeDictionary() will push notifications into stderr if"] - #[doc = " instructed to, using notificationLevel>0."] - #[doc = " NOTE: This function currently may fail in several edge cases including:"] - #[doc = " * Not enough samples"] - #[doc = " * Samples are uncompressible"] - #[doc = " * Samples are all exactly the same"] - pub fn ZDICT_finalizeDictionary( - dstDictBuffer: *mut libc::c_void, - maxDictSize: usize, - dictContent: *const libc::c_void, - dictContentSize: usize, - samplesBuffer: *const libc::c_void, - samplesSizes: *const usize, - nbSamples: libc::c_uint, - parameters: ZDICT_params_t, - ) -> usize; -} -extern "C" { - pub fn ZDICT_getDictID( - dictBuffer: *const libc::c_void, - dictSize: usize, - ) -> libc::c_uint; -} -extern "C" { - pub fn ZDICT_getDictHeaderSize( - dictBuffer: *const libc::c_void, - dictSize: usize, - ) -> usize; -} -extern "C" { - pub fn ZDICT_isError(errorCode: usize) -> libc::c_uint; -} -extern "C" { - pub fn ZDICT_getErrorName(errorCode: usize) -> *const libc::c_char; -} -#[doc = " ZDICT_cover_params_t:"] -#[doc = " k and d are the only required parameters."] -#[doc = " For others, value 0 means default."] -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct ZDICT_cover_params_t { - pub k: libc::c_uint, - pub d: libc::c_uint, - pub steps: libc::c_uint, - pub nbThreads: libc::c_uint, - pub splitPoint: f64, - pub shrinkDict: libc::c_uint, - pub shrinkDictMaxRegression: libc::c_uint, - pub zParams: ZDICT_params_t, -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct ZDICT_fastCover_params_t { - pub k: libc::c_uint, - pub d: libc::c_uint, - pub f: libc::c_uint, - pub steps: libc::c_uint, - pub nbThreads: libc::c_uint, - pub splitPoint: f64, - pub accel: libc::c_uint, - pub shrinkDict: libc::c_uint, - pub shrinkDictMaxRegression: libc::c_uint, - pub zParams: ZDICT_params_t, -} -extern "C" { - #[doc = " ZDICT_trainFromBuffer_cover():"] - #[doc = " Train a dictionary from an array of samples using the COVER algorithm."] - #[doc = " Samples must be stored concatenated in a single flat buffer `samplesBuffer`,"] - #[doc = " supplied with an array of sizes `samplesSizes`, providing the size of each sample, in order."] - #[doc = " The resulting dictionary will be saved into `dictBuffer`."] - #[doc = " @return: size of dictionary stored into `dictBuffer` (<= `dictBufferCapacity`)"] - #[doc = " or an error code, which can be tested with ZDICT_isError()."] - #[doc = " See ZDICT_trainFromBuffer() for details on failure modes."] - #[doc = " Note: ZDICT_trainFromBuffer_cover() requires about 9 bytes of memory for each input byte."] - #[doc = " Tips: In general, a reasonable dictionary has a size of ~ 100 KB."] - #[doc = " It's possible to select smaller or larger size, just by specifying `dictBufferCapacity`."] - #[doc = " In general, it's recommended to provide a few thousands samples, though this can vary a lot."] - #[doc = " It's recommended that total size of all samples be about ~x100 times the target size of dictionary."] - pub fn ZDICT_trainFromBuffer_cover( - dictBuffer: *mut libc::c_void, - dictBufferCapacity: usize, - samplesBuffer: *const libc::c_void, - samplesSizes: *const usize, - nbSamples: libc::c_uint, - parameters: ZDICT_cover_params_t, - ) -> usize; -} -extern "C" { - #[doc = " ZDICT_optimizeTrainFromBuffer_cover():"] - #[doc = " The same requirements as above hold for all the parameters except `parameters`."] - #[doc = " This function tries many parameter combinations and picks the best parameters."] - #[doc = " `*parameters` is filled with the best parameters found,"] - #[doc = " dictionary constructed with those parameters is stored in `dictBuffer`."] - #[doc = ""] - #[doc = " All of the parameters d, k, steps are optional."] - #[doc = " If d is non-zero then we don't check multiple values of d, otherwise we check d = {6, 8}."] - #[doc = " if steps is zero it defaults to its default value."] - #[doc = " If k is non-zero then we don't check multiple values of k, otherwise we check steps values in [50, 2000]."] - #[doc = ""] - #[doc = " @return: size of dictionary stored into `dictBuffer` (<= `dictBufferCapacity`)"] - #[doc = " or an error code, which can be tested with ZDICT_isError()."] - #[doc = " On success `*parameters` contains the parameters selected."] - #[doc = " See ZDICT_trainFromBuffer() for details on failure modes."] - #[doc = " Note: ZDICT_optimizeTrainFromBuffer_cover() requires about 8 bytes of memory for each input byte and additionally another 5 bytes of memory for each byte of memory for each thread."] - pub fn ZDICT_optimizeTrainFromBuffer_cover( - dictBuffer: *mut libc::c_void, - dictBufferCapacity: usize, - samplesBuffer: *const libc::c_void, - samplesSizes: *const usize, - nbSamples: libc::c_uint, - parameters: *mut ZDICT_cover_params_t, - ) -> usize; -} -extern "C" { - #[doc = " ZDICT_trainFromBuffer_fastCover():"] - #[doc = " Train a dictionary from an array of samples using a modified version of COVER algorithm."] - #[doc = " Samples must be stored concatenated in a single flat buffer `samplesBuffer`,"] - #[doc = " supplied with an array of sizes `samplesSizes`, providing the size of each sample, in order."] - #[doc = " d and k are required."] - #[doc = " All other parameters are optional, will use default values if not provided"] - #[doc = " The resulting dictionary will be saved into `dictBuffer`."] - #[doc = " @return: size of dictionary stored into `dictBuffer` (<= `dictBufferCapacity`)"] - #[doc = " or an error code, which can be tested with ZDICT_isError()."] - #[doc = " See ZDICT_trainFromBuffer() for details on failure modes."] - #[doc = " Note: ZDICT_trainFromBuffer_fastCover() requires 6 * 2^f bytes of memory."] - #[doc = " Tips: In general, a reasonable dictionary has a size of ~ 100 KB."] - #[doc = " It's possible to select smaller or larger size, just by specifying `dictBufferCapacity`."] - #[doc = " In general, it's recommended to provide a few thousands samples, though this can vary a lot."] - #[doc = " It's recommended that total size of all samples be about ~x100 times the target size of dictionary."] - pub fn ZDICT_trainFromBuffer_fastCover( - dictBuffer: *mut libc::c_void, - dictBufferCapacity: usize, - samplesBuffer: *const libc::c_void, - samplesSizes: *const usize, - nbSamples: libc::c_uint, - parameters: ZDICT_fastCover_params_t, - ) -> usize; -} -extern "C" { - #[doc = " ZDICT_optimizeTrainFromBuffer_fastCover():"] - #[doc = " The same requirements as above hold for all the parameters except `parameters`."] - #[doc = " This function tries many parameter combinations (specifically, k and d combinations)"] - #[doc = " and picks the best parameters. `*parameters` is filled with the best parameters found,"] - #[doc = " dictionary constructed with those parameters is stored in `dictBuffer`."] - #[doc = " All of the parameters d, k, steps, f, and accel are optional."] - #[doc = " If d is non-zero then we don't check multiple values of d, otherwise we check d = {6, 8}."] - #[doc = " if steps is zero it defaults to its default value."] - #[doc = " If k is non-zero then we don't check multiple values of k, otherwise we check steps values in [50, 2000]."] - #[doc = " If f is zero, default value of 20 is used."] - #[doc = " If accel is zero, default value of 1 is used."] - #[doc = ""] - #[doc = " @return: size of dictionary stored into `dictBuffer` (<= `dictBufferCapacity`)"] - #[doc = " or an error code, which can be tested with ZDICT_isError()."] - #[doc = " On success `*parameters` contains the parameters selected."] - #[doc = " See ZDICT_trainFromBuffer() for details on failure modes."] - #[doc = " Note: ZDICT_optimizeTrainFromBuffer_fastCover() requires about 6 * 2^f bytes of memory for each thread."] - pub fn ZDICT_optimizeTrainFromBuffer_fastCover( - dictBuffer: *mut libc::c_void, - dictBufferCapacity: usize, - samplesBuffer: *const libc::c_void, - samplesSizes: *const usize, - nbSamples: libc::c_uint, - parameters: *mut ZDICT_fastCover_params_t, - ) -> usize; -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct ZDICT_legacy_params_t { - pub selectivityLevel: libc::c_uint, - pub zParams: ZDICT_params_t, -} -extern "C" { - #[doc = " ZDICT_trainFromBuffer_legacy():"] - #[doc = " Train a dictionary from an array of samples."] - #[doc = " Samples must be stored concatenated in a single flat buffer `samplesBuffer`,"] - #[doc = " supplied with an array of sizes `samplesSizes`, providing the size of each sample, in order."] - #[doc = " The resulting dictionary will be saved into `dictBuffer`."] - #[doc = " `parameters` is optional and can be provided with values set to 0 to mean \"default\"."] - #[doc = " @return: size of dictionary stored into `dictBuffer` (<= `dictBufferCapacity`)"] - #[doc = " or an error code, which can be tested with ZDICT_isError()."] - #[doc = " See ZDICT_trainFromBuffer() for details on failure modes."] - #[doc = " Tips: In general, a reasonable dictionary has a size of ~ 100 KB."] - #[doc = " It's possible to select smaller or larger size, just by specifying `dictBufferCapacity`."] - #[doc = " In general, it's recommended to provide a few thousands samples, though this can vary a lot."] - #[doc = " It's recommended that total size of all samples be about ~x100 times the target size of dictionary."] - #[doc = " Note: ZDICT_trainFromBuffer_legacy() will send notifications into stderr if instructed to, using notificationLevel>0."] - pub fn ZDICT_trainFromBuffer_legacy( - dictBuffer: *mut libc::c_void, - dictBufferCapacity: usize, - samplesBuffer: *const libc::c_void, - samplesSizes: *const usize, - nbSamples: libc::c_uint, - parameters: ZDICT_legacy_params_t, - ) -> usize; -} -extern "C" { - pub fn ZDICT_addEntropyTablesFromBuffer( - dictBuffer: *mut libc::c_void, - dictContentSize: usize, - dictBufferCapacity: usize, - samplesBuffer: *const libc::c_void, - samplesSizes: *const usize, - nbSamples: libc::c_uint, - ) -> usize; -} diff --git a/zstd-safe/zstd-sys/src/bindings_std.rs b/zstd-safe/zstd-sys/src/bindings_zstd_std.rs similarity index 89% rename from zstd-safe/zstd-sys/src/bindings_std.rs rename to zstd-safe/zstd-sys/src/bindings_zstd_std.rs index 2927ecd4..d1b734c4 100644 --- a/zstd-safe/zstd-sys/src/bindings_std.rs +++ b/zstd-safe/zstd-sys/src/bindings_zstd_std.rs @@ -946,104 +946,3 @@ extern "C" { extern "C" { pub fn ZSTD_sizeof_DDict(ddict: *const ZSTD_DDict) -> usize; } -extern "C" { - #[doc = " ZDICT_trainFromBuffer():"] - #[doc = " Train a dictionary from an array of samples."] - #[doc = " Redirect towards ZDICT_optimizeTrainFromBuffer_fastCover() single-threaded, with d=8, steps=4,"] - #[doc = " f=20, and accel=1."] - #[doc = " Samples must be stored concatenated in a single flat buffer `samplesBuffer`,"] - #[doc = " supplied with an array of sizes `samplesSizes`, providing the size of each sample, in order."] - #[doc = " The resulting dictionary will be saved into `dictBuffer`."] - #[doc = " @return: size of dictionary stored into `dictBuffer` (<= `dictBufferCapacity`)"] - #[doc = " or an error code, which can be tested with ZDICT_isError()."] - #[doc = " Note: Dictionary training will fail if there are not enough samples to construct a"] - #[doc = " dictionary, or if most of the samples are too small (< 8 bytes being the lower limit)."] - #[doc = " If dictionary training fails, you should use zstd without a dictionary, as the dictionary"] - #[doc = " would've been ineffective anyways. If you believe your samples would benefit from a dictionary"] - #[doc = " please open an issue with details, and we can look into it."] - #[doc = " Note: ZDICT_trainFromBuffer()'s memory usage is about 6 MB."] - #[doc = " Tips: In general, a reasonable dictionary has a size of ~ 100 KB."] - #[doc = " It's possible to select smaller or larger size, just by specifying `dictBufferCapacity`."] - #[doc = " In general, it's recommended to provide a few thousands samples, though this can vary a lot."] - #[doc = " It's recommended that total size of all samples be about ~x100 times the target size of dictionary."] - pub fn ZDICT_trainFromBuffer( - dictBuffer: *mut ::core::ffi::c_void, - dictBufferCapacity: usize, - samplesBuffer: *const ::core::ffi::c_void, - samplesSizes: *const usize, - nbSamples: ::std::os::raw::c_uint, - ) -> usize; -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct ZDICT_params_t { - pub compressionLevel: ::std::os::raw::c_int, - pub notificationLevel: ::std::os::raw::c_uint, - pub dictID: ::std::os::raw::c_uint, -} -extern "C" { - #[doc = " ZDICT_finalizeDictionary():"] - #[doc = " Given a custom content as a basis for dictionary, and a set of samples,"] - #[doc = " finalize dictionary by adding headers and statistics according to the zstd"] - #[doc = " dictionary format."] - #[doc = ""] - #[doc = " Samples must be stored concatenated in a flat buffer `samplesBuffer`,"] - #[doc = " supplied with an array of sizes `samplesSizes`, providing the size of each"] - #[doc = " sample in order. The samples are used to construct the statistics, so they"] - #[doc = " should be representative of what you will compress with this dictionary."] - #[doc = ""] - #[doc = " The compression level can be set in `parameters`. You should pass the"] - #[doc = " compression level you expect to use in production. The statistics for each"] - #[doc = " compression level differ, so tuning the dictionary for the compression level"] - #[doc = " can help quite a bit."] - #[doc = ""] - #[doc = " You can set an explicit dictionary ID in `parameters`, or allow us to pick"] - #[doc = " a random dictionary ID for you, but we can't guarantee no collisions."] - #[doc = ""] - #[doc = " The dstDictBuffer and the dictContent may overlap, and the content will be"] - #[doc = " appended to the end of the header. If the header + the content doesn't fit in"] - #[doc = " maxDictSize the beginning of the content is truncated to make room, since it"] - #[doc = " is presumed that the most profitable content is at the end of the dictionary,"] - #[doc = " since that is the cheapest to reference."] - #[doc = ""] - #[doc = " `maxDictSize` must be >= max(dictContentSize, ZSTD_DICTSIZE_MIN)."] - #[doc = ""] - #[doc = " @return: size of dictionary stored into `dstDictBuffer` (<= `maxDictSize`),"] - #[doc = " or an error code, which can be tested by ZDICT_isError()."] - #[doc = " Note: ZDICT_finalizeDictionary() will push notifications into stderr if"] - #[doc = " instructed to, using notificationLevel>0."] - #[doc = " NOTE: This function currently may fail in several edge cases including:"] - #[doc = " * Not enough samples"] - #[doc = " * Samples are uncompressible"] - #[doc = " * Samples are all exactly the same"] - pub fn ZDICT_finalizeDictionary( - dstDictBuffer: *mut ::core::ffi::c_void, - maxDictSize: usize, - dictContent: *const ::core::ffi::c_void, - dictContentSize: usize, - samplesBuffer: *const ::core::ffi::c_void, - samplesSizes: *const usize, - nbSamples: ::std::os::raw::c_uint, - parameters: ZDICT_params_t, - ) -> usize; -} -extern "C" { - pub fn ZDICT_getDictID( - dictBuffer: *const ::core::ffi::c_void, - dictSize: usize, - ) -> ::std::os::raw::c_uint; -} -extern "C" { - pub fn ZDICT_getDictHeaderSize( - dictBuffer: *const ::core::ffi::c_void, - dictSize: usize, - ) -> usize; -} -extern "C" { - pub fn ZDICT_isError(errorCode: usize) -> ::std::os::raw::c_uint; -} -extern "C" { - pub fn ZDICT_getErrorName( - errorCode: usize, - ) -> *const ::std::os::raw::c_char; -} diff --git a/zstd-safe/zstd-sys/src/bindings_std_experimental.rs b/zstd-safe/zstd-sys/src/bindings_zstd_std_experimental.rs similarity index 87% rename from zstd-safe/zstd-sys/src/bindings_std_experimental.rs rename to zstd-safe/zstd-sys/src/bindings_zstd_std_experimental.rs index e4c02254..fbe5c304 100644 --- a/zstd-safe/zstd-sys/src/bindings_std_experimental.rs +++ b/zstd-safe/zstd-sys/src/bindings_zstd_std_experimental.rs @@ -193,8 +193,6 @@ pub const ZSTD_LDM_HASHRATELOG_MIN: u32 = 0; pub const ZSTD_TARGETCBLOCKSIZE_MIN: u32 = 64; pub const ZSTD_TARGETCBLOCKSIZE_MAX: u32 = 131072; pub const ZSTD_SRCSIZEHINT_MIN: u32 = 0; -pub const ZDICT_DICTSIZE_MIN: u32 = 256; -pub const ZDICT_CONTENTSIZE_MIN: u32 = 128; pub type wchar_t = ::std::os::raw::c_int; extern "C" { #[doc = " ZSTD_versionNumber() :"] @@ -2359,274 +2357,3 @@ extern "C" { blockSize: usize, ) -> usize; } -extern "C" { - #[doc = " ZDICT_trainFromBuffer():"] - #[doc = " Train a dictionary from an array of samples."] - #[doc = " Redirect towards ZDICT_optimizeTrainFromBuffer_fastCover() single-threaded, with d=8, steps=4,"] - #[doc = " f=20, and accel=1."] - #[doc = " Samples must be stored concatenated in a single flat buffer `samplesBuffer`,"] - #[doc = " supplied with an array of sizes `samplesSizes`, providing the size of each sample, in order."] - #[doc = " The resulting dictionary will be saved into `dictBuffer`."] - #[doc = " @return: size of dictionary stored into `dictBuffer` (<= `dictBufferCapacity`)"] - #[doc = " or an error code, which can be tested with ZDICT_isError()."] - #[doc = " Note: Dictionary training will fail if there are not enough samples to construct a"] - #[doc = " dictionary, or if most of the samples are too small (< 8 bytes being the lower limit)."] - #[doc = " If dictionary training fails, you should use zstd without a dictionary, as the dictionary"] - #[doc = " would've been ineffective anyways. If you believe your samples would benefit from a dictionary"] - #[doc = " please open an issue with details, and we can look into it."] - #[doc = " Note: ZDICT_trainFromBuffer()'s memory usage is about 6 MB."] - #[doc = " Tips: In general, a reasonable dictionary has a size of ~ 100 KB."] - #[doc = " It's possible to select smaller or larger size, just by specifying `dictBufferCapacity`."] - #[doc = " In general, it's recommended to provide a few thousands samples, though this can vary a lot."] - #[doc = " It's recommended that total size of all samples be about ~x100 times the target size of dictionary."] - pub fn ZDICT_trainFromBuffer( - dictBuffer: *mut ::core::ffi::c_void, - dictBufferCapacity: usize, - samplesBuffer: *const ::core::ffi::c_void, - samplesSizes: *const usize, - nbSamples: ::std::os::raw::c_uint, - ) -> usize; -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct ZDICT_params_t { - pub compressionLevel: ::std::os::raw::c_int, - pub notificationLevel: ::std::os::raw::c_uint, - pub dictID: ::std::os::raw::c_uint, -} -extern "C" { - #[doc = " ZDICT_finalizeDictionary():"] - #[doc = " Given a custom content as a basis for dictionary, and a set of samples,"] - #[doc = " finalize dictionary by adding headers and statistics according to the zstd"] - #[doc = " dictionary format."] - #[doc = ""] - #[doc = " Samples must be stored concatenated in a flat buffer `samplesBuffer`,"] - #[doc = " supplied with an array of sizes `samplesSizes`, providing the size of each"] - #[doc = " sample in order. The samples are used to construct the statistics, so they"] - #[doc = " should be representative of what you will compress with this dictionary."] - #[doc = ""] - #[doc = " The compression level can be set in `parameters`. You should pass the"] - #[doc = " compression level you expect to use in production. The statistics for each"] - #[doc = " compression level differ, so tuning the dictionary for the compression level"] - #[doc = " can help quite a bit."] - #[doc = ""] - #[doc = " You can set an explicit dictionary ID in `parameters`, or allow us to pick"] - #[doc = " a random dictionary ID for you, but we can't guarantee no collisions."] - #[doc = ""] - #[doc = " The dstDictBuffer and the dictContent may overlap, and the content will be"] - #[doc = " appended to the end of the header. If the header + the content doesn't fit in"] - #[doc = " maxDictSize the beginning of the content is truncated to make room, since it"] - #[doc = " is presumed that the most profitable content is at the end of the dictionary,"] - #[doc = " since that is the cheapest to reference."] - #[doc = ""] - #[doc = " `maxDictSize` must be >= max(dictContentSize, ZSTD_DICTSIZE_MIN)."] - #[doc = ""] - #[doc = " @return: size of dictionary stored into `dstDictBuffer` (<= `maxDictSize`),"] - #[doc = " or an error code, which can be tested by ZDICT_isError()."] - #[doc = " Note: ZDICT_finalizeDictionary() will push notifications into stderr if"] - #[doc = " instructed to, using notificationLevel>0."] - #[doc = " NOTE: This function currently may fail in several edge cases including:"] - #[doc = " * Not enough samples"] - #[doc = " * Samples are uncompressible"] - #[doc = " * Samples are all exactly the same"] - pub fn ZDICT_finalizeDictionary( - dstDictBuffer: *mut ::core::ffi::c_void, - maxDictSize: usize, - dictContent: *const ::core::ffi::c_void, - dictContentSize: usize, - samplesBuffer: *const ::core::ffi::c_void, - samplesSizes: *const usize, - nbSamples: ::std::os::raw::c_uint, - parameters: ZDICT_params_t, - ) -> usize; -} -extern "C" { - pub fn ZDICT_getDictID( - dictBuffer: *const ::core::ffi::c_void, - dictSize: usize, - ) -> ::std::os::raw::c_uint; -} -extern "C" { - pub fn ZDICT_getDictHeaderSize( - dictBuffer: *const ::core::ffi::c_void, - dictSize: usize, - ) -> usize; -} -extern "C" { - pub fn ZDICT_isError(errorCode: usize) -> ::std::os::raw::c_uint; -} -extern "C" { - pub fn ZDICT_getErrorName( - errorCode: usize, - ) -> *const ::std::os::raw::c_char; -} -#[doc = " ZDICT_cover_params_t:"] -#[doc = " k and d are the only required parameters."] -#[doc = " For others, value 0 means default."] -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct ZDICT_cover_params_t { - pub k: ::std::os::raw::c_uint, - pub d: ::std::os::raw::c_uint, - pub steps: ::std::os::raw::c_uint, - pub nbThreads: ::std::os::raw::c_uint, - pub splitPoint: f64, - pub shrinkDict: ::std::os::raw::c_uint, - pub shrinkDictMaxRegression: ::std::os::raw::c_uint, - pub zParams: ZDICT_params_t, -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct ZDICT_fastCover_params_t { - pub k: ::std::os::raw::c_uint, - pub d: ::std::os::raw::c_uint, - pub f: ::std::os::raw::c_uint, - pub steps: ::std::os::raw::c_uint, - pub nbThreads: ::std::os::raw::c_uint, - pub splitPoint: f64, - pub accel: ::std::os::raw::c_uint, - pub shrinkDict: ::std::os::raw::c_uint, - pub shrinkDictMaxRegression: ::std::os::raw::c_uint, - pub zParams: ZDICT_params_t, -} -extern "C" { - #[doc = " ZDICT_trainFromBuffer_cover():"] - #[doc = " Train a dictionary from an array of samples using the COVER algorithm."] - #[doc = " Samples must be stored concatenated in a single flat buffer `samplesBuffer`,"] - #[doc = " supplied with an array of sizes `samplesSizes`, providing the size of each sample, in order."] - #[doc = " The resulting dictionary will be saved into `dictBuffer`."] - #[doc = " @return: size of dictionary stored into `dictBuffer` (<= `dictBufferCapacity`)"] - #[doc = " or an error code, which can be tested with ZDICT_isError()."] - #[doc = " See ZDICT_trainFromBuffer() for details on failure modes."] - #[doc = " Note: ZDICT_trainFromBuffer_cover() requires about 9 bytes of memory for each input byte."] - #[doc = " Tips: In general, a reasonable dictionary has a size of ~ 100 KB."] - #[doc = " It's possible to select smaller or larger size, just by specifying `dictBufferCapacity`."] - #[doc = " In general, it's recommended to provide a few thousands samples, though this can vary a lot."] - #[doc = " It's recommended that total size of all samples be about ~x100 times the target size of dictionary."] - pub fn ZDICT_trainFromBuffer_cover( - dictBuffer: *mut ::core::ffi::c_void, - dictBufferCapacity: usize, - samplesBuffer: *const ::core::ffi::c_void, - samplesSizes: *const usize, - nbSamples: ::std::os::raw::c_uint, - parameters: ZDICT_cover_params_t, - ) -> usize; -} -extern "C" { - #[doc = " ZDICT_optimizeTrainFromBuffer_cover():"] - #[doc = " The same requirements as above hold for all the parameters except `parameters`."] - #[doc = " This function tries many parameter combinations and picks the best parameters."] - #[doc = " `*parameters` is filled with the best parameters found,"] - #[doc = " dictionary constructed with those parameters is stored in `dictBuffer`."] - #[doc = ""] - #[doc = " All of the parameters d, k, steps are optional."] - #[doc = " If d is non-zero then we don't check multiple values of d, otherwise we check d = {6, 8}."] - #[doc = " if steps is zero it defaults to its default value."] - #[doc = " If k is non-zero then we don't check multiple values of k, otherwise we check steps values in [50, 2000]."] - #[doc = ""] - #[doc = " @return: size of dictionary stored into `dictBuffer` (<= `dictBufferCapacity`)"] - #[doc = " or an error code, which can be tested with ZDICT_isError()."] - #[doc = " On success `*parameters` contains the parameters selected."] - #[doc = " See ZDICT_trainFromBuffer() for details on failure modes."] - #[doc = " Note: ZDICT_optimizeTrainFromBuffer_cover() requires about 8 bytes of memory for each input byte and additionally another 5 bytes of memory for each byte of memory for each thread."] - pub fn ZDICT_optimizeTrainFromBuffer_cover( - dictBuffer: *mut ::core::ffi::c_void, - dictBufferCapacity: usize, - samplesBuffer: *const ::core::ffi::c_void, - samplesSizes: *const usize, - nbSamples: ::std::os::raw::c_uint, - parameters: *mut ZDICT_cover_params_t, - ) -> usize; -} -extern "C" { - #[doc = " ZDICT_trainFromBuffer_fastCover():"] - #[doc = " Train a dictionary from an array of samples using a modified version of COVER algorithm."] - #[doc = " Samples must be stored concatenated in a single flat buffer `samplesBuffer`,"] - #[doc = " supplied with an array of sizes `samplesSizes`, providing the size of each sample, in order."] - #[doc = " d and k are required."] - #[doc = " All other parameters are optional, will use default values if not provided"] - #[doc = " The resulting dictionary will be saved into `dictBuffer`."] - #[doc = " @return: size of dictionary stored into `dictBuffer` (<= `dictBufferCapacity`)"] - #[doc = " or an error code, which can be tested with ZDICT_isError()."] - #[doc = " See ZDICT_trainFromBuffer() for details on failure modes."] - #[doc = " Note: ZDICT_trainFromBuffer_fastCover() requires 6 * 2^f bytes of memory."] - #[doc = " Tips: In general, a reasonable dictionary has a size of ~ 100 KB."] - #[doc = " It's possible to select smaller or larger size, just by specifying `dictBufferCapacity`."] - #[doc = " In general, it's recommended to provide a few thousands samples, though this can vary a lot."] - #[doc = " It's recommended that total size of all samples be about ~x100 times the target size of dictionary."] - pub fn ZDICT_trainFromBuffer_fastCover( - dictBuffer: *mut ::core::ffi::c_void, - dictBufferCapacity: usize, - samplesBuffer: *const ::core::ffi::c_void, - samplesSizes: *const usize, - nbSamples: ::std::os::raw::c_uint, - parameters: ZDICT_fastCover_params_t, - ) -> usize; -} -extern "C" { - #[doc = " ZDICT_optimizeTrainFromBuffer_fastCover():"] - #[doc = " The same requirements as above hold for all the parameters except `parameters`."] - #[doc = " This function tries many parameter combinations (specifically, k and d combinations)"] - #[doc = " and picks the best parameters. `*parameters` is filled with the best parameters found,"] - #[doc = " dictionary constructed with those parameters is stored in `dictBuffer`."] - #[doc = " All of the parameters d, k, steps, f, and accel are optional."] - #[doc = " If d is non-zero then we don't check multiple values of d, otherwise we check d = {6, 8}."] - #[doc = " if steps is zero it defaults to its default value."] - #[doc = " If k is non-zero then we don't check multiple values of k, otherwise we check steps values in [50, 2000]."] - #[doc = " If f is zero, default value of 20 is used."] - #[doc = " If accel is zero, default value of 1 is used."] - #[doc = ""] - #[doc = " @return: size of dictionary stored into `dictBuffer` (<= `dictBufferCapacity`)"] - #[doc = " or an error code, which can be tested with ZDICT_isError()."] - #[doc = " On success `*parameters` contains the parameters selected."] - #[doc = " See ZDICT_trainFromBuffer() for details on failure modes."] - #[doc = " Note: ZDICT_optimizeTrainFromBuffer_fastCover() requires about 6 * 2^f bytes of memory for each thread."] - pub fn ZDICT_optimizeTrainFromBuffer_fastCover( - dictBuffer: *mut ::core::ffi::c_void, - dictBufferCapacity: usize, - samplesBuffer: *const ::core::ffi::c_void, - samplesSizes: *const usize, - nbSamples: ::std::os::raw::c_uint, - parameters: *mut ZDICT_fastCover_params_t, - ) -> usize; -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct ZDICT_legacy_params_t { - pub selectivityLevel: ::std::os::raw::c_uint, - pub zParams: ZDICT_params_t, -} -extern "C" { - #[doc = " ZDICT_trainFromBuffer_legacy():"] - #[doc = " Train a dictionary from an array of samples."] - #[doc = " Samples must be stored concatenated in a single flat buffer `samplesBuffer`,"] - #[doc = " supplied with an array of sizes `samplesSizes`, providing the size of each sample, in order."] - #[doc = " The resulting dictionary will be saved into `dictBuffer`."] - #[doc = " `parameters` is optional and can be provided with values set to 0 to mean \"default\"."] - #[doc = " @return: size of dictionary stored into `dictBuffer` (<= `dictBufferCapacity`)"] - #[doc = " or an error code, which can be tested with ZDICT_isError()."] - #[doc = " See ZDICT_trainFromBuffer() for details on failure modes."] - #[doc = " Tips: In general, a reasonable dictionary has a size of ~ 100 KB."] - #[doc = " It's possible to select smaller or larger size, just by specifying `dictBufferCapacity`."] - #[doc = " In general, it's recommended to provide a few thousands samples, though this can vary a lot."] - #[doc = " It's recommended that total size of all samples be about ~x100 times the target size of dictionary."] - #[doc = " Note: ZDICT_trainFromBuffer_legacy() will send notifications into stderr if instructed to, using notificationLevel>0."] - pub fn ZDICT_trainFromBuffer_legacy( - dictBuffer: *mut ::core::ffi::c_void, - dictBufferCapacity: usize, - samplesBuffer: *const ::core::ffi::c_void, - samplesSizes: *const usize, - nbSamples: ::std::os::raw::c_uint, - parameters: ZDICT_legacy_params_t, - ) -> usize; -} -extern "C" { - pub fn ZDICT_addEntropyTablesFromBuffer( - dictBuffer: *mut ::core::ffi::c_void, - dictContentSize: usize, - dictBufferCapacity: usize, - samplesBuffer: *const ::core::ffi::c_void, - samplesSizes: *const usize, - nbSamples: ::std::os::raw::c_uint, - ) -> usize; -} diff --git a/zstd-safe/zstd-sys/src/lib.rs b/zstd-safe/zstd-sys/src/lib.rs index 9c825bdb..d6761966 100644 --- a/zstd-safe/zstd-sys/src/lib.rs +++ b/zstd-safe/zstd-sys/src/lib.rs @@ -21,14 +21,28 @@ include!(concat!(env!("OUT_DIR"), "/bindings.rs")); not(feature = "experimental"), not(feature = "bindgen") ))] -include!("bindings.rs"); +include!("bindings_zstd.rs"); + +#[cfg(all( + not(feature = "std"), + not(feature = "experimental"), + not(feature = "bindgen") +))] +include!("bindings_zdict.rs"); #[cfg(all( not(feature = "std"), feature = "experimental", not(feature = "bindgen") ))] -include!("bindings_experimental.rs"); +include!("bindings_zstd_experimental.rs"); + +#[cfg(all( + not(feature = "std"), + feature = "experimental", + not(feature = "bindgen") +))] +include!("bindings_zdict_experimental.rs"); // Std-based (no libc) #[cfg(all( @@ -36,11 +50,26 @@ include!("bindings_experimental.rs"); not(feature = "experimental"), not(feature = "bindgen") ))] -include!("bindings_std.rs"); +include!("bindings_zstd_std.rs"); + +// Std-based (no libc) +#[cfg(all( + feature = "std", + not(feature = "experimental"), + not(feature = "bindgen") +))] +include!("bindings_zdict_std.rs"); + +#[cfg(all( + feature = "std", + feature = "experimental", + not(feature = "bindgen") +))] +include!("bindings_zstd_std_experimental.rs"); #[cfg(all( feature = "std", feature = "experimental", not(feature = "bindgen") ))] -include!("bindings_std_experimental.rs"); +include!("bindings_zdict_std_experimental.rs"); diff --git a/zstd-safe/zstd-sys/update_bindings.sh b/zstd-safe/zstd-sys/update_bindings.sh index e510dd9c..a75fa121 100755 --- a/zstd-safe/zstd-sys/update_bindings.sh +++ b/zstd-safe/zstd-sys/update_bindings.sh @@ -3,19 +3,25 @@ bindgen="bindgen --no-layout-tests --blacklist-type=max_align_t --size_t-is-usiz no_std="--ctypes-prefix libc" experimental="-DZSTD_STATIC_LINKING_ONLY -DZDICT_STATIC_LINKING_ONLY" -for NO_STD_ARG in "$no_std" ""; do - for EXPERIMENTAL_ARG in "$experimental" ""; do - if [ -z "$NO_STD_ARG" ]; then STD="_std"; else STD=""; fi - if [ -z "$EXPERIMENTAL_ARG" ]; then EXPERIMENTAL=""; else EXPERIMENTAL="_experimental"; fi - filename=src/bindings${STD}${EXPERIMENTAL}.rs - ( +run_bindgen() +{ echo "/* This file is auto-generated from the public API of the zstd library. It is released under the same BSD license. $(cat zstd/LICENSE) */" - $bindgen zstd.h $NO_STD_ARG -- -Izstd/lib $EXPERIMENTAL_ARG - ) > $filename + + $bindgen $@ +} + +for NO_STD_ARG in "$no_std" ""; do + for EXPERIMENTAL_ARG in "$experimental" ""; do + if [ -z "$NO_STD_ARG" ]; then STD="_std"; else STD=""; fi + if [ -z "$EXPERIMENTAL_ARG" ]; then EXPERIMENTAL=""; else EXPERIMENTAL="_experimental"; fi + SUFFIX=${STD}${EXPERIMENTAL} + filename=src/bindings${STD}${EXPERIMENTAL}.rs + run_bindgen zstd.h $NO_STD_ARG -- -Izstd/lib $EXPERIMENTAL_ARG > src/bindings_zstd${SUFFIX}.rs + run_bindgen --blocklist-type wchar_t zdict.h $NO_STD_ARG -- -Izstd/lib $EXPERIMENTAL_ARG > src/bindings_zdict${SUFFIX}.rs done done diff --git a/zstd-safe/zstd-sys/zdict.h b/zstd-safe/zstd-sys/zdict.h new file mode 100644 index 00000000..a7a10aaf --- /dev/null +++ b/zstd-safe/zstd-sys/zdict.h @@ -0,0 +1,17 @@ +#ifdef PKG_CONFIG + +/* Just use installed headers */ +#include +// Don't use experimental features like zstdmt + +#else // #ifdef PKG_CONFIG + +#include "zstd/lib/zdict.h" + +#endif // #ifdef PKG_CONFIG + + +/* This file is used to generate bindings for both headers. + * Check update_bindings.sh to see how to use it. + * Or use the `bindgen` feature, which will create the bindings automatically. */ + diff --git a/zstd-safe/zstd-sys/zstd.h b/zstd-safe/zstd-sys/zstd.h index 5edd746b..08618386 100644 --- a/zstd-safe/zstd-sys/zstd.h +++ b/zstd-safe/zstd-sys/zstd.h @@ -2,13 +2,11 @@ /* Just use installed headers */ #include -#include // Don't use experimental features like zstdmt #else // #ifdef PKG_CONFIG #include "zstd/lib/zstd.h" -#include "zstd/lib/zdict.h" #endif // #ifdef PKG_CONFIG