Home | History | Annotate | Line # | Download | only in regression
config.h revision 1.1
      1  1.1  christos /*
      2  1.1  christos  * Copyright (c) Meta Platforms, Inc. and affiliates.
      3  1.1  christos  * All rights reserved.
      4  1.1  christos  *
      5  1.1  christos  * This source code is licensed under both the BSD-style license (found in the
      6  1.1  christos  * LICENSE file in the root directory of this source tree) and the GPLv2 (found
      7  1.1  christos  * in the COPYING file in the root directory of this source tree).
      8  1.1  christos  * You may select, at your option, one of the above-listed licenses.
      9  1.1  christos  */
     10  1.1  christos 
     11  1.1  christos #ifndef CONFIG_H
     12  1.1  christos #define CONFIG_H
     13  1.1  christos 
     14  1.1  christos #include <stddef.h>
     15  1.1  christos 
     16  1.1  christos #define ZSTD_STATIC_LINKING_ONLY
     17  1.1  christos #include <zstd.h>
     18  1.1  christos 
     19  1.1  christos #include "data.h"
     20  1.1  christos 
     21  1.1  christos typedef struct {
     22  1.1  christos     ZSTD_cParameter param;
     23  1.1  christos     int value;
     24  1.1  christos } param_value_t;
     25  1.1  christos 
     26  1.1  christos typedef struct {
     27  1.1  christos     size_t size;
     28  1.1  christos     param_value_t const* data;
     29  1.1  christos } param_values_t;
     30  1.1  christos 
     31  1.1  christos /**
     32  1.1  christos  * The config tells the compression method what options to use.
     33  1.1  christos  */
     34  1.1  christos typedef struct {
     35  1.1  christos     const char* name;  /**< Identifies the config in the results table */
     36  1.1  christos     /**
     37  1.1  christos      * Optional arguments to pass to the CLI. If not set, CLI-based methods
     38  1.1  christos      * will skip this config.
     39  1.1  christos      */
     40  1.1  christos     char const* cli_args;
     41  1.1  christos     /**
     42  1.1  christos      * Parameters to pass to the advanced API. If the advanced API isn't used,
     43  1.1  christos      * the parameters will be derived from these.
     44  1.1  christos      */
     45  1.1  christos     param_values_t param_values;
     46  1.1  christos     /**
     47  1.1  christos      * Boolean parameter that says if we should use a dictionary. If the data
     48  1.1  christos      * doesn't have a dictionary, this config is skipped. Defaults to no.
     49  1.1  christos      */
     50  1.1  christos     int use_dictionary;
     51  1.1  christos     /**
     52  1.1  christos      * Boolean parameter that says if we should pass the pledged source size
     53  1.1  christos      * when the method allows it. Defaults to yes.
     54  1.1  christos      */
     55  1.1  christos     int no_pledged_src_size;
     56  1.1  christos     /**
     57  1.1  christos      * Boolean parameter that says that this config should only be used
     58  1.1  christos      * for methods that use the advanced compression API
     59  1.1  christos      */
     60  1.1  christos     int advanced_api_only;
     61  1.1  christos } config_t;
     62  1.1  christos 
     63  1.1  christos /**
     64  1.1  christos  * Returns true if the config should skip this data.
     65  1.1  christos  * For instance, if the config requires a dictionary but the data doesn't have
     66  1.1  christos  * one.
     67  1.1  christos  */
     68  1.1  christos int config_skip_data(config_t const* config, data_t const* data);
     69  1.1  christos 
     70  1.1  christos #define CONFIG_NO_LEVEL (-ZSTD_TARGETLENGTH_MAX - 1)
     71  1.1  christos /**
     72  1.1  christos  * Returns the compression level specified by the config, or CONFIG_NO_LEVEL if
     73  1.1  christos  * no level is specified. Note that 0 is a valid compression level, meaning
     74  1.1  christos  * default.
     75  1.1  christos  */
     76  1.1  christos int config_get_level(config_t const* config);
     77  1.1  christos 
     78  1.1  christos /**
     79  1.1  christos  * Returns the compression parameters specified by the config.
     80  1.1  christos  */
     81  1.1  christos ZSTD_parameters config_get_zstd_params(
     82  1.1  christos     config_t const* config,
     83  1.1  christos     uint64_t srcSize,
     84  1.1  christos     size_t dictSize);
     85  1.1  christos 
     86  1.1  christos /**
     87  1.1  christos  * The NULL-terminated list of configs.
     88  1.1  christos  */
     89  1.1  christos extern config_t const* const* configs;
     90  1.1  christos 
     91  1.1  christos #endif
     92