mirror of
https://git.tukaani.org/xz.git
synced 2024-04-04 12:36:23 +02:00
Sort of garbage collection commit. :-| Many things are still
broken. API has changed a lot and it will still change a little more here and there. The command line tool doesn't have all the required changes to reflect the API changes, so it's easy to get "internal error" or trigger assertions.
This commit is contained in:
parent
57b9a145a5
commit
3b34851de1
277 changed files with 9164 additions and 7591 deletions
358
configure.ac
358
configure.ac
|
@ -39,10 +39,15 @@ echo "System type:"
|
|||
# This is needed to know if assembler optimizations can be used.
|
||||
AC_CANONICAL_HOST
|
||||
|
||||
|
||||
echo
|
||||
echo "Configure options:"
|
||||
|
||||
# Enable/disable debugging code:
|
||||
|
||||
#############
|
||||
# Debugging #
|
||||
#############
|
||||
|
||||
AC_MSG_CHECKING([if debugging code should be compiled])
|
||||
AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [Enable debugging code.]),
|
||||
[], enable_debug=no)
|
||||
|
@ -53,7 +58,11 @@ else
|
|||
AC_MSG_RESULT([no])
|
||||
fi
|
||||
|
||||
# Enable/disable the encoder components:
|
||||
|
||||
###########
|
||||
# Encoder #
|
||||
###########
|
||||
|
||||
AC_MSG_CHECKING([if encoder components should be built])
|
||||
AC_ARG_ENABLE(encoder, AC_HELP_STRING([--disable-encoder],
|
||||
[Do not build the encoder components.]),
|
||||
|
@ -67,7 +76,11 @@ else
|
|||
fi
|
||||
AM_CONDITIONAL(COND_MAIN_ENCODER, test "x$enable_encoder" = xyes)
|
||||
|
||||
# Enable/disable the decoder components:
|
||||
|
||||
###########
|
||||
# Decoder #
|
||||
###########
|
||||
|
||||
AC_MSG_CHECKING([if decoder components should be built])
|
||||
AC_ARG_ENABLE(decoder, AC_HELP_STRING([--disable-decoder],
|
||||
[Do not build the decoder components.]),
|
||||
|
@ -84,146 +97,146 @@ else
|
|||
fi
|
||||
AM_CONDITIONAL(COND_MAIN_DECODER, test "x$enable_decoder" = xyes)
|
||||
|
||||
# Filters
|
||||
AC_MSG_CHECKING([which filters to build])
|
||||
AC_ARG_ENABLE(filters, AC_HELP_STRING([--enable-filters=LIST],
|
||||
[Comma-separated list of filters to build. Default=all.
|
||||
Filters used in encoding are needed also in decoding.
|
||||
Available filters: copy subblock x86 powerpc ia64
|
||||
arm armthumb sparc delta lzma]),
|
||||
[], [enable_filters=copy,subblock,x86,powerpc,ia64,arm,armthumb,sparc,delta,lzma])
|
||||
enable_filters=`echo "$enable_filters" | sed 's/,/ /g'`
|
||||
enable_filters_copy=no
|
||||
enable_filters_subblock=no
|
||||
enable_filters_x86=no
|
||||
enable_filters_powerpc=no
|
||||
enable_filters_ia64=no
|
||||
enable_filters_arm=no
|
||||
enable_filters_armthumb=no
|
||||
enable_filters_sparc=no
|
||||
enable_filters_delta=no
|
||||
enable_filters_lzma=no
|
||||
enable_simple_filters=no
|
||||
if test "x$enable_filters" = xno || test "x$enable_filters" = x; then
|
||||
AC_MSG_RESULT([])
|
||||
AC_MSG_ERROR([Please enable at least one filter.])
|
||||
|
||||
###########
|
||||
# Filters #
|
||||
###########
|
||||
|
||||
m4_define([SUPPORTED_FILTERS], [lzma,lzma2,subblock,delta,x86,powerpc,ia64,arm,armthumb,sparc])dnl
|
||||
m4_define([SIMPLE_FILTERS], [x86,powerpc,ia64,arm,armthumb,sparc])
|
||||
m4_define([LZ_FILTERS], [lzma,lzma2])
|
||||
|
||||
m4_foreach([NAME], [SUPPORTED_FILTERS],
|
||||
[enable_filter_[]NAME=no
|
||||
enable_encoder_[]NAME=no
|
||||
enable_decoder_[]NAME=no
|
||||
])dnl
|
||||
|
||||
AC_MSG_CHECKING([which encoders to build])
|
||||
AC_ARG_ENABLE([encoders], AC_HELP_STRING([--enable-encoders=LIST],
|
||||
[Comma-separated list of encoders to build. Default=all.
|
||||
Available encoders:]
|
||||
m4_translit(m4_defn([SUPPORTED_FILTERS]), [,], [ ])),
|
||||
[], [enable_encoders=SUPPORTED_FILTERS])
|
||||
enable_encoders=`echo "$enable_encoders" | sed 's/,/ /g'`
|
||||
if test "x$enable_encoders" = xno || test "x$enable_encoders" = x; then
|
||||
AC_MSG_RESULT([(none)])
|
||||
else
|
||||
for arg in $enable_filters
|
||||
for arg in $enable_encoders
|
||||
do
|
||||
case $arg in
|
||||
copy)
|
||||
enable_filters_copy=yes
|
||||
AC_DEFINE([HAVE_FILTER_COPY], 1,
|
||||
[Define to 1 if support for the
|
||||
Copy filter is enabled.])
|
||||
;;
|
||||
subblock)
|
||||
enable_filters_subblock=yes
|
||||
AC_DEFINE([HAVE_FILTER_SUBBLOCK], 1,
|
||||
[Define to 1 if support for the
|
||||
Subblock filter is enabled.])
|
||||
;;
|
||||
x86)
|
||||
enable_filters_x86=yes
|
||||
enable_simple_filters=yes
|
||||
AC_DEFINE([HAVE_FILTER_X86], 1,
|
||||
[Define to 1 if support for the
|
||||
x86 (BCJ) filter is enabled.])
|
||||
;;
|
||||
powerpc)
|
||||
enable_filters_powerpc=yes
|
||||
enable_simple_filters=yes
|
||||
AC_DEFINE([HAVE_FILTER_POWERPC], 1,
|
||||
[Define to 1 if support for the
|
||||
PowerPC filter is enabled.])
|
||||
;;
|
||||
ia64)
|
||||
enable_filters_ia64=yes
|
||||
enable_simple_filters=yes
|
||||
AC_DEFINE([HAVE_FILTER_IA64], 1,
|
||||
[Define to 1 if support for the
|
||||
IA64 filter is enabled.])
|
||||
;;
|
||||
arm)
|
||||
enable_filters_arm=yes
|
||||
enable_simple_filters=yes
|
||||
AC_DEFINE([HAVE_FILTER_ARM], 1,
|
||||
[Define to 1 if support for the
|
||||
ARM filter is enabled.])
|
||||
;;
|
||||
armthumb)
|
||||
enable_filters_armthumb=yes
|
||||
enable_simple_filters=yes
|
||||
AC_DEFINE([HAVE_FILTER_ARMTHUMB], 1,
|
||||
[Define to 1 if support for the
|
||||
ARMThumb filter is enabled.])
|
||||
;;
|
||||
sparc)
|
||||
enable_filters_sparc=yes
|
||||
enable_simple_filters=yes
|
||||
AC_DEFINE([HAVE_FILTER_SPARC], 1,
|
||||
[Define to 1 if support for the
|
||||
SPARC filter is enabled.])
|
||||
;;
|
||||
delta)
|
||||
enable_filters_delta=yes
|
||||
AC_DEFINE([HAVE_FILTER_DELTA], 1,
|
||||
[Define to 1 if support for the
|
||||
Delta filter is enabled.])
|
||||
;;
|
||||
lzma)
|
||||
enable_filters_lzma=yes
|
||||
AC_DEFINE([HAVE_FILTER_LZMA], 1,
|
||||
[Define to 1 if support for the
|
||||
LZMA filter is enabled.])
|
||||
;;
|
||||
case $arg in m4_foreach([NAME], [SUPPORTED_FILTERS], [
|
||||
NAME)
|
||||
enable_filter_[]NAME=yes
|
||||
enable_encoder_[]NAME=yes
|
||||
AC_DEFINE(HAVE_ENCODER_[]m4_toupper(NAME), [1],
|
||||
[Define to 1 if] NAME [encoder is enabled.])
|
||||
;;])
|
||||
*)
|
||||
AC_MSG_RESULT([])
|
||||
AC_MSG_ERROR([unknown filter: $arg])
|
||||
;;
|
||||
esac
|
||||
done
|
||||
AC_MSG_RESULT([$enable_filters])
|
||||
AC_MSG_RESULT([$enable_encoders])
|
||||
fi
|
||||
if test "x$enable_simple_filters" = xyes ; then
|
||||
AC_DEFINE([HAVE_FILTER_SIMPLE], 1, [Define to 1 if support for any
|
||||
of the so called simple filters is enabled.])
|
||||
fi
|
||||
AM_CONDITIONAL(COND_FILTER_COPY, test "x$enable_filters_copy" = xyes)
|
||||
AM_CONDITIONAL(COND_FILTER_SUBBLOCK, test "x$enable_filters_subblock" = xyes)
|
||||
AM_CONDITIONAL(COND_FILTER_X86, test "x$enable_filters_x86" = xyes)
|
||||
AM_CONDITIONAL(COND_FILTER_POWERPC, test "x$enable_filters_powerpc" = xyes)
|
||||
AM_CONDITIONAL(COND_FILTER_IA64, test "x$enable_filters_ia64" = xyes)
|
||||
AM_CONDITIONAL(COND_FILTER_ARM, test "x$enable_filters_arm" = xyes)
|
||||
AM_CONDITIONAL(COND_FILTER_ARMTHUMB, test "x$enable_filters_armthumb" = xyes)
|
||||
AM_CONDITIONAL(COND_FILTER_SPARC, test "x$enable_filters_sparc" = xyes)
|
||||
AM_CONDITIONAL(COND_FILTER_DELTA, test "x$enable_filters_delta" = xyes)
|
||||
AM_CONDITIONAL(COND_FILTER_LZMA, test "x$enable_filters_lzma" = xyes)
|
||||
AM_CONDITIONAL(COND_MAIN_SIMPLE, test "x$enable_simple_filters" = xyes)
|
||||
|
||||
# Which match finders should be enabled:
|
||||
AC_MSG_CHECKING([which decoders to build])
|
||||
AC_ARG_ENABLE([decoders], AC_HELP_STRING([--enable-decoders=LIST],
|
||||
[Comma-separated list of decoders to build. Default=all.
|
||||
Available decoders are the same as available encoders.]),
|
||||
[], [enable_decoders=SUPPORTED_FILTERS])
|
||||
enable_decoders=`echo "$enable_decoders" | sed 's/,/ /g'`
|
||||
if test "x$enable_decoders" = xno || test "x$enable_decoders" = x; then
|
||||
AC_MSG_RESULT([(none)])
|
||||
else
|
||||
for arg in $enable_decoders
|
||||
do
|
||||
case $arg in m4_foreach([NAME], [SUPPORTED_FILTERS], [
|
||||
NAME)
|
||||
enable_filter_[]NAME=yes
|
||||
enable_decoder_[]NAME=yes
|
||||
AC_DEFINE(HAVE_DECODER_[]m4_toupper(NAME), [1],
|
||||
[Define to 1 if] NAME [decoder is enabled.])
|
||||
;;])
|
||||
*)
|
||||
AC_MSG_RESULT([])
|
||||
AC_MSG_ERROR([unknown filter: $arg])
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# LZMA2 requires that LZMA is enabled.
|
||||
test "x$enable_encoder_lzma2" = xyes && enable_encoder_lzma=yes
|
||||
test "x$enable_decoder_lzma2" = xyes && enable_decoder_lzma=yes
|
||||
|
||||
AC_MSG_RESULT([$enable_decoders])
|
||||
fi
|
||||
|
||||
if test "x$enable_encoder_lzma2$enable_encoder_lzma" = xyesno \
|
||||
|| test "x$enable_decoder_lzma2$enable_decoder_lzma" = xyesno; then
|
||||
AC_MSG_ERROR([LZMA2 requires that LZMA is also enabled.])
|
||||
fi
|
||||
|
||||
m4_foreach([NAME], [SUPPORTED_FILTERS],
|
||||
[AM_CONDITIONAL(COND_FILTER_[]m4_toupper(NAME), test "x$enable_filter_[]NAME" = xyes)
|
||||
AM_CONDITIONAL(COND_ENCODER_[]m4_toupper(NAME), test "x$enable_encoder_[]NAME" = xyes)
|
||||
AM_CONDITIONAL(COND_DECODER_[]m4_toupper(NAME), test "x$enable_decoder_[]NAME" = xyes)
|
||||
])dnl
|
||||
|
||||
# The so called "simple filters" share common code.
|
||||
enable_filter_simple=no
|
||||
enable_encoder_simple=no
|
||||
enable_decoder_simple=no
|
||||
m4_foreach([NAME], [SIMPLE_FILTERS],
|
||||
[test "x$enable_filter_[]NAME" = xyes && enable_filter_simple=yes
|
||||
test "x$enable_encoder_[]NAME" = xyes && enable_encoder_simple=yes
|
||||
test "x$enable_decoder_[]NAME" = xyes && enable_decoder_simple=yes
|
||||
])dnl
|
||||
AM_CONDITIONAL(COND_FILTER_SIMPLE, test "x$enable_filter_simple" = xyes)
|
||||
AM_CONDITIONAL(COND_ENCODER_SIMPLE, test "x$enable_encoder_simple" = xyes)
|
||||
AM_CONDITIONAL(COND_DECODER_SIMPLE, test "x$enable_decoder_simple" = xyes)
|
||||
|
||||
# LZ-based filters share common code.
|
||||
enable_filter_lz=no
|
||||
enable_encoder_lz=no
|
||||
enable_decoder_lz=no
|
||||
m4_foreach([NAME], [LZ_FILTERS],
|
||||
[test "x$enable_filter_[]NAME" = xyes && enable_filter_lz=yes
|
||||
test "x$enable_encoder_[]NAME" = xyes && enable_encoder_lz=yes
|
||||
test "x$enable_decoder_[]NAME" = xyes && enable_decoder_lz=yes
|
||||
])dnl
|
||||
AM_CONDITIONAL(COND_FILTER_LZ, test "x$enable_filter_lz" = xyes)
|
||||
AM_CONDITIONAL(COND_ENCODER_LZ, test "x$enable_encoder_lz" = xyes)
|
||||
AM_CONDITIONAL(COND_DECODER_LZ, test "x$enable_decoder_lz" = xyes)
|
||||
|
||||
|
||||
#################
|
||||
# Match finders #
|
||||
#################
|
||||
|
||||
m4_define([SUPPORTED_MATCH_FINDERS], [hc3,hc4,bt2,bt3,bt4])
|
||||
|
||||
m4_foreach([NAME], [SUPPORTED_MATCH_FINDERS],
|
||||
[enable_match_finder_[]NAME=no
|
||||
])
|
||||
|
||||
AC_MSG_CHECKING([which match finders to build])
|
||||
AC_ARG_ENABLE(match-finders, AC_HELP_STRING([--enable-match-finders=LIST],
|
||||
[Comma-separated list of match finders to build. Default=all.
|
||||
At least one match finder is required for encoding with
|
||||
the LZMA filter.
|
||||
Available match finders: hc3 hc4 bt2 bt3 bt4]), [],
|
||||
[enable_match_finders=hc3,hc4,bt2,bt3,bt4])
|
||||
the LZMA filter. Available match finders:]
|
||||
m4_translit(m4_defn([SUPPORTED_MATCH_FINDERS]), [,], [ ])), [],
|
||||
[enable_match_finders=SUPPORTED_MATCH_FINDERS])
|
||||
enable_match_finders=`echo "$enable_match_finders" | sed 's/,/ /g'`
|
||||
enable_match_finders_hc3=no
|
||||
enable_match_finders_hc4=no
|
||||
enable_match_finders_bt2=no
|
||||
enable_match_finders_bt3=no
|
||||
enable_match_finders_bt4=no
|
||||
if test "x$enable_encoder" = xyes && test "x$enable_filters_lzma" = xyes ; then
|
||||
if test "x$enable_encoder" = xyes && test "x$enable_encoder_lz" = xyes ; then
|
||||
for arg in $enable_match_finders
|
||||
do
|
||||
case $arg in
|
||||
hc3) enable_match_finders_hc3=yes ;;
|
||||
hc4) enable_match_finders_hc4=yes ;;
|
||||
bt2) enable_match_finders_bt2=yes ;;
|
||||
bt3) enable_match_finders_bt3=yes ;;
|
||||
bt4) enable_match_finders_bt4=yes ;;
|
||||
case $arg in m4_foreach([NAME], [SUPPORTED_MATCH_FINDERS], [
|
||||
NAME)
|
||||
enable_match_finder_[]NAME=yes
|
||||
AC_DEFINE(HAVE_MF_[]m4_toupper(NAME), [1],
|
||||
[Define to 1 to enable] NAME [match finder.])
|
||||
;;])
|
||||
*)
|
||||
AC_MSG_RESULT([])
|
||||
AC_MSG_ERROR([unknown match finder: $arg])
|
||||
|
@ -232,48 +245,39 @@ if test "x$enable_encoder" = xyes && test "x$enable_filters_lzma" = xyes ; then
|
|||
done
|
||||
AC_MSG_RESULT([$enable_match_finders])
|
||||
else
|
||||
AC_MSG_RESULT([(none because not building the LZMA encoder)])
|
||||
AC_MSG_RESULT([(none because not building any LZ-based encoder)])
|
||||
fi
|
||||
AM_CONDITIONAL(COND_MF_HC3, test "x$enable_match_finders_hc3" = xyes)
|
||||
AM_CONDITIONAL(COND_MF_HC4, test "x$enable_match_finders_hc4" = xyes)
|
||||
AM_CONDITIONAL(COND_MF_BT2, test "x$enable_match_finders_bt2" = xyes)
|
||||
AM_CONDITIONAL(COND_MF_BT3, test "x$enable_match_finders_bt3" = xyes)
|
||||
AM_CONDITIONAL(COND_MF_BT4, test "x$enable_match_finders_bt4" = xyes)
|
||||
|
||||
# Which integrity checks to build
|
||||
|
||||
####################
|
||||
# Integrity checks #
|
||||
####################
|
||||
|
||||
m4_define([SUPPORTED_CHECKS], [crc32,crc64,sha256])
|
||||
|
||||
m4_foreach([NAME], [SUPPORTED_FILTERS],
|
||||
[enable_check_[]NAME=no
|
||||
])dnl
|
||||
|
||||
AC_MSG_CHECKING([which integrity checks to build])
|
||||
AC_ARG_ENABLE(checks, AC_HELP_STRING([--enable-checks=LIST],
|
||||
[Comma-separated list of integrity checks to build.
|
||||
Default=all. Available integrity checks: crc32 crc64 sha256]),
|
||||
[], [enable_checks=crc32,crc64,sha256])
|
||||
Default=all. Available integrity checks:]
|
||||
m4_translit(m4_defn([SUPPORTED_CHECKS]), [,], [ ])),
|
||||
[], [enable_checks=SUPPORTED_CHECKS])
|
||||
enable_checks=`echo "$enable_checks" | sed 's/,/ /g'`
|
||||
enable_checks_crc32=no
|
||||
enable_checks_crc64=no
|
||||
enable_checks_sha256=no
|
||||
if test "x$enable_checks" = xno || test "x$enable_checks" = x; then
|
||||
AC_MSG_RESULT([(none)])
|
||||
else
|
||||
for arg in $enable_checks
|
||||
do
|
||||
case $arg in
|
||||
crc32)
|
||||
enable_checks_crc32=yes
|
||||
AC_DEFINE([HAVE_CHECK_CRC32], 1,
|
||||
[Define to 1 if CRC32 support
|
||||
is enabled.])
|
||||
;;
|
||||
crc64)
|
||||
enable_checks_crc64=yes
|
||||
AC_DEFINE([HAVE_CHECK_CRC64], 1,
|
||||
[Define to 1 if CRC64 support
|
||||
is enabled.])
|
||||
;;
|
||||
sha256)
|
||||
enable_checks_sha256=yes
|
||||
AC_DEFINE([HAVE_CHECK_SHA256], 1,
|
||||
[Define to 1 if SHA256 support
|
||||
is enabled.])
|
||||
;;
|
||||
case $arg in m4_foreach([NAME], [SUPPORTED_CHECKS], [
|
||||
NAME)
|
||||
enable_check_[]NAME=yes
|
||||
AC_DEFINE(HAVE_CHECK_[]m4_toupper(NAME), [1],
|
||||
[Define to 1 if] NAME
|
||||
[integrity check is enabled.])
|
||||
;;])
|
||||
*)
|
||||
AC_MSG_RESULT([])
|
||||
AC_MSG_ERROR([unknown integrity check: $arg])
|
||||
|
@ -285,11 +289,16 @@ fi
|
|||
if test "x$enable_checks_crc32" = xno ; then
|
||||
AC_MSG_ERROR([For now, the CRC32 check must always be enabled.])
|
||||
fi
|
||||
AM_CONDITIONAL(COND_CHECK_CRC32, test "x$enable_checks_crc32" = xyes)
|
||||
AM_CONDITIONAL(COND_CHECK_CRC64, test "x$enable_checks_crc64" = xyes)
|
||||
AM_CONDITIONAL(COND_CHECK_SHA256, test "x$enable_checks_sha256" = xyes)
|
||||
|
||||
# Assembler optimizations
|
||||
m4_foreach([NAME], [SUPPORTED_CHECKS],
|
||||
[AM_CONDITIONAL(COND_CHECK_[]m4_toupper(NAME), test "x$enable_check_[]NAME" = xyes)
|
||||
])dnl
|
||||
|
||||
|
||||
###########################
|
||||
# Assembler optimizations #
|
||||
###########################
|
||||
|
||||
AC_MSG_CHECKING([if assembler optimizations should be used])
|
||||
AC_ARG_ENABLE(assembler, AC_HELP_STRING([--disable-assembler],
|
||||
[Do not use assembler optimizations even if such exist
|
||||
|
@ -321,13 +330,18 @@ case $enable_assembler in
|
|||
;;
|
||||
*)
|
||||
AC_MSG_RESULT([])
|
||||
AC_MSG_ERROR([--enable-assembler accepts only \`yes', \`no', or \`x86'.])
|
||||
AC_MSG_ERROR([--enable-assembler accepts only \`yes', \`no', \`x86', or \`x86_64'.])
|
||||
;;
|
||||
esac
|
||||
AC_MSG_RESULT([$enable_assembler])
|
||||
AM_CONDITIONAL(COND_ASM_X86, test "x$enable_assembler" = xx86)
|
||||
AM_CONDITIONAL(COND_ASM_X86_64, test "x$enable_assembler" = xx86_64)
|
||||
|
||||
|
||||
################################
|
||||
# Fast unaligned memory access #
|
||||
################################
|
||||
|
||||
# Fast unaligned memory access
|
||||
AC_MSG_CHECKING([if unaligned memory access should be used])
|
||||
AC_ARG_ENABLE(unaligned-access, AC_HELP_STRING([--enable-unaligned-access],
|
||||
[Enable if the system supports *fast* unaligned memory access
|
||||
|
@ -352,12 +366,15 @@ else
|
|||
AC_MSG_RESULT([no])
|
||||
fi
|
||||
|
||||
# Size optimization
|
||||
|
||||
#####################
|
||||
# Size optimization #
|
||||
#####################
|
||||
|
||||
AC_MSG_CHECKING([if small size is preferred over speed])
|
||||
AC_ARG_ENABLE(small, AC_HELP_STRING([--enable-small],
|
||||
[Omit precomputed tables to make liblzma a few kilobytes
|
||||
smaller. This will increase startup time of applications
|
||||
slightly, because the tables need to be computed first.]),
|
||||
[Make liblzma smaller and a little slower.
|
||||
This is disabled by default to optimize for speed.]),
|
||||
[], [enable_small=no])
|
||||
if test "x$enable_small" = xyes; then
|
||||
AC_DEFINE([HAVE_SMALL], 1, [Define to 1 if optimizing for size.])
|
||||
|
@ -368,6 +385,7 @@ fi
|
|||
AC_MSG_RESULT([$enable_small])
|
||||
AM_CONDITIONAL(COND_SMALL, test "x$enable_small" = xyes)
|
||||
|
||||
|
||||
###############################################################################
|
||||
# Checks for programs.
|
||||
###############################################################################
|
||||
|
@ -447,7 +465,6 @@ AC_TYPE_INT64_T
|
|||
AC_TYPE_UINT64_T
|
||||
AC_TYPE_UINTPTR_T
|
||||
|
||||
AC_CHECK_SIZEOF([unsigned long])
|
||||
AC_CHECK_SIZEOF([size_t])
|
||||
|
||||
# The command line tool can copy high resolution timestamps if such
|
||||
|
@ -662,11 +679,12 @@ AC_CONFIG_FILES([
|
|||
src/liblzma/api/Makefile
|
||||
src/liblzma/common/Makefile
|
||||
src/liblzma/check/Makefile
|
||||
src/liblzma/rangecoder/Makefile
|
||||
src/liblzma/lz/Makefile
|
||||
src/liblzma/lzma/Makefile
|
||||
src/liblzma/simple/Makefile
|
||||
src/liblzma/subblock/Makefile
|
||||
src/liblzma/rangecoder/Makefile
|
||||
src/liblzma/delta/Makefile
|
||||
src/liblzma/simple/Makefile
|
||||
src/lzma/Makefile
|
||||
src/lzmadec/Makefile
|
||||
src/scripts/Makefile
|
||||
|
|
|
@ -16,7 +16,10 @@ noinst_PROGRAMS = \
|
|||
repeat \
|
||||
sync_flush \
|
||||
full_flush \
|
||||
memusage
|
||||
memusage \
|
||||
crc32 \
|
||||
known_sizes \
|
||||
hex2bin
|
||||
|
||||
AM_CPPFLAGS = \
|
||||
-I@top_srcdir@/src/common \
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
/// \file lz_encoder_private.h
|
||||
/// \brief Private definitions for LZ encoder
|
||||
/// \file crc32.c
|
||||
/// \brief Primitive CRC32 calculation tool
|
||||
//
|
||||
// Copyright (C) 1999-2006 Igor Pavlov
|
||||
// Copyright (C) 2007 Lasse Collin
|
||||
// Copyright (C) 2008 Lasse Collin
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
|
@ -18,23 +17,29 @@
|
|||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef LZMA_LZ_ENCODER_PRIVATE_H
|
||||
#define LZMA_LZ_ENCODER_PRIVATE_H
|
||||
|
||||
#include "lz_encoder.h"
|
||||
|
||||
/// Value used to indicate unused slot
|
||||
#define EMPTY_HASH_VALUE 0
|
||||
|
||||
/// When the dictionary and hash variables need to be adjusted to prevent
|
||||
/// integer overflows. Since we use uint32_t to store the offsets, half
|
||||
/// of it is the biggest safe limit.
|
||||
#define MAX_VAL_FOR_NORMALIZE (UINT32_MAX / 2)
|
||||
#include "sysdefs.h"
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
struct lzma_coder_s {
|
||||
lzma_next_coder next;
|
||||
lzma_lz_encoder lz;
|
||||
};
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
uint32_t crc = 0;
|
||||
|
||||
#endif
|
||||
do {
|
||||
uint8_t buf[BUFSIZ];
|
||||
const size_t size = fread(buf, 1, sizeof(buf), stdin);
|
||||
crc = lzma_crc32(buf, size, crc);
|
||||
} while (!ferror(stdin) && !feof(stdin));
|
||||
|
||||
//printf("%08" PRIX32 "\n", crc);
|
||||
|
||||
// I want it little endian so it's easy to work with hex editor.
|
||||
printf("%02" PRIX32 " ", crc & 0xFF);
|
||||
printf("%02" PRIX32 " ", (crc >> 8) & 0xFF);
|
||||
printf("%02" PRIX32 " ", (crc >> 16) & 0xFF);
|
||||
printf("%02" PRIX32 " ", crc >> 24);
|
||||
printf("\n");
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -72,18 +72,24 @@ main(int argc, char **argv)
|
|||
|
||||
file_in = argc > 1 ? fopen(argv[1], "rb") : stdin;
|
||||
|
||||
|
||||
// Config
|
||||
lzma_options_filter filters[LZMA_BLOCK_FILTERS_MAX + 1];
|
||||
filters[0].id = LZMA_FILTER_SUBBLOCK;
|
||||
filters[0].options = NULL;
|
||||
lzma_filter filters[LZMA_BLOCK_FILTERS_MAX + 1];
|
||||
filters[0].id = LZMA_FILTER_LZMA2;
|
||||
filters[0].options = (void *)&lzma_preset_lzma[0];
|
||||
filters[1].id = LZMA_VLI_VALUE_UNKNOWN;
|
||||
|
||||
// Init
|
||||
if (lzma_stream_encoder(&strm, filters, LZMA_CHECK_CRC32) != LZMA_OK) {
|
||||
if (lzma_stream_encoder(&strm, filters, LZMA_CHECK_SHA256) != LZMA_OK) {
|
||||
fprintf(stderr, "init failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// if (lzma_easy_encoder(&strm, 1)) {
|
||||
// fprintf(stderr, "init failed\n");
|
||||
// exit(1);
|
||||
// }
|
||||
|
||||
// Encoding
|
||||
encode(0, LZMA_FULL_FLUSH);
|
||||
encode(6, LZMA_FULL_FLUSH);
|
||||
|
|
54
debug/hex2bin.c
Normal file
54
debug/hex2bin.c
Normal file
|
@ -0,0 +1,54 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
/// \file hex2bin.c
|
||||
/// \brief Converts hexadecimal input strings to binary
|
||||
//
|
||||
// This code has been put into the public domain.
|
||||
//
|
||||
// This library 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.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "sysdefs.h"
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
|
||||
|
||||
static int
|
||||
getbin(int x)
|
||||
{
|
||||
if (x >= '0' && x <= '9')
|
||||
return x - '0';
|
||||
|
||||
if (x >= 'A' && x <= 'F')
|
||||
return x - 'A' + 10;
|
||||
|
||||
return x - 'a' + 10;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
while (true) {
|
||||
int byte = getchar();
|
||||
if (byte == EOF)
|
||||
return 0;
|
||||
if (!isxdigit(byte))
|
||||
continue;
|
||||
|
||||
const int digit = getchar();
|
||||
if (digit == EOF || !isxdigit(digit)) {
|
||||
fprintf(stderr, "Invalid input\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
byte = (getbin(byte) << 4) | getbin(digit);
|
||||
if (putchar(byte) == EOF) {
|
||||
perror(NULL);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
135
debug/known_sizes.c
Normal file
135
debug/known_sizes.c
Normal file
|
@ -0,0 +1,135 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
/// \file known_sizes.c
|
||||
/// \brief Encodes .lzma Stream with sizes known in Block Header
|
||||
///
|
||||
/// The input file is encoded in RAM, and the known Compressed Size
|
||||
/// and/or Uncompressed Size values are stored in the Block Header.
|
||||
/// As of writing there's no such Stream encoder in liblzma.
|
||||
//
|
||||
// Copyright (C) 2008 Lasse Collin
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library 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
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "sysdefs.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/unistd.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
// Support file sizes up to 1 MiB. We use this for output space too, so files
|
||||
// close to 1 MiB had better compress at least a little or we have a buffer
|
||||
// overflow.
|
||||
#define BUFFER_SIZE (1U << 20)
|
||||
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
// Allocate the buffers.
|
||||
uint8_t *in = malloc(BUFFER_SIZE);
|
||||
uint8_t *out = malloc(BUFFER_SIZE);
|
||||
if (in == NULL || out == NULL)
|
||||
return 1;
|
||||
|
||||
// Fill the input buffer.
|
||||
const size_t in_size = fread(in, 1, BUFFER_SIZE, stdin);
|
||||
|
||||
// Filter setup
|
||||
lzma_filter filters[] = {
|
||||
{
|
||||
.id = LZMA_FILTER_LZMA2,
|
||||
.options = (void *)(&lzma_preset_lzma[0])
|
||||
},
|
||||
{
|
||||
.id = LZMA_VLI_VALUE_UNKNOWN
|
||||
}
|
||||
};
|
||||
|
||||
lzma_block block = {
|
||||
.check = LZMA_CHECK_CRC32,
|
||||
.compressed_size = BUFFER_SIZE, // Worst case reserve
|
||||
.uncompressed_size = in_size,
|
||||
.filters = filters,
|
||||
};
|
||||
|
||||
// FIXME Insane paranoia in liblzma.
|
||||
if (lzma_block_header_size(&block) != LZMA_OK)
|
||||
return 1;
|
||||
|
||||
// We don't actually know the compressed size, so don't tell it to
|
||||
// Block encoder.
|
||||
block.compressed_size = LZMA_VLI_VALUE_UNKNOWN;
|
||||
|
||||
lzma_stream strm = LZMA_STREAM_INIT;
|
||||
if (lzma_block_encoder(&strm, &block) != LZMA_OK)
|
||||
return 1;
|
||||
|
||||
// Reserve space for Stream Header and Block Header.
|
||||
size_t out_size = LZMA_STREAM_HEADER_SIZE + block.header_size;
|
||||
|
||||
strm.next_in = in;
|
||||
strm.avail_in = in_size;
|
||||
strm.next_out = out + out_size;
|
||||
strm.avail_out = BUFFER_SIZE - out_size;
|
||||
|
||||
if (lzma_code(&strm, LZMA_FINISH) != LZMA_STREAM_END)
|
||||
return 1;
|
||||
|
||||
out_size += strm.total_out;
|
||||
|
||||
if (lzma_block_header_encode(&block, out + LZMA_STREAM_HEADER_SIZE)
|
||||
!= LZMA_OK)
|
||||
return 1;
|
||||
|
||||
lzma_index *idx = lzma_index_init(NULL, NULL);
|
||||
if (idx == NULL)
|
||||
return 1;
|
||||
|
||||
if (lzma_index_append(idx, NULL, block.header_size + strm.total_out,
|
||||
strm.total_in) != LZMA_OK)
|
||||
return 1;
|
||||
|
||||
if (lzma_index_encoder(&strm, idx) != LZMA_OK)
|
||||
return 1;
|
||||
|
||||
if (lzma_code(&strm, LZMA_RUN) != LZMA_STREAM_END)
|
||||
return 1;
|
||||
|
||||
out_size += strm.total_out;
|
||||
|
||||
lzma_end(&strm);
|
||||
|
||||
lzma_index_end(idx, NULL);
|
||||
|
||||
// Encode the Stream Header and Stream Footer. backwards_size is
|
||||
// needed only for the Stream Footer.
|
||||
lzma_stream_flags sf = {
|
||||
.backward_size = strm.total_out,
|
||||
.check = block.check,
|
||||
};
|
||||
|
||||
if (lzma_stream_header_encode(&sf, out) != LZMA_OK)
|
||||
return 1;
|
||||
|
||||
if (lzma_stream_footer_encode(&sf, out + out_size) != LZMA_OK)
|
||||
return 1;
|
||||
|
||||
out_size += LZMA_STREAM_HEADER_SIZE;
|
||||
|
||||
// Write out the file.
|
||||
fwrite(out, 1, out_size, stdout);
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -23,6 +23,7 @@
|
|||
int
|
||||
main(void)
|
||||
{
|
||||
lzma_init();
|
||||
|
||||
lzma_options_lzma lzma = {
|
||||
.dictionary_size = (1 << 27) + (1 << 26),
|
||||
|
@ -31,7 +32,7 @@ main(void)
|
|||
.pos_bits = 2,
|
||||
.preset_dictionary = NULL,
|
||||
.preset_dictionary_size = 0,
|
||||
.mode = LZMA_MODE_BEST,
|
||||
.mode = LZMA_MODE_NORMAL,
|
||||
.fast_bytes = 48,
|
||||
.match_finder = LZMA_MF_BT4,
|
||||
.match_finder_cycles = 0,
|
||||
|
@ -44,12 +45,13 @@ main(void)
|
|||
{ UINT64_MAX, NULL }
|
||||
};
|
||||
*/
|
||||
lzma_options_filter filters[] = {
|
||||
lzma_filter filters[] = {
|
||||
{ LZMA_FILTER_LZMA, &lzma },
|
||||
{ UINT64_MAX, NULL }
|
||||
};
|
||||
|
||||
printf("%u MiB\n", lzma_memory_usage(filters, true));
|
||||
printf("Encoder: %10" PRIu64 " B\n", lzma_memusage_encoder(filters));
|
||||
printf("Decoder: %10" PRIu64 " B\n", lzma_memusage_decoder(filters));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -79,9 +79,10 @@ main(int argc, char **argv)
|
|||
.literal_pos_bits = LZMA_LITERAL_POS_BITS_DEFAULT,
|
||||
.pos_bits = LZMA_POS_BITS_DEFAULT,
|
||||
.preset_dictionary = NULL,
|
||||
.mode = LZMA_MODE_BEST,
|
||||
.persistent = true,
|
||||
.mode = LZMA_MODE_NORMAL,
|
||||
.fast_bytes = 32,
|
||||
.match_finder = LZMA_MF_BT3,
|
||||
.match_finder = LZMA_MF_HC3,
|
||||
.match_finder_cycles = 0,
|
||||
};
|
||||
|
||||
|
@ -101,24 +102,31 @@ main(int argc, char **argv)
|
|||
opt_subblock.subfilter_options.id = LZMA_FILTER_DELTA;
|
||||
opt_subblock.subfilter_options.options = &opt_delta;
|
||||
|
||||
lzma_options_filter filters[LZMA_BLOCK_FILTERS_MAX + 1];
|
||||
filters[0].id = LZMA_FILTER_LZMA;
|
||||
lzma_filter filters[LZMA_BLOCK_FILTERS_MAX + 1];
|
||||
filters[0].id = LZMA_FILTER_LZMA2;
|
||||
filters[0].options = &opt_lzma;
|
||||
filters[1].id = LZMA_VLI_VALUE_UNKNOWN;
|
||||
|
||||
// Init
|
||||
if (lzma_stream_encoder(&strm, filters, LZMA_CHECK_NONE) != LZMA_OK) {
|
||||
if (lzma_stream_encoder(&strm, filters, LZMA_CHECK_CRC32) != LZMA_OK) {
|
||||
fprintf(stderr, "init failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Encoding
|
||||
/*
|
||||
encode(0, LZMA_SYNC_FLUSH);
|
||||
encode(6, LZMA_SYNC_FLUSH);
|
||||
encode(0, LZMA_SYNC_FLUSH);
|
||||
encode(6, LZMA_SYNC_FLUSH);
|
||||
encode(7, LZMA_SYNC_FLUSH);
|
||||
encode(0, LZMA_SYNC_FLUSH);
|
||||
encode(0, LZMA_FINISH);
|
||||
*/
|
||||
encode(53, LZMA_SYNC_FLUSH);
|
||||
// opt_lzma.literal_context_bits = 2;
|
||||
// opt_lzma.literal_pos_bits = 1;
|
||||
// opt_lzma.pos_bits = 0;
|
||||
encode(404, LZMA_FINISH);
|
||||
|
||||
// Clean up
|
||||
lzma_end(&strm);
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#define LZMA_INTEGER_H
|
||||
|
||||
// I'm aware of AC_CHECK_ALIGNED_ACCESS_REQUIRED from Autoconf archive, but
|
||||
// it's not useful for us. We don't care if unaligned access is supported,
|
||||
// it's not useful here. We don't care if unaligned access is supported,
|
||||
// we care if it is fast. Some systems can emulate unaligned access in
|
||||
// software, which is horribly slow; we want to use byte-by-byte access on
|
||||
// such systems but the Autoconf test would detect such a system as
|
||||
|
@ -32,13 +32,13 @@
|
|||
// that also allow unaligned access. Inline assembler could be OK for that.
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
# include "bswap.h"
|
||||
# define integer_convert_16(n) bswap_16(n)
|
||||
# define integer_convert_32(n) bswap_32(n)
|
||||
# define integer_convert_64(n) bswap_64(n)
|
||||
# define integer_le_16(n) bswap_16(n)
|
||||
# define integer_le_32(n) bswap_32(n)
|
||||
# define integer_le_64(n) bswap_64(n)
|
||||
#else
|
||||
# define integer_convert_16(n) (n)
|
||||
# define integer_convert_32(n) (n)
|
||||
# define integer_convert_64(n) (n)
|
||||
# define integer_le_16(n) (n)
|
||||
# define integer_le_32(n) (n)
|
||||
# define integer_le_64(n) (n)
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -46,7 +46,7 @@ static inline uint16_t
|
|||
integer_read_16(const uint8_t buf[static 2])
|
||||
{
|
||||
uint16_t ret = *(const uint16_t *)(buf);
|
||||
return integer_convert_16(ret);
|
||||
return integer_le_16(ret);
|
||||
}
|
||||
|
||||
|
||||
|
@ -54,7 +54,7 @@ static inline uint32_t
|
|||
integer_read_32(const uint8_t buf[static 4])
|
||||
{
|
||||
uint32_t ret = *(const uint32_t *)(buf);
|
||||
return integer_convert_32(ret);
|
||||
return integer_le_32(ret);
|
||||
}
|
||||
|
||||
|
||||
|
@ -63,7 +63,7 @@ static inline uint64_t
|
|||
integer_read_64(const uint8_t buf[static 8])
|
||||
{
|
||||
uint64_t ret = *(const uint64_t *)(buf);
|
||||
return integer_convert_64(ret);
|
||||
return integer_le_64(ret);
|
||||
}
|
||||
*/
|
||||
|
||||
|
@ -71,14 +71,14 @@ integer_read_64(const uint8_t buf[static 8])
|
|||
static inline void
|
||||
integer_write_16(uint8_t buf[static 2], uint16_t num)
|
||||
{
|
||||
*(uint16_t *)(buf) = integer_convert_16(num);
|
||||
*(uint16_t *)(buf) = integer_le_16(num);
|
||||
}
|
||||
|
||||
|
||||
static inline void
|
||||
integer_write_32(uint8_t buf[static 4], uint32_t num)
|
||||
{
|
||||
*(uint32_t *)(buf) = integer_convert_32(num);
|
||||
*(uint32_t *)(buf) = integer_le_32(num);
|
||||
}
|
||||
|
||||
|
||||
|
@ -86,7 +86,7 @@ integer_write_32(uint8_t buf[static 4], uint32_t num)
|
|||
static inline void
|
||||
integer_write_64(uint8_t buf[static 8], uint64_t num)
|
||||
{
|
||||
*(uint64_t *)(buf) = integer_convert_64(num);
|
||||
*(uint64_t *)(buf) = integer_le_64(num);
|
||||
}
|
||||
*/
|
||||
|
||||
|
|
|
@ -31,12 +31,21 @@
|
|||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
// size_t and NULL
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef HAVE_INTTYPES_H
|
||||
# include <inttypes.h>
|
||||
#endif
|
||||
|
||||
// C99 says that inttypes.h always includes stdint.h, but some systems
|
||||
// don't do that, and require including stdint.h separately.
|
||||
#ifdef HAVE_STDINT_H
|
||||
# include <stdint.h>
|
||||
#endif
|
||||
|
||||
// Some pre-C99 systems have SIZE_MAX in limits.h instead of stdint.h. The
|
||||
// limits are also used to figure out some macros missing from pre-C99 systems.
|
||||
#ifdef HAVE_LIMITS_H
|
||||
# include <limits.h>
|
||||
#endif
|
||||
|
@ -44,7 +53,12 @@
|
|||
// Be more compatible with systems that have non-conforming inttypes.h.
|
||||
// We assume that int is 32-bit and that long is either 32-bit or 64-bit.
|
||||
// Full Autoconf test could be more correct, but this should work well enough.
|
||||
// Note that this duplicates some code from lzma.h, but this is better since
|
||||
// we can work without inttypes.h thanks to Autoconf tests.
|
||||
#ifndef UINT32_C
|
||||
# if UINT_MAX != 4294967295U
|
||||
# error UINT32_C is not defined and unsiged int is not 32-bit.
|
||||
# endif
|
||||
# define UINT32_C(n) n ## U
|
||||
#endif
|
||||
#ifndef UINT32_MAX
|
||||
|
@ -56,7 +70,8 @@
|
|||
#ifndef PRIX32
|
||||
# define PRIX32 "X"
|
||||
#endif
|
||||
#if SIZEOF_UNSIGNED_LONG == 4
|
||||
|
||||
#if ULONG_MAX == 4294967295UL
|
||||
# ifndef UINT64_C
|
||||
# define UINT64_C(n) n ## ULL
|
||||
# endif
|
||||
|
@ -80,16 +95,33 @@
|
|||
#ifndef UINT64_MAX
|
||||
# define UINT64_MAX UINT64_C(18446744073709551615)
|
||||
#endif
|
||||
|
||||
// The code currently assumes that size_t is either 32-bit or 64-bit.
|
||||
#ifndef SIZE_MAX
|
||||
# if SIZEOF_SIZE_T == 4
|
||||
# define SIZE_MAX UINT32_MAX
|
||||
# else
|
||||
# elif SIZEOF_SIZE_T == 8
|
||||
# define SIZE_MAX UINT64_MAX
|
||||
# else
|
||||
# error sizeof(size_t) is not 32-bit or 64-bit
|
||||
# endif
|
||||
#endif
|
||||
#if SIZE_MAX != UINT32_MAX && SIZE_MAX != UINT64_MAX
|
||||
# error sizeof(size_t) is not 32-bit or 64-bit
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
// Pre-C99 systems lack stdbool.h. All the code in LZMA Utils must be written
|
||||
// so that it works with fake bool type, for example:
|
||||
//
|
||||
// bool foo = (flags & 0x100) != 0;
|
||||
// bool bar = !!(flags & 0x100);
|
||||
//
|
||||
// This works with the real C99 bool but breaks with fake bool:
|
||||
//
|
||||
// bool baz = (flags & 0x100);
|
||||
//
|
||||
#ifdef HAVE_STDBOOL_H
|
||||
# include <stdbool.h>
|
||||
#else
|
||||
|
@ -108,11 +140,13 @@ typedef unsigned char _Bool;
|
|||
# ifdef NDEBUG
|
||||
# define assert(x)
|
||||
# else
|
||||
// TODO: Pretty bad assert() macro.
|
||||
// TODO: Pretty bad assert macro.
|
||||
# define assert(x) (!(x) && abort())
|
||||
# endif
|
||||
#endif
|
||||
|
||||
// string.h should be enough but let's include strings.h and memory.h too if
|
||||
// they exists, since that shouldn't do any harm, but may improve portability.
|
||||
#ifdef HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#endif
|
||||
|
|
|
@ -22,11 +22,15 @@ liblzma_la_LIBADD = \
|
|||
common/libcommon.la \
|
||||
check/libcheck.la
|
||||
|
||||
if COND_FILTER_LZ
|
||||
SUBDIRS += lz
|
||||
liblzma_la_LIBADD += lz/liblz.la
|
||||
endif
|
||||
|
||||
if COND_FILTER_LZMA
|
||||
SUBDIRS += lz lzma rangecoder
|
||||
SUBDIRS += lzma rangecoder
|
||||
liblzma_la_LIBADD += \
|
||||
lz/liblz.la \
|
||||
lzma/liblzma4.la \
|
||||
lzma/liblzma2.la \
|
||||
rangecoder/librangecoder.la
|
||||
endif
|
||||
|
||||
|
@ -35,7 +39,12 @@ SUBDIRS += subblock
|
|||
liblzma_la_LIBADD += subblock/libsubblock.la
|
||||
endif
|
||||
|
||||
if COND_MAIN_SIMPLE
|
||||
if COND_FILTER_DELTA
|
||||
SUBDIRS += delta
|
||||
liblzma_la_LIBADD += delta/libdelta.la
|
||||
endif
|
||||
|
||||
if COND_FILTER_SIMPLE
|
||||
SUBDIRS += simple
|
||||
liblzma_la_LIBADD += simple/libsimple.la
|
||||
endif
|
||||
|
|
|
@ -15,22 +15,18 @@
|
|||
nobase_include_HEADERS = \
|
||||
lzma.h \
|
||||
lzma/alignment.h \
|
||||
lzma/alone.h \
|
||||
lzma/auto.h \
|
||||
lzma/base.h \
|
||||
lzma/block.h \
|
||||
lzma/check.h \
|
||||
lzma/container.h \
|
||||
lzma/delta.h \
|
||||
lzma/easy.h \
|
||||
lzma/filter.h \
|
||||
lzma/index.h \
|
||||
lzma/index_hash.h \
|
||||
lzma/init.h \
|
||||
lzma/lzma.h \
|
||||
lzma/memlimit.h \
|
||||
lzma/raw.h \
|
||||
lzma/simple.h \
|
||||
lzma/stream.h \
|
||||
lzma/stream_flags.h \
|
||||
lzma/subblock.h \
|
||||
lzma/version.h \
|
||||
|
|
|
@ -17,37 +17,104 @@
|
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
*
|
||||
* Before #including this file, you must make the following types available:
|
||||
* - size_t
|
||||
* - uint8_t
|
||||
* - int32_t
|
||||
* - uint32_t
|
||||
* - int64_t
|
||||
* - uint64_t
|
||||
*
|
||||
* Before #including this file, you must make the following macros available:
|
||||
* - UINT32_C(n)
|
||||
* - UINT64_C(n)
|
||||
* - UINT32_MAX
|
||||
* - UINT64_MAX
|
||||
*
|
||||
* Easiest way to achieve the above is to #include sys/types.h and inttypes.h
|
||||
* before #including lzma.h. However, some pre-C99 libc headers don't provide
|
||||
* all the required types in inttypes.h (that file may even be missing).
|
||||
* Portable applications need to provide these types themselves. This way
|
||||
* liblzma API can use the standard types instead of defining its own
|
||||
* (e.g. lzma_uint32).
|
||||
*
|
||||
* Note that the API still has lzma_bool, because using stdbool.h would
|
||||
* break C89 and C++ programs on many systems.
|
||||
*/
|
||||
|
||||
#ifndef LZMA_H
|
||||
#define LZMA_H
|
||||
|
||||
/*****************************
|
||||
* Required standard headers *
|
||||
*****************************/
|
||||
|
||||
/**
|
||||
* liblzma API headers need some standard types and macros. To allow
|
||||
* including lzma.h without requiring the application to include other
|
||||
* headers first, lzma.h includes the required standard headers unless
|
||||
* they already seem to be included.
|
||||
*
|
||||
* Here's what types and macros are needed and from which headers:
|
||||
* - stddef.h: size_t, NULL
|
||||
* - stdint.h: uint8_t, uint32_t, uint64_t, UINT32_C(n), uint64_C(n),
|
||||
* UINT32_MAX, UINT64_MAX
|
||||
*
|
||||
* However, inttypes.h is a little more portable than stdint.h, although
|
||||
* inttypes.h declares some unneeded things compared to plain stdint.h.
|
||||
*
|
||||
* The hacks below aren't perfect, specifically they assume that inttypes.h
|
||||
* exists and that it typedefs at least uint8_t, uint32_t, and uint64_t,
|
||||
* and that unsigned int is 32-bit. If your application already takes care
|
||||
* of setting up all the types properly (for example by using gnulib's
|
||||
* stdint.h or inttypes.h), feel free to define LZMA_MANUAL_HEADERS before
|
||||
* including lzma.h.
|
||||
*
|
||||
* Some could argue that liblzma API should provide all the required types,
|
||||
* for example lzma_uint64, LZMA_UINT64_C(n), and LZMA_UINT64_MAX. This was
|
||||
* seen unnecessary mess, since most systems already provide all the necessary
|
||||
* types and macros in the standard headers.
|
||||
*
|
||||
* Note that liblzma API still has lzma_bool, because using stdbool.h would
|
||||
* break C89 and C++ programs on many systems.
|
||||
*/
|
||||
|
||||
/* stddef.h even in C++ so that we get size_t in global namespace. */
|
||||
#include <stddef.h>
|
||||
|
||||
#if !defined(UINT32_C) || !defined(UINT64_C) \
|
||||
|| !defined(UINT32_MAX) || !defined(UINT64_MAX)
|
||||
# ifdef __cplusplus
|
||||
/*
|
||||
* C99 sections 7.18.2 and 7.18.4 specify that in C++
|
||||
* implementations define the limit and constant macros only
|
||||
* if specifically requested. Note that if you want the
|
||||
* format macros too, you need to define __STDC_FORMAT_MACROS
|
||||
* before including lzma.h, since re-including inttypes.h
|
||||
* with __STDC_FORMAT_MACROS defined doesn't necessarily work.
|
||||
*/
|
||||
# ifndef __STDC_LIMIT_MACROS
|
||||
# define __STDC_LIMIT_MACROS 1
|
||||
# endif
|
||||
# ifndef __STDC_CONSTANT_MACROS
|
||||
# define __STDC_CONSTANT_MACROS 1
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# include <inttypes.h>
|
||||
|
||||
/*
|
||||
* Some old systems have only the typedefs in inttypes.h, and lack
|
||||
* all the macros. For those systems, we need a few more hacks.
|
||||
* We assume that unsigned int is 32-bit and unsigned long is either
|
||||
* 32-bit or 64-bit. If these hacks aren't enough, the application
|
||||
* has to use setup the types manually before including lzma.h.
|
||||
*/
|
||||
# ifndef UINT32_C
|
||||
# define UINT32_C(n) n # U
|
||||
# endif
|
||||
|
||||
# ifndef UINT64_C
|
||||
/* Get ULONG_MAX. */
|
||||
# ifndef __cplusplus
|
||||
# include <limits.h>
|
||||
# else
|
||||
# include <climits>
|
||||
# endif
|
||||
# if ULONG_MAX == 4294967295UL
|
||||
# define UINT64_C(n) n ## ULL
|
||||
# else
|
||||
# define UINT64_C(n) n ## UL
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# ifndef UINT32_MAX
|
||||
# define UINT32_MAX (UINT32_C(4294967295))
|
||||
# endif
|
||||
|
||||
# ifndef UINT64_MAX
|
||||
# define UINT64_MAX (UINT64_C(18446744073709551615))
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
/******************
|
||||
* GCC extensions *
|
||||
******************/
|
||||
|
@ -57,20 +124,50 @@
|
|||
* break anything if these are sometimes enabled and sometimes not, only
|
||||
* affects warnings and optimizations.
|
||||
*/
|
||||
#if defined(__GNUC__) && __GNUC__ >= 3
|
||||
#if __GNUC__ >= 3
|
||||
# ifndef lzma_attribute
|
||||
# define lzma_attribute(attr) __attribute__(attr)
|
||||
# endif
|
||||
|
||||
# ifndef lzma_restrict
|
||||
# define lzma_restrict __restrict__
|
||||
# endif
|
||||
|
||||
/* warn_unused_result was added in GCC 3.4. */
|
||||
# ifndef lzma_attr_warn_unused_result
|
||||
# if __GNUC__ == 3 && __GNUC_MINOR__ < 4
|
||||
# define lzma_attr_warn_unused_result
|
||||
# endif
|
||||
# endif
|
||||
|
||||
#else
|
||||
# ifndef lzma_attribute
|
||||
# define lzma_attribute(attr)
|
||||
# endif
|
||||
|
||||
# ifndef lzma_restrict
|
||||
# define lzma_restrict
|
||||
# if __STDC_VERSION__ >= 199901L
|
||||
# define lzma_restrict restrict
|
||||
# else
|
||||
# define lzma_restrict
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# define lzma_attr_warn_unused_result
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef lzma_attr_pure
|
||||
# define lzma_attr_pure lzma_attribute((__pure__))
|
||||
#endif
|
||||
|
||||
#ifndef lzma_attr_const
|
||||
# define lzma_attr_const lzma_attribute((__const__))
|
||||
#endif
|
||||
|
||||
#ifndef lzma_attr_warn_unused_result
|
||||
# define lzma_attr_warn_unused_result \
|
||||
lzma_attribute((__warn_unused_result__))
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -89,36 +186,30 @@ extern "C" {
|
|||
#define LZMA_H_INTERNAL 1
|
||||
|
||||
/* Basic features */
|
||||
#include "lzma/version.h"
|
||||
#include "lzma/init.h"
|
||||
#include "lzma/base.h"
|
||||
#include "lzma/vli.h"
|
||||
#include "lzma/filter.h"
|
||||
#include "lzma/check.h"
|
||||
|
||||
/* Filters */
|
||||
#include "lzma/filter.h"
|
||||
#include "lzma/subblock.h"
|
||||
#include "lzma/simple.h"
|
||||
#include "lzma/delta.h"
|
||||
#include "lzma/lzma.h"
|
||||
|
||||
/* Container formats */
|
||||
#include "lzma/block.h"
|
||||
#include "lzma/stream.h"
|
||||
#include "lzma/alone.h"
|
||||
#include "lzma/raw.h"
|
||||
#include "lzma/auto.h"
|
||||
#include "lzma/easy.h"
|
||||
#include "lzma/container.h"
|
||||
|
||||
/* Advanced features */
|
||||
#include "lzma/alignment.h" /* FIXME */
|
||||
#include "lzma/block.h"
|
||||
#include "lzma/index.h"
|
||||
#include "lzma/index_hash.h"
|
||||
#include "lzma/alignment.h"
|
||||
#include "lzma/stream_flags.h"
|
||||
#include "lzma/memlimit.h"
|
||||
|
||||
/* Version number */
|
||||
#include "lzma/version.h"
|
||||
|
||||
/*
|
||||
* All subheaders included. Undefine LZMA_H_INTERNAL to prevent applications
|
||||
* re-including the subheaders.
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
* FIXME desc
|
||||
*/
|
||||
extern uint32_t lzma_alignment_input(
|
||||
const lzma_options_filter *filters, uint32_t guess);
|
||||
const lzma_filter *filters, uint32_t guess);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -36,7 +36,7 @@ extern uint32_t lzma_alignment_input(
|
|||
* Knowing the alignment of the output data is useful e.g. in the Block
|
||||
* encoder which tries to align the Compressed Data field optimally.
|
||||
*
|
||||
* \param filters Pointer to lzma_options_filter array, whose last
|
||||
* \param filters Pointer to lzma_filter array, whose last
|
||||
* member must have .id = LZMA_VLI_VALUE_UNKNOWN.
|
||||
* \param guess The value to return if the alignment of the output
|
||||
* is the same as the alignment of the input data.
|
||||
|
@ -57,4 +57,4 @@ extern uint32_t lzma_alignment_input(
|
|||
* options), UINT32_MAX is returned.
|
||||
*/
|
||||
extern uint32_t lzma_alignment_output(
|
||||
const lzma_options_filter *filters, uint32_t guess);
|
||||
const lzma_filter *filters, uint32_t guess);
|
||||
|
|
|
@ -1,52 +0,0 @@
|
|||
/**
|
||||
* \file lzma/alone.h
|
||||
* \brief Handling of the legacy LZMA_Alone format
|
||||
*
|
||||
* \author Copyright (C) 1999-2006 Igor Pavlov
|
||||
* \author Copyright (C) 2007 Lasse Collin
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef LZMA_H_INTERNAL
|
||||
# error Never include this file directly. Use <lzma.h> instead.
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* \brief Initializes LZMA_Alone encoder
|
||||
*
|
||||
* LZMA_Alone files have the suffix .lzma like the .lzma Stream files.
|
||||
* LZMA_Alone format supports only one filter, the LZMA filter. There is
|
||||
* no support for integrity checks like CRC32.
|
||||
*
|
||||
* Use this format if and only if you need to create files readable by
|
||||
* legacy LZMA tools.
|
||||
*
|
||||
* LZMA_Alone encoder doesn't support LZMA_SYNC_FLUSH or LZMA_FULL_FLUSH.
|
||||
*
|
||||
* \return - LZMA_OK
|
||||
* - LZMA_MEM_ERROR
|
||||
* - LZMA_PROG_ERROR
|
||||
*/
|
||||
extern lzma_ret lzma_alone_encoder(
|
||||
lzma_stream *strm, const lzma_options_lzma *options);
|
||||
|
||||
|
||||
/**
|
||||
* \brief Initializes decoder for LZMA_Alone file
|
||||
*
|
||||
* The LZMA_Alone decoder supports LZMA_SYNC_FLUSH.
|
||||
*
|
||||
* \return - LZMA_OK
|
||||
* - LZMA_MEM_ERROR
|
||||
*/
|
||||
extern lzma_ret lzma_alone_decoder(lzma_stream *strm);
|
|
@ -1,36 +0,0 @@
|
|||
/**
|
||||
* \file lzma/auto.h
|
||||
* \brief Decoder with automatic file format detection
|
||||
*
|
||||
* \author Copyright (C) 1999-2006 Igor Pavlov
|
||||
* \author Copyright (C) 2007 Lasse Collin
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef LZMA_H_INTERNAL
|
||||
# error Never include this file directly. Use <lzma.h> instead.
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* \brief Decode .lzma Streams and LZMA_Alone files with autodetection
|
||||
*
|
||||
* Autodetects between the .lzma Stream and LZMA_Alone formats, and
|
||||
* calls lzma_stream_decoder_init() or lzma_alone_decoder_init() once
|
||||
* the type of the file has been detected.
|
||||
*
|
||||
* \param strm Pointer to propertily prepared lzma_stream
|
||||
*
|
||||
* \return - LZMA_OK: Initialization was successful.
|
||||
* - LZMA_MEM_ERROR: Cannot allocate memory.
|
||||
*/
|
||||
extern lzma_ret lzma_auto_decoder(lzma_stream *strm);
|
|
@ -134,7 +134,7 @@ typedef enum {
|
|||
* \brief Unknown file format
|
||||
*/
|
||||
|
||||
LZMA_MEMLIMIT_ERROR = -9
|
||||
LZMA_MEMLIMIT_ERROR = -9,
|
||||
/**
|
||||
* \brief Memory usage limit was reached
|
||||
*
|
||||
|
@ -143,6 +143,9 @@ typedef enum {
|
|||
* the memory usage limit has to be increased. See functions
|
||||
* lzma_memlimit_get() and lzma_memlimit_set().
|
||||
*/
|
||||
|
||||
LZMA_NO_CHECK = -10,
|
||||
LZMA_SEE_CHECK = -11
|
||||
} lzma_ret;
|
||||
|
||||
|
||||
|
@ -229,11 +232,6 @@ typedef struct {
|
|||
/**
|
||||
* \brief Pointer to custom memory allocation function
|
||||
*
|
||||
* Set this to point to your custom memory allocation function.
|
||||
* It can be useful for example if you want to limit how much
|
||||
* memory liblzma is allowed to use: for this, you may use
|
||||
* a pointer to lzma_memory_alloc().
|
||||
*
|
||||
* If you don't want a custom allocator, but still |