mirror of
https://github.com/ckolivas/lrzip.git
synced 2025-12-06 07:12:00 +01:00
Compare commits
20 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1242aecfed | ||
|
|
dc6342ea61 | ||
|
|
15f5621928 | ||
|
|
3f19396fba | ||
|
|
813f06becf | ||
|
|
0c6f6b5723 | ||
|
|
d713d86af1 | ||
|
|
7bd62530f9 | ||
|
|
700ad23a2d | ||
|
|
dce1ab8ec8 | ||
|
|
469074b4a5 | ||
|
|
7c079abb17 | ||
|
|
2c50a224f8 | ||
|
|
3495188cd8 | ||
|
|
e5e9a61fcc | ||
|
|
cdec0951d7 | ||
|
|
80f7d91044 | ||
|
|
e816f1dece | ||
|
|
53029415df | ||
|
|
7404f72afd |
14
Dockerfile
Normal file
14
Dockerfile
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
FROM alpine as builder
|
||||||
|
|
||||||
|
RUN apk add --update git autoconf automake libtool gcc musl-dev zlib-dev bzip2-dev lzo-dev coreutils make g++ lz4-dev && \
|
||||||
|
git clone https://github.com/ckolivas/lrzip.git && \
|
||||||
|
cd /lrzip && ./autogen.sh && ./configure && make -j `nproc` && make install
|
||||||
|
|
||||||
|
FROM alpine
|
||||||
|
|
||||||
|
RUN apk add --update --no-cache lzo libbz2 libstdc++ lz4-dev && \
|
||||||
|
rm -rf /tmp/* /var/tmp/*
|
||||||
|
|
||||||
|
COPY --from=builder /usr/local/bin/lrzip /usr/local/bin/lrzip
|
||||||
|
|
||||||
|
CMD ["/bin/sh"]
|
||||||
767
Lrzip.h
767
Lrzip.h
|
|
@ -1,767 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright (C) 2006-2011 Con Kolivas
|
|
||||||
Copyright (C) 2011 Peter Hyman
|
|
||||||
Copyright (C) 1998-2003 Andrew Tridgell
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef LIBLRZIP_H
|
|
||||||
#define LIBLRZIP_H
|
|
||||||
|
|
||||||
#include <stdarg.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#ifdef _WIN32
|
|
||||||
# include <stddef.h>
|
|
||||||
#else
|
|
||||||
# include <inttypes.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
|
||||||
@brief LRZIP library
|
|
||||||
|
|
||||||
@mainpage lrzip
|
|
||||||
@version 1.0
|
|
||||||
@date 2011
|
|
||||||
|
|
||||||
@section intro What is LRZIP?
|
|
||||||
|
|
||||||
LRZIP is a compression program optimised for large files. The larger the file
|
|
||||||
and the more memory you have, the better the compression advantage this will
|
|
||||||
provide, especially once the files are larger than 100MB. The advantage can
|
|
||||||
be chosen to be either size (much smaller than bzip2) or speed (much faster
|
|
||||||
than bzip2).
|
|
||||||
* @link Lrzip.h LRZIP API @endlink
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @file Lrzip.h */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef Lrzip
|
|
||||||
* @brief The overall struct for managing all operations
|
|
||||||
*/
|
|
||||||
typedef struct Lrzip Lrzip;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef Lrzip_Log_Level
|
|
||||||
* @brief The amount of information to display using logging functions
|
|
||||||
* This enum is used when setting or getting the log level of an #Lrzip
|
|
||||||
* struct. It determines how much information is shown about the current operation,
|
|
||||||
* either in stdout/stderr or using logging callbacks.
|
|
||||||
* @see lrzip_log_level_set()
|
|
||||||
* @see lrzip_log_level_get()
|
|
||||||
*/
|
|
||||||
typedef enum {
|
|
||||||
LRZIP_LOG_LEVEL_ERROR = 0, /**< Only display errors */
|
|
||||||
LRZIP_LOG_LEVEL_INFO, /**< Display information and errors */
|
|
||||||
LRZIP_LOG_LEVEL_PROGRESS, /**< Display progress updates, information, and errors */
|
|
||||||
LRZIP_LOG_LEVEL_VERBOSE, /**< Display verbose progress updates, information, and errors */
|
|
||||||
LRZIP_LOG_LEVEL_DEBUG /**< Display all possible information */
|
|
||||||
} Lrzip_Log_Level;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef Lrzip_Mode
|
|
||||||
* @brief The mode of operation for an #Lrzip struct
|
|
||||||
* This enum is used when setting or getting the operation mode of an #Lrzip
|
|
||||||
* struct. It determines what will happen when lrzip_run() is called.
|
|
||||||
* @see lrzip_mode_set()
|
|
||||||
* @see lrzip_mode_get()
|
|
||||||
*/
|
|
||||||
typedef enum {
|
|
||||||
LRZIP_MODE_NONE = 0, /**< No operation set */
|
|
||||||
LRZIP_MODE_INFO, /**< Retrieve info about an archive */
|
|
||||||
LRZIP_MODE_TEST, /**< Test an archive's integrity */
|
|
||||||
LRZIP_MODE_DECOMPRESS, /**< Decompress an archive */
|
|
||||||
LRZIP_MODE_COMPRESS_NONE, /**< RZIP preprocess only */
|
|
||||||
LRZIP_MODE_COMPRESS_LZO, /**< Use LZO compression */
|
|
||||||
LRZIP_MODE_COMPRESS_ZLIB, /**< Use ZLIB (GZIP) compression */
|
|
||||||
LRZIP_MODE_COMPRESS_BZIP2, /**< Use BZIP2 compression */
|
|
||||||
LRZIP_MODE_COMPRESS_LZMA, /**< Use LZMA compression */
|
|
||||||
LRZIP_MODE_COMPRESS_ZPAQ /**< Use ZPAQ compression */
|
|
||||||
} Lrzip_Mode;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef Lrzip_Flag
|
|
||||||
* @brief The extra params for an #Lrzip struct's operations
|
|
||||||
* This enum is used when setting or getting the flags of an #Lrzip
|
|
||||||
* struct. It determines some of the miscellaneous extra abilities of LRZIP.
|
|
||||||
* @see lrzip_flags_set()
|
|
||||||
* @see lrzip_flags_get()
|
|
||||||
*/
|
|
||||||
typedef enum {
|
|
||||||
LRZIP_FLAG_REMOVE_SOURCE = (1 << 0), /**< Remove the input file after the operation completes */
|
|
||||||
LRZIP_FLAG_REMOVE_DESTINATION = (1 << 1), /**< Remove matching destination file if it exists */
|
|
||||||
LRZIP_FLAG_KEEP_BROKEN = (1 << 2), /**< Do not remove broken files */
|
|
||||||
LRZIP_FLAG_VERIFY = (1 << 3), /**< Only verify the archive, do not perform any compression/decompression */
|
|
||||||
LRZIP_FLAG_DISABLE_LZO_CHECK = (1 << 4), /**< Disable test to determine if LZO compression will be useful */
|
|
||||||
LRZIP_FLAG_UNLIMITED_RAM = (1 << 5), /**< Use unlimited ram window size for compression */
|
|
||||||
LRZIP_FLAG_ENCRYPT = (1 << 6) /**< Encrypt archive during compression; @see lrzip_pass_cb_set() */
|
|
||||||
} Lrzip_Flag;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef Lrzip_Info_Cb
|
|
||||||
* @brief The callback to call when an operation's progress changes
|
|
||||||
* @param data The data param passed in lrzip_info_cb_set()
|
|
||||||
* @param pct The overall operation progress as a percent
|
|
||||||
* @param chunk_pct The current chunk's operation progress as a percent
|
|
||||||
*/
|
|
||||||
typedef void (*Lrzip_Info_Cb)(void *data, int pct, int chunk_pct);
|
|
||||||
/**
|
|
||||||
* @typedef Lrzip_Log_Cb
|
|
||||||
* @brief The callback to call when a log message is to be shown
|
|
||||||
* @param data The data param passed in lrzip_log_cb_set()
|
|
||||||
* @param level The Lrzip_Log_Level of the message
|
|
||||||
* @param line The line in LRZIP code where the message originated
|
|
||||||
* @param file The file in LRZIP code where the message originated
|
|
||||||
* @param func The function in LRZIP code where the message originated
|
|
||||||
* @param format The printf-style format of the message
|
|
||||||
* @param args The matching va_list for @p format
|
|
||||||
*/
|
|
||||||
typedef void (*Lrzip_Log_Cb)(void *data, unsigned int level, unsigned int line, const char *file, const char *func, const char *format, va_list args);
|
|
||||||
/**
|
|
||||||
* @typedef Lrzip_Password_Cb
|
|
||||||
* @brief The callback to call for operations requiring a password
|
|
||||||
* @param data The data param passed in lrzip_pass_cb_set()
|
|
||||||
* @param buffer The pre-allocated buffer to write the password into
|
|
||||||
* @param buf_size The size, in bytes, of @p buffer
|
|
||||||
*/
|
|
||||||
typedef void (*Lrzip_Password_Cb)(void *data, char *buffer, size_t buf_size);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Initialize liblrzip
|
|
||||||
* This function must be called prior to running any other liblrzip
|
|
||||||
* functions to initialize compression algorithms. It does not allocate.
|
|
||||||
* @return true on success, false on failure
|
|
||||||
*/
|
|
||||||
bool lrzip_init(void);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Create a new #Lrzip struct
|
|
||||||
* Use this function to allocate a new struct for immediate or later use,
|
|
||||||
* optionally setting flags and changing modes at a later time.
|
|
||||||
* @param mode The optional Lrzip_Mode to set, or LRZIP_MODE_NONE to allow
|
|
||||||
* setting a mode later.
|
|
||||||
* @return The new #Lrzip struct, or NULL on failure
|
|
||||||
* @see lrzip_mode_set()
|
|
||||||
*/
|
|
||||||
Lrzip *lrzip_new(Lrzip_Mode mode);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Free an #Lrzip struct
|
|
||||||
* Use this function to free all memory associated with an existing struct.
|
|
||||||
* @param lr The struct to free
|
|
||||||
*/
|
|
||||||
void lrzip_free(Lrzip *lr);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Set up an #Lrzip struct using environment settings
|
|
||||||
* Use this function to acquire and utilize settings already existing in
|
|
||||||
* either environment variables or configuration files for LRZIP. For more detailed
|
|
||||||
* information, see the LRZIP manual.
|
|
||||||
* @param lr The struct to configure
|
|
||||||
* @note This function cannot fail.
|
|
||||||
*/
|
|
||||||
void lrzip_config_env(Lrzip *lr);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Retrieve the operation mode of an #Lrzip struct
|
|
||||||
* @param lr The struct to query
|
|
||||||
* @return The Lrzip_Mode of @p lr, or LRZIP_MODE_NONE on failure
|
|
||||||
*/
|
|
||||||
Lrzip_Mode lrzip_mode_get(Lrzip *lr);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Set the operation mode of an #Lrzip struct
|
|
||||||
* @param lr The struct to change the mode for
|
|
||||||
* @param mode The Lrzip_Mode to set for @p lr
|
|
||||||
* @return true on success, false on failure
|
|
||||||
*/
|
|
||||||
bool lrzip_mode_set(Lrzip *lr, Lrzip_Mode mode);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Set the compression level of an #Lrzip struct
|
|
||||||
* @param lr The struct to change the compression level for
|
|
||||||
* @param level The value, 1-9, to use as the compression level for operations with @p lr
|
|
||||||
* @return true on success, false on failure
|
|
||||||
* @note This function is only valid for compression operations
|
|
||||||
*/
|
|
||||||
bool lrzip_compression_level_set(Lrzip *lr, unsigned int level);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Get the compression level of an #Lrzip struct
|
|
||||||
* @param lr The struct to get the compression level of
|
|
||||||
* @return The value, 1-9, used as the compression level for operations with @p lr,
|
|
||||||
* or 0 on failure
|
|
||||||
* @note This function is only valid for compression operations
|
|
||||||
*/
|
|
||||||
unsigned int lrzip_compression_level_get(Lrzip *lr);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Set the operation specific parameters
|
|
||||||
* @param lr The struct to set parameters for
|
|
||||||
* @param flags A bitwise ORed set of Lrzip_Flags
|
|
||||||
* @note This function does not perform any error checking. Any errors in flags
|
|
||||||
* will be determined when lrzip_run() is called.
|
|
||||||
*/
|
|
||||||
void lrzip_flags_set(Lrzip *lr, unsigned int flags);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Get the operation specific parameters
|
|
||||||
* @param lr The struct to get parameters of
|
|
||||||
* @return A bitwise ORed set of Lrzip_Flags
|
|
||||||
*/
|
|
||||||
unsigned int lrzip_flags_get(Lrzip *lr);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Set the nice level for operations in a struct
|
|
||||||
* @param lr The struct to set the nice level for
|
|
||||||
* @param nice The value to use when nicing during operations
|
|
||||||
*/
|
|
||||||
void lrzip_nice_set(Lrzip *lr, int nice);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Get the nice level for operations in a struct
|
|
||||||
* @param lr The struct to get the nice level of
|
|
||||||
* @return The value to use when nicing during operations
|
|
||||||
*/
|
|
||||||
int lrzip_nice_get(Lrzip *lr);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Explicitly set the number of threads to use during operations
|
|
||||||
* @param lr The struct to set the threads for
|
|
||||||
* @param threads The number of threads to use for operations
|
|
||||||
* @note LRZIP will automatically determine the optimal number of threads to use,
|
|
||||||
* so this function should only be used to specify FEWER than optimal threads.
|
|
||||||
*/
|
|
||||||
void lrzip_threads_set(Lrzip *lr, unsigned int threads);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Get the number of threads used during operations
|
|
||||||
* @param lr The struct to query
|
|
||||||
* @return The number of threads to use for operations
|
|
||||||
*/
|
|
||||||
unsigned int lrzip_threads_get(Lrzip *lr);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Set the maximum compression window for operations
|
|
||||||
* @param lr The struct to set the maximum compression window for
|
|
||||||
* @param size The size (in hundreds of MB) to use for the maximum size of compression
|
|
||||||
* chunks.
|
|
||||||
* @note LRZIP will automatically determine the optimal maximum compression window to use,
|
|
||||||
* so this function should only be used to specify a LOWER value.
|
|
||||||
*/
|
|
||||||
void lrzip_compression_window_max_set(Lrzip *lr, int64_t size);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Get the maximum compression window for operations
|
|
||||||
* @param lr The struct to query
|
|
||||||
* @return The size (in hundreds of MB) to use for the maximum size of compression
|
|
||||||
* chunks.
|
|
||||||
*/
|
|
||||||
int64_t lrzip_compression_window_max_get(Lrzip *lr);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Return the size of the stream queue in a struct
|
|
||||||
* This function returns the current count of streams added for processing
|
|
||||||
* using lrzip_file_add. It always returns instantly.
|
|
||||||
* @param lr The struct to query
|
|
||||||
* @return The current number of streams in the queue
|
|
||||||
*/
|
|
||||||
unsigned int lrzip_files_count(Lrzip *lr);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Return the size of the file queue in a struct
|
|
||||||
* This function returns the current count of files added for processing
|
|
||||||
* using lrzip_filename_add. It always returns instantly.
|
|
||||||
* @param lr The struct to query
|
|
||||||
* @return The current number of files in the queue
|
|
||||||
*/
|
|
||||||
unsigned int lrzip_filenames_count(Lrzip *lr);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Return the array of the stream queue in a struct
|
|
||||||
* This function returns the current queue of streams added for processing
|
|
||||||
* using lrzip_file_add. It always returns instantly.
|
|
||||||
* @param lr The struct to query
|
|
||||||
* @return The current stream queue
|
|
||||||
*/
|
|
||||||
FILE **lrzip_files_get(Lrzip *lr);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Return the array of the filename queue in a struct
|
|
||||||
* This function returns the current queue of files added for processing
|
|
||||||
* using lrzip_filename_add. It always returns instantly.
|
|
||||||
* @param lr The struct to query
|
|
||||||
* @return The current filename queue
|
|
||||||
*/
|
|
||||||
char **lrzip_filenames_get(Lrzip *lr);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Add a stream (FILE) to the operation queue
|
|
||||||
* This function adds a stream to the input queue. Each time lrzip_run()
|
|
||||||
* is called, it will run the current operation (specified by the Lrzip_Mode)
|
|
||||||
* on either a stream or file in the queue.
|
|
||||||
* @param lr The struct
|
|
||||||
* @param file The stream descriptor to queue
|
|
||||||
* @return true on success, false on failure
|
|
||||||
* @note The file queue will be fully processed prior to beginning processing
|
|
||||||
* the stream queue.
|
|
||||||
* @warning Any streams added to this queue MUST NOT be closed until they have
|
|
||||||
* either been processed or removed from the queue!
|
|
||||||
*/
|
|
||||||
bool lrzip_file_add(Lrzip *lr, FILE *file);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Remove a stream from the operation queue
|
|
||||||
* This function removes a previously added stream from the operation queue by
|
|
||||||
* iterating through the queue and removing the stream if found.
|
|
||||||
* @param lr The struct
|
|
||||||
* @param file The stream to remove
|
|
||||||
* @return true only on successful removal, else false
|
|
||||||
*/
|
|
||||||
bool lrzip_file_del(Lrzip *lr, FILE *file);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Pop the current head of the stream queue
|
|
||||||
* This function is used to remove the current head of the stream queue. It can be called
|
|
||||||
* immediately following any lrzip_run() stream operation to remove the just-processed stream. This
|
|
||||||
* function modifies the stream queue array, reordering and updating the index count.
|
|
||||||
* @param lr The struct to pop the stream queue of
|
|
||||||
* @return The stream removed from the queue, or NULL on failure
|
|
||||||
*/
|
|
||||||
FILE *lrzip_file_pop(Lrzip *lr);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Clear the stream queue
|
|
||||||
* This function is used to free and reset the stream queue. The streams
|
|
||||||
* themselves are untouched.
|
|
||||||
* @param lr The struct
|
|
||||||
*/
|
|
||||||
void lrzip_files_clear(Lrzip *lr);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Add a file to the operation queue
|
|
||||||
* This function adds a file to the input queue. Each time lrzip_run()
|
|
||||||
* is called, it will run the current operation (specified by the Lrzip_Mode)
|
|
||||||
* on either a stream or file in the queue.
|
|
||||||
* @param lr The struct
|
|
||||||
* @param file The file (by absolute path) to queue
|
|
||||||
* @return true on success, false on failure
|
|
||||||
* @note The file queue will be fully processed prior to beginning processing
|
|
||||||
* the stream queue.
|
|
||||||
*/
|
|
||||||
bool lrzip_filename_add(Lrzip *lr, const char *file);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Remove a filename from the operation queue
|
|
||||||
* This function removes a previously added filename from the operation queue by
|
|
||||||
* iterating through the queue and removing the filename if found.
|
|
||||||
* @param lr The struct
|
|
||||||
* @param file The file to remove
|
|
||||||
* @return true only on successful removal, else false
|
|
||||||
*/
|
|
||||||
bool lrzip_filename_del(Lrzip *lr, const char *file);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Pop the current head of the file queue
|
|
||||||
* This function is used to remove the current head of the file queue. It can be called
|
|
||||||
* immediately following any lrzip_run() file operation to remove the just-processed file. This
|
|
||||||
* function modifies the file queue array, reordering and updating the index count.
|
|
||||||
* @param lr The struct to pop the filename queue of
|
|
||||||
* @return The filename removed from the queue, or NULL on failure
|
|
||||||
*/
|
|
||||||
const char *lrzip_filename_pop(Lrzip *lr);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Clear the file queue
|
|
||||||
* This function is used to free and reset the file queue.
|
|
||||||
* @param lr The struct
|
|
||||||
*/
|
|
||||||
void lrzip_filenames_clear(Lrzip *lr);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Set the default suffix for LRZIP compression operations
|
|
||||||
* This function is used to change the default ".lrz" suffix for operations
|
|
||||||
* to @p suffix.
|
|
||||||
* @param lr The struct
|
|
||||||
* @param suffix The suffix to use for compression operations
|
|
||||||
*/
|
|
||||||
void lrzip_suffix_set(Lrzip *lr, const char *suffix);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Get the default suffix for LRZIP compression operations
|
|
||||||
* @param lr The struct
|
|
||||||
* @return The suffix to use for compression operations, or NULL on failure
|
|
||||||
*/
|
|
||||||
const char *lrzip_suffix_get(Lrzip *lr);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Set the output directory for operations
|
|
||||||
* This function can be used to set the output directory for operations.
|
|
||||||
* Files will be stored according to their basename and lrzip suffix where
|
|
||||||
* applicable.
|
|
||||||
* @param lr The struct
|
|
||||||
* @param dir The absolute path of the output directory
|
|
||||||
*/
|
|
||||||
void lrzip_outdir_set(Lrzip *lr, const char *dir);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Get the output directory for operations
|
|
||||||
* @param lr The struct
|
|
||||||
* @return The previously set output directory
|
|
||||||
*/
|
|
||||||
const char *lrzip_outdir_get(Lrzip *lr);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Set the output stream for operations
|
|
||||||
* This function can be used to set the output stream for operations.
|
|
||||||
* Raw data will be written to this stream for the duration of lrzip_run().
|
|
||||||
* @param lr The struct
|
|
||||||
* @param file The stream to write to
|
|
||||||
* @warning @p file is NOT created by this library and must be opened by the user!
|
|
||||||
*/
|
|
||||||
void lrzip_outfile_set(Lrzip *lr, FILE *file);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Get the output stream for operations
|
|
||||||
* @param lr The struct
|
|
||||||
* @return The previously set output stream
|
|
||||||
*/
|
|
||||||
FILE *lrzip_outfile_get(Lrzip *lr);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Set the output file for operations
|
|
||||||
* This function can be used to set the output file for operations.
|
|
||||||
* Raw data will be written to the file with this name for the duration of lrzip_run().
|
|
||||||
* @param lr The struct
|
|
||||||
* @param file The name of the file to write to
|
|
||||||
*/
|
|
||||||
void lrzip_outfilename_set(Lrzip *lr, const char *file);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Get the output filename for operations
|
|
||||||
* @param lr The struct
|
|
||||||
* @return The previously set output filename
|
|
||||||
*/
|
|
||||||
const char *lrzip_outfilename_get(Lrzip *lr);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Retrieve the MD5 digest of an LRZIP file
|
|
||||||
* Use this function after calling lrzip_run() to retrieve the digest of
|
|
||||||
* the processed archive.
|
|
||||||
* @param lr The struct having run an operation
|
|
||||||
* @return The MD5 digest of the operation's associated archive
|
|
||||||
* @note The return value of this function will change after each operation
|
|
||||||
*/
|
|
||||||
const unsigned char *lrzip_md5digest_get(Lrzip *lr);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Run the current operation
|
|
||||||
* This function is called when all necessary parameters have been set for an operation.
|
|
||||||
* The calling thread will then block until the operation has fully completed, writing
|
|
||||||
* output using logging and progress callbacks and calling password callbacks as required.
|
|
||||||
* @param lr The struct to run an operation with
|
|
||||||
* @return true if the operation successfully completed, else false
|
|
||||||
*/
|
|
||||||
bool lrzip_run(Lrzip *lr);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Set the logging level
|
|
||||||
* @param lr The struct
|
|
||||||
* @param level The #Lrzip_Log_Level to use
|
|
||||||
*/
|
|
||||||
void lrzip_log_level_set(Lrzip *lr, int level);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Get the logging level
|
|
||||||
* @param lr The struct to query
|
|
||||||
* @return The #Lrzip_Log_Level of @p lr
|
|
||||||
*/
|
|
||||||
int lrzip_log_level_get(Lrzip *lr);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Set a logging callback for use with all operations
|
|
||||||
* This function sets an Lrzip_Log_Cb which will be called any time logging
|
|
||||||
* output is to be displayed. The callback will be called as many times as the #Lrzip_Log_Level
|
|
||||||
* requires.
|
|
||||||
* @param lr The struct
|
|
||||||
* @param cb The callback
|
|
||||||
* @param log_data The data param to use in the logging callback
|
|
||||||
*/
|
|
||||||
void lrzip_log_cb_set(Lrzip *lr, Lrzip_Log_Cb cb, void *log_data);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Redirect stdout log messages to another stream
|
|
||||||
* This function sends any logging messages which would normally go to stdout into another stream.
|
|
||||||
* Useful for when stdout is the target set by lrzip_outfile_set().
|
|
||||||
* @param lr The struct
|
|
||||||
* @param out The stream to use instead of stdout
|
|
||||||
*/
|
|
||||||
void lrzip_log_stdout_set(Lrzip *lr, FILE *out);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Return the stream currently used as stdout
|
|
||||||
* @param lr The struct to query
|
|
||||||
* @return A stream where stdout messages will be sent, NULL on failure
|
|
||||||
*/
|
|
||||||
FILE *lrzip_log_stdout_get(Lrzip *lr);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Redirect stderr log messages to another stream
|
|
||||||
* This function sends any logging messages which would normally go to stderr into another stream.
|
|
||||||
* @param lr The struct
|
|
||||||
* @param err The stream to use instead of stderr
|
|
||||||
*/
|
|
||||||
void lrzip_log_stderr_set(Lrzip *lr, FILE *err);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Return the stream currently used as stderr
|
|
||||||
* @param lr The struct to query
|
|
||||||
* @return A stream where stderr messages will be sent, NULL on failure
|
|
||||||
*/
|
|
||||||
FILE *lrzip_log_stderr_get(Lrzip *lr);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Set a password callback for use with all operations
|
|
||||||
* This function sets an Lrzip_Password_Cb which will be used when working with encrypted
|
|
||||||
* LRZIP archives. It will be called both when compressing and decompressing archives.
|
|
||||||
* @param lr The struct
|
|
||||||
* @param cb The callback to set
|
|
||||||
* @param data The data param to use in the password callback
|
|
||||||
*/
|
|
||||||
void lrzip_pass_cb_set(Lrzip *lr, Lrzip_Password_Cb cb, void *data);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Set an info callback for use with all operations
|
|
||||||
* This function sets an Lrzip_Info_Cb which will be called any time there is a
|
|
||||||
* progress update in an operation.
|
|
||||||
* @param lr The struct
|
|
||||||
* @param cb The callback to set
|
|
||||||
* @param data The data param to use in the info callback
|
|
||||||
*/
|
|
||||||
void lrzip_info_cb_set(Lrzip *lr, Lrzip_Info_Cb cb, void *data);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Quick setup for performing a decompression
|
|
||||||
* This function performs all the required allocations and sets necessary parameters
|
|
||||||
* to decompress @p source to @p dest. No extra functions are necessary to call, and
|
|
||||||
* this function will block until it completes.
|
|
||||||
* @param dest A pointer to the LRZIP-allocated destination buffer
|
|
||||||
* @param dest_len A pointer to the length of @p dest
|
|
||||||
* @param source The allocated source buffer to read from
|
|
||||||
* @param source_len The length of @p source
|
|
||||||
* @return true on success, else false
|
|
||||||
*/
|
|
||||||
bool lrzip_decompress(void *dest, unsigned long *dest_len, const void *source, unsigned long source_len);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Quick setup for performing a compression
|
|
||||||
* This function performs all the required allocations and sets necessary parameters
|
|
||||||
* to compress @p source to @p dest. No extra functions are necessary to call, and
|
|
||||||
* this function will block until it completes.
|
|
||||||
* @param dest A pointer to the LRZIP-allocated destination buffer
|
|
||||||
* @param dest_len A pointer to the length of @p dest
|
|
||||||
* @param source The allocated source buffer to read from
|
|
||||||
* @param source_len The length of @p source
|
|
||||||
* @param mode The compression mode to use
|
|
||||||
* @param compress_level The value, 1-9, to use as a compression level
|
|
||||||
* @return true on success, else false
|
|
||||||
*/
|
|
||||||
bool lrzip_compress_full(void *dest, unsigned long *dest_len, const void *source, unsigned long source_len, Lrzip_Mode mode, int compress_level);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Quick setup for performing a compression using LZMA
|
|
||||||
* This function performs all the required allocations and sets necessary parameters
|
|
||||||
* to compress @p source to @p dest. No extra functions are necessary to call, and
|
|
||||||
* this function will block until it completes.
|
|
||||||
* @param dest A pointer to the LRZIP-allocated destination buffer
|
|
||||||
* @param dest_len A pointer to the length of @p dest
|
|
||||||
* @param source The allocated source buffer to read from
|
|
||||||
* @param source_len The length of @p source
|
|
||||||
* @return true on success, else false
|
|
||||||
*/
|
|
||||||
static inline bool lrzip_compress(void *dest, unsigned long *dest_len, const void *source, unsigned long source_len)
|
|
||||||
{ return lrzip_compress_full(dest, dest_len, source, source_len, LRZIP_MODE_COMPRESS_LZMA, 7); }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Quick setup for performing a compression using LZO
|
|
||||||
* This function performs all the required allocations and sets necessary parameters
|
|
||||||
* to compress @p source to @p dest. No extra functions are necessary to call, and
|
|
||||||
* this function will block until it completes.
|
|
||||||
* @param dest A pointer to the LRZIP-allocated destination buffer
|
|
||||||
* @param dest_len A pointer to the length of @p dest
|
|
||||||
* @param source The allocated source buffer to read from
|
|
||||||
* @param source_len The length of @p source
|
|
||||||
* @return true on success, else false
|
|
||||||
*/
|
|
||||||
static inline bool lrzip_lcompress(void *dest, unsigned long *dest_len, const void *source, unsigned long source_len)
|
|
||||||
{ return lrzip_compress_full(dest, dest_len, source, source_len, LRZIP_MODE_COMPRESS_LZO, 7); }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Quick setup for performing a compression using ZLIB (GZIP)
|
|
||||||
* This function performs all the required allocations and sets necessary parameters
|
|
||||||
* to compress @p source to @p dest. No extra functions are necessary to call, and
|
|
||||||
* this function will block until it completes.
|
|
||||||
* @param dest A pointer to the LRZIP-allocated destination buffer
|
|
||||||
* @param dest_len A pointer to the length of @p dest
|
|
||||||
* @param source The allocated source buffer to read from
|
|
||||||
* @param source_len The length of @p source
|
|
||||||
* @return true on success, else false
|
|
||||||
*/
|
|
||||||
static inline bool lrzip_gcompress(void *dest, unsigned long *dest_len, const void *source, unsigned long source_len)
|
|
||||||
{ return lrzip_compress_full(dest, dest_len, source, source_len, LRZIP_MODE_COMPRESS_ZLIB, 7); }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Quick setup for performing a compression using ZPAQ
|
|
||||||
* This function performs all the required allocations and sets necessary parameters
|
|
||||||
* to compress @p source to @p dest. No extra functions are necessary to call, and
|
|
||||||
* this function will block until it completes.
|
|
||||||
* @param dest A pointer to the LRZIP-allocated destination buffer
|
|
||||||
* @param dest_len A pointer to the length of @p dest
|
|
||||||
* @param source The allocated source buffer to read from
|
|
||||||
* @param source_len The length of @p source
|
|
||||||
* @return true on success, else false
|
|
||||||
*/
|
|
||||||
static inline bool lrzip_zcompress(void *dest, unsigned long *dest_len, const void *source, unsigned long source_len)
|
|
||||||
{ return lrzip_compress_full(dest, dest_len, source, source_len, LRZIP_MODE_COMPRESS_ZPAQ, 7); }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Quick setup for performing a compression using BZIP
|
|
||||||
* This function performs all the required allocations and sets necessary parameters
|
|
||||||
* to compress @p source to @p dest. No extra functions are necessary to call, and
|
|
||||||
* this function will block until it completes.
|
|
||||||
* @param dest A pointer to the LRZIP-allocated destination buffer
|
|
||||||
* @param dest_len A pointer to the length of @p dest
|
|
||||||
* @param source The allocated source buffer to read from
|
|
||||||
* @param source_len The length of @p source
|
|
||||||
* @return true on success, else false
|
|
||||||
*/
|
|
||||||
static inline bool lrzip_bcompress(void *dest, unsigned long *dest_len, const void *source, unsigned long source_len)
|
|
||||||
{ return lrzip_compress_full(dest, dest_len, source, source_len, LRZIP_MODE_COMPRESS_BZIP2, 7); }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Quick setup for performing RZIP preprocessing
|
|
||||||
* This function performs all the required allocations and sets necessary parameters
|
|
||||||
* to preprocess @p source to @p dest. No extra functions are necessary to call, and
|
|
||||||
* this function will block until it completes.
|
|
||||||
* @param dest A pointer to the LRZIP-allocated destination buffer
|
|
||||||
* @param dest_len A pointer to the length of @p dest
|
|
||||||
* @param source The allocated source buffer to read from
|
|
||||||
* @param source_len The length of @p source
|
|
||||||
* @return true on success, else false
|
|
||||||
*/
|
|
||||||
static inline bool lrzip_rcompress(void *dest, unsigned long *dest_len, const void *source, unsigned long source_len)
|
|
||||||
{ return lrzip_compress_full(dest, dest_len, source, source_len, LRZIP_MODE_COMPRESS_NONE, 7); }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Quick setup for performing a compression using LZMA and a user-defined compression level
|
|
||||||
* This function performs all the required allocations and sets necessary parameters
|
|
||||||
* to compress @p source to @p dest. No extra functions are necessary to call, and
|
|
||||||
* this function will block until it completes.
|
|
||||||
* @param dest A pointer to the LRZIP-allocated destination buffer
|
|
||||||
* @param dest_len A pointer to the length of @p dest
|
|
||||||
* @param source The allocated source buffer to read from
|
|
||||||
* @param source_len The length of @p source
|
|
||||||
* @param compress_level The value, 1-9, to use as a compression level
|
|
||||||
* @return true on success, else false
|
|
||||||
*/
|
|
||||||
static inline bool lrzip_compress2(void *dest, unsigned long *dest_len, const void *source, unsigned long source_len, int compress_level)
|
|
||||||
{ return lrzip_compress_full(dest, dest_len, source, source_len, LRZIP_MODE_COMPRESS_LZMA, compress_level); }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Quick setup for performing a compression using LZO and a user-defined compression level
|
|
||||||
* This function performs all the required allocations and sets necessary parameters
|
|
||||||
* to compress @p source to @p dest. No extra functions are necessary to call, and
|
|
||||||
* this function will block until it completes.
|
|
||||||
* @param dest A pointer to the LRZIP-allocated destination buffer
|
|
||||||
* @param dest_len A pointer to the length of @p dest
|
|
||||||
* @param source The allocated source buffer to read from
|
|
||||||
* @param source_len The length of @p source
|
|
||||||
* @param compress_level The value, 1-9, to use as a compression level
|
|
||||||
* @return true on success, else false
|
|
||||||
*/
|
|
||||||
static inline bool lrzip_lcompress2(void *dest, unsigned long *dest_len, const void *source, unsigned long source_len, int compress_level)
|
|
||||||
{ return lrzip_compress_full(dest, dest_len, source, source_len, LRZIP_MODE_COMPRESS_LZO, compress_level); }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Quick setup for performing a compression using ZLIB (GZIP) and a user-defined compression level
|
|
||||||
* This function performs all the required allocations and sets necessary parameters
|
|
||||||
* to compress @p source to @p dest. No extra functions are necessary to call, and
|
|
||||||
* this function will block until it completes.
|
|
||||||
* @param dest A pointer to the LRZIP-allocated destination buffer
|
|
||||||
* @param dest_len A pointer to the length of @p dest
|
|
||||||
* @param source The allocated source buffer to read from
|
|
||||||
* @param source_len The length of @p source
|
|
||||||
* @param compress_level The value, 1-9, to use as a compression level
|
|
||||||
* @return true on success, else false
|
|
||||||
*/
|
|
||||||
static inline bool lrzip_gcompress2(void *dest, unsigned long *dest_len, const void *source, unsigned long source_len, int compress_level)
|
|
||||||
{ return lrzip_compress_full(dest, dest_len, source, source_len, LRZIP_MODE_COMPRESS_ZLIB, compress_level); }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Quick setup for performing a compression using ZPAQ and a user-defined compression level
|
|
||||||
* This function performs all the required allocations and sets necessary parameters
|
|
||||||
* to compress @p source to @p dest. No extra functions are necessary to call, and
|
|
||||||
* this function will block until it completes.
|
|
||||||
* @param dest A pointer to the LRZIP-allocated destination buffer
|
|
||||||
* @param dest_len A pointer to the length of @p dest
|
|
||||||
* @param source The allocated source buffer to read from
|
|
||||||
* @param source_len The length of @p source
|
|
||||||
* @param compress_level The value, 1-9, to use as a compression level
|
|
||||||
* @return true on success, else false
|
|
||||||
*/
|
|
||||||
static inline bool lrzip_zcompress2(void *dest, unsigned long *dest_len, const void *source, unsigned long source_len, int compress_level)
|
|
||||||
{ return lrzip_compress_full(dest, dest_len, source, source_len, LRZIP_MODE_COMPRESS_ZPAQ, compress_level); }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Quick setup for performing a compression using BZIP and a user-defined compression level
|
|
||||||
* This function performs all the required allocations and sets necessary parameters
|
|
||||||
* to compress @p source to @p dest. No extra functions are necessary to call, and
|
|
||||||
* this function will block until it completes.
|
|
||||||
* @param dest A pointer to the LRZIP-allocated destination buffer
|
|
||||||
* @param dest_len A pointer to the length of @p dest
|
|
||||||
* @param source The allocated source buffer to read from
|
|
||||||
* @param source_len The length of @p source
|
|
||||||
* @param compress_level The value, 1-9, to use as a compression level
|
|
||||||
* @return true on success, else false
|
|
||||||
*/
|
|
||||||
static inline bool lrzip_bcompress2(void *dest, unsigned long *dest_len, const void *source, unsigned long source_len, int compress_level)
|
|
||||||
{ return lrzip_compress_full(dest, dest_len, source, source_len, LRZIP_MODE_COMPRESS_BZIP2, compress_level); }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Quick setup for performing RZIP preprocessing and a user-defined compression level
|
|
||||||
* This function performs all the required allocations and sets necessary parameters
|
|
||||||
* to preprocess @p source to @p dest. No extra functions are necessary to call, and
|
|
||||||
* this function will block until it completes.
|
|
||||||
* @param dest A pointer to the LRZIP-allocated destination buffer
|
|
||||||
* @param dest_len A pointer to the length of @p dest
|
|
||||||
* @param source The allocated source buffer to read from
|
|
||||||
* @param source_len The length of @p source
|
|
||||||
* @param compress_level The value, 1-9, to use as a compression level
|
|
||||||
* @return true on success, else false
|
|
||||||
*/
|
|
||||||
static inline bool lrzip_rcompress2(void *dest, unsigned long *dest_len, const void *source, unsigned long source_len, int compress_level)
|
|
||||||
{ return lrzip_compress_full(dest, dest_len, source, source_len, LRZIP_MODE_COMPRESS_NONE, compress_level); }
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
@ -76,14 +76,9 @@ dist_doc_DATA = \
|
||||||
TODO \
|
TODO \
|
||||||
WHATS-NEW
|
WHATS-NEW
|
||||||
|
|
||||||
pkgconfigdir = $(libdir)/pkgconfig
|
|
||||||
pkgconfig_DATA = lrzip.pc
|
|
||||||
|
|
||||||
lrzip_HEADERS = Lrzip.h
|
|
||||||
lrzipdir = $(includedir)
|
lrzipdir = $(includedir)
|
||||||
|
|
||||||
EXTRA_DIST = \
|
EXTRA_DIST = \
|
||||||
lrzip.pc.in \
|
|
||||||
lrztar \
|
lrztar \
|
||||||
description-pak \
|
description-pak \
|
||||||
autogen.sh \
|
autogen.sh \
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,8 @@
|
||||||
Changelog will be moved to git entirely from this point forward.
|
lrzip-0.651
|
||||||
|
|
||||||
|
Remove redundant files
|
||||||
|
Revert locale dependent output
|
||||||
|
Add warnings for low memory and threads
|
||||||
|
|
||||||
lrzip-0.650
|
lrzip-0.650
|
||||||
|
|
||||||
|
|
|
||||||
16
configure.ac
16
configure.ac
|
|
@ -2,7 +2,7 @@
|
||||||
##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##
|
##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##
|
||||||
m4_define([v_maj], [0])
|
m4_define([v_maj], [0])
|
||||||
m4_define([v_min], [6])
|
m4_define([v_min], [6])
|
||||||
m4_define([v_mic], [50])
|
m4_define([v_mic], [51])
|
||||||
##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##
|
##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##
|
||||||
m4_define([v_v], m4_join([], v_min, v_mic))
|
m4_define([v_v], m4_join([], v_min, v_mic))
|
||||||
m4_define([v_ver], [v_maj.v_v])
|
m4_define([v_ver], [v_maj.v_v])
|
||||||
|
|
@ -15,7 +15,7 @@ m4_define([lt_age], v_min)
|
||||||
|
|
||||||
dnl Process this file with autoconf to produce a configure script.
|
dnl Process this file with autoconf to produce a configure script.
|
||||||
AC_INIT([lrzip],[v_ver],[kernel@kolivas.org])
|
AC_INIT([lrzip],[v_ver],[kernel@kolivas.org])
|
||||||
AC_PREREQ([2.59])
|
AC_PREREQ([2.71])
|
||||||
AC_CONFIG_SRCDIR([configure.ac])
|
AC_CONFIG_SRCDIR([configure.ac])
|
||||||
AC_CONFIG_MACRO_DIR([m4])
|
AC_CONFIG_MACRO_DIR([m4])
|
||||||
AC_CONFIG_HEADERS([config.h])
|
AC_CONFIG_HEADERS([config.h])
|
||||||
|
|
@ -24,7 +24,7 @@ AM_INIT_AUTOMAKE([1.6 dist-bzip2 foreign subdir-objects])
|
||||||
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
|
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
|
||||||
AC_USE_SYSTEM_EXTENSIONS
|
AC_USE_SYSTEM_EXTENSIONS
|
||||||
|
|
||||||
AC_PROG_LIBTOOL
|
LT_INIT
|
||||||
##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##
|
##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##
|
||||||
##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##
|
##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##
|
||||||
m4_ifdef([v_rev], , [m4_define([v_rev], [0])])
|
m4_ifdef([v_rev], , [m4_define([v_rev], [0])])
|
||||||
|
|
@ -53,17 +53,14 @@ AC_SUBST(SHELL)
|
||||||
AC_SYS_LARGEFILE
|
AC_SYS_LARGEFILE
|
||||||
AC_FUNC_FSEEKO
|
AC_FUNC_FSEEKO
|
||||||
AC_FUNC_ALLOCA
|
AC_FUNC_ALLOCA
|
||||||
AC_PROG_CC_C99
|
|
||||||
AS_IF([test x"$ac_cv_prog_cc_c99" = x"no"],
|
|
||||||
AC_MSG_ERROR([C compiler does not support C99], 1))
|
|
||||||
AC_CHECK_PROG([HAVE_POD2MAN], [pod2man], [yes])
|
AC_CHECK_PROG([HAVE_POD2MAN], [pod2man], [yes])
|
||||||
AS_IF([test "$HAVE_POD2MAN" != "yes"],
|
AS_IF([test "$HAVE_POD2MAN" != "yes"],
|
||||||
AC_MSG_FAILURE([pod2man is needed to generate manual from POD]))
|
AC_MSG_FAILURE([pod2man is needed to generate manual from POD]))
|
||||||
|
|
||||||
|
|
||||||
AC_ARG_ENABLE(
|
AC_ARG_ENABLE(
|
||||||
asm,
|
asm,
|
||||||
[AC_HELP_STRING([--enable-asm],[Enable native Assembly code])],
|
[AS_HELP_STRING([--enable-asm],[Enable native Assembly code])],
|
||||||
ASM=$enableval,
|
ASM=$enableval,
|
||||||
ASM=yes
|
ASM=yes
|
||||||
)
|
)
|
||||||
|
|
@ -77,7 +74,7 @@ fi
|
||||||
|
|
||||||
static=no
|
static=no
|
||||||
AC_ARG_ENABLE([static-bin],
|
AC_ARG_ENABLE([static-bin],
|
||||||
[AC_HELP_STRING([--enable-static-bin],[Build statically linked binary @<:@default=no@:>@])],
|
[AS_HELP_STRING([--enable-static-bin],[Build statically linked binary @<:@default=no@:>@])],
|
||||||
[static=$enableval]
|
[static=$enableval]
|
||||||
)
|
)
|
||||||
AM_CONDITIONAL([STATIC], [test x"$static" = x"yes"])
|
AM_CONDITIONAL([STATIC], [test x"$static" = x"yes"])
|
||||||
|
|
@ -150,7 +147,6 @@ EFL_CHECK_DOXYGEN([build_doc="yes"], [build_doc="no"])
|
||||||
|
|
||||||
AC_CONFIG_FILES([
|
AC_CONFIG_FILES([
|
||||||
Makefile
|
Makefile
|
||||||
lrzip.pc
|
|
||||||
lzma/Makefile
|
lzma/Makefile
|
||||||
lzma/C/Makefile
|
lzma/C/Makefile
|
||||||
lzma/ASM/x86/Makefile
|
lzma/ASM/x86/Makefile
|
||||||
|
|
|
||||||
111
lrzip.c
111
lrzip.c
|
|
@ -56,6 +56,7 @@
|
||||||
#include "stream.h"
|
#include "stream.h"
|
||||||
|
|
||||||
#define MAGIC_LEN (24)
|
#define MAGIC_LEN (24)
|
||||||
|
#define STDIO_TMPFILE_BUFFER_SIZE (65536) // used in read_tmpinfile and dump_tmpoutfile
|
||||||
|
|
||||||
static void release_hashes(rzip_control *control);
|
static void release_hashes(rzip_control *control);
|
||||||
|
|
||||||
|
|
@ -90,6 +91,32 @@ i64 get_ram(rzip_control *control)
|
||||||
|
|
||||||
return ramsize;
|
return ramsize;
|
||||||
}
|
}
|
||||||
|
#elif defined(__OpenBSD__)
|
||||||
|
# include <sys/resource.h>
|
||||||
|
i64 get_ram(rzip_control *control)
|
||||||
|
{
|
||||||
|
struct rlimit rl;
|
||||||
|
i64 ramsize = (i64)sysconf(_SC_PHYS_PAGES) * PAGE_SIZE;
|
||||||
|
|
||||||
|
/* Raise limits all the way to the max */
|
||||||
|
|
||||||
|
if (getrlimit(RLIMIT_DATA, &rl) == -1)
|
||||||
|
fatal_return(("Failed to get limits in get_ram\n"), -1);
|
||||||
|
|
||||||
|
rl.rlim_cur = rl.rlim_max;
|
||||||
|
if (setrlimit(RLIMIT_DATA, &rl) == -1)
|
||||||
|
fatal_return(("Failed to set limits in get_ram\n"), -1);
|
||||||
|
|
||||||
|
/* Declare detected RAM to be either the max RAM available from
|
||||||
|
physical memory or the max RAM allowed by RLIMIT_DATA, whatever
|
||||||
|
is smaller, to prevent the heuristics from selecting
|
||||||
|
compression windows which cause lrzip to go into deep swap */
|
||||||
|
|
||||||
|
if (rl.rlim_max < ramsize)
|
||||||
|
return rl.rlim_max;
|
||||||
|
|
||||||
|
return ramsize;
|
||||||
|
}
|
||||||
#else /* __APPLE__ */
|
#else /* __APPLE__ */
|
||||||
i64 get_ram(rzip_control *control)
|
i64 get_ram(rzip_control *control)
|
||||||
{
|
{
|
||||||
|
|
@ -386,7 +413,7 @@ static bool flush_tmpoutbuf(rzip_control *control)
|
||||||
/* Dump temporary outputfile to perform stdout */
|
/* Dump temporary outputfile to perform stdout */
|
||||||
static bool dump_tmpoutfile(rzip_control *control)
|
static bool dump_tmpoutfile(rzip_control *control)
|
||||||
{
|
{
|
||||||
int tmpchar, fd_out = control->fd_out;
|
int fd_out = control->fd_out;
|
||||||
FILE *tmpoutfp;
|
FILE *tmpoutfp;
|
||||||
|
|
||||||
if (unlikely(fd_out == -1))
|
if (unlikely(fd_out == -1))
|
||||||
|
|
@ -399,9 +426,35 @@ static bool dump_tmpoutfile(rzip_control *control)
|
||||||
rewind(tmpoutfp);
|
rewind(tmpoutfp);
|
||||||
|
|
||||||
if (!TEST_ONLY) {
|
if (!TEST_ONLY) {
|
||||||
|
char* buf;
|
||||||
|
|
||||||
print_verbose("Dumping temporary file to control->outFILE.\n");
|
print_verbose("Dumping temporary file to control->outFILE.\n");
|
||||||
while ((tmpchar = fgetc(tmpoutfp)) != EOF)
|
fflush(control->outFILE);
|
||||||
putchar(tmpchar);
|
|
||||||
|
buf = malloc(STDIO_TMPFILE_BUFFER_SIZE);
|
||||||
|
if (unlikely(!buf))
|
||||||
|
fatal_return(("Failed to allocate buffer in dump_tmpoutfile\n"), false);
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
ssize_t num_read, num_written;
|
||||||
|
num_read = fread(buf, 1, STDIO_TMPFILE_BUFFER_SIZE, tmpoutfp);
|
||||||
|
if (unlikely(num_read == 0)) {
|
||||||
|
if (ferror(tmpoutfp)) {
|
||||||
|
dealloc(buf);
|
||||||
|
fatal_return(("Failed read in dump_tmpoutfile\n"), false);
|
||||||
|
} else {
|
||||||
|
break; // must be at EOF
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
num_written = fwrite(buf, 1, num_read, control->outFILE);
|
||||||
|
if (unlikely(num_written != num_read)) {
|
||||||
|
dealloc(buf);
|
||||||
|
fatal_return(("Failed write in dump_tmpoutfile\n"), false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dealloc(buf);
|
||||||
fflush(control->outFILE);
|
fflush(control->outFILE);
|
||||||
rewind(tmpoutfp);
|
rewind(tmpoutfp);
|
||||||
}
|
}
|
||||||
|
|
@ -513,6 +566,7 @@ bool read_tmpinfile(rzip_control *control, int fd_in)
|
||||||
{
|
{
|
||||||
FILE *tmpinfp;
|
FILE *tmpinfp;
|
||||||
int tmpchar;
|
int tmpchar;
|
||||||
|
char* buf;
|
||||||
|
|
||||||
if (fd_in == -1)
|
if (fd_in == -1)
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -522,9 +576,30 @@ bool read_tmpinfile(rzip_control *control, int fd_in)
|
||||||
if (unlikely(tmpinfp == NULL))
|
if (unlikely(tmpinfp == NULL))
|
||||||
fatal_return(("Failed to fdopen in tmpfile\n"), false);
|
fatal_return(("Failed to fdopen in tmpfile\n"), false);
|
||||||
|
|
||||||
while ((tmpchar = getchar()) != EOF)
|
buf = malloc(STDIO_TMPFILE_BUFFER_SIZE);
|
||||||
fputc(tmpchar, tmpinfp);
|
if (unlikely(!buf))
|
||||||
|
fatal_return(("Failed to allocate buffer in read_tmpinfile\n"), false);
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
ssize_t num_read, num_written;
|
||||||
|
num_read = fread(buf, 1, STDIO_TMPFILE_BUFFER_SIZE, stdin);
|
||||||
|
if (unlikely(num_read == 0)) {
|
||||||
|
if (ferror(stdin)) {
|
||||||
|
dealloc(buf);
|
||||||
|
fatal_return(("Failed read in read_tmpinfile\n"), false);
|
||||||
|
} else {
|
||||||
|
break; // must be at EOF
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
num_written = fwrite(buf, 1, num_read, tmpinfp);
|
||||||
|
if (unlikely(num_written != num_read)) {
|
||||||
|
dealloc(buf);
|
||||||
|
fatal_return(("Failed write in read_tmpinfile\n"), false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dealloc(buf);
|
||||||
fflush(tmpinfp);
|
fflush(tmpinfp);
|
||||||
rewind(tmpinfp);
|
rewind(tmpinfp);
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -1072,7 +1147,7 @@ next_chunk:
|
||||||
print_verbose("Chunk byte width: %d\n", chunk_byte);
|
print_verbose("Chunk byte width: %d\n", chunk_byte);
|
||||||
if (chunk_size) {
|
if (chunk_size) {
|
||||||
chunk_total += chunk_size;
|
chunk_total += chunk_size;
|
||||||
print_verbose("Chunk size: %'"PRId64"\n", chunk_size);
|
print_verbose("Chunk size: %"PRId64"\n", chunk_size);
|
||||||
}
|
}
|
||||||
if (unlikely(chunk_byte && (chunk_byte > 8 || chunk_size < 0)))
|
if (unlikely(chunk_byte && (chunk_byte > 8 || chunk_size < 0)))
|
||||||
failure("Invalid chunk data\n");
|
failure("Invalid chunk data\n");
|
||||||
|
|
@ -1086,14 +1161,14 @@ next_chunk:
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
print_verbose("Stream: %d\n", stream);
|
print_verbose("Stream: %d\n", stream);
|
||||||
print_maxverbose("Offset: %'"PRId64"\n", stream_head[stream] + ofs);
|
print_maxverbose("Offset: %"PRId64"\n", stream_head[stream] + ofs);
|
||||||
print_verbose("%s\t%s\t%s\t%16s / %14s", "Block","Comp","Percent","Comp Size", "UComp Size");
|
print_verbose("%s\t%s\t%s\t%16s / %14s", "Block","Comp","Percent","Comp Size", "UComp Size");
|
||||||
print_maxverbose("%18s : %14s", "Offset", "Head");
|
print_maxverbose("%18s : %14s", "Offset", "Head");
|
||||||
print_verbose("\n");
|
print_verbose("\n");
|
||||||
do {
|
do {
|
||||||
i64 head_off;
|
i64 head_off;
|
||||||
|
|
||||||
if (unlikely(last_head && last_head < second_last))
|
if (unlikely(last_head && last_head <= second_last))
|
||||||
failure_goto(("Invalid earlier last_head position, corrupt archive.\n"), error);
|
failure_goto(("Invalid earlier last_head position, corrupt archive.\n"), error);
|
||||||
second_last = last_head;
|
second_last = last_head;
|
||||||
if (unlikely(last_head + ofs > infile_size))
|
if (unlikely(last_head + ofs > infile_size))
|
||||||
|
|
@ -1127,8 +1202,8 @@ next_chunk:
|
||||||
* the future */
|
* the future */
|
||||||
utotal += u_len;
|
utotal += u_len;
|
||||||
ctotal += c_len;
|
ctotal += c_len;
|
||||||
print_verbose("\t%5.1f%%\t%'16"PRId64" / %'14"PRId64"", percentage(c_len, u_len), c_len, u_len);
|
print_verbose("\t%5.1f%%\t%16"PRId64" / %14"PRId64"", percentage(c_len, u_len), c_len, u_len);
|
||||||
print_maxverbose("%'18"PRId64" : %'14"PRId64"", head_off, last_head);
|
print_maxverbose("%18"PRId64" : %14"PRId64"", head_off, last_head);
|
||||||
print_verbose("\n");
|
print_verbose("\n");
|
||||||
block++;
|
block++;
|
||||||
} while (last_head);
|
} while (last_head);
|
||||||
|
|
@ -1165,7 +1240,7 @@ done:
|
||||||
if (unlikely(ofs > infile_size))
|
if (unlikely(ofs > infile_size))
|
||||||
failure_goto(("Offset greater than archive size, likely corrupted/truncated archive.\n"), error);
|
failure_goto(("Offset greater than archive size, likely corrupted/truncated archive.\n"), error);
|
||||||
print_output("\nSummary\n=======\n");
|
print_output("\nSummary\n=======\n");
|
||||||
print_output("File: %s\nlrzip version: %'d.%'d \n\n", infilecopy,
|
print_output("File: %s\nlrzip version: %d.%d \n\n", infilecopy,
|
||||||
control->major_version, control->minor_version);
|
control->major_version, control->minor_version);
|
||||||
|
|
||||||
if (!expected_size)
|
if (!expected_size)
|
||||||
|
|
@ -1173,18 +1248,18 @@ done:
|
||||||
print_verbose(" Stats Percent Compressed / Uncompressed\n -------------------------------------------------------\n");
|
print_verbose(" Stats Percent Compressed / Uncompressed\n -------------------------------------------------------\n");
|
||||||
/* If we can't show expected size, tailor output for it */
|
/* If we can't show expected size, tailor output for it */
|
||||||
if (expected_size) {
|
if (expected_size) {
|
||||||
print_verbose(" Rzip: %5.1f%%\t%'16"PRId64" / %'14"PRId64"\n",
|
print_verbose(" Rzip: %5.1f%%\t%16"PRId64" / %14"PRId64"\n",
|
||||||
percentage (utotal, expected_size),
|
percentage (utotal, expected_size),
|
||||||
utotal, expected_size);
|
utotal, expected_size);
|
||||||
print_verbose(" Back end: %5.1f%%\t%'16"PRId64" / %'14"PRId64"\n",
|
print_verbose(" Back end: %5.1f%%\t%16"PRId64" / %14"PRId64"\n",
|
||||||
percentage(ctotal, utotal),
|
percentage(ctotal, utotal),
|
||||||
ctotal, utotal);
|
ctotal, utotal);
|
||||||
print_verbose(" Overall: %5.1f%%\t%'16"PRId64" / %'14"PRId64"\n",
|
print_verbose(" Overall: %5.1f%%\t%16"PRId64" / %14"PRId64"\n",
|
||||||
percentage(ctotal, expected_size),
|
percentage(ctotal, expected_size),
|
||||||
ctotal, expected_size);
|
ctotal, expected_size);
|
||||||
} else {
|
} else {
|
||||||
print_verbose(" Rzip: Unavailable\n");
|
print_verbose(" Rzip: Unavailable\n");
|
||||||
print_verbose(" Back end: %5.1f%%\t%'16"PRId64" / %'14"PRId64"\n", percentage(ctotal, utotal), ctotal, utotal);
|
print_verbose(" Back end: %5.1f%%\t%16"PRId64" / %14"PRId64"\n", percentage(ctotal, utotal), ctotal, utotal);
|
||||||
print_verbose(" Overall: Unavailable\n");
|
print_verbose(" Overall: Unavailable\n");
|
||||||
}
|
}
|
||||||
print_verbose("\n");
|
print_verbose("\n");
|
||||||
|
|
@ -1209,12 +1284,12 @@ done:
|
||||||
print_output("\n");
|
print_output("\n");
|
||||||
|
|
||||||
if (expected_size) {
|
if (expected_size) {
|
||||||
print_output(" Decompressed file size: %'14"PRIu64"\n", expected_size);
|
print_output(" Decompressed file size: %14"PRIu64"\n", expected_size);
|
||||||
print_output(" Compressed file size: %'14"PRIu64"\n", infile_size);
|
print_output(" Compressed file size: %14"PRIu64"\n", infile_size);
|
||||||
print_output(" Compression ratio: %14.3Lfx\n", cratio);
|
print_output(" Compression ratio: %14.3Lfx\n", cratio);
|
||||||
} else {
|
} else {
|
||||||
print_output(" Decompressed file size: Unavailable\n");
|
print_output(" Decompressed file size: Unavailable\n");
|
||||||
print_output(" Compressed file size: %'14"PRIu64"\n", infile_size);
|
print_output(" Compressed file size: %14"PRIu64"\n", infile_size);
|
||||||
print_output(" Compression ratio: Unavailable\n");
|
print_output(" Compression ratio: Unavailable\n");
|
||||||
}
|
}
|
||||||
if (HAS_MD5) {
|
if (HAS_MD5) {
|
||||||
|
|
|
||||||
10
lrzip.pc.in
10
lrzip.pc.in
|
|
@ -1,10 +0,0 @@
|
||||||
prefix=@prefix@
|
|
||||||
exec_prefix=@exec_prefix@
|
|
||||||
libdir=@libdir@
|
|
||||||
includedir=@includedir@
|
|
||||||
|
|
||||||
Name: lrzip
|
|
||||||
Description: lrzip compression library
|
|
||||||
Version: @VERSION@
|
|
||||||
Libs: -L${libdir} -llrzip
|
|
||||||
Libs.private: @LIBS@
|
|
||||||
|
|
@ -144,7 +144,7 @@ extern int errno;
|
||||||
#define unlikely(x) __builtin_expect(!!(x), 0)
|
#define unlikely(x) __builtin_expect(!!(x), 0)
|
||||||
#define __maybe_unused __attribute__((unused))
|
#define __maybe_unused __attribute__((unused))
|
||||||
|
|
||||||
#if defined(__MINGW32__) || defined(__CYGWIN__) || defined(__ANDROID__) || defined(__APPLE__)
|
#if defined(__MINGW32__) || defined(__CYGWIN__) || defined(__ANDROID__) || defined(__APPLE__) || defined(__OpenBSD__)
|
||||||
# define ffsll __builtin_ffsll
|
# define ffsll __builtin_ffsll
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -138,4 +138,10 @@ MY_ENDP
|
||||||
%ifidn __OUTPUT_FORMAT__,elf
|
%ifidn __OUTPUT_FORMAT__,elf
|
||||||
section .note.GNU-stack noalloc noexec nowrite progbits
|
section .note.GNU-stack noalloc noexec nowrite progbits
|
||||||
%endif
|
%endif
|
||||||
|
%ifidn __OUTPUT_FORMAT__,elf32
|
||||||
|
section .note.GNU-stack noalloc noexec nowrite progbits
|
||||||
|
%endif
|
||||||
|
%ifidn __OUTPUT_FORMAT__,elf64
|
||||||
|
section .note.GNU-stack noalloc noexec nowrite progbits
|
||||||
|
%endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -53,11 +53,12 @@ liblzma_la_LIBADD = $(ASM_7z).lo
|
||||||
\n\# Generated by libtool -- hack to allow asm linking\
|
\n\# Generated by libtool -- hack to allow asm linking\
|
||||||
\n\# Peter Hyman\
|
\n\# Peter Hyman\
|
||||||
\npic_object='.libs/$(ASM_7z).o'\
|
\npic_object='.libs/$(ASM_7z).o'\
|
||||||
\nnon_pic_object='$(ASM_7z).o'
|
\nnon_pic_object='$(ASM_7z).o'\
|
||||||
|
\n
|
||||||
|
|
||||||
$(ASM_7z).lo: $(ASM_S)
|
$(ASM_7z).lo: $(ASM_S)
|
||||||
$(ASM_PROG) $(ASM_OPT) -o $(ASM_7z).o $(ASM_S)
|
$(ASM_PROG) $(ASM_OPT) -o $(ASM_7z).o $(ASM_S)
|
||||||
mkdir -p .libs
|
mkdir -p .libs
|
||||||
cp $(ASM_7z).o .libs/
|
cp $(ASM_7z).o .libs/
|
||||||
@echo -e "$(7ZIPASMLOFILE)" > $(ASM_7z).lo
|
@printf "$(7ZIPASMLOFILE)" > $(ASM_7z).lo
|
||||||
endif
|
endif
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,7 @@ AC_DEFUN([AC_C___ATTRIBUTE__],
|
||||||
AC_MSG_CHECKING([for __attribute__])
|
AC_MSG_CHECKING([for __attribute__])
|
||||||
|
|
||||||
AC_CACHE_VAL([ac_cv___attribute__],
|
AC_CACHE_VAL([ac_cv___attribute__],
|
||||||
[AC_TRY_COMPILE(
|
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
|
||||||
[
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
int func(int x);
|
int func(int x);
|
||||||
|
|
@ -27,11 +26,8 @@ int foo(int x __attribute__ ((unused)))
|
||||||
{
|
{
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
],
|
]], [[]])],[ac_cv___attribute__="yes"],[ac_cv___attribute__="no"
|
||||||
[],
|
])])
|
||||||
[ac_cv___attribute__="yes"],
|
|
||||||
[ac_cv___attribute__="no"]
|
|
||||||
)])
|
|
||||||
|
|
||||||
AC_MSG_RESULT($ac_cv___attribute__)
|
AC_MSG_RESULT($ac_cv___attribute__)
|
||||||
|
|
||||||
|
|
|
||||||
486
m4/ax_pthread.m4
486
m4/ax_pthread.m4
|
|
@ -1,486 +0,0 @@
|
||||||
# ===========================================================================
|
|
||||||
# https://www.gnu.org/software/autoconf-archive/ax_pthread.html
|
|
||||||
# ===========================================================================
|
|
||||||
#
|
|
||||||
# SYNOPSIS
|
|
||||||
#
|
|
||||||
# AX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
|
|
||||||
#
|
|
||||||
# DESCRIPTION
|
|
||||||
#
|
|
||||||
# This macro figures out how to build C programs using POSIX threads. It
|
|
||||||
# sets the PTHREAD_LIBS output variable to the threads library and linker
|
|
||||||
# flags, and the PTHREAD_CFLAGS output variable to any special C compiler
|
|
||||||
# flags that are needed. (The user can also force certain compiler
|
|
||||||
# flags/libs to be tested by setting these environment variables.)
|
|
||||||
#
|
|
||||||
# Also sets PTHREAD_CC to any special C compiler that is needed for
|
|
||||||
# multi-threaded programs (defaults to the value of CC otherwise). (This
|
|
||||||
# is necessary on AIX to use the special cc_r compiler alias.)
|
|
||||||
#
|
|
||||||
# NOTE: You are assumed to not only compile your program with these flags,
|
|
||||||
# but also to link with them as well. For example, you might link with
|
|
||||||
# $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS
|
|
||||||
#
|
|
||||||
# If you are only building threaded programs, you may wish to use these
|
|
||||||
# variables in your default LIBS, CFLAGS, and CC:
|
|
||||||
#
|
|
||||||
# LIBS="$PTHREAD_LIBS $LIBS"
|
|
||||||
# CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
|
|
||||||
# CC="$PTHREAD_CC"
|
|
||||||
#
|
|
||||||
# In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute constant
|
|
||||||
# has a nonstandard name, this macro defines PTHREAD_CREATE_JOINABLE to
|
|
||||||
# that name (e.g. PTHREAD_CREATE_UNDETACHED on AIX).
|
|
||||||
#
|
|
||||||
# Also HAVE_PTHREAD_PRIO_INHERIT is defined if pthread is found and the
|
|
||||||
# PTHREAD_PRIO_INHERIT symbol is defined when compiling with
|
|
||||||
# PTHREAD_CFLAGS.
|
|
||||||
#
|
|
||||||
# ACTION-IF-FOUND is a list of shell commands to run if a threads library
|
|
||||||
# is found, and ACTION-IF-NOT-FOUND is a list of commands to run it if it
|
|
||||||
# is not found. If ACTION-IF-FOUND is not specified, the default action
|
|
||||||
# will define HAVE_PTHREAD.
|
|
||||||
#
|
|
||||||
# Please let the authors know if this macro fails on any platform, or if
|
|
||||||
# you have any other suggestions or comments. This macro was based on work
|
|
||||||
# by SGJ on autoconf scripts for FFTW (http://www.fftw.org/) (with help
|
|
||||||
# from M. Frigo), as well as ac_pthread and hb_pthread macros posted by
|
|
||||||
# Alejandro Forero Cuervo to the autoconf macro repository. We are also
|
|
||||||
# grateful for the helpful feedback of numerous users.
|
|
||||||
#
|
|
||||||
# Updated for Autoconf 2.68 by Daniel Richard G.
|
|
||||||
#
|
|
||||||
# LICENSE
|
|
||||||
#
|
|
||||||
# Copyright (c) 2008 Steven G. Johnson <stevenj@alum.mit.edu>
|
|
||||||
# Copyright (c) 2011 Daniel Richard G. <skunk@iSKUNK.ORG>
|
|
||||||
#
|
|
||||||
# This program is free software: you can redistribute it and/or modify it
|
|
||||||
# under the terms of the GNU General Public License as published by the
|
|
||||||
# Free Software Foundation, either version 3 of the License, or (at your
|
|
||||||
# option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful, but
|
|
||||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
|
||||||
# Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License along
|
|
||||||
# with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
# As a special exception, the respective Autoconf Macro's copyright owner
|
|
||||||
# gives unlimited permission to copy, distribute and modify the configure
|
|
||||||
# scripts that are the output of Autoconf when processing the Macro. You
|
|
||||||
# need not follow the terms of the GNU General Public License when using
|
|
||||||
# or distributing such scripts, even though portions of the text of the
|
|
||||||
# Macro appear in them. The GNU General Public License (GPL) does govern
|
|
||||||
# all other use of the material that constitutes the Autoconf Macro.
|
|
||||||
#
|
|
||||||
# This special exception to the GPL applies to versions of the Autoconf
|
|
||||||
# Macro released by the Autoconf Archive. When you make and distribute a
|
|
||||||
# modified version of the Autoconf Macro, you may extend this special
|
|
||||||
# exception to the GPL to apply to your modified version as well.
|
|
||||||
|
|
||||||
#serial 25
|
|
||||||
|
|
||||||
AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD])
|
|
||||||
AC_DEFUN([AX_PTHREAD], [
|
|
||||||
AC_REQUIRE([AC_CANONICAL_HOST])
|
|
||||||
AC_REQUIRE([AC_PROG_CC])
|
|
||||||
AC_REQUIRE([AC_PROG_SED])
|
|
||||||
AC_LANG_PUSH([C])
|
|
||||||
ax_pthread_ok=no
|
|
||||||
|
|
||||||
# We used to check for pthread.h first, but this fails if pthread.h
|
|
||||||
# requires special compiler flags (e.g. on Tru64 or Sequent).
|
|
||||||
# It gets checked for in the link test anyway.
|
|
||||||
|
|
||||||
# First of all, check if the user has set any of the PTHREAD_LIBS,
|
|
||||||
# etcetera environment variables, and if threads linking works using
|
|
||||||
# them:
|
|
||||||
if test "x$PTHREAD_CFLAGS$PTHREAD_LIBS" != "x"; then
|
|
||||||
ax_pthread_save_CC="$CC"
|
|
||||||
ax_pthread_save_CFLAGS="$CFLAGS"
|
|
||||||
ax_pthread_save_LIBS="$LIBS"
|
|
||||||
AS_IF([test "x$PTHREAD_CC" != "x"], [CC="$PTHREAD_CC"])
|
|
||||||
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
|
|
||||||
LIBS="$PTHREAD_LIBS $LIBS"
|
|
||||||
AC_MSG_CHECKING([for pthread_join using $CC $PTHREAD_CFLAGS $PTHREAD_LIBS])
|
|
||||||
AC_LINK_IFELSE([AC_LANG_CALL([], [pthread_join])], [ax_pthread_ok=yes])
|
|
||||||
AC_MSG_RESULT([$ax_pthread_ok])
|
|
||||||
if test "x$ax_pthread_ok" = "xno"; then
|
|
||||||
PTHREAD_LIBS=""
|
|
||||||
PTHREAD_CFLAGS=""
|
|
||||||
fi
|
|
||||||
CC="$ax_pthread_save_CC"
|
|
||||||
CFLAGS="$ax_pthread_save_CFLAGS"
|
|
||||||
LIBS="$ax_pthread_save_LIBS"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# We must check for the threads library under a number of different
|
|
||||||
# names; the ordering is very important because some systems
|
|
||||||
# (e.g. DEC) have both -lpthread and -lpthreads, where one of the
|
|
||||||
# libraries is broken (non-POSIX).
|
|
||||||
|
|
||||||
# Create a list of thread flags to try. Items starting with a "-" are
|
|
||||||
# C compiler flags, and other items are library names, except for "none"
|
|
||||||
# which indicates that we try without any flags at all, and "pthread-config"
|
|
||||||
# which is a program returning the flags for the Pth emulation library.
|
|
||||||
|
|
||||||
ax_pthread_flags="pthreads none -Kthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config"
|
|
||||||
|
|
||||||
# The ordering *is* (sometimes) important. Some notes on the
|
|
||||||
# individual items follow:
|
|
||||||
|
|
||||||
# pthreads: AIX (must check this before -lpthread)
|
|
||||||
# none: in case threads are in libc; should be tried before -Kthread and
|
|
||||||
# other compiler flags to prevent continual compiler warnings
|
|
||||||
# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
|
|
||||||
# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads), Tru64
|
|
||||||
# (Note: HP C rejects this with "bad form for `-t' option")
|
|
||||||
# -pthreads: Solaris/gcc (Note: HP C also rejects)
|
|
||||||
# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
|
|
||||||
# doesn't hurt to check since this sometimes defines pthreads and
|
|
||||||
# -D_REENTRANT too), HP C (must be checked before -lpthread, which
|
|
||||||
# is present but should not be used directly; and before -mthreads,
|
|
||||||
# because the compiler interprets this as "-mt" + "-hreads")
|
|
||||||
# -mthreads: Mingw32/gcc, Lynx/gcc
|
|
||||||
# pthread: Linux, etcetera
|
|
||||||
# --thread-safe: KAI C++
|
|
||||||
# pthread-config: use pthread-config program (for GNU Pth library)
|
|
||||||
|
|
||||||
case $host_os in
|
|
||||||
|
|
||||||
freebsd*)
|
|
||||||
|
|
||||||
# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
|
|
||||||
# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
|
|
||||||
|
|
||||||
ax_pthread_flags="-kthread lthread $ax_pthread_flags"
|
|
||||||
;;
|
|
||||||
|
|
||||||
hpux*)
|
|
||||||
|
|
||||||
# From the cc(1) man page: "[-mt] Sets various -D flags to enable
|
|
||||||
# multi-threading and also sets -lpthread."
|
|
||||||
|
|
||||||
ax_pthread_flags="-mt -pthread pthread $ax_pthread_flags"
|
|
||||||
;;
|
|
||||||
|
|
||||||
openedition*)
|
|
||||||
|
|
||||||
# IBM z/OS requires a feature-test macro to be defined in order to
|
|
||||||
# enable POSIX threads at all, so give the user a hint if this is
|
|
||||||
# not set. (We don't define these ourselves, as they can affect
|
|
||||||
# other portions of the system API in unpredictable ways.)
|
|
||||||
|
|
||||||
AC_EGREP_CPP([AX_PTHREAD_ZOS_MISSING],
|
|
||||||
[
|
|
||||||
# if !defined(_OPEN_THREADS) && !defined(_UNIX03_THREADS)
|
|
||||||
AX_PTHREAD_ZOS_MISSING
|
|
||||||
# endif
|
|
||||||
],
|
|
||||||
[AC_MSG_WARN([IBM z/OS requires -D_OPEN_THREADS or -D_UNIX03_THREADS to enable pthreads support.])])
|
|
||||||
;;
|
|
||||||
|
|
||||||
solaris*)
|
|
||||||
|
|
||||||
# On Solaris (at least, for some versions), libc contains stubbed
|
|
||||||
# (non-functional) versions of the pthreads routines, so link-based
|
|
||||||
# tests will erroneously succeed. (N.B.: The stubs are missing
|
|
||||||
# pthread_cleanup_push, or rather a function called by this macro,
|
|
||||||
# so we could check for that, but who knows whether they'll stub
|
|
||||||
# that too in a future libc.) So we'll check first for the
|
|
||||||
# standard Solaris way of linking pthreads (-mt -lpthread).
|
|
||||||
|
|
||||||
ax_pthread_flags="-mt,pthread pthread $ax_pthread_flags"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# GCC generally uses -pthread, or -pthreads on some platforms (e.g. SPARC)
|
|
||||||
|
|
||||||
AS_IF([test "x$GCC" = "xyes"],
|
|
||||||
[ax_pthread_flags="-pthread -pthreads $ax_pthread_flags"])
|
|
||||||
|
|
||||||
# The presence of a feature test macro requesting re-entrant function
|
|
||||||
# definitions is, on some systems, a strong hint that pthreads support is
|
|
||||||
# correctly enabled
|
|
||||||
|
|
||||||
case $host_os in
|
|
||||||
darwin* | hpux* | linux* | osf* | solaris*)
|
|
||||||
ax_pthread_check_macro="_REENTRANT"
|
|
||||||
;;
|
|
||||||
|
|
||||||
aix*)
|
|
||||||
ax_pthread_check_macro="_THREAD_SAFE"
|
|
||||||
;;
|
|
||||||
|
|
||||||
*)
|
|
||||||
ax_pthread_check_macro="--"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
AS_IF([test "x$ax_pthread_check_macro" = "x--"],
|
|
||||||
[ax_pthread_check_cond=0],
|
|
||||||
[ax_pthread_check_cond="!defined($ax_pthread_check_macro)"])
|
|
||||||
|
|
||||||
# Are we compiling with Clang?
|
|
||||||
|
|
||||||
AC_CACHE_CHECK([whether $CC is Clang],
|
|
||||||
[ax_cv_PTHREAD_CLANG],
|
|
||||||
[ax_cv_PTHREAD_CLANG=no
|
|
||||||
# Note that Autoconf sets GCC=yes for Clang as well as GCC
|
|
||||||
if test "x$GCC" = "xyes"; then
|
|
||||||
AC_EGREP_CPP([AX_PTHREAD_CC_IS_CLANG],
|
|
||||||
[/* Note: Clang 2.7 lacks __clang_[a-z]+__ */
|
|
||||||
# if defined(__clang__) && defined(__llvm__)
|
|
||||||
AX_PTHREAD_CC_IS_CLANG
|
|
||||||
# endif
|
|
||||||
],
|
|
||||||
[ax_cv_PTHREAD_CLANG=yes])
|
|
||||||
fi
|
|
||||||
])
|
|
||||||
ax_pthread_clang="$ax_cv_PTHREAD_CLANG"
|
|
||||||
|
|
||||||
ax_pthread_clang_warning=no
|
|
||||||
|
|
||||||
# Clang needs special handling, because older versions handle the -pthread
|
|
||||||
# option in a rather... idiosyncratic way
|
|
||||||
|
|
||||||
if test "x$ax_pthread_clang" = "xyes"; then
|
|
||||||
|
|
||||||
# Clang takes -pthread; it has never supported any other flag
|
|
||||||
|
|
||||||
# (Note 1: This will need to be revisited if a system that Clang
|
|
||||||
# supports has POSIX threads in a separate library. This tends not
|
|
||||||
# to be the way of modern systems, but it's conceivable.)
|
|
||||||
|
|
||||||
# (Note 2: On some systems, notably Darwin, -pthread is not needed
|
|
||||||
# to get POSIX threads support; the API is always present and
|
|
||||||
# active. We could reasonably leave PTHREAD_CFLAGS empty. But
|
|
||||||
# -pthread does define _REENTRANT, and while the Darwin headers
|
|
||||||
# ignore this macro, third-party headers might not.)
|
|
||||||
|
|
||||||
PTHREAD_CFLAGS="-pthread"
|
|
||||||
PTHREAD_LIBS=
|
|
||||||
|
|
||||||
ax_pthread_ok=yes
|
|
||||||
|
|
||||||
# However, older versions of Clang make a point of warning the user
|
|
||||||
# that, in an invocation where only linking and no compilation is
|
|
||||||
# taking place, the -pthread option has no effect ("argument unused
|
|
||||||
# during compilation"). They expect -pthread to be passed in only
|
|
||||||
# when source code is being compiled.
|
|
||||||
#
|
|
||||||
# Problem is, this is at odds with the way Automake and most other
|
|
||||||
# C build frameworks function, which is that the same flags used in
|
|
||||||
# compilation (CFLAGS) are also used in linking. Many systems
|
|
||||||
# supported by AX_PTHREAD require exactly this for POSIX threads
|
|
||||||
# support, and in fact it is often not straightforward to specify a
|
|
||||||
# flag that is used only in the compilation phase and not in
|
|
||||||
# linking. Such a scenario is extremely rare in practice.
|
|
||||||
#
|
|
||||||
# Even though use of the -pthread flag in linking would only print
|
|
||||||
# a warning, this can be a nuisance for well-run software projects
|
|
||||||
# that build with -Werror. So if the active version of Clang has
|
|
||||||
# this misfeature, we search for an option to squash it.
|
|
||||||
|
|
||||||
AC_CACHE_CHECK([whether Clang needs flag to prevent "argument unused" warning when linking with -pthread],
|
|
||||||
[ax_cv_PTHREAD_CLANG_NO_WARN_FLAG],
|
|
||||||
[ax_cv_PTHREAD_CLANG_NO_WARN_FLAG=unknown
|
|
||||||
# Create an alternate version of $ac_link that compiles and
|
|
||||||
# links in two steps (.c -> .o, .o -> exe) instead of one
|
|
||||||
# (.c -> exe), because the warning occurs only in the second
|
|
||||||
# step
|
|
||||||
ax_pthread_save_ac_link="$ac_link"
|
|
||||||
ax_pthread_sed='s/conftest\.\$ac_ext/conftest.$ac_objext/g'
|
|
||||||
ax_pthread_link_step=`$as_echo "$ac_link" | sed "$ax_pthread_sed"`
|
|
||||||
ax_pthread_2step_ac_link="($ac_compile) && (echo ==== >&5) && ($ax_pthread_link_step)"
|
|
||||||
ax_pthread_save_CFLAGS="$CFLAGS"
|
|
||||||
for ax_pthread_try in '' -Qunused-arguments -Wno-unused-command-line-argument unknown; do
|
|
||||||
AS_IF([test "x$ax_pthread_try" = "xunknown"], [break])
|
|
||||||
CFLAGS="-Werror -Wunknown-warning-option $ax_pthread_try -pthread $ax_pthread_save_CFLAGS"
|
|
||||||
ac_link="$ax_pthread_save_ac_link"
|
|
||||||
AC_LINK_IFELSE([AC_LANG_SOURCE([[int main(void){return 0;}]])],
|
|
||||||
[ac_link="$ax_pthread_2step_ac_link"
|
|
||||||
AC_LINK_IFELSE([AC_LANG_SOURCE([[int main(void){return 0;}]])],
|
|
||||||
[break])
|
|
||||||
])
|
|
||||||
done
|
|
||||||
ac_link="$ax_pthread_save_ac_link"
|
|
||||||
CFLAGS="$ax_pthread_save_CFLAGS"
|
|
||||||
AS_IF([test "x$ax_pthread_try" = "x"], [ax_pthread_try=no])
|
|
||||||
ax_cv_PTHREAD_CLANG_NO_WARN_FLAG="$ax_pthread_try"
|
|
||||||
])
|
|
||||||
|
|
||||||
case "$ax_cv_PTHREAD_CLANG_NO_WARN_FLAG" in
|
|
||||||
no | unknown) ;;
|
|
||||||
*) PTHREAD_CFLAGS="$ax_cv_PTHREAD_CLANG_NO_WARN_FLAG $PTHREAD_CFLAGS" ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
fi # $ax_pthread_clang = yes
|
|
||||||
|
|
||||||
if test "x$ax_pthread_ok" = "xno"; then
|
|
||||||
for ax_pthread_try_flag in $ax_pthread_flags; do
|
|
||||||
|
|
||||||
case $ax_pthread_try_flag in
|
|
||||||
none)
|
|
||||||
AC_MSG_CHECKING([whether pthreads work without any flags])
|
|
||||||
;;
|
|
||||||
|
|
||||||
-mt,pthread)
|
|
||||||
AC_MSG_CHECKING([whether pthreads work with -mt -lpthread])
|
|
||||||
PTHREAD_CFLAGS="-mt"
|
|
||||||
PTHREAD_LIBS="-lpthread"
|
|
||||||
;;
|
|
||||||
|
|
||||||
-*)
|
|
||||||
AC_MSG_CHECKING([whether pthreads work with $ax_pthread_try_flag])
|
|
||||||
PTHREAD_CFLAGS="$ax_pthread_try_flag"
|
|
||||||
;;
|
|
||||||
|
|
||||||
pthread-config)
|
|
||||||
AC_CHECK_PROG([ax_pthread_config], [pthread-config], [yes], [no])
|
|
||||||
AS_IF([test "x$ax_pthread_config" = "xno"], [continue])
|
|
||||||
PTHREAD_CFLAGS="`pthread-config --cflags`"
|
|
||||||
PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
|
|
||||||
;;
|
|
||||||
|
|
||||||
*)
|
|
||||||
AC_MSG_CHECKING([for the pthreads library -l$ax_pthread_try_flag])
|
|
||||||
PTHREAD_LIBS="-l$ax_pthread_try_flag"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
ax_pthread_save_CFLAGS="$CFLAGS"
|
|
||||||
ax_pthread_save_LIBS="$LIBS"
|
|
||||||
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
|
|
||||||
LIBS="$PTHREAD_LIBS $LIBS"
|
|
||||||
|
|
||||||
# Check for various functions. We must include pthread.h,
|
|
||||||
# since some functions may be macros. (On the Sequent, we
|
|
||||||
# need a special flag -Kthread to make this header compile.)
|
|
||||||
# We check for pthread_join because it is in -lpthread on IRIX
|
|
||||||
# while pthread_create is in libc. We check for pthread_attr_init
|
|
||||||
# due to DEC craziness with -lpthreads. We check for
|
|
||||||
# pthread_cleanup_push because it is one of the few pthread
|
|
||||||
# functions on Solaris that doesn't have a non-functional libc stub.
|
|
||||||
# We try pthread_create on general principles.
|
|
||||||
|
|
||||||
AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>
|
|
||||||
# if $ax_pthread_check_cond
|
|
||||||
# error "$ax_pthread_check_macro must be defined"
|
|
||||||
# endif
|
|
||||||
static void routine(void *a) { a = 0; }
|
|
||||||
static void *start_routine(void *a) { return a; }],
|
|
||||||
[pthread_t th; pthread_attr_t attr;
|
|
||||||
pthread_create(&th, 0, start_routine, 0);
|
|
||||||
pthread_join(th, 0);
|
|
||||||
pthread_attr_init(&attr);
|
|
||||||
pthread_cleanup_push(routine, 0);
|
|
||||||
pthread_cleanup_pop(0) /* ; */])],
|
|
||||||
[ax_pthread_ok=yes],
|
|
||||||
[])
|
|
||||||
|
|
||||||
CFLAGS="$ax_pthread_save_CFLAGS"
|
|
||||||
LIBS="$ax_pthread_save_LIBS"
|
|
||||||
|
|
||||||
AC_MSG_RESULT([$ax_pthread_ok])
|
|
||||||
AS_IF([test "x$ax_pthread_ok" = "xyes"], [break])
|
|
||||||
|
|
||||||
PTHREAD_LIBS=""
|
|
||||||
PTHREAD_CFLAGS=""
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Various other checks:
|
|
||||||
if test "x$ax_pthread_ok" = "xyes"; then
|
|
||||||
ax_pthread_save_CFLAGS="$CFLAGS"
|
|
||||||
ax_pthread_save_LIBS="$LIBS"
|
|
||||||
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
|
|
||||||
LIBS="$PTHREAD_LIBS $LIBS"
|
|
||||||
|
|
||||||
# Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
|
|
||||||
AC_CACHE_CHECK([for joinable pthread attribute],
|
|
||||||
[ax_cv_PTHREAD_JOINABLE_ATTR],
|
|
||||||
[ax_cv_PTHREAD_JOINABLE_ATTR=unknown
|
|
||||||
for ax_pthread_attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
|
|
||||||
AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>],
|
|
||||||
[int attr = $ax_pthread_attr; return attr /* ; */])],
|
|
||||||
[ax_cv_PTHREAD_JOINABLE_ATTR=$ax_pthread_attr; break],
|
|
||||||
[])
|
|
||||||
done
|
|
||||||
])
|
|
||||||
AS_IF([test "x$ax_cv_PTHREAD_JOINABLE_ATTR" != "xunknown" && \
|
|
||||||
test "x$ax_cv_PTHREAD_JOINABLE_ATTR" != "xPTHREAD_CREATE_JOINABLE" && \
|
|
||||||
test "x$ax_pthread_joinable_attr_defined" != "xyes"],
|
|
||||||
[AC_DEFINE_UNQUOTED([PTHREAD_CREATE_JOINABLE],
|
|
||||||
[$ax_cv_PTHREAD_JOINABLE_ATTR],
|
|
||||||
[Define to necessary symbol if this constant
|
|
||||||
uses a non-standard name on your system.])
|
|
||||||
ax_pthread_joinable_attr_defined=yes
|
|
||||||
])
|
|
||||||
|
|
||||||
AC_CACHE_CHECK([whether more special flags are required for pthreads],
|
|
||||||
[ax_cv_PTHREAD_SPECIAL_FLAGS],
|
|
||||||
[ax_cv_PTHREAD_SPECIAL_FLAGS=no
|
|
||||||
case $host_os in
|
|
||||||
solaris*)
|
|
||||||
ax_cv_PTHREAD_SPECIAL_FLAGS="-D_POSIX_PTHREAD_SEMANTICS"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
])
|
|
||||||
AS_IF([test "x$ax_cv_PTHREAD_SPECIAL_FLAGS" != "xno" && \
|
|
||||||
test "x$ax_pthread_special_flags_added" != "xyes"],
|
|
||||||
[PTHREAD_CFLAGS="$ax_cv_PTHREAD_SPECIAL_FLAGS $PTHREAD_CFLAGS"
|
|
||||||
ax_pthread_special_flags_added=yes])
|
|
||||||
|
|
||||||
AC_CACHE_CHECK([for PTHREAD_PRIO_INHERIT],
|
|
||||||
[ax_cv_PTHREAD_PRIO_INHERIT],
|
|
||||||
[AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>]],
|
|
||||||
[[int i = PTHREAD_PRIO_INHERIT;
|
|
||||||
return i;]])],
|
|
||||||
[ax_cv_PTHREAD_PRIO_INHERIT=yes],
|
|
||||||
[ax_cv_PTHREAD_PRIO_INHERIT=no])
|
|
||||||
])
|
|
||||||
AS_IF([test "x$ax_cv_PTHREAD_PRIO_INHERIT" = "xyes" && \
|
|
||||||
test "x$ax_pthread_prio_inherit_defined" != "xyes"],
|
|
||||||
[AC_DEFINE([HAVE_PTHREAD_PRIO_INHERIT], [1], [Have PTHREAD_PRIO_INHERIT.])
|
|
||||||
ax_pthread_prio_inherit_defined=yes
|
|
||||||
])
|
|
||||||
|
|
||||||
CFLAGS="$ax_pthread_save_CFLAGS"
|
|
||||||
LIBS="$ax_pthread_save_LIBS"
|
|
||||||
|
|
||||||
# More AIX lossage: compile with *_r variant
|
|
||||||
if test "x$GCC" != "xyes"; then
|
|
||||||
case $host_os in
|
|
||||||
aix*)
|
|
||||||
AS_CASE(["x/$CC"],
|
|
||||||
[x*/c89|x*/c89_128|x*/c99|x*/c99_128|x*/cc|x*/cc128|x*/xlc|x*/xlc_v6|x*/xlc128|x*/xlc128_v6],
|
|
||||||
[#handle absolute path differently from PATH based program lookup
|
|
||||||
AS_CASE(["x$CC"],
|
|
||||||
[x/*],
|
|
||||||
[AS_IF([AS_EXECUTABLE_P([${CC}_r])],[PTHREAD_CC="${CC}_r"])],
|
|
||||||
[AC_CHECK_PROGS([PTHREAD_CC],[${CC}_r],[$CC])])])
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
test -n "$PTHREAD_CC" || PTHREAD_CC="$CC"
|
|
||||||
|
|
||||||
AC_SUBST([PTHREAD_LIBS])
|
|
||||||
AC_SUBST([PTHREAD_CFLAGS])
|
|
||||||
AC_SUBST([PTHREAD_CC])
|
|
||||||
|
|
||||||
# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
|
|
||||||
if test "x$ax_pthread_ok" = "xyes"; then
|
|
||||||
ifelse([$1],,[AC_DEFINE([HAVE_PTHREAD],[1],[Define if you have POSIX threads libraries and header files.])],[$1])
|
|
||||||
:
|
|
||||||
else
|
|
||||||
ax_pthread_ok=no
|
|
||||||
$2
|
|
||||||
fi
|
|
||||||
AC_LANG_POP
|
|
||||||
])dnl AX_PTHREAD
|
|
||||||
|
|
@ -15,9 +15,7 @@ dnl
|
||||||
dnl Disable the build of the documentation
|
dnl Disable the build of the documentation
|
||||||
dnl
|
dnl
|
||||||
AC_ARG_ENABLE([doc],
|
AC_ARG_ENABLE([doc],
|
||||||
[AC_HELP_STRING(
|
[AS_HELP_STRING([--disable-doc],[Disable documentation build @<:@default=enabled@:>@])],
|
||||||
[--disable-doc],
|
|
||||||
[Disable documentation build @<:@default=enabled@:>@])],
|
|
||||||
[
|
[
|
||||||
if test "x${enableval}" = "xyes" ; then
|
if test "x${enableval}" = "xyes" ; then
|
||||||
efl_enable_doc="yes"
|
efl_enable_doc="yes"
|
||||||
|
|
@ -39,9 +37,7 @@ dnl
|
||||||
efl_doxygen="doxygen"
|
efl_doxygen="doxygen"
|
||||||
|
|
||||||
AC_ARG_WITH([doxygen],
|
AC_ARG_WITH([doxygen],
|
||||||
[AC_HELP_STRING(
|
[AS_HELP_STRING([--with-doxygen=FILE],[doxygen program to use @<:@default=doxygen@:>@])],
|
||||||
[--with-doxygen=FILE],
|
|
||||||
[doxygen program to use @<:@default=doxygen@:>@])],
|
|
||||||
dnl
|
dnl
|
||||||
dnl Check the given doxygen program.
|
dnl Check the given doxygen program.
|
||||||
dnl
|
dnl
|
||||||
|
|
|
||||||
5
main.c
5
main.c
|
|
@ -57,7 +57,6 @@
|
||||||
#include "lrzip_core.h"
|
#include "lrzip_core.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "stream.h"
|
#include "stream.h"
|
||||||
#include <locale.h>
|
|
||||||
|
|
||||||
/* needed for CRC routines */
|
/* needed for CRC routines */
|
||||||
#include "lzma/C/7zCrc.h"
|
#include "lzma/C/7zCrc.h"
|
||||||
|
|
@ -320,8 +319,6 @@ int main(int argc, char *argv[])
|
||||||
char *eptr, *av; /* for environment */
|
char *eptr, *av; /* for environment */
|
||||||
char *endptr = NULL;
|
char *endptr = NULL;
|
||||||
|
|
||||||
setlocale(LC_ALL, ""); /* for printf features */
|
|
||||||
|
|
||||||
control = &base_control;
|
control = &base_control;
|
||||||
|
|
||||||
initialise_control(control);
|
initialise_control(control);
|
||||||
|
|
@ -715,7 +712,7 @@ recursion:
|
||||||
|
|
||||||
gettimeofday(&start_time, NULL);
|
gettimeofday(&start_time, NULL);
|
||||||
|
|
||||||
if (unlikely((STDIN || STDOUT) && ENCRYPT))
|
if (!control->passphrase && (unlikely((STDIN || STDOUT) && ENCRYPT)))
|
||||||
failure("Unable to work from STDIO while reading password\n");
|
failure("Unable to work from STDIO while reading password\n");
|
||||||
|
|
||||||
memcpy(&local_control, &base_control, sizeof(rzip_control));
|
memcpy(&local_control, &base_control, sizeof(rzip_control));
|
||||||
|
|
|
||||||
15
stream.c
15
stream.c
|
|
@ -937,9 +937,10 @@ bool close_streamout_threads(rzip_control *control)
|
||||||
void *open_stream_out(rzip_control *control, int f, unsigned int n, i64 chunk_limit, char cbytes)
|
void *open_stream_out(rzip_control *control, int f, unsigned int n, i64 chunk_limit, char cbytes)
|
||||||
{
|
{
|
||||||
struct stream_info *sinfo;
|
struct stream_info *sinfo;
|
||||||
|
unsigned int i, testbufs;
|
||||||
|
bool threadlimit = false;
|
||||||
i64 testsize, limit;
|
i64 testsize, limit;
|
||||||
uchar *testmalloc;
|
uchar *testmalloc;
|
||||||
unsigned int i, testbufs;
|
|
||||||
|
|
||||||
sinfo = calloc(sizeof(struct stream_info), 1);
|
sinfo = calloc(sizeof(struct stream_info), 1);
|
||||||
if (unlikely(!sinfo))
|
if (unlikely(!sinfo))
|
||||||
|
|
@ -975,20 +976,28 @@ void *open_stream_out(rzip_control *control, int f, unsigned int n, i64 chunk_li
|
||||||
/* If we don't have enough ram for the number of threads, decrease the
|
/* If we don't have enough ram for the number of threads, decrease the
|
||||||
* number of threads till we do, or only have one thread. */
|
* number of threads till we do, or only have one thread. */
|
||||||
while (limit < STREAM_BUFSIZE && limit < chunk_limit) {
|
while (limit < STREAM_BUFSIZE && limit < chunk_limit) {
|
||||||
if (control->threads > 1)
|
if (control->threads > 1) {
|
||||||
--control->threads;
|
--control->threads;
|
||||||
else
|
threadlimit = true;
|
||||||
|
} else
|
||||||
break;
|
break;
|
||||||
limit = (control->usable_ram - (control->overhead * control->threads)) / testbufs;
|
limit = (control->usable_ram - (control->overhead * control->threads)) / testbufs;
|
||||||
limit = MIN(limit, chunk_limit);
|
limit = MIN(limit, chunk_limit);
|
||||||
}
|
}
|
||||||
|
if (threadlimit) {
|
||||||
|
print_output("Minimising number of threads to %d to limit memory usage\n",
|
||||||
|
control->threads);
|
||||||
|
}
|
||||||
if (BITS32) {
|
if (BITS32) {
|
||||||
limit = MIN(limit, one_g);
|
limit = MIN(limit, one_g);
|
||||||
if (limit + (control->overhead * control->threads) > one_g)
|
if (limit + (control->overhead * control->threads) > one_g)
|
||||||
limit = one_g - (control->overhead * control->threads);
|
limit = one_g - (control->overhead * control->threads);
|
||||||
}
|
}
|
||||||
/* Use a nominal minimum size should we fail all previous shrinking */
|
/* Use a nominal minimum size should we fail all previous shrinking */
|
||||||
|
if (limit < STREAM_BUFSIZE) {
|
||||||
limit = MAX(limit, STREAM_BUFSIZE);
|
limit = MAX(limit, STREAM_BUFSIZE);
|
||||||
|
print_output("Warning, low memory for chosen compression settings\n");
|
||||||
|
}
|
||||||
limit = MIN(limit, chunk_limit);
|
limit = MIN(limit, chunk_limit);
|
||||||
retest_malloc:
|
retest_malloc:
|
||||||
testsize = limit + (control->overhead * control->threads);
|
testsize = limit + (control->overhead * control->threads);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue